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

Размер файла: 4.43Kb
<?php
#-----------------------------------------------------#
#          ********* WAP-MOTORS *********             #
#             Made by   :  VANTUZ                     #
#               E-mail  :  [email protected]         #
#                 Site  :  http://pizdec.ru           #
#             WAP-Site  :  http://visavi.net          #
#                  ICQ  :  36-44-66                   #
#  Вы не имеете право вносить изменения в код скрипта #
#-----------------------------------------------------#	
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";

echo '<img src="../images/img/menu.gif" alt=""> <b>Топ популярных тем</b><br><br>';

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

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

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



$dir = opendir (BASEDIR."local/dataforum"); 
while ($file = readdir ($dir)) {
if (ereg ("\.dat$", $file) && !ereg("^top", $file)&& !ereg("^main", $file)) {
$alltopthem[]=$file;
}} 
closedir ($dir); 		
$total = count($alltopthem); 
	
	
$alltopthem=str_replace(".dat","",$alltopthem);		
for ($i = 0; $i < $total; $i++){
$tex = file(BASEDIR."local/dataforum/$alltopthem[$i].dat");
$summa=count($tex);
$dat_total[]=$summa;
$dat_count[]=$alltopthem[$i];
}

arsort($dat_total);

foreach($dat_total as $k=>$v){ $gg++;

$tex = file(BASEDIR."local/dataforum/$dat_count[$k].dat");
$tex = array_reverse($tex);
$data = explode("|",$tex[0]);	
	

if($dat_count[$k]!="" && $data[8]!=""){
$dat_top[]='|'.$gg.'|'.$data[8].'|'.$dat_count[$k].'|'.$data[3].'|'.$v.'|'.$data[0].'||'.$data[9].'|';	
}}

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

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


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

$start = (int)$_GET['start'];
if($start < 0 || $start > $total){$start = 0;}
if ($total < $start + $config_forumtem){ $end = $total; }
else {$end = $start + $config_forumtem; }
for ($i = $start; $i < $end; $i++){
	
$data = explode("|",$file[$i]);

echo '<div class=b><b><img src="../images/img/files.gif" alt="">  '.$data[1].'. 
<a href="index.php?fid='.$data[2].'&amp;id='.$data[3].'&amp;'.SID.'">'.$data[4].'</a></b></div>
Всего сообщений: '.$data[5].'<br>
Посл. сообщение: <b>'.$data[6].'</b> ('.date_fixed($data[8]).')<br>';

}

    
echo'<hr>';
if ($start != 0) {echo '<a href="top.php?start='.($start - $config_forumtem).'&amp;'.SID.'">&lt;-Назад</a> ';}else{echo'&lt;-Назад';}
echo ' | ';
if ($total > $start + $config_forumtem) {echo ' <a href="top.php?start='.($start + $config_forumtem).'&amp;'.SID.'">Далее-&gt;</a>';}else{echo'Далее-&gt;';}


if($total>0){

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

echo '<br><hr>Страницы:';
$asd=$start-($config_forumtem*4);
$asd2=$start+($config_forumtem*5);

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

for($i=$asd; $i<$asd2;)
{
if($i<$total && $i>=0){
$ii=floor(1+$i/$config_forumtem);

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


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



echo '<br><br><img src="../images/img/back.gif" alt=""> <a href="index.php?'.SID.'">В форум</a><br>';
echo '<img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a>';
include_once"../themes/$config_themes/foot.php";
	?>