File size: 5.53Kb
<?php
// mod by Golem http://veplog.ru
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
include_once"../themes/$config_themes/index.php";
include_once"../template/isset.php";
$uz=check($uz);
echo '<div class=tp> <b>Рейтинг толстосумов</b></div><div class"forum">';
//------------------------------ НОВАЯ ФУНКЦИЯ КЕШИРОВАНИЯ ------------------------------//
$filtime=filemtime(BASEDIR."local/datatmp/raitinglist.dat");
$userfile=file(BASEDIR."local/datatmp/raitinglist.dat");
$user_count=count($userfile);
$filtime=$filtime+(3600*$config_raitinglistcache); //12-часовое индексирование
if($sitetime>$filtime || $user_count<50){
foreach (glob(BASEDIR."local/profil/*.prof") as $filename) {
$a[] = basename($filename);
}
$total = count($a);
for ($i = 0; $i < $total; $i++){
$tex = file(BASEDIR."local/profil/$a[$i]");
$data = explode(":||:",$tex[0]);
$dat_log[]=$data[0];
$dat_gold[]=$data[41];
}
foreach($dat_gold as $k=>$v){
$usersum="0";
$lines=file(BASEDIR."local/bank.dat");
$county=count($lines);
for ($b=0; $b<$county; $b++) {
$dty=explode("|",$lines[$b]); if ($dty[1]==$dat_log[$k]) {$usersum=$dty[2];}}
$ob_summa=$v+$usersum;
if($ob_summa>0){
$dat_login[]=$dat_log[$k];
$dat_bank[]=$usersum;
$dat_golden[]=$ob_summa;
$dat_all[]=$v;
}}
arsort($dat_golden);
foreach($dat_golden as $k=>$v){ $gg++;
$dat_top[]='|'.$gg.'|'.$dat_login[$k].'|'.$v.'|'.$dat_all[$k].'|'.$dat_bank[$k].'|';
}
$dat_top=implode("\r\n",$dat_top);
if($dat_top!=""){
$fp = fopen(BASEDIR."local/datatmp/raitinglist.dat","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);
fputs($fp,"$dat_top\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
chmod ($fp, 0666);
chmod (BASEDIR."local/datatmp/raitinglist.dat", 0666);
}
}
//------------------------------ ВЫВОД ИЗ КЕША ------------------------------//
echo'<div class="forum">';
$file = file(BASEDIR."local/datatmp/raitinglist.dat");
$total = count($file);
$start = (int)$_GET['start'];
if($start < 0 || $start > $total){$start = 0;}
if ($total < $start + $config_userlist){ $end = $total; }
else {$end = $start + $config_userlist; }
for ($i = $start; $i < $end; $i++){
$data = explode("|",$file[$i]);
echo '<div class=r0>'.$data[1].'. ';
if($uz==$data[2]){
echo '<b><big><a href="../pages/anketa.php?uz='.$data[2].'&'.SID.'"><font color="#FF0000">'.nickname($data[2]).'</font></a></big></b> ';
}else{
echo '<b><a href="../pages/anketa.php?uz='.$data[2].'&'.SID.'">'.nickname($data[2]).'</a></b> ';
}
echo '('.(int)$data[3].' монет)<br>';
echo 'На руках: '.(int)$data[4].'<br>В банке: '.(int)$data[5].'</div>';
}
echo'</div><div class="body">';
if ($start != 0) {echo '<a href="raitinglist.php?start='.($start - $config_userlist).'&'.SID.'"><пред.</a> ';}else{echo'<пред.';}
echo' | ';
if ($total > $start + $config_userlist) {echo ' <a href="raitinglist.php?start='.($start + $config_userlist).'&'.SID.'">след.></a>';}else{echo'след.>';}
if($total>0){
$ba=ceil($total/$config_userlist);
$ba2=$ba*$config_userlist-$config_userlist;
echo '<br>Стр.:';
$asd=$start-($config_userlist*4);
$asd2=$start+($config_userlist*5);
if($asd<$total && $asd>0){echo ' <a href="raitinglist.php?start=0&'.SID.'">1</a> ... ';}
for($i=$asd; $i<$asd2;){
if($i<$total && $i>=0){
$ii=floor(1+$i/$config_userlist);
if ($start==$i) {
echo ' <b>('.$ii.')</b>';
} else {
echo ' <a href="raitinglist.php?start='.$i.'&'.SID.'">'.$ii.'</a>';
}}
$i=$i+$config_userlist;}
if($asd2<$total){echo ' ... <a href="raitinglist.php?start='.$ba2.'&'.SID.'">'.$ba.'</a>';}
}
//-----------------------------------------------------------------//
if($uz==""){
echo '<div class="panel">Поиск пользователя:<br>';
if($config_themes!="wml"){
echo '<form action="raitinglist.php?start='.$start.'&'.SID.'" method="post">';
echo'<input name="uz" value="'.$log.'" /><br>';
echo '<input type="submit" value="Искать" /></form>';
}else{
echo'<input name="uz" value="'.$log.'"/><br>';
echo'<anchor>Искать';
echo'<go href="raitinglist.php?start='.$start.'&'.SID.'" method="post">';
echo'<postfield name="uz" value="$(uz)"/>';
echo'</go></anchor><br>--------------------';
}
}else{
$file = file(BASEDIR."local/datatmp/raitinglist.dat");
$total = count($file);
for ($i = 0; $i < $total; $i++){
$data = explode("|",$file[$i]);
if (trim($uz)==$data[2]){
$stranica = floor($i / $config_userlist) * $config_userlist;
if($start!=$stranica){
header ("Location: raitinglist.php?start=$stranica&uz=$uz&".SID);
}
$pos = $i + 1;
echo '<div class="panel"><font color="#00FF00">Позиция в рейтинге:</font> <b>'.$pos.'</b><br>';
break;
}}
if($pos==""){ echo '<hr><br><b><font color="#FF0000">Пользователь с таким логином не найден!</font></b><br>';}
echo '<a href="raitinglist.php?start='.$start.'&'.SID.'">Искать еще</a><br>';
}
echo 'Всего юзеров: <b>'.(int)$total.'</b></div>';
echo'<div class="btm">[<a href="../index.php?'.SID.'">На главную</a>]</div>';
include_once"../themes/$config_themes/foot.php";
?>