Файл: vsime.com/diary/inc/act_index.php
Строк: 85
<?
ex_head();
if(isset($_GET['rating']))$rating=1;
if (isset($_POST['query'])) {
$query = esc(stripcslashes(hsc(search_str($_POST['query']))));
header("Location: /search/?act=diaries&query=$query");
exit();
}
echo '<div class = menu>';
echo "<form action='' method='POST'>n";
echo "<input type='text' name='query' value='' placeholder='Введите пару слов для поиска...' style='width: 65%' />n";
echo "<input type='submit' value='Поиск' />n";
echo "</form></div>n";
echo "<div class='foot'>n";
echo "<table>n";
echo "<td>".(isset($rating)?"<a href='/diary'>":NULL)."<span class='block_l'>Новые</span>".(isset($rating)?"</a>":NULL)."</td><td>".(!isset($rating)?"<a href='?rating'>":NULL)."<span class='block_l'>Популярные</span>".(!isset($rating)?"</a>":NULL)."</td>n";
echo "</table>n";
echo "</div>n";
$where = array();
$query=mysqli_query($dbi, "SELECT * FROM `diary` WHERE `sk` = '0'");
while ($post = mysqli_fetch_array($query))
{
$ank = profile($post['id_user']);
if(($post['access']=='all' || $post['access']=='friends' && is_friend($ank['id'], $user['id']) || $post['access']=='pass' || $post['access']=='auth' && isset($user)) || isset($moderate_diary))$where[] = $post['id'];
}
if (!count($where))
{
echo "<div class='list_empty'>Нет записей</div>n";
} else {
$where = implode("' OR `id` = '", $where);
$count_results = mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `diary` WHERE `sk` = '0' AND (`id` = '$where')"));
$count_pages = count_pages($count_results);
$page = page();
$start = start_pages();
$query = mysqli_query($dbi, "SELECT * FROM `diary` WHERE `sk` = '0' AND (`id` = '$where') ORDER BY `".(isset($rating)?'rating` DESC, `time':'time')."` DESC LIMIT $start, $config[rop]");
while ($post = mysqli_fetch_array($query))
{
$ank = profile($post['id_user']);
$count_komms = mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `diary_komm` WHERE `id_diary` = '$post[id]'"));
echo "<div class='list'>n";
echo "<div class='left'>n";
show_avatar($ank['id'], 'small');
echo "</div>n";
echo "<div class='overfl_hid'>n";
if (isset($rating))echo "<span class='right'><img src='/i/site/star.png'/> $post[rating]</span>n";
echo profile_icon($ank['id']).profile_nick($ank['id'], 1).profile_medal($ank['id'])."<br />n";
echo "<a href='/diary/?act=diary&id=$post[id]'>".($post['name']!=NULL?hsc($post['name']):hsc(str_cut($post['text'], 5, 50)))."</a>n";
echo "<span class='grey right'>".vremja($post['time'])."</span><br/>n";
echo hsc(str_cut($post['text'], 20, 200))."".(hsc(str_cut($post['text'], 20, 200))!=$post['text']?" <a href='/diary/?act=diary&id=$post[id]&'>подробнее →</a>":null)."<br/>n";
echo "<a href='/diary/?act=diary&id=$post[id]#komms'>Обсудить".($count_komms!=0?" ($count_komms)":null)."</a><br/>n";
echo "</div>n";
echo "<div class='clear'></div>n";
echo "</div>n";
}
pages_show("?".(isset($rating)?'rating&':null)); // Вывод страниц
}
if (isset($user) || isset($moderate_diary)) {
echo "<div class='mod_grad'>n";
echo $config['code_add']." <a href='/diary/?act=create'>Создать запись</a><br />n";
if (isset($moderate_diary)) {
echo "<img src='/i/site/key.png'/> <a href='/diary/?act=sk'>Заблокированные записи (".mysqli_result("SELECT COUNT(*) FROM `diary` WHERE `sk` = '1'").")</a><br />n";
}
echo "</div>n";
}
ex_foot();
?>