Файл: bloodlands.pw/lenta.php
Строк: 138
<?php
require 'system/sid.php';
require 'system/config.php';
include 'system/user.php';
include 'system/head.php';
include 'system/navigator.php';
whorm(0, 'lenta');
$do = isset($_GET['do']) ? $_GET['do'] : NULL;
switch($do) {
default:
// полная очистка
if (isset($_GET['clean'])) {
mysql_query("DELETE FROM `lenta` WHERE `user` = '$user[id]'");
header('Location: lenta.php?');
}
// всего
$sql_1 = mysql_result(mysql_query("SELECT COUNT(id) FROM `lenta` WHERE `type` = 'friends' AND `user` = '$user[id]'"), 0);
$sql_2 = mysql_result(mysql_query("SELECT COUNT(id) FROM `lenta` WHERE `type` = 'comments' AND `user` = '$user[id]'"), 0);
// не прочитаные
$new_1 = mysql_result(mysql_query("SELECT COUNT(id) FROM `lenta` WHERE `read` = '1' AND `type` = 'friends' AND `user` = '$user[id]'"), 0);
$new_2 = mysql_result(mysql_query("SELECT COUNT(id) FROM `lenta` WHERE `read` = '1' AND `type` = 'comments' AND `user` = '$user[id]'"), 0);
$new_1 = ($new_1 != 0) ? '<span style="color:#FF0000;">+' . $new_1 . '</span>' : '';
$new_2 = ($new_2 != 0) ? '<span style="color:#FF0000;">+' . $new_2 . '</span>' : '';
mysql_query("UPDATE `lenta` SET `read` = '0' WHERE `type` = 'friends' AND `user` = '$user[id]'");
echo $div_title . us($user['id']) . ' / Лента
' . $div_end . $div_menu . '
<div class="auth2"><b>Друзья(' . $sql_1 . ') ' . $new_1 . '</b> |
<a href="lenta.php?do=comment">Комментарии(' . $sql_2 . ') ' . $new_2 . '</a></div>' . $div_end;
if (isset($_GET['x'])) {
$x = my_int($_GET['x']);
$empty = mysql_query("SELECT `id` FROM `lenta` WHERE `type` = 'friends' AND `user` = '$user[id]' AND `id` = '$x' LIMIT 1");
if (mysql_num_rows($empty) != FALSE) {
mysql_query("DELETE FROM `lenta` WHERE `type` = 'friends' AND `user` = '$user[id]' AND `id` = '$x' LIMIT 1");
header('Location: lenta.php?');
} else {
header('Location: lenta.php?');
}
}
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM `lenta` WHERE `type` = 'friends' AND `user` = '$user[id]'"), 0);
$n = new navigator($count, $user['onp_comments'], '?');
if ($count != FALSE) {
$look = mysql_query("SELECT * FROM `lenta` WHERE `type` = 'friends' AND `user` = '$user[id]' ORDER BY `id` DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($look)) {
$d = '<a href="lenta.php?x='.$a['id'].'"><img src="ico/delete.gif" alt=""/></a> ';
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $d . $a['text'] . $div_end;
}
echo $n->navi();
} else {
echo 'Записей не найдено!<br/>';
}
if ($count != FALSE) {
echo $div_menu . '<a href="lenta.php?clean">Очистить ленту</a>' . $div_end;
}
break;
case comment:
// всего
$sql_1 = mysql_result(mysql_query("SELECT COUNT(id) FROM `lenta` WHERE `type` = 'friends' AND `user` = '$user[id]'"), 0);
$sql_2 = mysql_result(mysql_query("SELECT COUNT(id) FROM `lenta` WHERE `type` = 'comments' AND `user` = '$user[id]'"), 0);
// не прочитаные
$new_1 = mysql_result(mysql_query("SELECT COUNT(id) FROM `lenta` WHERE `read` = '1' AND `type` = 'friends' AND `user` = '$user[id]'"), 0);
$new_2 = mysql_result(mysql_query("SELECT COUNT(id) FROM `lenta` WHERE `read` = '1' AND `type` = 'comments' AND `user` = '$user[id]'"), 0);
$new_1 = ($new_1 != 0) ? '<span style="color:#FF0000;">+' . $new_1 . '</span>' : '';
$new_2 = ($new_2 != 0) ? '<span style="color:#FF0000;">+' . $new_2 . '</span>' : '';
mysql_query("UPDATE `lenta` SET `read` = '0' WHERE `type` = 'comments' AND `user` = '$user[id]'");
echo $div_title . us($user['id']) . ' / Лента
' . $div_end . $div_menu . '
<div class="auth2"><a href="lenta.php?">Друзья(' . $sql_1 . ') ' . $new_1 . '</a> |
<b>Комментарии(' . $sql_2 . ') ' . $new_2 . '</b></div>' . $div_end;
if (isset($_GET['x'])) {
$x = my_int($_GET['x']);
$empty = mysql_query("SELECT `id` FROM `lenta` WHERE `type` = 'comments' AND `user` = '$user[id]' AND `id` = '$x' LIMIT 1");
if (mysql_num_rows($empty) != FALSE) {
mysql_query("DELETE FROM `lenta` WHERE `type` = 'comments' AND `user` = '$user[id]' AND `id` = '$x' LIMIT 1");
header('Location: lenta.php?do=comment');
} else {
header('Location: lenta.php?do=comment');
}
}
$count = mysql_result(mysql_query("SELECT COUNT(id) FROM `lenta` WHERE `type` = 'comments' AND `user` = '$user[id]'"), 0);
$n = new navigator($count, $user['onp_comments'], '?do=comment&');
if ($count != FALSE) {
$look = mysql_query("SELECT * FROM `lenta` WHERE `type` = 'comments' AND `user` = '$user[id]' ORDER BY `id` DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($look)) {
$d = '<a href="lenta.php?do=comment&x='.$a['id'].'"><img src="ico/delete.gif" alt=""/></a> ';
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $d . $a['text'] . '<br/>' . date('d-m-y H:i', $a['date']) . $div_end;
}
echo $n->navi();
} else {
echo 'Записей не найдено!<br/>';
}
if ($count != FALSE) {
echo $div_menu . '<a href="lenta.php?clean">Очистить ленту</a>' . $div_end;
}
break;
}
include 'system/foot.php';
?>