Файл: page/notifications.php
Строк: 46
<?php
$title = 'Уведомления';
require_once($_SERVER["DOCUMENT_ROOT"]."/inc/head.php");
if (isset($active)) {
$clear = $connect->prepare("delete from `notifications` where `new` = '0' and `uid` = ?");
$read = $connect->prepare("update `notifications` set `new` = '0' where `id` = ?");
echo '<div class="title">Уведомления ('.$not . $new_not.')</div>';
if ($not == 0) {
echo '<div class="menu">Уведомлений нет!</div>';
} else {
if (isset($_GET['clear'])) {
if ($clear->execute(array($user['id']))) {
header('Location: /notifications');
} else {
echo '<div class="menu">Произошла ошибка!</div>';
}
}
echo '<div class="forlink"><a href="?clear" class="links"><img src="/img/clear.png" alt="clear">Очистить прочитанное</a></div>';
$page = new Pagination($not, 10);
$data = $connect->prepare("select * from `notifications` where `uid` = :uid order by `new` desc, `id` desc limit :start, 10");
$data->bindValue(':uid', $user['id'], PDO::PARAM_INT);
$data->bindValue(':start', $page->start, PDO::PARAM_INT);
$data->execute();
$sql = $data->fetchAll();
foreach ($sql as $row) {
if ($row['new'] == 1)
$read->execute(array($row['id']));
echo '<div class="menu">
'.nl2br(smiles(bb(bblinks($row['text'])))).'<br/>
'.daytime($row['time']).'<br/>
<div class="chi">'.($row['new'] == 1 ? 'новое' : 'прочитано').'</div>
</div>';
}
$page->navigation();
}
} else {
header('Location: /');
}
require($_SERVER["DOCUMENT_ROOT"]."/inc/foot.php");
?>