Файл: 4mast/profmas.ru/downloads/search.php
Строк: 24
<?php
require_once('../includes/Headers.php');
require_once('../includes/PDO_func.php');
H ('Поиск файлов', 'Поиск файлов');
if (isset($_SESSION['search'])) $search = htmlspecialchars(trim($_SESSION['search']));
if (isset($_POST['search'])) $search = htmlspecialchars(trim($_POST['search']));
$_SESSION['search'] = $search;
if ($_POST['search'] || $search)
{
$count = DB::$dbs->querySingle("SELECT COUNT(id) FROM down_files WHERE dop = ? AND name LIKE ?", array("da","%$search%"));
$items_per_page = 10;
$pages = ceil($count/$items_per_page);
if ($page < 1) {
$page = 1;
}
if ($page > $pages) {
$page = $pages;
}
$start = $page * $items_per_page - $items_per_page;
if ($count == 0) {
echo '<div class="error">Поиск не дал результата!</div>';
unset($_SESSION['search']);
}
else {
$sql = DB::$dbs->query("SELECT * FROM down_files WHERE dop = ? AND name LIKE ? ORDER BY time DESC LIMIT $start, $items_per_page", array("da","%$search%"));
while($a = $sql -> fetch ()) {
echo '<div class="block">' .fname($a['id']). ' ('.sizef($a['size']). ') ' . ($a['time'] > (time () - 86400) ? ' <b style="color:red;">new</b>':NULL).'</div>';
}
}
if ($pages > 1) {
echo '<div class="lst">' .pages('?'). '</div>';
}
}
echo '<div class="ass"><div class="news">Введите поисковый запрос:<br/><form method="POST" action="?"><input type="text" name="search" value="'.$search.'" /><br/><input type="submit" value="Поиск"/></form></div>';
echo '</div></div>';
require_once('../includes/Footers.php');
?>