<?php

$k_post = $db->super_query("SELECT COUNT(*) as count FROM `diary` WHERE `name` like '%" . $db->safesql($search_text) . "%' OR `name` like '%" . translit($search_text) . "%' OR `name` like '%" . retranslit($search_text) . "%' OR `msg` like '%" . $search_text . "%' OR `msg` like '%" . translit($search_text) . "%' OR `msg` like '%" . retranslit($search_text) . "%'");
$k_post = $k_post['count'];
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$q = $db->query("SELECT * FROM `diary` WHERE `name` like '%" . $db->safesql($search_text) . "%' OR	`name` like '%" . translit($search_text) . "%' OR `name` like '%" . retranslit($search_text) . "%' OR `msg` like '%" . $search_text . "%' OR `msg` like '%" . translit($search_text) . "%' OR `msg` like '%" . retranslit($search_text) . "%' ORDER BY `id` DESC LIMIT $start, $set[p_str]");

if ($k_post == 0) {
    $doc->NoResult();
}

while ($post = $db->get_row($q)) {
    $us = get_user($post['id_user']);

    echo '<div class="list-group-item-null">';
    echo "<a href='/modules/diary/$post[name]/'><i class='fa fa-book fa-fw'></i> $post[name]</a> <small style='color: grey;'>" . date::time($post['time']) . "</small><br />";

    echo '<i class="fa fa-eye fa-fw"></i> Просмотров: ' . $post['viewings'] . ' | ';
    echo '<i class="fa fa-star fa-fw"></i> Рейтинг: ' . $post['rating'] . '<br/>';

    echo '</div>';
    echo "<div class='hr'></div>";
}

if ($k_page > 1) {
    str("?search=people&amp;", $k_page, $page);
}
