<?php

  include 'system/core.php';
$_title = 'Администрация';
  include 'system/header.php';

  if(!$user['id']){
  header('Location: /index.php/?m=guest'); exit;
  }
 
echo '<div class="tegi"><b>Список администрации</b></div></div>';
echo '</div>';


  switch($_GET['m']){
  
  default:
    //////////////////////////////////////////

$cop = 10;
  $ca = mysql_result(mysql_query("SELECT COUNT(*) FROM `user`"),0);
  $cp = ceil($ca/$cop);
  if(isset($_GET['p']) && is_numeric($_GET['p'])){
  $p = $_GET['p'];
  if($_GET['p']>$cp) $p = $cp;
  if($_GET['p']<1)$p = 1;
  }else{
  $p = 1;
  }
  $start = $p*$cop-$cop;
  
  $sort = trim($_GET['sort']);
  if(empty($sort) or !is_numeric($sort) or $sort < 0 or $sort > 2){
  
  $sort2 = 'id';
  $sort = 0;
  
  }elseif($sort == 1){
  
  $sort2 = 'registration';
  $desc  = 'DESC';
  
  }elseif($sort == 2){
  
  $sort2 = 'rating';
  $desc  = 'DESC';

  }
 

  $users = mysql_query("SELECT * FROM `user`  WHERE `status` >= 1 AND `status` <= 4 ORDER BY `$sort2` $desc LIMIT $start,$cop");

  
  while($users2 = mysql_fetch_assoc($users)){
 echo '<div class="post2"><table cellpadding="0" cellspacing="4"><tr><td style="width: 40px; vertical-align: top; height: 40px; margin: 0; padding:0; border: 0;" id="mail_avatar"><img src="/modules/profile/';
  if(empty($users2['ava'])) echo 'images/noava.png'; else echo 'ava/'.$users2['ava'];
  echo '"style="max-width:40px;"/>';
echo '</td><td style="vertical-align: top;" id="mail_textarea">'.ustatus($users2['id']).' <a href="/us'.$users2['id'].'">'.uname($users2['id']).' </a>'.ced($users2['id']).''.uaccess($users2['id']);
  if(empty($sort)) echo ' (ID '.$users2['id'].')';
  if($sort == 1) echo ' ('.times($users2['registration']).')';
  elseif($sort == 2) echo ' ('.$users2['rating'].')';
echo '<br/>Рейтинг: <font color="green">'.$users2['rating'].'</font><br/>Активность: '.times($users2['online']).'';
echo '</td></tr></table></div>';

}
  break;
 /////////////////////// 
  
 
  
  
  }

  include 'system/footer.php';

?>