<?php
define ('_IN_JOHNCMS', 1);
require('../incfiles/core.php');
require('../incfiles/head.php');
//MORGAN TOMONIDAN YOZILDI

echo '<div class="phdr">Sayt faollari Top-10</div>';

$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` "),0);
$ab = mysql_query("SELECT * FROM `users` ORDER BY `total_on_site` DESC LIMIT 10");
$i = 0;
if($total){
while($aa = mysql_fetch_assoc($ab)){
echo $i % 2 ? '<div  class="list2">' : '<div  class="list1">';
echo '<table cellpadding="0" cellspacing="0"><tr><td>';
if (file_exists((ROOTPATH . 'files/users/avatar/' . $total['id'] .'.png')))
echo '<img src="' . $home . '/files/users/avatar/' . $total['id'] . '.png" width="32" height="32" alt="" />&#160;';
else
echo '<img src="' . $home . '/images/empty.png" width="32" height="32" alt="" />&#160;';
echo '</td><td>';
if ($aa['sex'])
echo functions::image(($aa['sex'] == 'm' ? 'm' : 'w') . ($aa['datereg'] > time() - 86400 ? '_new' : '') . '.png', array('class' => 'icon-inline'));
$colornick = mysql_fetch_assoc(mysql_query("select `colornick`,`colornick2` from `users` where `id`='".$aa['id']."';"));
echo !$user_id || $user_id == $total['id'] ? '<b>'.functions::gradient('' . $aa['name'] . '', '' . $colornick['colornick'] . '',''.$colornick['colornick2'].'').'</b>&#160;' : '<a href="' . $home . '/users/profile.php?user=' . $aa['id'] .'"><b>'.functions::gradient('' . $aa['name'] . '', '' . $colornick['colornick'] . '',''.$colornick['colornick2'].'').'</b></a>&#160;';
$rank  = array(
0  => '',
1  => '(GMod)',
2  => '(CMod)',
3  => '(FMod)',
4  => '(DMod)',
5  => '(LMod)',
6  => '(Smd)',
7  => '(Adm)',
9  => '(SV!)'
);
$Rights  = isset($aa['rights']) ? $aa['rights'] : 0;
echo  $rank[$Rights];
echo ( time() > $aa['lastdate'] + 300 ? '<span class="red"> [Off]</span>' : '<span class="green"> [ON]</span>');
if (!empty($aa['status'])) {
echo '<div class="status">' . functions::image('label.png', array('class' => 'icon-inline')).(strlen($cstat) == 1 ? '' . $aa['status'] . '' : '<font color="'.$aa['cstat'].'">' . $aa['status'] . '</font>').'</div>';
}
echo '<br/><span class="gray">Faollik darajasi:</span> ' . functions::timecount($aa['total_on_site']) . '';
 echo '</td></tr></table></div>';
}
}

//BU BALLAR
echo '<div class="phdr">Ballar bo`yicha Top-10</div>';

