Просмотр файла forum/topusers.php

Размер файла: 4.98Kb
<?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>';

//------------------------------ НОВАЯ ФУНКЦИЯ КЕШИРОВАНИЯ ------------------------------//
$filtime=filemtime("../local/datatmp/topusers.dat");
$userfile=file("../local/datatmp/topusers.dat");
$user_count=count($userfile);

$filtime=$filtime+(3600*$config_userforumcache);

if($sitetime>$filtime || $user_count<50){

$dir = opendir ("../local/profil");
while ($file = readdir ($dir)) {
if (ereg ("\.prof$", $file)) {
$alltopusers[]=$file;}}
closedir ($dir);
$total = count($alltopusers);

for ($i = 0; $i < $total; $i++){
$tex = file("../local/profil/$alltopusers[$i]");
$data = explode(":||:",$tex[0]);

if($data[8]>0  && $data[0]!=""){
$dat_log[]=$data[0];
$dat_forum[]=$data[8];
}}

arsort($dat_forum);

foreach($dat_forum as $k=>$v){ $gg++;
$dat_top[]='|'.$gg.'|'.$dat_log[$k].'|'.$dat_forum[$k].'|';
}

$dat_top=implode("\r\n",$dat_top);

if($dat_top!=""){
$fp = fopen("../local/datatmp/topusers.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 ("../local/datatmp/topusers.dat", 0666);
}
}



//------------------------------ ВЫВОД ИЗ КЕША ------------------------------//
$file = file("../local/datatmp/topusers.dat");
$total = count($file);

$start = (int)$_GET['start'];
if($start < 0 || $start > $total){$start = 0;}
if ($total < $start + $config_topforums){ $end = $total; }
else {$end = $start + $config_topforums; }
for ($i = $start; $i < $end; $i++){

$data = explode("|",$file[$i]);

echo '<div class="forum"><div class="r0">';

echo $data[1].'.  ';
if($uz==$data[2]){
echo '<big><a href="../pages/anketa.php?uz='.$data[2].'&amp;'.SID.'"><font color="#FF0000">'.nickname($data[2]).'</font></a></big>';
}else{
echo '<a href="../pages/anketa.php?uz='.$data[2].'&amp;'.SID.'">'.nickname($data[2]).'</a>';}
echo ' ['.$data[3].']</div></div>';
}
echo'';
if ($start != 0) {echo '<a href="topusers.php?start='.($start - $config_topforums).'&amp;'.SID.'">&lt;Пред.</a> ';}else{echo'&lt;Пред.';}
echo' | ';
if ($total > $start + $config_topforums) {echo ' <a href="topusers.php?start='.($start + $config_topforums).'&amp;'.SID.'">След.&gt;</a>';}else{echo'След.&gt;';}
if($total>0){
$ba=ceil($total/$config_topforums);
$ba2=$ba*$config_topforums-$config_topforums;

echo '<br>Стр.:';
$asd=$start-($config_topforums*4);
$asd2=$start+($config_topforums*5);

if($asd<$total && $asd>0){echo ' <a href="topusers.php?start=0&amp;'.SID.'">1</a> ... ';}
for($i=$asd; $i<$asd2;){
if($i<$total && $i>=0){
$ii=floor(1+$i/$config_topforums);

if ($start==$i) {
echo ' <b>('.$ii.')</b>';
} else {
echo ' <a href="topusers.php?start='.$i.'&amp;'.SID.'">'.$ii.'</a>';
}}

$i=$i+$config_topforums;}
if($asd2<$total){echo ' ... <a href="topusers.php?start='.$ba2.'&amp;'.SID.'">'.$ba.'</a>';}
}

//-----------------------------------------------------------------//
if($uz==""){
echo '<div class="panel"><b>Поиск пользователя:</b><br>';
if($config_themes!="wml"){
echo '<form action="topusers.php?start='.$start.'&amp;'.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="topusers.php?start='.$start.'&amp;'.SID.'" method="post">';
echo'<postfield name="uz" value="$(uz)"/>';
echo'</go></anchor><br>--------------------';
echo'</div>';
}
}else{

$file = file("../local/datatmp/topusers.dat");
$total = count($file);
for ($i = 0; $i < $total; $i++){

$data = explode("|",$file[$i]);
if (trim($uz)==$data[2]){

$stranica = floor($i / $config_topforums) * $config_topforums;
if($start!=$stranica){
header ("Location: topusers.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="topusers.php?start='.$start.'&amp;'.SID.'">Искать еще</a><br>';
}


echo 'Всего юзеров: <b>'.(int)$total.'</b></div>';
echo'<div class="btm">[<a href="../forum/index.php">В форум</a>]</div>';



include_once"../themes/$config_themes/foot.php";
?>