Размер файла: 5.81Kb
<?php
#--------THE XSIT.RU--------------#
require_once ("../includes/start.php");
require_once ("../includes/functions.php");
require_once ("../includes/header.php");
include_once ("../themes/".$config['themes']."/index.php");
if (isset($_GET['start'])){$start = (int)$_GET['start'];} else {$start = 0;}
show_title('partners.gif', 'Библиотека');
require_once ("../local/library.dat");
$act = $_GET['act'];
$sd = str_replace('..', '', $_GET['sd']);
$d = str_replace('..', '', $_GET['d']);
$f = str_replace('..', '', $_GET['f']);
$page = intval($_GET['page']);
if(!$act)
{
$basesd='../local/datamain/library.dat';
$num_sep = 20;
$preview = file($basesd);
$count = count($preview);
if($count>$num_sep){
nav_page(ceil($count/$num_sep),(isset($_GET['page']) ? $_GET['page']: 1),'index.php?page=');
}
$num_page=1;
if (isset($_GET['page'])) {
if (($_GET['page']>0) and ($_GET['page']<=ceil($count/$num_sep))) $num_page=$_GET['page'];
}
for ( $i=($num_page-1)*$num_sep; $i<=(($num_page*$num_sep<$count) ? $num_page*$num_sep-1: $count-1); $i++)
{
$nomer = $i+1;
$oss = file($basesd);
$selectsd = explode('|', $oss[$i]);
$sdir = opendir(''.$nomer.'/');
$file_array = array();
while($file = readdir ($sdir))
{
if($file[0] != '.'){
$file_array[] = $file;
}
}
$file_count = count($file_array);
echo '<img src="../images/img/dir.gif" alt="image" /> <a href="index.php?act=sd&sd='.$nomer.'">'.$selectsd[1].'</a> ('.$file_count.')<li>'.$selectsd[2].'</li>';
closedir ($sdir);
}
if($count>$num_sep) nav_page(ceil($count/$num_sep),(isset($_GET['page']) ? $_GET['page']: 1),'index.php?page=');
}
if($act=='sd')
{
$conf['items_per_page'] = $sdlist;
if (!isset($page)) {$page = 0;}
$total = 0;
if(!($dp = opendir("$sd"))) die ('Ошибка открытия папки ./');
$file_array = array();
while($file = readdir ($dp))
{
if($file[0] != '.')
{$file_array[] = $file;}
}
$file_count = sizeof($file_array);
natsort($file_array);
if($file_count == 0){
echo 'В разделе пока нет файлов, зайдите позже.<br />';}
if($file_count > 0)
{
$first_record = $page * $conf['items_per_page'];
$last_record = $first_record + $conf['items_per_page'];
while (list($fileIndexValue, $file_name) = each ($file_array))
{
if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record))
{
$datafiles = "$sd/$file_name";
$dataname = file($datafiles);
$filename = trim($dataname[0]);
$file_name = str_replace('.txt','',$file_name);
echo '<a href="index.php?act=view&d='.$sd.'&f='.$file_name.'">'.$filename.'</a><br/>';
}
}
if (($file_count > 0) AND ($page != 0))
{
$prev_page = $page -1;
echo '<br /><a href="'.$_SERVER['PHP_SELF'].'?act=sd&sd='.$sd.'&page='.$prev_page.'"><-Назад</a>';
} else {
echo '<br /><-Назад';}
echo ' | ';
if (($file_count > 0) AND ($last_record < $file_count))
{
$next_page = $page + 1;
echo '<a href="'.$_SERVER['PHP_SELF'].'?act=sd&sd='.$sd.'&page='.$next_page.'">Далее-></a><br/>';
} else {
echo 'Далее-><br/>';}
echo '<br />Всего: '.$file_count;
}
closedir($dp);
echo '<br /><a href="./">к разделам</a><br />';
}
if ($act=='view')
{
$text = file("$d/$f.txt");
function nav_page($count, $num_page, $url)
{
$page_nav = 3;
$begin_loop = 1;
$end_loop=$count;
echo " Страница $num_page из $count<br />";
if ($num_page>$count or $num_page<1) $num_page=1;
if ($num_page>$page_nav) {
echo "  <a href=\"$url".($page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0))).'">'.($page_nav*(floor($num_page/$page_nav)-1-($num_page%$page_nav==0 ? 1: 0))+1).'-'.($page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0))).'</a> ...';
$begin_loop=$page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0))+1;
}
if ($count>$page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0)+1)) { $end_loop=$page_nav*ceil($num_page/$page_nav); }
for ($i = $begin_loop; $i <= $end_loop; $i++) {
if ($i==$num_page) echo '  <strong>'.$i.'</strong>';
else echo '  <a href="'.$url.$i.'">'.$i.'</a>';
}
if ($count>$page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0)+1)) {
echo '  ... <a href="'.$url.($page_nav*ceil($num_page/$page_nav)+1).'">'.($page_nav*ceil($num_page/$page_nav)+1);
if ($page_nav*ceil($num_page/$page_nav)+1<$count) {
echo '-'.($count<=$page_nav*(ceil($num_page/$page_nav)+1) ? $count: $page_nav*(ceil($num_page/$page_nav)+1));
}
echo '</a>';
}
print '<hr />';
}
$count = count($text);
if ($count>$num_sep) nav_page(ceil($count/$num_sep),(isset($_GET['page']) ? $_GET['page']: 1),'index.php?act=view&d='.$d.'&f='.$f.'&page=');
$num_page=1;
if (isset($_GET['page'])) {
if (($_GET['page']>0) and ($_GET['page']<=ceil($count/$num_sep))) $num_page=$_GET['page'];
}
for ( $i=($num_page-1)*$num_sep; $i<=(($num_page*$num_sep<$count) ? $num_page*$num_sep-1: $count-1); $i++) {
echo $text[$i].'<br />';
}
if ($count>$num_sep) nav_page(ceil($count/$num_sep),(isset($_GET['page']) ? $_GET['page']: 1),'index.php?act=view&d='.$d.'&f='.$f.'&page=');
echo '<form action="index.php?" method="get">
<input type="hidden" name="act" value="view"/>
<input type="hidden" name="d" value="'.$d.'"/>
<input type="hidden" name="f" value="'.$f.'"/>
<input type="text" size="3" name="page" value=""/>
<input value="GO" name="do" type="submit"/>
</form>
';
echo '<br /><a href="./">к разделам</a><br />';
}
echo '<img src="../images/img/homepage.gif" alt="image" /> <a href="../index.php?'.SID.'">На главную</a>';
include_once ("../themes/".$config['themes']."/foot.php");
?>