<?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="container-fluid page_header"><div class="container"><div class="row"><div class="col-xs-12 col-sm-8 col-md-9 col-lg-9"><h1>Панель управления </h1><ol class="breadcrumb" xmlns:v="http://'.homeurl.'/#"><li typeof="v:Breadcrumb"><a href="/" rel="v:url" property="v:title">'.homeurl.'</a></li><li typeof="v:Breadcrumb"><a href="/panel" rel="v:url" property="v:title">Дата-центр</a></li> <li class="active" typeof="v:Breadcrumb"><span property="v:title">Модерация кодов</span></li></ol></div></div></div></div>';
echo'<div class="container page_body"><div class="row"><div class="col-xs-12 page_content col-lg-9"><div class="navbar page_content_navbar collapse hidden-lg"><div class="container-fluid"><div class="navbar-collapse"></div></div></div><div class="text_box hidden-lg pr_block_small hidden"></div><div class="container-fluid cols_table">';
echo '<div class="catSides"><a href="/panel"><i class="md-format-list-bulleted"></i> Админка</a> - Модерация кодов</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="row text_box" 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="error">Нет кодов на модерации</div>';
} else {
while ($row = $query -> fetch()) {
$cat = DB::$dbs->queryFetch("SELECT * FROM codes_cat WHERE id = ? LIMIT 1", [$row['cid']]);
echo '<div class="row text_box"><i class="md-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();
?>