Файл: mpanel/spam.php
Строк: 85
<?php
include('../core/core.php');
include(MAINDIR.'style/head.php');
title('Спам система');
if (is_admin()) {
$act = '<img src="/images/act.png">';
$id = abs(intval($_GET['id']));
echo'<div class="title">Управление сайтом</div>';
switch ($mode):
case 'index':
echo'<div class="menu"><a href="?mode=1">Жалобы на файл</a> ('.count_one('files_spam').')</div>';
echo'<div class="menu_2"><a href="?mode=2">Жалобы на сообщения</a> ('.count_one('spam').')</div>';
break;
case '1':
define('TOPAGE',10); $num = TOPAGE;
$links = '&page=';
$page = intval($_GET['page']);
$posts = DB::run() -> query("SELECT * FROM `files_spam`") -> rowCount();
$total = intval(($posts - 1) / $num) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$themes = DB::run()->query("SELECT * FROM `files_spam` ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
$themes = $themes -> fetchAll();
foreach($themes AS $u){
$files = DB::run() -> queryFetch("SELECT * FROM `files` WHERE `id`=? LIMIT 1",array($u['id_file']));
echo'<div class="menu">';
echo $files['link'];
echo' [<a href="?mode=del&id='.$u['id_file'].'">Удл файл</a>][<a href="?mode=dell&id='.$u['id'].'">Удл жалобу</a>]';
echo'</div>';
}
if ($page != 1) $pervpage = '<a href= '.$links.'1><<</a> <a href= '.$links.''. ($page - 1) .'><</a> ';
if ($page != $total) $nextpage = ' <a href= '.$links.''. ($page + 1) .'>></a> <a href= '.$links.'' .$total. '>>></a>';
if($page - 2 > 0) $page2left = ' <a href= '.$links.''. ($page - 2) .'>'. ($page - 2) .'</a> | ';
if($page - 1 > 0) $page1left = '<a href= '.$links.''. ($page - 1) .'>'. ($page - 1) .'</a> | ';
if($page + 2 <= $total) $page2right = ' | <a href= '.$links.''. ($page + 2) .'>'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' | <a href= '.$links.''. ($page + 1) .'>'. ($page + 1) .'</a>';
if($posts == 0){ echo'<div class="menu">Жалоб не найдено!</div>'; } else {echo '<div class="menu_2">'.$pervpage.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$nextpage.'</div>'; }
break;
case '2':
define('TOPAGE',10); $num = TOPAGE;
$links = '&page=';
$page = intval($_GET['page']);
$posts = DB::run() -> query("SELECT * FROM `spam`") -> rowCount();
$total = intval(($posts - 1) / $num) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$themes = DB::run()->query("SELECT * FROM `spam` ORDER BY `id` DESC LIMIT $start,".TOPAGE."");
$themes = $themes -> fetchAll();
foreach($themes AS $u){
echo'<div class="menu">';
echo'<a href="/profile/'.$u['login'].'">'.$u['login'].'</a> '.$u['data'].'<hr>'.$u['spam'].'<hr>
[<a href="?mode=dee&id='.$u['id'].'">Удл жалобу</a>] ';
echo'</div>';
}
if ($page != 1) $pervpage = '<a href= '.$links.'1><<</a> <a href= '.$links.''. ($page - 1) .'><</a> ';
if ($page != $total) $nextpage = ' <a href= '.$links.''. ($page + 1) .'>></a> <a href= '.$links.'' .$total. '>>></a>';
if($page - 2 > 0) $page2left = ' <a href= '.$links.''. ($page - 2) .'>'. ($page - 2) .'</a> | ';
if($page - 1 > 0) $page1left = '<a href= '.$links.''. ($page - 1) .'>'. ($page - 1) .'</a> | ';
if($page + 2 <= $total) $page2right = ' | <a href= '.$links.''. ($page + 2) .'>'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' | <a href= '.$links.''. ($page + 1) .'>'. ($page + 1) .'</a>';
if($posts == 0){ echo'<div class="menu">Жалоб не найдено!</div>'; } else {echo '<div class="menu_2">'.$pervpage.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$nextpage.'</div>'; }
break;
case 'del':
$files = DB::run() -> queryFetch("SELECT * FROM `files` WHERE `id`=? LIMIT 1",array($id));
unlink('../obmen/files/'.$files['name'].'');
DB::run()->query("DELETE FROM `files` WHERE `id` =?",array($id));
header ('location: '.check($_SERVER['HTTP_REFERER']).'');
break;
case 'dell':
DB::run()->query("DELETE FROM `files_spam` WHERE `id` =?",array($id));
header ('location: '.check($_SERVER['HTTP_REFERER']).'');
break;
case 'dee':
DB::run()->query("DELETE FROM `spam` WHERE `id` =?",array($id));
header ('location: '.check($_SERVER['HTTP_REFERER']).'');
break;
default:
header ('location: ?mode=index');
endswitch;
echo'<div class="menu"><a href="/mpanel/">В админку</a></div>';
} else {header ('location: /index.php?mode=index'); }
include(MAINDIR.'style/foot.php');
?>