Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<?php
$dir = "files/"; // директорията, задължително с "/" накрая
function cmp($a, $b)
{
global $dir;
$o = strcmp(fileatime($dir.$b), fileatime($dir.$a));
return (!$o) ? strcmp($a, $b) : $o;
}
$files = array_diff(scandir($dir), array(".", ".."));
usort($files, "cmp");
foreach ($files as $file)
echo $file."<br />\n";
?>
<?php
$page = 2; //брой на новини на странца
$broi = 0;
$handle = opendir('posts/');
while ($read_file = readdir($handle))
{
if (!is_link($read_file) and $read_file != "." and $read_file != ".." and $read_file != "thumbs.db")
{
$broi = $broi + 1;
}
}
closedir($handle);
$pages=ceil($broi/$page); //пресмятаме колко ще са страниците
$pg = (int)$_GET['page'];
if(!$pg || !isset($pg))
{
$pg = 1; $n = 1;
$handle = opendir('posts/');
while ($read_file = readdir($handle))
{
if (!is_link($read_file) and $read_file != "." and $read_file != ".." and $read_file != "thumbs.db")
{
if($n<=$page)
{
include "./posts/$read_file";
echo "<BR />";
$n = $n + 1;
}
}
}
}
else
{
if($pg <= 0 || $pg == NULL || $pg>$pages)
{
$pg = 1;
}
else
{
$limit = ($pg-1)*$page;
$limh = 0; $i = 0;
$handle = opendir('posts/');
while ($read_file = readdir($handle))
{
if (!is_link($read_file) and $read_file != "." and $read_file != ".." and $read_file != "thumbs.db")
{
$limh = $limh + 1;
if($limit < $limh and $i<$page)
{
include "./posts/$read_file";
echo "<BR />";
$i = $i + 1;
}
}
}
}
}
if($pg <= $pages and $pg != 1)
{
$prev = $pg - 1;
echo "<a href='index.php?page=$prev'>[Предишна]</a>";
}
elseif($pg == 1)
{
echo "[Предишна]";
}
if($pg < $pages and $pg != $pages)
{
$next = $pg + 1;
echo "<a href='index.php?page=$next'>[Следваща]</a>";
}
elseif($pg == $pages)
{
echo "[Следваща]";
}
?>