Просмотр файла read.php

Размер файла: 2.81Kb
<?php
error_reporting(0);
header("Content-type: text/html; charset=utf-8");
header("Cache-Control: no-cache");
include 'connect.php';
include 'functions.php';
include 'config.php';
$p=@$_GET['p'];
$p=valid_number($p);
$f=$_GET['f'];
$f=valid_number($f);
$list=$_GET['list'];
$list=valid_number($list);
$res2=mysql_query("SELECT * 
FROM `category`
WHERE `id`='$p'
LIMIT 1");
$arr = mysql_fetch_assoc($res2);
$dec=urldecode($arr['array']);
$dec=unserialize($dec);
if (!is_file($dec[$f]))
{echo 'File not found 404!';
exit();}
$f_read=file_get_contents($dec[$f]);
///--------------------------Определение кодировки-------------------------------------///
if (!preg_match('#.#u',$f_read)){}
else {$f_read=iconv("UTF-8", "windows-1251", $f_read);}///перекодировка в Вин-1251}
///-----------------------------------------------------------------------------------///
$pg_count=ceil(strlen($f_read)/$read_count);
$f_c_r=strlen($f_read);
if ($list>($pg_count-1)){$list=0;}
$list_t=$list*$read_count;
$f_read=htmlspecialchars(substr($f_read,$list_t,$read_count));
$f_read=iconv("windows-1251", "UTF-8", $f_read);///перекодировка в UTF-8





echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<title>'.$title.' -&gt; Библиотека -&gt; '.$arr['name'].' -&gt; '.basename($dec[$f]).'</title>
'.$css.'
</head><body><div align="center">'.$logo.'</div><div class="rekl">'.$reklama.''.$banner_top.'</div>
<div class="zag" align="center">Библиотека -&gt; '.$arr['name'].' -&gt; '.basename($dec[$f]).'</div><div class="c">';
echo nl2br($f_read).'<br/>';


if ($read_count>$f_c_r){}
else
{
	if($list==0)
	{echo '||<a href="'.$folder.'/read.php?p='.$p.'&amp;f='.$f.'&amp;list='.($list+1).'">Далее&gt;</a><br/>';}
	elseif($list>0 and $list<($pg_count-1))
	{echo '<a href="'.$folder.'/read.php?p='.$p.'&amp;f='.$f.'&amp;list='.($list-1).'">&lt;Назад</a>||<a href="'.$folder.'/read.php?p='.$p.'&amp;f='.$f.'&amp;list='.($list+1).'">Далее&gt;</a><br/>';}
	elseif($list==($pg_count-1))
	{echo '<a href="'.$folder.'/read.php?p='.$p.'&amp;f='.$f.'&amp;list='.($list-1).'">&lt;Назад</a>||<br/>';}
echo 'Страница '.$list.' из '.($pg_count-1).'<form action="?" method="get">
<input type="hidden" name="p" value="'.$p.'" />
<input type="hidden" name="f" value="'.$f.'" />
<input type="text" name="list" maxlength="3" size="3" style="-wap-input-format:\'3N\'" />
<input type="submit" value="Ок" />
</form>';
}
echo '<a href="'.$folder.'/?p='.$p.'&amp;f='.$f.'">Меню файла '.basename($dec[$f]).'</a><br/>
<a href="'.$folder.'/?p='.$p.'">Назад в '.$arr['name'].'</a><br/>
'.$banner_foot.'
</div><div class="kon" align="center">
'.$lnk_partner.'
'.$back_link.''.$copy.'</div>
</body></html>';
?>