Файл: modules/admin/phpcodes/moderation.php
Строк: 46
<?php
$title = 'Полезные PHP коды | Модерация';
include_once($_SERVER["DOCUMENT_ROOT"].'/style/head.php');
mode('user');
level(1);
switch ($_GET['act']) {
default:
?>
<div class="title"><a href="/phpcodes">Полезные PHP коды</a> | Модерация</div>
<?
$nav=new navig("SELECT * FROM `phpcodes_codes` WHERE `moderation`='0'");
$q = $db->query('SELECT * FROM `phpcodes_codes` WHERE `moderation`=0 ORDER BY `id` DESC LIMIT '.$nav->start.','.$nav->nstr);
while($c=$q->fetch_assoc()){
?>
<div class="section"><a href="/phpcodes/code/<?=$c['id']?>"><?=htmlspecialchars($c['name'])?></a><br/>
<a href="/admin/phpcodes/moderation/yes/<?=$c['id']?>">[Одобр.]</a> <a href="/admin/phpcodes/moderation/no/<?=$c['id']?>">[Отклон.]</a> </div>
<?
}
?>
<div class="nvgstr">
<?
$nav->panel();
?>
</div>
<?
if($db->query("SELECT `id` FROM `phpcodes_codes` WHERE `moderation`='0'")->num_rows==0){
error('Кодов на модераци нет.');
}
break;
case 'yes':
$_GET['id'] = abs(intval($_GET['id']));
if($db->query("SELECT `id` FROM `phpcodes_codes` WHERE `id`='".$_GET['id']."'")->num_rows==0){
error('Кода не существует.');
}
$code = $db->query("SELECT `id_us` FROM `phpcodes_codes` WHERE `id`='".$_GET['id']."'")->fetch_assoc();
$db->query("UPDATE `phpcodes_codes` SET `moderation`='1' WHERE `id`='".$_GET['id']."'");
$db->query("INSERT INTO `notifications` SET `id_us`='".$code['id_us']."', `time`='".time()."', `section`='phpcodes', `sender`='".$user['id']."', `text`='одобил ваш [url=http://".$_SERVER["HTTP_HOST"]."/phpcodes/code/".$_GET['id']."]кусок кода[/url]'");
header('location:/admin/phpcodes/moderation');
break;
case 'no':
$_GET['id'] = abs(intval($_GET['id']));
if($db->query("SELECT `id` FROM `phpcodes_codes` WHERE `id`='".$_GET['id']."'")->num_rows==0){
error('Кода не существует.');
}
$code = $db->query("SELECT `id_us` FROM `phpcodes_codes` WHERE `id`='".$_GET['id']."'")->fetch_assoc();
$db->query("UPDATE `phpcodes_codes` SET `moderation`='2' WHERE `id`='".$_GET['id']."'");
$db->query("INSERT INTO `notifications` SET `id_us`='".$code['id_us']."', `time`='".time()."', `section`='phpcodes', `sender`='".$user['id']."', `text`='отклонил ваш [url=http://".$_SERVER["HTTP_HOST"]."/phpcodes/code/".$_GET['id']."]кусок кода[/url]'");
header('location:/admin/phpcodes/moderation');
break;
}
include_once($_SERVER["DOCUMENT_ROOT"].'/style/foot.php');
?>