View file top.php

File size: 1.73Kb
<?php 
$mt=microtime(1);
require_once('config.php');
require_once('shapka.php');
require_once('func.php');
print '<div class="top">Топ-50 статей</div>';
$result=mysql_query("SELECT * from filelib  ORDER by look DESC LIMIT 50") or die(mysql_error());
$page=intval(@$_GET['page']);
$start=$page*$filestr;
$end=$start+$filestr;
mysql_data_seek($result, $start);
while($filearr=mysql_fetch_assoc($result))
		{
		$filename="$maindir/$filearr[filename]";
		if(file_exists($filename))
		{
		$filectime=filectime($filename);
		$namef='';
			$opisf='';
			$fp=fopen($filename, 'r');
			for($i=0; $i<5; $i++)
				{
				$tt=fgets($fp);
				if($i==$namestr)
					{
					$namef=htmlspecialchars($tt);
					if($encoding)
					$namef=mb_convert_encoding($namef,'utf-8', $encoding );
					}
				if($i==$opisstr)
					{
					$opisf=htmlspecialchars($tt);
					if($encoding)
					$opisf=mb_convert_encoding($opisf,'utf-8', $encoding );
					}
				}
			$opisf=trim($opisf);
			fclose($fp);
		if($filectime>time()-$timenew)
		print '<b>new!</b>';
		print "<a href=\"look.php?file=$filearr[fid]\">$namef</a><br />";
		if($opisf)
		print $opisf.'<br />';
		print 'Просмотров: '.$filearr['look'].'<br />';
		$start++;
		if($start>=$end)
		break;
		}
		}
	$count=mysql_num_rows($result);
		if($count>$filestr)
			{
			$countstr=ceil($count/$filestr);
			print nav_page($countstr,$page,'top.php?page=');
			}


if(@$_SESSION['admin'])
print '<a href="admin.php">Админ-панель</a><br />';
print "&gt;<a href=\"index.php\">Разделы</a><br />";
print '</div><div class="down"><a href="'.$mainpage.'">'.$mainname.'</a><br /></div><div>';

require('foot.php');
echo '<!--'.(microtime(1)-$mt).'-->';
?>