Файл: Arhmobi_esdcms/pages/users.php
Строк: 99
<?php
include_once '../sys/inc/start.php';
$doc = new document();
$doc->title = __('Пользователи');
$none = __('Нет пользователей');
switch ($order = (string) @$_GET['order']) {
case 'birthdays':
$sort = 'DESC';
$order = 'ank_g_r';
$where = "WHERE `ank_m_r` = '".date("m")."' AND `ank_d_r` = '".date("d")."'";
$none = __('Сегодня нет именинников');
$doc->title = __('Именинники');
break;
case 'age':
$order = "ank_g_r";
$sort = 'DESC,`ank_m_r` DESC, `ank_d_r` DESC';
$doc->title = __('По возрасту');
$none = __('Нет пользователей, указавших дату рождения');
$where = "WHERE `ank_g_r` > '0' AND `ank_m_r` > '0' AND `ank_d_r` > '0'";
break;
case 'donate_rub':
$sort = 'DESC';
$where = "WHERE `donate_rub` > '0'";
$none = __('Нет пользователей, пожертвовавших денег на проект');
$doc->title = __('Пожертвования');
break;
case 'group':
$sort = 'DESC';
$where = "WHERE `group` > '1'";
$doc->title = __('Администрация сайта');
break;
case 'login':
$order = 'login';
$sort = 'ASC';
$where = '';
$doc->title = __('По логину');
break;
default:
$order = 'id';
$sort = 'DESC';
$where = '';
break;
}
if (!empty($_GET['search']))
$search = text::input_text($_GET['search']);
if (isset($search) && !$search)
$doc->err(__('Пустой запрос'));
elseif (isset($search) && $search) {
$where = "WHERE `vk_first_name` LIKE " . $db->quote('%' . $search . '%') . " ||`login` LIKE " . $db->quote('%' . $search . '%');
$doc->title = __('Поиск по запросу "%s"', $search);
}
$posts = array();
$pages = new pages;
$res = $db->query("SELECT COUNT(*) FROM `users` $where");
$pages->posts = $res->fetchColumn();
if ((string) @$_GET['order'] != 'birthdays') {
/* проверяем есть-ли сегодня именинники */
$res = $db->query("SELECT COUNT(*) FROM `users` WHERE `ank_m_r` = '".date("m")."' AND `ank_d_r` = '".date("d")."'");
$bds = $res->fetchColumn(); } else {
$bds = $pages->posts; }
// меню сортировки
$ord = array();
$ord[] = array("?order=id&page={$pages->this_page}" . (isset($search) ? '&search=' . urlencode($search) : ''), __('ID пользователя'), $order == 'id'); if ($bds || (string) @$_GET['order'] == 'birthdays')
$ord[] = array("?order=birthdays&page={$pages->this_page}" . (isset($search) ? '&search=' . urlencode($search) : ''), __('Именинники'), (string) @$_GET['order'] == 'birthdays');
$ord[] = array("?order=group&page={$pages->this_page}" . (isset($search) ? '&search=' . urlencode($search) : ''), __('Администрация сайта'), $order == 'group');
$ord[] = array("?order=login&page={$pages->this_page}" . (isset($search) ? '&search=' . urlencode($search) : ''), __('Логин'), $order == 'login');
$ord[] = array("?order=age&page={$pages->this_page}" . (isset($search) ? '&search=' . urlencode($search) : ''), __('Возраст'), (string) @$_GET['order'] == 'age');
$or = new design();
$or->assign('order', $ord);
$or->display('design.order.tpl');
$q = $db->query("SELECT `id` FROM `users` $where ORDER BY `$order` " . $sort . " LIMIT $pages->limit");
$listing = new listing();
if ($arr = $q->fetchAll()) {
foreach ($arr AS $ank) {
$post = $listing->post();
$p_user = new user($ank['id']);
if ($path = $p_user->ava()) {
$post->image=$path;
}else{
$post->image='/no_avatar.png';
}
$post->title = $p_user->nick();
$post->url = '/profile.view.php?id=' . $p_user->id;
switch ($order) {
case 'id':
$post->content[] = '[b]' . 'ID: ' . $p_user->id . '[/b]';
break;
case 'group':
$post->content[] = '[b]' . $p_user->group_name . '[/b]';
break;
case 'ank_g_r':
$post->content[] = '[b]' . (((int) $p_user->ank_g_r > 0) ? __('Дата рождения') . ": $p_user->ank_d_r.$p_user->ank_m_r.$p_user->ank_g_r (" . misc::get_age($p_user->ank_g_r, $p_user->ank_m_r, $p_user->ank_d_r) . ')' : __('День рождения').": $p_user->ank_d_r " . misc::getLocaleMonth($p_user->ank_m_r)) . '[/b]';
break;
case 'donate_rub':
$post->content[] = '[b]' . __('Сумма пожертвований: %s руб.', $p_user->donate_rub) . '[/b]';
break;
}
$post->content[] = '[small]' . __('Дата регистрации') . ': ' . date('d-m-Y', $p_user->reg_date) . '[/small]';
$post->content[] = '[small]' . __('Последний визит') . ': ' . ($p_user->last_visit ? misc::when($p_user->last_visit) : misc::when($p_user->reg_date)) . '[/small]';
}
if ($order == 'ank_g_r') { /* fix */
$order = (string) $_GET['order'];
}
}
$form = new form('?', false);
$form->hidden('order', $order);
$form->text('search', __('Ник или его часть'), @$search, false);
$form->button(__('Поиск'));
$form->display();
$listing->display($none);
$pages->display("?order=$order&" . (isset($search) ? 'search=' . urlencode($search) . '&' : ''));