Файл: modules/user/cab/notifications.php
Строк: 648
<?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;
$pc = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='phpcodes'")->num_rows;
$pcn = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='phpcodes' && `read`='0'")->num_rows;
$bc = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='billing'")->num_rows;
$bcn = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='billing' && `read`='0'")->num_rows;
$wc = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='portfolio'")->num_rows;
$wcn = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='portfolio' && `read`='0'")->num_rows;
$nc = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='newspaper_comm'")->num_rows;
$ncn = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='newspaper_comm' && `read`='0'")->num_rows;
$nch = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='shop'")->num_rows;
$nchn = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='shop' && `read`='0'")->num_rows;
$ca = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='arbitration'")->num_rows;
$cna = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' && `section`='arbitration' && `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>
<?
}
if($pc!=0){
?>
<div class="text"><a href="?act=phpcodes">Полезные PHP коды</a> (<?=$pc?><?
if($pcn!=0){
?>
<font color="red">+<?=$pcn?></font><?
}
?>)</div>
<?
}
if($bc!=0){
?>
<div class="text"><a href="?act=billing">Биллинг</a> (<?=$bc?><?
if($bcn!=0){
?>
<font color="red">+<?=$bcn?></font><?
}
?>)</div>
<?
}
if($wc!=0){
?>
<div class="text"><a href="?act=portfolio">Портфолио</a> (<?=$wc?><?
if($wcn!=0){
?>
<font color="red">+<?=$wcn?></font><?
}
?>)</div>
<?
}
if($nc!=0){
?>
<div class="text"><a href="?act=newspaper">Газета</a> (<?=$nc?><?
if($ncn!=0){
?>
<font color="red">+<?=$ncn?></font><?
}
?>)</div>
<?
}
if($nch!=0){
?>
<div class="text"><a href="?act=shop">Магазин</a> (<?=$nch?><?
if($nchn!=0){
?>
<font color="red">+<?=$nchn?></font><?
}
?>)</div>
<?
}
if($ca!=0){
?>
<div class="text"><a href="?act=arbitration">Арбитраж</a> (<?=$ca?><?
if($cna!=0){
?>
<font color="red">+<?=$cna?></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 'phpcodes':
?>
<div class="title">Полезные PHP коды</div>
<div class="nvgup"><a href="/cab/notifications?act=clear_section§ion=phpcodes">Очистить раздел</a></div>
<?
$nav=new navig("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='phpcodes'");
$q = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='phpcodes' 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`='phpcodes'");
?>
<div class="nvgstr">
<?
$nav->panel();
?>
</div>
<?
break;
case 'billing':
?>
<div class="title">Полезные PHP коды</div>
<div class="nvgup"><a href="/cab/notifications?act=clear_section§ion=billing">Очистить раздел</a></div>
<?
$nav=new navig("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='billing'");
$q = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='billing' 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`='billing'");
?>
<div class="nvgstr">
<?
$nav->panel();
?>
</div>
<?
break;
case 'portfolio':
?>
<div class="title">Портфолио</div>
<div class="nvgup"><a href="/cab/notifications?act=clear_section§ion=portfolio">Очистить раздел</a></div>
<?
$nav=new navig("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='portfolio'");
$q = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='portfolio' 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`='portfolio'");
?>
<div class="nvgstr">
<?
$nav->panel();
?>
</div>
<?
break;
case 'newspaper_comm':
?>
<div class="title">Газета</div>
<div class="nvgup"><a href="/cab/notifications?act=clear_section§ion=newspaper_comm">Очистить раздел</a></div>
<?
$nav=new navig("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='newspaper_comm'");
$q = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='newspaper_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`='newspaper_comm'");
?>
<div class="nvgstr">
<?
$nav->panel();
?>
</div>
<?
break;
case 'shop':
?>
<div class="title">Газета</div>
<div class="nvgup"><a href="/cab/notifications?act=clear_section§ion=shop">Очистить раздел</a></div>
<?
$nav=new navig("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='shop'");
$q = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='shop' 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`='shop'");
?>
<div class="nvgstr">
<?
$nav->panel();
?>
</div>
<?
break;
case 'arbitration':
?>
<div class="title">Уведомления с арбитража</div>
<div class="nvgup"><a href="/cab/notifications?act=clear_section§ion=arbitration">Очистить раздел</a></div>
<?
$nav=new navig("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='arbitration'");
$q = $db->query("SELECT * FROM `notifications` WHERE `id_us`='".$user['id']."' AND `section`='arbitration' 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`='arbitration'");
?>
<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');
?>