load_template('users.tpl');
$tpl->set( '[all]', "" );
$tpl->set( '[/all]', "" );
$tpl->set( '[last]', "" );
$tpl->set( '[/last]', "" );
$tpl->set( '[banned]', "" );
$tpl->set( '[/banned]', "" );
switch($action){
case 'last':
$tpl->set_block( "'\\[list_all\\].*?\\[/list_all\\]'si", "" );
$tpl->set_block( "'\\[list_banned\\].*?\\[/list_banned\\]'si", "" );
$tpl->set( '[list_last]', "" );
$tpl->set( '[/list_last]', "" );
$today = mktime(0,0,0,date('m'),date('d'),date('Y'));
$last_num = $db->super_query( "SELECT COUNT(*) as count FROM " . USERPREFIX . "_users WHERE `lastdate` > '$today'" );
$last = $db->query("SELECT * FROM `". PREFIX ."_users` WHERE `lastdate` > '$today' ORDER BY `lastdate`");
$last_list = "Ник | Группа | Время | ";
while($row = $db->get_row($last)){
if ($user_group[$row['user_group']]['colour']){
$group_span = $user_group[$row['user_group']]['colour'];
$group_name = "".$user_group[$row['user_group']]['group_name']."";
}else $group_name = $user_group[$row['user_group']]['group_name'];
$last_list .= "
".$row['name']." | ".$group_name." | ". langdate( "H:i:s", $row['lastdate'] )." |
";
} $db->free();
$tpl->set( '{last_users}', $last_num['count']);
$tpl->set( '{lastusers}', $last_list );
break;
case 'banned':
$tpl->set_block( "'\\[list_all\\].*?\\[/list_all\\]'si", "" );
$tpl->set_block( "'\\[list_last\\].*?\\[/list_last\\]'si", "" );
$tpl->set( '[list_banned]', "" );
$tpl->set( '[/list_banned]', "" );
$banned_num = $db->super_query( "SELECT COUNT(*) as count FROM " . USERPREFIX . "_users WHERE banned='yes'" );
if(!$banned_num['count'] == 0){
$banned = $db->query("SELECT " . USERPREFIX . "_users.*, " . USERPREFIX . "_banned.days, " . USERPREFIX . "_banned.descr, " . USERPREFIX . "_banned.date as banned_date FROM " . USERPREFIX . "_users LEFT JOIN " . USERPREFIX . "_banned ON " . USERPREFIX . "_users.user_id=" . USERPREFIX . "_banned.users_id WHERE banned='yes'");
$banned_list = "Ник | Срок | Окончание бана | Причина | ";
while($row = $db->get_row($banned)){
$days = $row['days']; if ($days == 0)$ava = "Пожизненно";else$ava = "".$row['days']." дней";
$banned_date = $row['banned_date']; if ($banned_date == 0) $dated = "Никогда"; else $dated = $lang['ban_edate']." ".langdate("j M Y H:i", $row['banned_date']);
$descr = $row['descr']; if ($descr == "") $descru = "Нет причины"; else $descru = "".$row['descr']."";
$banned_list .= "" . $row['name']." | ".$ava." | ".$dated." | ".$descru." |
";
}
} else $banned_list = "Забаненные пользователи отсутствуют";
$tpl->set( '{banneds}', $banned_list );
$db->free();
break;
default:
if (isset($_POST['uname'])){$sql_count = "SELECT COUNT(*) as count FROM " . PREFIX . "_users WHERE name LIKE '%{$_POST['uname']}%'";
}else $sql_count = "SELECT COUNT(*) as count FROM " . PREFIX . "_users";
$count_all = $db->super_query($sql_count);
$count_all = $count_all['count'];
$page = intval( $_REQUEST['cstart'] );
$total = intval( ( ( $count_all - 1 ) / $limit ) + 1 );
if( $page <= 0 ) $page = 1;
if( $page > $total ) $page = $total;
$start = $page * $limit - $limit;
$i = $start;
switch($order_by) {case 1: $orderby = 'user_id ASC'; break;case 2: $orderby = 'user_id DESC'; break;case 3: $orderby = 'news_num DESC'; break;case 4: $orderby = 'comm_num DESC'; break;case 5: $orderby = 'name ASC'; break;}
$i = $start;
$result = $db->Query("SELECT * FROM ". USERPREFIX ."_users ORDER BY ".$orderby." LIMIT $start,$limit");
if ($_REQUEST['act'] == 'dosearch') {$result = $db->Query("SELECT * FROM ". USERPREFIX ."_users WHERE name LIKE '".$_POST['uname']."%' ORDER BY user_id ASC LIMIT $start,$limit"); }
if ($_REQUEST['order'] == 'asc'){ $result = $db->Query("SELECT * FROM ". USERPREFIX ."_users ORDER BY user_id ASC LIMIT $start,$limit");}
elseif($_REQUEST['order'] == 'desc') {$result = $db->Query("SELECT * FROM ". USERPREFIX ."_users ORDER BY user_id DESC LIMIT $start,$limit");}
elseif($_REQUEST['order'] == 'newsnum'){$result = $db->Query("SELECT * FROM ". USERPREFIX ."_users ORDER BY news_num DESC LIMIT $start,$limit");}
elseif($_REQUEST['order'] == 'commnum'){$result = $db->Query("SELECT * FROM ". USERPREFIX ."_users ORDER BY comm_num DESC LIMIT $start,$limit");}
elseif($_REQUEST['order'] == 'az'){$result = $db->Query("SELECT * FROM ". USERPREFIX ."_users ORDER BY name ASC LIMIT $start,$limit");}
elseif($_REQUEST['order'] == 'rand'){$result = $db->Query("SELECT * FROM ". USERPREFIX ."_users ORDER BY rand() DESC LIMIT $start,$limit");}
$tpl->set_block( "'\\[list_last\\].*?\\[/list_last\\]'si", "" );
$tpl->set_block( "'\\[list_banned\\].*?\\[/list_banned\\]'si", "" );
$tpl->set( '[list_all]', "" );
$tpl->set( '[/list_all]', "" );
$all_users = '
Список пользователей
№ | Имя | Группа | Email | ICQ | Дата регистрации | Новостей | Комментариев |
';
while ($row = $db->get_row($result)){
$i ++;
$prifile_link = ''.$row['name'].'';
if ($row['icq'] != '') {$icq = $row['icq'];
}else {
$icq = '--';$icq_status = '--';
}
$all_users .= '
'. $row['user_id'] .' | ' . $prifile_link .' | '.stripslashes($user_group[$row['user_group']]['group_name']).' | | '.$icq.' | '.langdate("j F Y H:i", $row['reg_date']).' | '.$row['news_num'].' | '.$row['comm_num'].' |
';
};
$all_users .= '
';
$tpl->set('{all_users}',$all_users);
break;
}
$tpl->compile('content');
$tpl->clear();
$nav = "/users/page/{page}";
CreateNavigation( $nav, $page, $total );
?>