Просмотр файла pages/lifelist.php

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

if(isset($_POST['uz'])){$uz=check(trim($_POST['uz']));} else {$uz=check(trim($_GET['uz']));}

echo '<div class=tp>Рейтинг долгожителей</div><div class="forum">';

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

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

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

foreach (glob(BASEDIR."local/datalife/*.dat") as $filename) {
$a[] = basename($filename);
}

$total = count($a);

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

if($data[0]!=""){

$dat_life[]=(int)$data[1];
$dat_login[]=check($data[2]);
}}

arsort($dat_life);

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

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

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



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

$start = (int)$_GET['start'];
if($start < 0 || $start > $total){$start = 0;}
if ($total < $start + $config_lifelist){ $end = $total; }
else {$end = $start + $config_lifelist; }
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].'&amp;'.SID.'"><font color="#FF0000">'.nickname($data[2]).'</font></a></big></b> ';
}else{
echo '<b><a href="../pages/anketa.php?uz='.$data[2].'&amp;'.SID.'">'.nickname($data[2]).'</a></b> ';
}

echo user_online($data[2]).'<br>';
echo 'Провел на сайте: '.makestime($data[3]).'<br>';

$text = file(BASEDIR."local/profil/$data[2].prof");
if ($text!=""){
$uzdata = explode(":||:",$text[0]);
if ($uzdata[6]!="") {echo'Дата регистрации: '.date("j.m.Y",check($uzdata[6])).'</div>';}
}


}

echo '</div><div class="body">';
if ($start != 0) {echo '<a href="lifelist.php?start='.($start - $config_lifelist).'&amp;'.SID.'">&lt;пред. </a>';}else{echo'&lt;пред.';}
echo' | ';
if ($total > $start + $config_lifelist) {echo ' <a href="lifelist.php?start='.($start + $config_lifelist).'&amp;'.SID.'">след.&gt;</a>';}else{echo'след.&gt;';}

if($total>0){

$ba=ceil($total/$config_lifelist);
$ba2=$ba*$config_lifelist-$config_lifelist;

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

if($asd<$total && $asd>0){echo ' <a href="lifelist.php?start=0&amp;'.SID.'">1</a> ... ';}

for($i=$asd; $i<$asd2;){

if($i<$total && $i>=0){
$ii=floor(1+$i/$config_lifelist);

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

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


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


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

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

$stranica = floor($i / $config_lifelist) * $config_lifelist;

if($start!=$stranica){
header ("Location: lifelist.php?start=$stranica&uz=$uz&".SID);
}

$pos = $i + 1;
echo '<br><font color="#00FF00">Позиция в рейтинге:</font> <b>'.$pos.'</b><br>';

break;
}}

if($pos==""){ echo '<div class="panel"><font color="#FF0000">Пользователь с таким логином не найден!</font><br>';}

echo '<a href="lifelist.php?start='.$start.'&amp;'.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";
?>