Файл: modules/diary/inc/all.php
Строк: 76
<?php
/* Мод "Блоги"
* Версия v0.0.3
* Дата последнего редактирования 22.04.2015
* Двиг DCMS Special
* Модифицировал densnet
* Автор неизвестно
* Файл all.php
* Описание: выводит основную часть блогов
*/
if (isset($_GET['sort']) && $_GET['sort'] == 1) {
$rating = 1;
}
$search = NULL;
if (isset($_POST['search']) && $_POST['search'] != NULL) {
header("Location: /modules/diary/search/" . mysql_real_escape_string($_POST['search']) . "");
exit;
}
$null = 1;
if (isset($_SESSION['search'])) {
$search = $_SESSION['search'];
}
echo "<form action = '' method = 'POST' class = 'comm'>";
echo "<input type = 'search' name = 'search' value = '" . output_title(stripcslashes(htmlspecialchars($search))) . "' placeholder = 'Что ищите?' style='width: 60%' />";
echo "<button class = 'action'>";
echo img('non_derivative.png', '');
echo "</button></form>";
$where = NULL;
if (!isset($umodd)) {
$q = mysql_query("SELECT * FROM `diary` WHERE `sk` = '0' ORDER BY `" . (isset($rating) ? 'rating` DESC, `time' : 'time') . "` DESC");
while ($post = mysql_fetch_assoc($q)) {
$ank = user::get_user($post['id_user']);
if ($post['access'] == 'all' || $post['access'] == 'friends' && mysql_result(mysql_query("SELECT COUNT(*) FROM `friends` WHERE (`user` = '$user[id]' AND `friends` = '$ank[id]') OR (`user` = '$ank[id]' AND `friends` = '$user[id]')"), 0) != 0 || $post['access'] == 'auth' && isset($user)) {
$where = $where . " " . ($where == NULL ? "AND (" : "OR ") . "`id` = '$post[id]'";
}
}
if ($where != NULL) {
$where = $where . ")";
}
}
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary` WHERE `sk` = '0'$where"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if (isset($user)) {
echo "<div class = 'comm'>";
echo "<a href = '/modules/diary/create'>" . img('komms.png', '') . " Написать в блог</a> ";
echo "</div>";
}
echo '<div class="busi_switcher"><table width="100%"><tr><td>';
echo (!isset($rating) ? "<span class='active_item brd_l'>" : "<a href='/modules/diary/?p=blogs/all&sort=0' class='brd_l'>") . "Новые" . (!isset($rating) ? "</span>" : "</a>");
echo '</td><td>';
echo (isset($rating) ? "<span class='active_item brd_r'>" : "<a href='/modules/diary/?p=blogs/all&sort=1' class='brd_r'>") . "Популярные" . (isset($rating) ? "</span>" : "</a>");
echo '</td></tr></table></div>';
if ($k_post == 0) {
echo "<div class = 'errs'>";
echo img('error.png', '16') . " Нет результатов";
echo "</div>";
}
if ($k_post > 0) {
$lq = mysql_fetch_array(mysql_query("SELECT * FROM `diary` WHERE `sk` = '0'$where ORDER BY `" . (isset($rating) ? 'rating` ASC, `time' : 'time') . "` ASC LIMIT $start, 1"));
}
$q = mysql_query("SELECT * FROM `diary` WHERE `sk` = '0'$where ORDER BY `" . (isset($rating) ? 'rating` DESC, `time' : 'time') . "` DESC LIMIT $start, $set[p_str]");
$num = 0;
while ($post = mysql_fetch_assoc($q)) {
echo "<div class='comm'>";
$ank = user::get_user($post['id_user']);
$count_komms = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_komm` WHERE `id_diary` = '$post[id]'"), 0);
echo img("" . ($post['poll'] == 1 ? 'poll_1' : 'book') . ".png", '') . " <a href='/modules/diary/$post[id]/read'>" . ($post['name'] != NULL ? output_title($post['name']) : text_cutter($post['text'], 30) . "" . (text_cutter($post['text'], 30) != $post['text'] ? '...' : null) . "") . "</a>n";
echo "<span style='float:right;'>" . (isset($rating) ? "<span class = 'add'>" . img('star.png', '') . " <small>$post[rating]</small></span>" : "") . "</span><br />";
echo "" . output_title(text_cutter($post['text'], 100)) . "" . (text_cutter($post['text'], 100) != $post['text'] ? "... <a href='/modules/diary/$post[id]/read?p'>подробнее →</a>" : null) . "<br /><br />n";
echo "<span class = 'add'>";
echo user($ank['id']) . "n";
echo "<small>" . date::times($post['time']) . "</small></span>n";
echo "<a class = 'add' href='/modules/diary/$post[id]/read#komms'>" . img('comment_white_mini.png', '') . " Обсудить" . ($count_komms != 0 ? " ($count_komms)" : null) . "</a>";
echo "</div>n";
}
if ($k_page > 1) {
str("?" . (isset($rating) ? 'rating&' : null) . "", $k_page, $page);
} // Вывод страниц
if (isset($umodd)) {
echo "<div class = 'comm'>";
echo "<span style = 'float:right;'>";
echo "<small>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `diary` WHERE `sk` = '1'"), 0) . "</small>";
echo "</span>";
echo "<a href = '/modules/diary/sk'>" . img('lock_edit.png', '16') . " Заблокированные записи</a>";
echo "</div>";
}
require_once H . 'sys/inc/tfoot.php';
exit;