$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` "),0);
$ab = mysql_query("SELECT * FROM `users` ORDER BY `balans` DESC LIMIT 10");
$i = 0;
if($total){
while($aa = mysql_fetch_assoc($ab)){
echo $i % 2 ? '<div  class="list2">' : '<div  class="list1">';
echo '<table cellpadding="0" cellspacing="0"><tr><td>';
if (file_exists((ROOTPATH . 'files/users/avatar/' . $total['id'] .'.png')))
echo '<img src="' . $home . '/files/users/avatar/' . $total['id'] . '.png" width="32" height="32" alt="" />&#160;';
else
echo '<img src="' . $home . '/images/empty.png" width="32" height="32" alt="" />&#160;';
echo '</td><td>';
if ($aa['sex'])
echo functions::image(($aa['sex'] == 'm' ? 'm' : 'w') . ($aa['datereg'] > time() - 86400 ? '_new' : '') . '.png', array('class' => 'icon-inline'));
$colornick = mysql_fetch_assoc(mysql_query("select `colornick`,`colornick2` from `users` where `id`='".$aa['id']."';"));
echo !$user_id || $user_id == $total['id'] ? '<b>'.functions::gradient('' . $aa['name'] . '', '' . $colornick['colornick'] . '',''.$colornick['colornick2'].'').'</b>&#160;' : '<a href="' . $home . '/users/profile.php?user=' . $aa['id'] .'"><b>'.functions::gradient('' . $aa['name'] . '', '' . $colornick['colornick'] . '',''.$colornick['colornick2'].'').'</b></a>&#160;';
$rank  = array(
0  => '',
1  => '(GMod)',
2  => '(CMod)',
3  => '(FMod)',
4  => '(DMod)',
5  => '(LMod)',
6  => '(Smd)',
7  => '(Adm)',
9  => '(SV!)'
);
$Rights  = isset($aa['rights']) ? $aa['rights'] : 0;
echo  $rank[$Rights];
echo ( time() > $aa['lastdate'] + 300 ? '<span class="red"> [Off]</span>' : '<span class="green"> [ON]</span>');
if (!empty($aa['status'])) {
echo '<div class="status">' . functions::image('label.png', array('class' => 'icon-inline')).(strlen($cstat) == 1 ? '' . $aa['status'] . '' : '<font color="'.$aa['cstat'].'">' . $aa['status'] . '</font>').'</div>';
}
echo '<br/><span class="gray"> Ballar:</span> ' . $aa['balans'] . '';
 echo '</td></tr></table></div>';
}
}

//CHAT POSLAR

echo ' <div class="phdr">Chat xabarlari Top-10 Umumiy</div>';

$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` "),0);
$ab = mysql_query("SELECT * FROM `users` ORDER BY `postchat` DESC LIMIT 10");
$i = 0;
if($total){
while($aa = mysql_fetch_assoc($ab)){
echo $i % 2 ? '<div  class="list2">' : '<div  class="list1">';
echo '<table cellpadding="0" cellspacing="0"><tr><td>';
if (file_exists((ROOTPATH . 'files/users/avatar/' . $total['id'] .'.png')))
echo '<img src="' . $home . '/files/users/avatar/' . $total['id'] . '.png" width="32" height="32" alt="" />&#160;';
else
echo '<img src="' . $home . '/images/empty.png" width="32" height="32" alt="" />&#160;';
echo '</td><td>';
if ($aa['sex'])
echo functions::image(($aa['sex'] == 'm' ? 'm' : 'w') . ($aa['datereg'] > time() - 86400 ? '_new' : '') . '.png', array('class' => 'icon-inline'));
$colornick = mysql_fetch_assoc(mysql_query("select `colornick`,`colornick2` from `users` where `id`='".$aa['id']."';"));
echo !$user_id || $user_id == $total['id'] ? '<b>'.functions::gradient('' . $aa['name'] . '', '' . $colornick['colornick'] . '',''.$colornick['colornick2'].'').'</b>&#160;' : '<a href="' . $home . '/users/profile.php?user=' . $aa['id'] .'"><b>'.functions::gradient('' . $aa['name'] . '', '' . $colornick['colornick'] . '',''.$colornick['colornick2'].'').'</b></a>&#160;';
$rank  = array(
0  => '',
1  => '(GMod)',
2  => '(CMod)',
3  => '(FMod)',
4  => '(DMod)',
5  => '(LMod)',
6  => '(Smd)',
7  => '(Adm)',
9  => '(SV!)'
);
$Rights  = isset($aa['rights']) ? $aa['rights'] : 0;
echo  $rank[$Rights];
echo ( time() > $aa['lastdate'] + 300 ? '<span class="red"> [Off]</span>' : '<span class="green"> [ON]</span>');
if (!empty($aa['status'])) {
echo '<div class="status">' . functions::image('label.png', array('class' => 'icon-inline')).(strlen($cstat) == 1 ? '' . $aa['status'] . '' : '<font color="'.$aa['cstat'].'">' . $aa['status'] . '</font>').'</div>';
}
echo '<br/><span class="gray"></span> ' . $aa['postchat'] . ' ta xabar';
 echo '</td></tr></table></div>';
}
}

//KOMMENTLAR

echo ' <div class="phdr">Fikrlari bo`yicha Top-10</div>';

