View file chat_statistic.php

File size: 12.52Kb
<?php
if (!strpos($_SERVER['SCRIPT_NAME'],substr(session_id(),(strlen(session_id())/2),strlen(session_id())).session_id().substr(session_id(),0,(strlen(session_id())/2)).'/index.php'))
    {
     header('location: http://'.$_SERVER['SERVER_NAME'].'/'); exit();
    }
$cls->a_header('Статистика чата.');
$cls->write('<div class="d1"><h5 align="center">Статистика</h5></div>');


$q3 = mysql_query('SELECT * FROM `'.$px.$utable.'`');

         if ($target['2'] == $_SESSION['statistic1'] && $target['2'] != ''){
         $q = mysql_query('SELECT `login`, `posts` FROM `'.$px.$utable.'` WHERE  `level` >= 6');
         $cls->write('<div class="d0">Администраторы</div>');
         if (mysql_num_rows($q) == '0') {$cls->write('<div class="d0">Администраторов нет.</div>');}
             else
                 {
                  while ($arr = mysql_fetch_object($q))
                         {
                          ++$i; $cls->write('<div class="d0">'.$i.'. '.$arr->login.' - '.$arr->posts.'</div>');
                         }
                 }
         }
         elseif ($target['2'] == $_SESSION['statistic2'] && $target['2'] != ''){
         $q = mysql_query('SELECT `login`, `posts` FROM `'.$px.$utable.'` WHERE `level` = "5"');
         $cls->write('<div class="d0">Высшие модераторы</div>');
         if (mysql_num_rows($q) == '0') {$cls->write('<div class="d0">Высших модераторов нет.</div>');}
             else
                 {
                  while ($arr = mysql_fetch_object($q))
                         {
                          ++$i; $cls->write('<div class="d0">'.$i.'. '.$arr->login.' - '.$arr->posts.'</div>');
                         }
                 }
         }
         elseif ($target['2'] == $_SESSION['statistic3'] && $target['2'] != ''){
         $q = mysql_query('SELECT `login`, `posts` FROM `'.$px.$utable.'` WHERE `level` = "4"');
         $cls->write('<div class="d0">Модераторы</div>');
         if (mysql_num_rows($q) == '0') {$cls->write('<div class="d0">Модераторов нет.</div>');}
             else
                 {
                  while ($arr = mysql_fetch_object($q))
                         {
                          ++$i; $cls->write('<div class="d0">'.$i.'. '.$arr->login.' - '.$arr->posts.'</div>');
                         }
                 }
         }
         elseif ($target['2'] == $_SESSION['statistic4'] && $target['2'] != ''){
         $q = mysql_query('SELECT `login`, `posts` FROM `'.$px.$utable.'` WHERE `level` = "3"');
         $cls->write('<div class="d0">Предмодераторы</div>');
         if (mysql_num_rows($q) == '0') {$cls->write('<div class="d0">Предмодераторов нет.</div>');}
             else
                 {
                  while ($arr = mysql_fetch_object($q))
                         {
                          ++$i; $cls->write('<div class="d0">'.$i.'. '.$arr->login.' - '.$arr->posts.'</div>');
                         }
                 }
         }
         elseif ($target['2'] == $_SESSION['statistic5'] && $target['2'] != ''){
         $q = mysql_query('SELECT * FROM `'.$px.$utable.'` ORDER BY `posts` DESC LIMIT 10');
         $cls->write('<div class="d0">Рейтинг по постам</div>');
         if (mysql_num_rows($q) == '0') {$cls->write('<div class="d0">Рейтинг пуст.</div>');}
             else
                 {
                  while ($arr = mysql_fetch_object($q))
                         {
                          ++$i; $cls->write('<div class="d0">'.$i.'. '.$arr->login.' - '.$arr->posts.'</div>');
                         }
                 }
         }
         elseif ($target['2'] == $_SESSION['statistic6'] && $target['2'] != ''){
         $q = mysql_query('SELECT * FROM `'.$px.$utable.'` ORDER BY `vposts` DESC LIMIT 10');
         $cls->write('<div class="d0">Рейтинг по ответам</div>');
         if (mysql_num_rows($q) == '0') {$cls->write('<div class="d0">Рейтинг пуст.</div>');}
             else
                 {
                  while ($arr = mysql_fetch_object($q))
                         {
                          ++$i; $cls->write('<div class="d0">'.$i.'. '.$arr->login.' - '.$arr->vposts.'</div>');
                         }
                 }
         }
         elseif ($target['2'] == $_SESSION['statistic7'] && $target['2'] != ''){
         $q = mysql_query('SELECT * FROM `'.$px.$utable.'` ORDER BY `vst` DESC LIMIT 10');
         $cls->write('<div class="d0">Рейтинг по переходам</div>');
         if (mysql_num_rows($q) == '0') {$cls->write('<div class="d0">Рейтинг пуст.</div>');}
             else
                 {
                  while ($arr = mysql_fetch_object($q))
                         {
                          ++$i; $cls->write('<div class="d0">'.$i.'. '.$arr->login.' - '.$arr->vst.'</div>');
                         }
                 }
         }
         elseif ($target['2'] == $_SESSION['statistic10'] && $target['2'] != ''){
         $q = mysql_query('SELECT * FROM `'.$px.$utable.'` ORDER BY `atraf` DESC LIMIT 10');
         $cls->write('<div class="d0">Рейтинг по трафику</div>');
         if (mysql_num_rows($q) == '0') {$cls->write('<div class="d0">Рейтинг пуст.</div>');}
             else
                 {
                  while ($arr = mysql_fetch_object($q))
                         {
                          ++$i; $cls->write('<div class="d0">'.$i.'. '.$arr->login.' - '.$arr->atraf.'</div>');
                         }
                 }
         }
         elseif ($target['2'] == $_SESSION['statistic11'] && $target['2'] != ''){
         $q = mysql_query('SELECT * FROM `'.$px.$utable.'` ORDER BY `adtime` DESC LIMIT 10');
         $cls->write('<div class="d0">Рейтинг по времени</div>');
         if (mysql_num_rows($q) == '0') {$cls->write('<div class="d0">Рейтинг пуст.</div>');}
             else
                 {
                  while ($arr = mysql_fetch_object($q))
                         {
                          ++$i; $cls->write('<div class="d0">'.$i.'. '.$arr->login.' - '.all_time($arr->adtime).'</div>');
                         }
                 }
         }
         elseif ($target['2'] == $_SESSION['statistic8'] && $target['2'] != ''){
         $q = mysql_query('SELECT * FROM `'.$px.$utable.'` ORDER BY `rtime` DESC LIMIT 10');
         $cls->write('<div class="d0">Новые пользователи</div>');
         if (mysql_num_rows($q) == '0') {$cls->write('<div class="d0">Список пуст.</div>');}
             else
                 {
                  while ($arr = mysql_fetch_object($q))
                         {
                          ++$i; $cls->write('<div class="d0">'.$i.'. '.$arr->login.' - '.date('H:i:s',$arr->rtime).'</div>');
                         }
                 }
         }
         elseif ($target['2'] == $_SESSION['statistic9'] && $target['2'] != ''){
         if (empty($target['3'])){$from = 0;}
         if (!is_numeric($target['3'])){$from = 0;}
         if ($target['3'] >= 0 && $target['3'] <= $_SESSION['t_pages']){$from = intval($target['3']);}
         if ($target['3'] < 0 || $target['3'] > $_SESSION['t_pages']){$from = 0;}
         $from = trim(addslashes(htmlspecialchars($from)));
         $count = mysql_query('SELECT count(`id`) FROM `'.$px.$utable.'`');
         list($total_links) = mysql_fetch_array($count);
         $total_pages = ceil($total_links / 10); $_SESSION['t_pages'] = $total_pages; session_register('t_pages');

         $k = mysql_num_rows($q3);
         $q = mysql_query('SELECT * FROM `'.$px.$utable.'` ORDER BY `rtime` LIMIT '.($from*10).', 10');
         $cls->write('<div class="d0">Все пользователи</div>');
         if (mysql_num_rows($q) == '0') {$cls->write('<div class="d0">Список пуст.</div>');}
             else
                 {
                  while ($arr = mysql_fetch_object($q))
                         {
                          ++$i; $cls->write('<div class="d0">'.$i.'. '.$arr->login.' - '.$arr->posts.'</div>');
                         }
                 }
         if ($total_pages > 3 && $from > 1)
             {
              $cls->write('<a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/gusers/0&amp;'.SID.'">&lt;-0</a>,');
             }
              if ($from != '0' && $total_pages != '0')
                  {
                   $cls->write('<a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/gusers/'.($from-1).'&amp;'.SID.'">&lt;'.($from-1).'</a>,');
                  }
                   if ($total_links > 10)
                       {
                        echo $from;
                       }
                        if (($from+1) != $total_pages && $total_pages != '0')
                             {
                              $cls->write(',<a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/gusers/'.($from+1).'&amp;'.SID.'">'.($from+1).'&gt;</a>');
                             }
                              if ($total_pages > 3 && $from < $total_pages-2)
                                  {
                                   $cls->write(',<a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/gusers/'.($total_pages-1).'&amp;'.SID.'">'.($total_pages-1).'-&gt;</a>');
                                  }
         }
         else{
         $q1 = mysql_query('SELECT * FROM `'.$px.$utable.'` WHERE `sex` = "М"');

         $cls->write('<div class="d0">Жителей: '.mysql_num_rows($q3).' <br/>'.
         'Парней: '.mysql_num_rows($q1).' <br/>'.
         'Девушек: '.(mysql_num_rows($q3)-mysql_num_rows($q1)).'</div>'.
         '<div class="d1"><a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/'.ref1.'&amp;'.SID.'">Администрация</a></div>'.
         '<div class="d0"><a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/'.ref2.'&amp;'.SID.'">Высшие модераторы</a></div>'.
         '<div class="d0"><a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/'.ref3.'&amp;'.SID.'">Модераторы</a></div>'.
         '<div class="d0"><a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/'.ref4.'&amp;'.SID.'">Предмодераторы</a></div>'.
         '<div class="d0"><a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/'.ref5.'&amp;'.SID.'">Рейтинг по постам</a></div>'.
         '<div class="d0"><a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/'.ref6.'&amp;'.SID.'">Рейтинг по ответам</a></div>'.
         '<div class="d0"><a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/'.ref7.'&amp;'.SID.'">Рейтинг по переходам</a></div>'.
         '<div class="d0"><a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/'.ref10.'&amp;'.SID.'">Рейтинг по трафику</a></div>'.
         '<div class="d0"><a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/'.ref11.'&amp;'.SID.'">Рейтинг по времени</a></div>'.
         '<div class="d0"><a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/'.ref8.'&amp;'.SID.'">Новые пользователи</a></div>'.
         '<div class="d0"><a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'/'.ref9.'&amp;'.SID.'">Все пользователи</a></div>');

         $_SESSION['statistic1'] = ref1; session_register('statistic1');
         $_SESSION['statistic2'] = ref2; session_register('statistic2');
         $_SESSION['statistic3'] = ref3; session_register('statistic3');
         $_SESSION['statistic4'] = ref4; session_register('statistic4');
         $_SESSION['statistic5'] = ref5; session_register('statistic5');
         $_SESSION['statistic6'] = ref6; session_register('statistic6');
         $_SESSION['statistic7'] = ref7; session_register('statistic7');
         $_SESSION['statistic8'] = ref8; session_register('statistic8');
         $_SESSION['statistic9'] = ref9; session_register('statistic9');
         $_SESSION['statistic10'] = ref10; session_register('statistic10');
         $_SESSION['statistic11'] = ref11; session_register('statistic11');
         }
if ($target['2']) {$cls->write('<br/><a href="?'.$_SESSION['re'].'/'.$_SESSION['re8'].'&amp;'.SID.'">Статистика</a><br/>');}
$pagesize = round((ob_get_length()+500)/1024,1);
require_once(rootpath.'trafic.php');
$end = gettime();
$cls->write('<div class="foot"><a href="?'.SID.'">В прихожую</a>['.round(($end - $mystart), 5).']</div>');
$cls->a_footer();
ob_end_flush();
@mysql_close();
?>