<?php
include 'system/functions.php';
require 'system/start.php';
if (isset($_GET['path']) && isset($_GET['view'])) {
$view = txt($_GET['view']);
$ob = explode('.', $view);
echo '<div class="title">'. outtext($ob[0]) .'</div>
<div class="menu2">';
$path = txt($_GET['path']);
$fl = file('category/'. $path .'/'. $view);
$text = implode($fl);
$ar = explode(' ', $text);
$it = count($ar);
$word = (isset($_GET['word']) ? num($_GET['word']) : 190);
$str = ceil($it/$word);
$pg = (isset($_GET['page']) ? intval($_GET['page']) : 1);
$do = $word * ($pg - 1);
$end = $word * $pg;
$pgn = $pg - 1;
$pgd = $pg + 1;
if ($pg < 0 || $pg > $str)$pg = 1;
for($i=$do; $i<$end; $i++) {
if (!empty($ar[$i]))echo $ar[$i] .' ';
}
echo '</div>
<table style="width:100%" cellspacing="0" cellpadding="0"><tr>';
if ($pg > 1)echo '<td style="width:25%;"><a class="panel" href="index.php?path='. $path .'&view='. $view .'&word='. $word .'&page=1">В начало</a></td>';
if ($pg > 1)echo '<td style="width:25%;"><a class="panel" href="index.php?path='. $path .'&view='. $view .'&word='. $word .'&page='.$pgn .'">Назад</a></td>';
if ($str > $pg)echo '<td style="width:25%;"><a class="panel" href="index.php?path='. $path .'&view='. $view .'&word='. $word .'&page='.$pgd .'">Дальше</a></td>';
if ($str > $pg)echo '<td style="width:25%;"><a class="panel" href="index.php?path='. $path .'&view='. $view .'&word='. $word .'&page='. $str .'">В конец</a></td>';
echo '</tr></table>
<div class="menu2">
Страница: '. $pg .'<br/>
Всего страниц: '. $str .'<br/>
</div>
<a class="menu3" href="index.php?path='. $path .'">В '. outtext($path) .'</a>';
require 'system/end.php';
}
if (isset($_GET['path'])) {
$path = txt($_GET['path']);
$ob = explode('.', $path);
$dir = opendir('category/'. $path);
while($file = readdir($dir))
{
if($file != '.' && $file != '..' && $file[0] != '.' && strtoupper(strrchr($file,'.')) != '.PHP')
{
$file = outtext($file);
$files[] = $file;
}
}
closedir($dir);
echo '<div class="title"><img src="img/ico3.png" alt="menu"/> '. outtext($ob[0]) .'</div>';
if (!isset($files) || $files == 0) {
echo '<div class="menu2"> Файлов нет</div>';
require 'system/end.php';
}
sort($files);
$it = count($files);
$ob = ($it > 10 ? 10 : $it);
$str = ceil($it/$ob);
$pg = (isset($_GET['page']) ? intval($_GET['page']) : 1);
$do = $ob * ($pg - 1);
$end = $ob * $pg;
$pgn = $pg - 1;
$pgd = $pg + 1;
if ($pg < 0 || $pg > $str)$pg = 1;
if ($str <= $pg) $end = round($it-($str/10));
for($i=$do; $i<$end; $i++) {
$file = intext($files[$i]);
$fil = explode('.', $file);
echo '<a class="menu3" href="index.php?path='. $path .'&view='. $file .'"><img src="img/ico.png" alt="-"/> '. outtext($fil[0]) .'</a>';
}
if ($it > $ob) {
echo '<table style="width:100%" cellspacing="0" cellpadding="0"><tr>';
if ($pg > 1)echo '<td style="width:25%;"><a class="panel" href="index.php?path='. $path .'&page='.$pgn .'">Назад</a></td>';
if ($str > $pg)echo '<td style="width:25%;"><a class="panel" href="index.php?path='. $path .'&page='. $pgd .'">Дальше</a></td>';
echo '</tr></table>';
}
echo '<table class="menu2" style="width:100%;" cellspacing="0" cellpadding="0"><tr>
<td style="width:25%;">
<img src="img/count.png" alt="-"/></td>
<td style="width:75%;"> Страница: '. $pg .' из '. $str .'<br/>
Рассказов: '. $it .'</td></tr>
</table>
<a class="menu3" href="./?">К категориям</a>';
require 'system/end.php';
}
else
{
echo '<div class="title"><img src="img/ico3.png" alt="menu"/> Разделы сайта</div>';
$dir = opendir('category');
while($file = readdir($dir))
{
if(!is_dir($file)) {
echo '<a class="menu3" href="index.php?path='.$file.'"><img src="img/ico.png" alt="-"/> '. outtext($file) .' '. getCount('category/'. $file .'/') .'</a>';
}
}
closedir($dir);
require 'system/end.php';
}
?>