View file plugins/notes/search.php

File size: 3.18Kb
<?php

include_once '../../sys/inc/start.php';
include_once '../../sys/inc/compress.php';
include_once '../../sys/inc/sess.php';
include_once '../../sys/inc/home.php';
include_once '../../sys/inc/settings.php';
include_once '../../sys/inc/db_connect.php';
include_once '../../sys/inc/ipua.php';
include_once '../../sys/inc/fnc.php';
include_once '../../sys/inc/user.php';

/* Бан пользователя */
if (isset($user) && dbresult(dbquery("SELECT COUNT(*) FROM `ban` WHERE `razdel` = 'notes' AND `id_user` = '$user[id]' AND (`time` > '$time' OR `view` = '0' OR `navsegda` = '1')"), 0) != 0) {
    header('Location: /ban.php?' . SID);
    exit;
}

$set['title'] = __('Блоги');
include_once '../../sys/inc/thead.php';

title();
aut(); // форма авторизации

echo "<div class='ui horizontal segments'>";

echo "<div class='ui center aligned segment'>";
echo "<a href='index.php'>" . __('Блоги') . "</a>";
echo "</div>";

echo "<div class='ui center aligned segment'>";
echo "<a href='dir.php'>" . __('Категории') . "</a>";
echo "</div>";

echo "<div class='ui center aligned segment'>";
echo "<a href='search.php'><b>" . __('Поиск') . "</b></a>";
echo "</div>";

echo "</div>";

$usearch = NULL;

if (isset($_SESSION['usearch'])) {
    $usearch = $_SESSION['usearch'];
}
if (isset($_POST['usearch'])) {
    $usearch = $_POST['usearch'];
}

if ($usearch == NULL) {
    unset($_SESSION['usearch']);
} else {
    $_SESSION['usearch'] = $usearch;
}

$usearch = preg_replace("#( ){1,}#", "", $usearch);

$order = 'order by `time` desc';
echo "<form method=\"post\" class='ui form segment' action=\"search.php?go\">" . __('Поиск') . "<br />";

$usearch = stripcslashes(htmlspecialchars($usearch));

echo "<input type=\"text\" name=\"usearch\" maxlength=\"16\" required value=\"$usearch\" /><br /><br />\n";

echo "<button class='ui green button'>" . __('Искать') . "</button>";
echo "</form>\n";

if (isset($_GET['go'])) {
    $k_post = dbresult(dbquery("SELECT COUNT(*) FROM `notes` where `name` like '%" . mysql_real_escape_string($usearch) . "%'"), 0);
    $k_page = k_page($k_post, $set['p_str']);
    $page = page($k_page);
    $start = $set['p_str'] * $page - $set['p_str'];
    $q = dbquery("SELECT * FROM `notes` WHERE `name` like '%" . mysql_real_escape_string($usearch) . "%' $order LIMIT $start, $set[p_str]");

    echo "<div class='ui segments'>\n";

    if ($k_post == 0) {
        echo "<div class='ui segment'>\n";
        echo "<i class='mdi mdi-layers-outline'></i> " . __('Нет результатов');
        echo "</div>\n";
    }
    while ($post = dbassoc($q)) {
        echo '<div class="ui segment">';

        echo "<a href='list.php?id=$post[id]'>" . text($post['name']) . "</a> \n";

        echo " (" . vremja($post['time']) . ")\n";

        $k_n = dbresult(dbquery("SELECT COUNT(*) FROM `notes` WHERE `id` = $post[id] AND `time` > '" . $ftime . "'", $db), 0);

        if ($k_n != 0) {
            echo " <i class='mdi mdi-new-box mdi-18px' style='color:red'></i>";
        }
        echo "  </div>\n";
    }
    echo "</div>\n";

    if ($k_page > 1) {
        str('?go&amp;', $k_page, $page);
    } // Вывод страниц
}

include_once '../../sys/inc/tfoot.php';
?>