Файл: pages/notifications/index.php
Строк: 75
<?php
include '../../system/mysql.php';
include '../../system/sys_func.php';
if (!isset($user)) {
header('location: /');
exit;
}
// Отмечаем уведомления прочитанными
mysql_query("UPDATE `notifications` SET `read` = '1' WHERE `user_id` = '". $user['id'] ."' AND `read` = '0'");
// Удаления уведомления
if (isset($_GET['del']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `notifications` WHERE `id` = '". intval($_GET['del']) ."'"), 0) == 1) {
$post = mysql_fetch_assoc(mysql_query("SELECT * FROM `notifications` WHERE `id` = '". intval($_GET['del']) ."' LIMIT 1"));
mysql_query("DELETE FROM `notifications` WHERE `id` = '". $post['id'] ."'");
header('Location: index.php');
} elseif (isset($_GET['del']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `notifications` WHERE `id` = '". intval($_GET['del']) ."'"), 0) != 1) {
header('Location: index.php');
}
// Удаление всех уведомлений
if (isset($_GET['del_all'])) {
if (isset($_POST['ok'])) {
mysql_query("DELETE FROM `notifications` WHERE `user_id` = '". $user['id'] ."'");
header('Location: index.php');
exit;
}
$title = 'Кабинет/Уведомления';
include '../../system/head.php';
echo '<div class="title"><a href="/pages/personal/">Кабинет</a> / Уведомления</div>
<form method="post" action="?del_all&ok">
Вы уверены что хотите удалить все уведомления?<br>
<input type="submit" name="ok" value="Да"> <a href="index.php">Нет</a>
</form>
<a class="link" href="index.php"><img src="/design/imgs/arr_b.png" align="center"> Назад</a>';
include '../../system/foot.php';
exit;
}
$title = 'Кабинет/Уведомления';
include '../../system/head.php';
echo '<div class="title"><a href="/pages/personal/">Кабинет</a> / Уведомления</div>';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `notifications` WHERE `user_id` = '". $user['id'] ."'"),0);
$k_page = k_page($k_post, $user['p_page']);
$page = page($k_page);
$start = $user['p_page']*$page-$user['p_page'];
if ($k_post == 0) echo '<div class="post">Нет новых уведомлений!</div>';
// Вывод уведомлений
$q = mysql_query("SELECT * FROM `notifications` WHERE `user_id` = '". $user['id'] ."' AND `read` = '1' ORDER BY `id` DESC LIMIT $start, ". $user['p_page']);
while ($post = mysql_fetch_assoc($q)){
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '". $post['from_id'] ."' LIMIT 1"));
echo '<div class="post">
<span class="c_date">'. ptime($post['time']) .'</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td>';
avatar($ank['id'], 'b');
echo ' </td>
<td>';
echo online($ank['id']);
echo '<a href="/pages/users/user.php?name='. $ank['login'] .'">'. $ank['login'] .'</a>';
echo user($ank['id']);
echo '</td>
</tr>
</table>
<hr>';
echo $post['msg'] .'
<br>'. (isset($post['message']) ? output($post['message']) : null) .'
</div>
<a class="link" href="?del='. $post['id'] .'"><img src="/design/imgs/delete.png"> Удалить уведомление</a>';
}
if($k_page > 1) str('?id='. $ank['id'] .'&', $k_page,$page);
if ($k_post > 1) echo '<a class="link" href="?del_all='. $user['id'] .'"><img src="/design/imgs/delete.png"> Удалить все уведомления</a>';
echo '<a class="link" href="/pages/personal/"><img src="/design/imgs/arr_b.png" align="center"> Вернуться в кабинет</a>';
include '../../system/foot.php';
?>