<?php
define('GCMS',true);
define('ROOT','../');
require_once (ROOT.'system/power.php');
if ($aut == true and $ya['level'] > 1) {
switch($do) {
case 'del':
$sql = $db -> query("SELECT * FROM `comes` WHERE `id` = '".$id."' LIMIT 1");
if ($sql -> num_rows > 0) {
$ass = $sql -> fetch_assoc();
$db -> query("DELETE FROM `comes` WHERE `id` = '".$id."' LIMIT 1");
header('location: ?');
} else header('location: ?');
break;
case'read':
$diz -> head('Модерирование комментариев');
$diz -> title('Модерирование комментариев');
$new = $db -> query("SELECT `id`,`name` FROM `books` WHERE `id` = '".$id."' LIMIT 1")-> fetch_assoc();
if($mode=='news' or $mode=='book' or $mode=='load' or $mode=='obmen' or $mode=='albom' or $mode=='other'){
if($mode=='news' or $mode=='book' or $mode=='load' or $mode=='obmen' or $mode=='albom'){
$count = $db -> dbcount('COUNT(`id`)','comes',"`where`='$mode'");}
elseif($mode=='other'){
$count = $db -> dbcount('COUNT(`id`)','comes',"`where`<>'load' and `where`<>'news' and `where`<>'book' and `where`<>'albom' and `where`<>'obmen'");
}
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1; 
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
if ($count>0){
if($mode=='news' or $mode=='book' or $mode=='load' or $mode=='obmen' or $mode=='albom'){
$for = $db -> query("SELECT * FROM `comes` WHERE `where`='$mode' ORDER BY `id` DESC LIMIT ".$start.",".$num);
}elseif($mode=='other'){
$for = $db -> query("SELECT * FROM `comes` where `where`<>'load' and `where`<>'news' and `where`<>'book' and `where`<>'albom' and `where`<>'obmen' ORDER BY `id` DESC LIMIT ".$start.",".$num);
}
while ($assoc = $for -> fetch_assoc()) {
$dop = null;
if ($aut) {
if ((int)$ya['level'] > 4) {
$dop = ' | <a href="comes.php?id='.$assoc['id'].'&do=del&mode='.$mode.'&page='.$page.'">[Удалить]</a>';
}
}
$msg .= '<div class="top">'.$func->user($assoc['user']).' ('.$func -> vremja($assoc['time']).') '.$dop.'<br/>';
$text = $func -> tags($func -> smiles($assoc['text']));
$msg .=''.$text.'</div>';
}
$act = '?do=read&mode='.$mode;
$msg .= ''.$func -> pagenav($act,$page,$total).'';
}else{$msg .= 'Комментариев пока нет!';}
$msg .= '</div><div class="levo">'.$diz -> img('back.png').'<a href="?">Назад</a><br/>
'.$diz -> img('back.png').'<a href="./index.php">Админка</a>';
$msg .= '</br>'.$diz -> img('home.png').'<a href="../">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);
}else header('location: ?');
break;
//главная
default:
$diz -> head('Модерирование комментариев');
$diz -> title('Модерирование комментариев');
$msg.='<div class="fon">';
$book = $db -> dbcount('COUNT(`id`)','comes',"`where`='books'");
$bookn = $db -> dbcount('COUNT(`id`)','comes',"`where`='books' and `time` > ".(time()-86400)."");
if($bookn>0){$b='<font color="red">+'.$bookn.'</font>';}
$msg .= $diz -> img('r.png').'<a href="?do=read&mode=book">Комментарии библиотеки</a> ('.$book.''.$b.')<br/>';
$albom = $db -> dbcount('COUNT(`id`)','comes',"`where`='albom'");
$albomn = $db -> dbcount('COUNT(`id`)','comes',"`where`='albom' and `time` > ".(time()-86400)."");
if($albomn>0){$a='<font color="red">+'.$albomn.'</font>';}
$msg .= $diz -> img('r.png').'<a href="?do=read&mode=albom">Комментарии к альбомам</a> ('.$albom.''.$a.')<br/>';
$news = $db -> dbcount('COUNT(`id`)','comes',"`where`='news'");
$newsn = $db -> dbcount('COUNT(`id`)','comes',"`where`='news' and `time` > ".(time()-86400)."");
if($newsn>0){$n='<font color="red">+'.$newsn.'</font>';}
$msg .= $diz -> img('r.png').'<a href="?do=read&mode=news">Комментарии к новостям</a> ('.$news.''.$n.')<br/>';
$load = $db -> dbcount('COUNT(`id`)','comes',"`where`='load'");
$loadn = $db -> dbcount('COUNT(`id`)','comes',"`where`='load' and `time` > ".(time()-86400)."");
if($loadn>0){$l='<font color="red">+'.$loadn.'</font>';}
$msg .= $diz -> img('r.png').'<a href="?do=read&mode=load">Комментарии ЗЦ</a> ('.$load.''.$l.')<br/>';
$obmen = $db -> dbcount('COUNT(`id`)','comes',"`where`='obmen'");
$obmenn = $db -> dbcount('COUNT(`id`)','comes',"`where`='obmen' and `time` > ".(time()-86400)."");
if($obmenn>0){$o='<font color="red">+'.$obmenn.'</font>';}
$msg .= $diz -> img('r.png').'<a href="?do=read&mode=obmen">Комментарии обменника</a> ('.$obmen.''.$o.')<br/>';
$other = $db -> dbcount('COUNT(`id`)','comes',"`where`<>'obmen' and `where`<>'load' and `where`<>'books' and `where`<>'albom' and `where`<>'news'");
$othern = $db -> dbcount('COUNT(`id`)','comes',"`where`<>'obmen' and `where`<>'load' and `where`<>'books' and `where`<>'albom' and `where`<>'news' and `time` > ".(time()-86400)."");
if($othern>0){$othe='<font color="red">+'.$othern.'</font>';}
$msg .= $diz -> img('r.png').'<a href="?do=read&mode=other">Прочие комментарии</a> ('.$other.''.$othe.')<br/>';
$msg .= '</div><div class="levo">'.$diz -> img('back.png').'<a href="./index.php">Админка</a>';
$msg .= '</br>'.$diz -> img('home.png').'<a href="../">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);
}
} else {
header('location: ../index.php');
}
?>