<?php
require_once('../classes/body.class.php');
require_once('../classes/db.class.php');
require_once('../classes/system.class.php');
$title= new Body;
$title->SetTitle('Панель управления - Модерация кодов');
$title->GetHeader();
if ($b['level'] < 3) {
header('location:/');
die();
}
echo '<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/"style="text-decoration:none; color:white;"> Главная</a> :: <a href="/administration/"style="text-decoration:none; color:white;"> Дата-центр</a> :: Модерация кодов</div></div></div>';
if (isset($_GET['yes'])) {
$arr = DB::$dbs->queryFetch("SELECT * FROM codes_code WHERE id = ?", array(abs((int)$_GET['yes'])));
DB::$dbs->query('UPDATE `codes_code` SET `check` = "1" WHERE `id` = '.DB::$dbs->quote($_GET['yes']));
DB::$dbs->query("UPDATE `blogger` SET `gears` = `gears` + ? WHERE id = ?", [1,$b['id']]);
lenta(Nick($arr['user_id']).' добавил новый <a href="/codes/code.php?id='.$arr['id'].'">[код]</a> в Полезные коды.');
}
if (isset($_GET['no'])) {
DB::$dbs->query('DELETE FROM `codes_code` WHERE `id` = '.DB::$dbs->quote($_GET['no']));
}
if (isset($_GET['show'])
AND DB::$dbs->query('SELECT `id` FROM `codes_code` WHERE `id` = '.DB::$dbs->quote($_GET['show']))->rowCount() == 1)
{
$row=DB::$dbs -> query('SELECT `code` FROM `codes_code` WHERE `id` = '.DB::$dbs->quote($_GET['show']))->fetch(PDO::FETCH_LAZY);
echo '<div class="list-group-item media" style="word-wrap:break-word;">',_highlight_code($row->code),'</div>';
}
$query=DB::$dbs -> query('SELECT * FROM `codes_code` WHERE `check` = "0" ORDER BY `id` DESC');
if ($query->rowCount() == 0)
{
echo '<div class="alert alert-danger" role="alert">Нет кодов на модерации</div>';
} else {
while ($row = $query -> fetch()) {
$cat = DB::$dbs->queryFetch("SELECT * FROM codes_cat WHERE id = ? LIMIT 1", [$row['cid']]);
echo '<div class="list-group-item media"><i class="zmdi zmdi-shuffle"></i>   <a href="/codes/code.php?id='.$row['id'].'">'.$row['name'].'</a><br/>Добавил: '.Nick($row['user_id']).'<br/>Категория: 
<a href="/codes/codlist.php?id='.$cat['id'].'"> '.$cat['name'].'</a><br/>
<a href="?yes='.$row['id'].'" style="color: green;">[Одобрить]</a> / <a style="color: red;" href="?no='.$row['id'].'">[Отклонить]</a></div>';
}
}
$title->GetMenu();
$title->GetFooter();
?>