File size: 4.48Kb
<?php
# Made by: Solo #
# Site: Wapik.us #
# ICQ: 921937 #
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";
if(!isset($_GET["action"]))
{
echo '<div align="center"><b>Рейтинг игроков!</b></div>';
$dir = opendir (BASEDIR."local/vis/prof");
unset($a);
while ($file = readdir ($dir))
{
if (ereg(".dat", $file))
{
$a[]=$file;
}
}
closedir ($dir);
$total = count($a);
//------------------------------ НОВАЯ ФУНКЦИЯ КЕШИРОВАНИЯ ------------------------------//
for ($i = 0; $i < $total; $i++)
{
$tex = file(BASEDIR."local/vis/prof/".$a[$i]);
$data = explode(":||:", $tex[0]);
$dat_log[]=$data[0];
$dat_vi[]=$data[1];
$dat_pro[]=$data[2];
}
if(isset($_GET["sort"])) $sort=$_GET["sort"];
else $sort="pob";
if($sort=="pob") $dat_s=$dat_vi;
if($sort=="pro") $dat_s=$dat_pro;
arsort($dat_s);
foreach($dat_s as $k=>$v)
{
$dat_log3[]=$dat_log[$k];
$dat_pro3[]=$dat_pro[$k];
$dat_s3[]=$dat_s[$k];
$dat_vi3[]=$dat_vi[$k];;
}
foreach($dat_s3 as $k2=>$v2)
{
$gg++;
$dat_ball2[]=$gg.'|'.$dat_log3[$k2].'|'.$dat_vi3[$k2].'|'.$dat_pro3[$k2].'|';
}
unlink(BASEDIR."local/vis/top.dat");
for ($i = 0; $i < $total; $i++)
{
$fp = fopen(BASEDIR."local/vis/top.dat","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$dat_ball2[$i]\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
chmod ($fp, 0666);
chmod (BASEDIR."local/vis/top.dat", 0666);
}
//------------------------------ ВЫВОД ИЗ КЕША ------------------------------//
$file = file(BASEDIR."local/vis/top.dat");
$total = counter_string(BASEDIR."local/vis/top.dat");
if ($_GET['start']=="") {$start = 0;}
if ($total < $start + $config_userlist){ $end = $total; }
else {$end = $start + $config_userlist; }
echo 'Сортировать по <br>';
if($_GET["sort"]!="pob" && isset($_GET["sort"]))
echo '[<a href="top.php?sort=pob&'.SID.'">победам</a>]';
if($_GET["sort"]!="pro")
echo '[<a href="top.php?sort=pro&'.SID.'">поражениям</a>]';
echo'<br><br>';
for ($i = $start; $i < $end; $i++)
{
$data = explode("|", $file[$i]);
echo '<div class=b><b>'.$data[0].'. <img src="../images/img/chel.gif" alt=""> ';
echo '<a href="../pages/anketa.php?uz='.$data[1].'&'.SID.'">'.nickname($data[1]).'</a></b> '.user_online($data[1]).'';
if($dostup==101 || $dostup==102)
{
echo ' [<a href="top.php?action=del&uz='.$data[1].'&'.SID.'"><font color="red">del</font></a>]';
}
echo '</div>';
echo 'Побед: <b>'.(int)$data[2].'</b><br>';
echo 'Поражений: <b>'.(int)$data[3].'</b><br>';
}
echo'<hr>';
if ($start != 0) {echo '<a href="top.php?start='.($start - $config_userlist).'&sort='.$sort.'&'.SID.'"><-Назад </a> ';}else{echo'<-Назад ';}
echo'|';
if ($total > $start + $config_userlist) {echo ' <a href="top.php?start='.($start + $config_userlist).'&sort='.$sort.'&'.SID.'"> Далее-></a>';}else{echo' Далее->';}
if($total>0)
{
$ba=ceil($total/$config_userlist);
$ba2=$ba*$config_userlist - $config_userlist;
echo '<br><hr>Страницы:';
$asd=$start- ($config_userlist*4);
$asd2=$start+($config_userlist*5);
if($asd<$total && $asd>0){echo ' <a href="top.php?start=0&sort='.$sort.'&'.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="top.php?start='.$i.'&sort='.$sort.'&'.SID.'">'.$ii.'</a>';
}
}
$i=$i+$config_userlist;
}
if($asd2<$total){echo ' ... <a href="top.php?start='.$ba2.'&sort='.$sort.'&'.SID.'">'.$ba.'</a>';}
}
echo '<br><br>Всего игроков: <b>'.$total.'</b><br>';
echo'<a href="index.php?'.SID.'">В меню</a>';
include_once"../themes/".$config_themes."/foot.php";
}
if($_GET["action"]=="del" && ($dostup==101 || $dostup==102))
{
if(!eregi("[^a-z0-9_.-]",$_GET["uz"]))
{
unlink(BASEDIR."local/vis/prof/$uz.dat");
header("location: top.php?".SID);
exit;
}
else
{
header("location: top.php?isset=403&".SID);
exit;
}
}
?>