$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` "),0);
$ab = mysql_query("SELECT * FROM `users` ORDER BY `komm` DESC LIMIT 10");
$i = 0;
if($total){
while($aa = mysql_fetch_assoc($ab)){
echo $i % 2 ? '<div  class="list2">' : '<div  class="list1">';
echo '<table cellpadding="0" cellspacing="0"><tr><td>';
if (file_exists((ROOTPATH . 'files/users/avatar/' . $total['id'] .'.png')))
echo '<img src="' . $home . '/files/users/avatar/' . $total['id'] . '.png" width="32" height="32" alt="" />&#160;';
else
echo '<img src="' . $home . '/images/empty.png" width="32" height="32" alt="" />&#160;';
echo '</td><td>';
if ($aa['sex'])
echo functions::image(($aa['sex'] == 'm' ? 'm' : 'w') . ($aa['datereg'] > time() - 86400 ? '_new' : '') . '.png', array('class' => 'icon-inline'));
$colornick = mysql_fetch_assoc(mysql_query("select `colornick`,`colornick2` from `users` where `id`='".$aa['id']."';"));
echo !$user_id || $user_id == $total['id'] ? '<b>'.functions::gradient('' . $aa['name'] . '', '' . $colornick['colornick'] . '',''.$colornick['colornick2'].'').'</b>&#160;' : '<a href="' . $home . '/users/profile.php?user=' . $aa['id'] .'"><b>'.functions::gradient('' . $aa['name'] . '', '' . $colornick['colornick'] . '',''.$colornick['colornick2'].'').'</b></a>&#160;';
$rank  = array(
0  => '',
1  => '(GMod)',
2  => '(CMod)',
3  => '(FMod)',
4  => '(DMod)',
5  => '(LMod)',
6  => '(Smd)',
7  => '(Adm)',
9  => '(SV!)'
);
$Rights  = isset($aa['rights']) ? $aa['rights'] : 0;
echo  $rank[$Rights];
echo ( time() > $aa['lastdate'] + 300 ? '<span class="red"> [Off]</span>' : '<span class="green"> [ON]</span>');
if (!empty($aa['status'])) {
echo '<div class="status">' . functions::image('label.png', array('class' => 'icon-inline')).(strlen($cstat) == 1 ? '' . $aa['status'] . '' : '<font color="'.$aa['cstat'].'">' . $aa['status'] . '</font>').'</div>';
}
echo '<br/><span class="gray">Fikrlar soni:</span> ' . $aa['komm'] . 'ta';
 echo '</td></tr></table></div>';
}
}


//FORUM

echo ' <div class="phdr">Forum postlari Top-10</div>';

$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` "),0);
$ab = mysql_query("SELECT * FROM `users` ORDER BY `postforum` DESC LIMIT 10");
$i = 0;
if($total){
while($aa = mysql_fetch_assoc($ab)){
echo $i % 2 ? '<div  class="list2">' : '<div  class="list1">';
echo '<table cellpadding="0" cellspacing="0"><tr><td>';
if (file_exists((ROOTPATH . 'files/users/avatar/' . $total['id'] .'.png')))
echo '<img src="' . $home . '/files/users/avatar/' . $total['id'] . '.png" width="32" height="32" alt="" />&#160;';
else
echo '<img src="' . $home . '/images/empty.png" width="32" height="32" alt="" />&#160;';
echo '</td><td>';
if ($aa['sex'])
echo functions::image(($aa['sex'] == 'm' ? 'm' : 'w') . ($aa['datereg'] > time() - 86400 ? '_new' : '') . '.png', array('class' => 'icon-inline'));
$colornick = mysql_fetch_assoc(mysql_query("select `colornick`,`colornick2` from `users` where `id`='".$aa['id']."';"));
echo !$user_id || $user_id == $total['id'] ? '<b>'.functions::gradient('' . $aa['name'] . '', '' . $colornick['colornick'] . '',''.$colornick['colornick2'].'').'</b>&#160;' : '<a href="' . $home . '/users/profile.php?user=' . $aa['id'] .'"><b>'.functions::gradient('' . $aa['name'] . '', '' . $colornick['colornick'] . '',''.$colornick['colornick2'].'').'</b></a>&#160;';
$rank  = array(
0  => '',
1  => '(GMod)',
2  => '(CMod)',
3  => '(FMod)',
4  => '(DMod)',
5  => '(LMod)',
6  => '(Smd)',
7  => '(Adm)',
9  => '(SV!)'
);
$Rights  = isset($aa['rights']) ? $aa['rights'] : 0;
echo  $rank[$Rights];
echo ( time() > $aa['lastdate'] + 300 ? '<span class="red"> [Off]</span>' : '<span class="green"> [ON]</span>');
if (!empty($aa['status'])) {
echo '<div class="status">' . functions::image('label.png', array('class' => 'icon-inline')).(strlen($cstat) == 1 ? '' . $aa['status'] . '' : '<font color="'.$aa['cstat'].'">' . $aa['status'] . '</font>').'</div>';
}
echo '<br/><span class="gray">Forum postlari:</span> ' . $aa['postforum'] . '';
 echo '</td></tr></table></div>';
}
}

require('../incfiles/end.php');
?>