Файл: php-zona.ru/modules/user/cab/notifications.php
Строк: 336
<?php
$title = 'Оповещания';
include_once($_SERVER["DOCUMENT_ROOT"].'/style/head.php');
mode('user');
switch($_GET['act']){
default:
$cnc = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='news_comm'")->num_rows;
$cncn = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='news_comm' && `read`='0'")->num_rows;
$czc = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='zc_comm'")->num_rows;
$czcn = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='zc_comm' && `read`='0'")->num_rows;
$zcc = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='zc'")->num_rows;
$zccn = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='zc' && `read`='0'")->num_rows;
$rc = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='rating'")->num_rows;
$rcn = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='rating' && `read`='0'")->num_rows;
$fc = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='forum'")->num_rows;
$fcn = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='forum' && `read`='0'")->num_rows;
$oc = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='other'")->num_rows;
$ocn = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='other' && `read`='0'")->num_rows;
?>
<div class="title">Оповещания</div>
<?
if($db->query("SELECT `id` FROM `notifications` WHERE `id_us`='".$user['id']."'")->num_rows!=0){
?><div class="nvgup"><a href="?act=clear_all">Очистить оповещания</a></div><?
}
if($db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."'")->num_rows==0){
?>
<div class="text">Оповещений нет!</div>
<?
}
if($cnc!=0){
?>
<div class="text"><a href="?act=news_comm">Комменатарии к новостям</a> (<?=$cnc?><?
if($cncn!=0){
?>
<font color="red">+<?=$cncn?></font><?
}
?>)</div>
<?
}
if($czc!=0){
?>
<div class="text"><a href="?act=zc_comm">Комменатарии к файлам</a> (<?=$czc?><?
if($czcn!=0){
?>
<font color="red">+<?=$czcn?></font><?
}
?>)</div>
<?
}
if($zcc!=0){
?>
<div class="text"><a href="?act=zc">Загруз-центр</a> (<?=$zcc?><?
if($zccn!=0){
?>
<font color="red">+<?=$zccn?></font><?
}?>)</div>
<?
}
if($rc!=0){
?>
<div class="text"><a href="?act=rating">Рейтинг</a> (<?=$rc?><?
if($rcn!=0){
?>
<font color="red">+<?=$rcn?></font><?
}
?>)</div>
<?
}
if($fc!=0){
?>
<div class="text"><a href="?act=forum">Форум</a> (<?=$fc?><?
if($fcn!=0){
?>
<font color="red">+<?=$fcn?></font><?
}
?>)</div>
<?
}
if($oc!=0){
?>
<div class="text"><a href="?act=other">Прочее</a> (<?=$oc?><?
if($ocn!=0){
?>
<font color="red">+<?=$ocn?></font><?
}
?>)</div>
<?
}
break;
case 'news_comm':
?>
<div class="title">Уведомления с комментариев к новостям</div>
<div class="nvgup"><a href="/cab/notifications?act=clear_section§ion=news_comm">Очистить раздел</a></div>
<?
$nav=new navig("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='news_comm'");
$q = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='news_comm' ORDER BY `id` DESC LIMIT ".$nav->start.", ".$nav->nstr);
while($n=$q->fetch_assoc()){
?>
<div class="textq">
<?=nick($n['sender'])?> <?=output($n['text'])?><br/>
<?=times($n['time'])?> <a href="/cab/notifications?act=del_one&id=<?=$n['id']?>">[Уд.]</a>
</div>
<?
}
$db->query("UPDATE `notifications` SET `read`='1' WHERE `id_us`='".$user['id']."' AND `section`='news_comm'");
?>
<div class="nvgstr">
<?
$nav->panel();
?>
</div>
<?
break;
case 'zc_comm':
?>
<div class="title">Уведомления с комментариев к файлам</div>
<div class="nvgup"><a href="/cab/notifications?act=clear_section§ion=zc_comm">Очистить раздел</a></div>
<?
$nav=new navig("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='zc_comm'");
$q = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='zc_comm' ORDER BY `id` DESC LIMIT ".$nav->start.", ".$nav->nstr);
while($n=$q->fetch_assoc()){
?>
<div class="textq">
<?=nick($n['sender'])?> <?=output($n['text'])?><br/>
<?=times($n['time'])?> <a href="/cab/notifications?act=del_one&id=<?=$n['id']?>">[Уд.]</a>
</div>
<?
}
$db->query("UPDATE `notifications` SET `read`='1' WHERE `id_us`='".$user['id']."' AND `section`='zc_comm'");
?>
<div class="nvgstr">
<?
$nav->panel();
?>
</div>
<?
break;
case 'zc':
?>
<div class="title">Уведомления с ЗЦ</div>
<div class="nvgup"><a href="/cab/notifications?act=clear_section§ion=zc">Очистить раздел</a></div>
<?
$nav=new navig("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='zc'");
$q = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='zc' ORDER BY `id` DESC LIMIT ".$nav->start.", ".$nav->nstr);
while($n=$q->fetch_assoc()){
?>
<div class="textq">
<?=nick($n['sender'])?> <?=output($n['text'])?><br/>
<?=times($n['time'])?> <a href="/cab/notifications?act=del_one&id=<?=$n['id']?>">[Уд.]</a>
</div>
<?
}
$db->query("UPDATE `notifications` SET `read`='1' WHERE `id_us`='".$user['id']."' AND `section`='zc'");
?>
<div class="nvgstr">
<?
$nav->panel();
?>
</div>
<?
break;
case 'rating':
?>
<div class="title">Изменение рейтинга</div>
<div class="nvgup"><a href="/cab/notifications?act=clear_section§ion=rating">Очистить раздел</a></div>
<?
$nav=new navig("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='raring'");
$q = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='rating' ORDER BY `id` DESC LIMIT ".$nav->start.", ".$nav->nstr);
while($n=$q->fetch_assoc()){
?>
<div class="textq">
<?=nick($n['sender'])?> <?=output($n['text'])?><br/>
<?=times($n['time'])?> <a href="/cab/notifications?act=del_one&id=<?=$n['id']?>">[Уд.]</a>
</div>
<?
}
$db->query("UPDATE `notifications` SET `read`='1' WHERE `id_us`='".$user['id']."' AND `section`='rating'");
?>
<div class="nvgstr">
<?
$nav->panel();
?>
</div>
<?
break;
case 'forum':
?>
<div class="title">Форум</div>
<div class="nvgup"><a href="/cab/notifications?act=clear_section§ion=forum">Очистить раздел</a></div>
<?
$nav=new navig("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='forum'");
$q = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='forum' ORDER BY `id` DESC LIMIT ".$nav->start.", ".$nav->nstr);
while($n=$q->fetch_assoc()){
?>
<div class="textq">
<?=nick($n['sender'])?> <?=output($n['text'])?><br/>
<?=times($n['time'])?> <a href="/cab/notifications?act=del_one&id=<?=$n['id']?>">[Уд.]</a>
</div>
<?
}
$db->query("UPDATE `notifications` SET `read`='1' WHERE `id_us`='".$user['id']."' AND `section`='forum'");
?>
<div class="nvgstr">
<?
$nav->panel();
?>
</div>
<?
break;
case 'other':
?>
<div class="title">Прочее</div>
<div class="nvgup"><a href="/cab/notifications?act=clear_section§ion=other">Очистить раздел</a></div>
<?
$nav=new navig("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='other'");
$q = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='other' ORDER BY `id` DESC LIMIT ".$nav->start.", ".$nav->nstr);
while($n=$q->fetch_assoc()){
?>
<div class="textq">
<?=nick($n['sender'])?> <?=output($n['text'])?><br/>
<?=times($n['time'])?> <a href="/cab/notifications?act=del_one&id=<?=$n['id']?>">[Уд.]</a>
</div>
<?
}
$db->query("UPDATE `notifications` SET `read`='1' WHERE `id_us`='".$user['id']."' AND `section`='other'");
?>
<div class="nvgstr">
<?
$nav->panel();
?>
</div>
<?
break;
case 'clear_all':
$db->query("DELETE FROM `notifications` WHERE `id_us`='".$user['id']."'");
success('Все оповещения удалены!');
break;
case 'clear_section':
$_GET['section'] = guard($db->real_escape_string($_GET['section']));
if($db->query("SELECT `id` FROM `notifications` WHERE `section`='".$_GET['section']."' AND `id_us`='".$user['id']."'")->num_rows==0){
error('Оповещений в данной разделе не найдено!');
}
$db->query("DELETE FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='".$_GET['section']."'");
success('Оповещания в данном разделе удалены!');
break;
case 'del_one':
$_GET['id'] = abs(intval($_GET['id']));
if($db->query("SELECT `id` FROM `notifications` WHERE `id`='".$user['id']."'")->num_rows==0){
error('Записи не существует!');
}
$not = $db->query("SELECT `id_us` FROM `notifications` WHERE `id`='".$user['id']."'")->fetch_assoc();
if($user['id']!=$not['id_us']){
error('Запрещено удалять чужие оповещения!');
}
$db->query("DELETE FROM `notifications` WHERE `id`='".$_GET['id']."'");
success('Оповещание успешно удалено!');
break;
}
include_once($_SERVER["DOCUMENT_ROOT"].'/style/foot.php');
?>