<?php
session_name('search');
session_start();
require_once('../classes/body.class.php');
require_once('../classes/db.class.php');
require_once('../classes/system.class.php');
$title= new Body;
$title->SetTitle('Свежие новости - Поиск новостей');

///Подключаем шапку
$title->GetHeader();
echo '<div class="container-fluid page_header"><div class="container"><div class="row"><div class="col-xs-12 col-sm-8 col-md-9 col-lg-9"><h1>Свежие новости </h1><ol class="breadcrumb" xmlns:v="http://'.homeurl.'/#"><li typeof="v:Breadcrumb"><a href="/" rel="v:url" property="v:title">'.homeurl.'</a></li><li typeof="v:Breadcrumb"><a href="/allnews" rel="v:url" property="v:title">Свежие новости</a></li><li class="active" typeof="v:Breadcrumb"><span property="v:title">Поиск новостей</span></li></ol></div></div></div></div>';
echo'<div class="container page_body"><div class="row"><div class="col-xs-12 page_content col-lg-9"><div class="navbar page_content_navbar collapse hidden-lg"><div class="container-fluid"><div class="navbar-collapse"></div></div></div><div class="text_box hidden-lg pr_block_small hidden"></div><div class="container-fluid cols_table">';

echo '<div class="catSides"><a href="/allnews"><i class="md-format-list-bulleted"></i> Свежие новости </a> - Поиск новостей</div>';
if (isset($_GET['search'])) {
$text = str_replace('%','',$_POST['text']);
$text = str_replace("'",'',$_POST['text']);
$text = str_replace('"','',$_POST['text']);
$text = str_replace('-','',$_POST['text']);
$text = check($text);
$_SESSION['text'] = $text;
$text = (!empty($_SESSION['text']) ? $_SESSION['text'] : NULL);
$look = DB::$dbs->querySingle("SELECT COUNT(id) FROM `gazeta_article` WHERE `name` LIKE '%$text%'");
if ($look == 0) {
err('Ничего не найдено!');
}
$num = 10;
$k_page = k_page($look, $num);
$page = page($k_page);
$start = $num*$page-$num;
$sql = DB::$dbs->query("SELECT * FROM `gazeta_article` WHERE `name` LIKE '%$text%' ORDER BY `id` DESC LIMIT $start,$num");
while($a = $sql->fetch()) {
echo '<div class="row text_box"><a href="news.html?id='.$a['id'].'"><i class="md-shuffle"></i>  '.$a['name'].' ('.vr($a['time']).')</a></div>';
}
if ($k_page > 1) {
str('?search&',$k_page,$page);
}
}
echo '<div class="row text_box"><form action="?search" method="POST">Запрос:<br/><input type="text" class="form-control" name="text" placeholder="Введите поисковый запрос"><br/><input type="submit" name="search" class="btn btn-primary" value="Искать"/></form></div>';

///Подключаем меню
$title->GetMenu();

///Подключаем футер
$title->GetFooter();
?>