File size: 4.92Kb
<?php
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"setforum.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>';
$suf = @file(BASEDIR."local/dataforumset/dataforumuser/$log.dat");
if ($suf!=""){
$lsf = explode(":||:",$suf[0]);}
if($config_forum_off=="1"){
if ($provlog==$_SESSION['log'] && $provpar==md5($_SESSION['par']) && $_SESSION['log']!="" && md5($_SESSION['par'])!=""){
if($config_top=="1"){
if(!empty($lsf[3]) || $config_usnastr==0){
$time=time();
$date=date("d.m.y");
//------------------------------ НОВАЯ ФУНКЦИЯ КЕШИРОВАНИЯ ------------------------------//
$filtime=filemtime("../local/datatmp/topthemes.dat");
$themfile=file("../local/datatmp/topthemes.dat");
$them_count=count($themfile);
$filtime=$filtime+(3600*$config_themesforumcache);
if($time>$filtime || $them_count<50){
$dir = opendir ("../local/dataforum");
while ($file = readdir ($dir)) {
if (ereg ("\.dat$", $file) && !ereg ("\.sex$", $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("../local/dataforum/$alltopthem[$i].dat");
$summa=count($tex);
$dat_total[]=$summa;
$dat_count[]=$alltopthem[$i]; }
arsort($dat_total);
clear_files("../local/datatmp/topthemes.dat");
foreach($dat_total as $k=>$v){ $gg++;
$tex = file("../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[5].'|'.$data[6].'|';
}}
$dat_top=implode("\r\n",$dat_top);
if($dat_top!=""){
$fp = fopen("../local/datatmp/topthemes.dat","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$dat_top\r\n");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
chmod ($fp, 0666);
chmod ("../local/datatmp/topthemes.dat", 0666);
}
}
//------------------------------ ВЫВОД ИЗ КЕША ------------------------------//
$file = file("../local/datatmp/topthemes.dat");
$total = count($file);
if ($start=="") {$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].'&id='.$data[3].'&'.SID.'">'.$data[4].'</a></b></div>
Всего сообщений: '.$data[5].'<br>
Посл. сообщение: <b>'.$data[6].'</b> ('.$data[7].'/'.$data[8].')<br>';
}
echo'<hr>';
if ($start != 0) {echo '<a href="top.php?start='.($start - $config_forumtem).'&'.SID.'"><-Назад</a> ';}else{echo'<-Назад';}
echo ' | ';
if ($total > $start + $config_forumtem) {echo ' <a href="top.php?start='.($start + $config_forumtem).'&'.SID.'">Далее-></a>';}else{echo'Далее->';}
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&'.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.'&'.SID.'">'.$ii.'</a>';
}}
$i=$i+$config_forumtem;}
if($asd2<$total){echo ' ... <a href="top.php?start='.$ba2.'&'.SID.'">'.$ba.'</a>';}
}
}else{
echo'<center><font color="red">Топ популярных тем на форуме отключен вами в личных настройках!!!</font></center>';}}
if($config_top=="0"){
echo'<center><font color="red">Топ популярных тем на форуме отключен!!!</font></center>';}
}else{
echo'Вы не авторизованы для просмотра';}
}
if($config_forum_off=="0"){
echo'<center><font color="red">Форум сайта отключен!</font></center>';}
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";
?>