Файл: modules/search.php
Строк: 115
<?php
session_start();
define('NTOP', 1);
$title = 'Поиск сайта';
require_once('../system/connect.php');
require_once('../system/core.php');
require_once('../system/function.php');
require_once ('../system/head.php');
echo'
<div id="container" class="container main-container" data-spy="affix" data-offset-top="160">
<!-- Breadcrumbs -->
<ol class="breadcrumb">
<li><a href="/">Главная</a></li>
<li class="active">Поиск сайтов</li>
</ol>
<!-- End of Breadcrumbs -->
<!-- Main Content -->
<section role="main">
<header class="main-page-header">
<h1>Поиск сайтов</h1>
<div class="social-share">
<script type="text/javascript" src="//yastatic.net/es5-shims/0.0.2/es5-shims.min.js" charset="utf-8"></script>
<script type="text/javascript" src="//yastatic.net/share2/share.js" charset="utf-8"></script>
<div class="ya-share2" data-services="vkontakte,facebook,gplus,twitter" data-counter=""></div>
</div>
</header>';
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="POST" name="form">
<label for="search" class="required">Введите запрос [min 4 , max 60 символов] <span class="required">*</span></label><br/>
<input size="25" maxlength="25" class="form-control" type="text" id="search" name="search" maxlenght="60" value="'.htmlspecialchars($_POST['search']).'"/><br/>
<label for="m" class="required">Параметры поиска <span class="required">*</span></label><br/>
<div class="form-group"><select class="chosen-select" name="m" id="m">
<option value="1">url</option>
<option value="2">название сайта</option>
<option value="3">описание сайта</option>
</select></div>
<input name="n" type="checkbox" value="1"/><label class="required"> Точный поиск</label><br/>
<hr/><div class="form-group buttons"><input class="btn btn-success" type="submit" name="go" value="Поиск"></div><hr/>
</form></div>';
if (isset($_POST['go']) ) {
if (empty($_POST['search'])) {
$error[1] = 'Вы не ввели адрес сайта !';
}
if (mb_strlen($_POST['search']) < 3 || mb_strlen($_POST['search']) > 64 ) {
$error[2] = 'Длина запроса должна быть не менее 3 символов и не привышать 64 символа !';
}
}
if (!empty($error)) {
echo '<div class="title">';
foreach($error as $value) {
echo "<b>$value</b> <br />";
}
echo '</div>';
require_once ('../modules/foot.php');
exit();
}
$mm = isset ($_POST['m']) ? intval($_POST['m']) : '';
$mm = $mm ? $mm : rawurldecode(trim($_GET['m']));
$n = isset ($_POST['n']) ? $_POST['n'] : '';
$n = $n ? $n : rawurldecode(trim($_GET['n']));
$search = isset ($_POST['search']) ? trim($_POST['search']) : '';
$search = strtr($search, array('_' => '\_', '%' => ' ','$' => ' ', '*' => '%'));
$search = $search ? $search : rawurldecode(trim($_GET['search']));
if ($search) {
$search_db = 'LIKE '' . mysql_real_escape_string('%' . $search . '%') . ''';
if ($_POST['n'] == false) $search_db = 'LIKE '' . mysql_real_escape_string('%' . $search . '%') . ''';
if ($_POST['n'] == true) {
$search_db = '= "'.mysql_real_escape_string($search).'"';
}
$zap = '`about`';
if ($_POST['m'] == 1 || $_GET['mm'] == 1) $zap = '`url`';
if ($_POST['m'] == 2 || $_GET['mm'] == 2) $zap = '`name`';
if ($_POST['m'] == 3 || $_GET['mm'] == 3) $zap = '`about`';
$count = mysql_num_rows(mysql_query("SELECT * FROM `".$prefix."sait` WHERE ".$zap." ".$search_db." "));
if($count > 0)
{
$total=intval(($count-1)/$page_sait)+1;
$page=abs(intval($_GET['page']));
if(empty($page) OR $page < 0)
{
$page = 1;
}
if($page > $total)
{
$page = $total;
}
$past=intval($count/$page_sait);
$start=$page*$page_sait-$page_sait;
$saits = mysql_query("SELECT * FROM `".$prefix."sait` WHERE ".$zap." ".$search_db." ORDER BY `id` DESC LIMIT ".$start.",".$page_sait."");
echo'<div class="container" id="page"><div class="rating">';
while($row = mysql_fetch_array($saits))
{
$start++;
echo'
<section class="server-pr-cards">
<div class="row">
<article class="col-xs-12 user-pr-card">
<div class="row">
<div class="col-xs-1">
<div class="user-pr-card__num">'.$start.'</div>
</div>
<div class="col-xs-11">
<div class="user-pr-card__h"><a href="http://'.$set['home'].'/stats/'.$row['id'].'">'.$row['url'].'</a></div>
<div class="row">
<div class="col-md-7 col-sm-6 user-pr-card__banner">
<a href="http://'.$set['home'].'/stats/'.$row['id'].'"><img src="http://mini.s-shot.ru/468x90/468/png/?'.$row['url'].'" alt="" class="img-responsive"></a>
</div>
<div class="col-md-5 col-sm-6 user-pr-card__info">
<div class="user-pr-card__rt"><div class="user-pr-card__rt-inner"><span>СТАТА</span><span class="user-pr-card__rt-qty">'.$row['hosts'].' / '.$row['hits'].'</span></div></div>
<div class="server-rt-card__btn"><a href="http://'.$set['home'].'/stats/'.$row['id'].'" class="btn btn-info btn-vote">ПЕРЕЙТИ</a></div>
</div>
</div>
</div>
</div>
</article>
</div>
</section>';
}
navigation($count,$page_sait,$page,'http://'.$set['home'].'/modules/search?search='.$search.'&n=0&mm='.$mm.'&page=',$total);
echo'</div></div>';
}
else {
echo '<div class="title">Ничего не найдено !</div>';
}
echo '<div class="container" id="page"><div class="rating">Совпадений : '.$count.'</div></div>';
}
require_once('foot.php');
?>