Файл: nar.php
Строк: 65
<?
include_once 'system/sys.php';
include 'system/funcs.php';
if(!$cms->us['id']){
header('location: /');
exit;
}
$us = DB::$dbs->queryFetch("SELECT * FROM `us` where `id` = ? limit 1",array(abs(intval($_GET['id']))));
if(empty($us['nick'])){
header('location:/');
exit;
}
$posts = DB::$dbs->querySingle("SELECT count(`id`) from `nar` where (`us` = ?)",array($us['id']));
verh('Пенализации '.$us['nick'],'Пенализации '.$func->uNick($us['id']).' ('.$posts.')');
switch($_GET['mod']){
default:
if($cms->us['level'] > 1 && $us['id'] != $cms->us['id']) echo '<div class="list1"><a href="/nar'.$us['id'].'?mod=add">Добавить</a></div>';
if($posts > 0){
$num = 10;
$total = intval(($posts - 1) / $num) + 1;
$page = abs(intval($_GET['page']));
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$nars = DB::$dbs->query("SELECT * FROM `nar` where (`us` = ?) order by `id` desc limit $start,$num",array($us['id']));
while($nar = $nars -> fetch()){
switch($nar['type']){
case 1:
$type = 'Предупреждение';
break;
case 2:
$type = 'Нарушение';
break;
case 3:
$type = 'Бан';
break;
}
echo '<div class="lst">Тип пенализации: '.$type.'<br>Применил: '.$func->uNick($nar['kem']).' ('.t($nar['time']).')<br>Причина: '.$func->text($nar['why']);
if($cms->us['level'] > 1) echo ' [<a href="/nar'.$us['id'].'?mod=del&nar_id='.$nar['id'].'">x</a>]';
echo '</div>';
}
echo '<div class="lst">';
$func->page('/nar'.$us['id'].'?');
echo '</div>';
}else{ echo '<div class="list1">Нет пенализаций!</div>'; }
break;
case 'del':
$nar = DB::$dbs->queryFetch("SELECT * FROM `nar` where `id` = ? limit 1",array(abs(intval($_GET['nar_id']))));
if(empty($nar['id'])){header('location:/nar'.$_GET['id']); exit;}
if(DB::$dbs->query("DELETE from `nar` where (`id`=?)",array($_GET['nar_id']))){
echo '<div class="list1">Пенализация удалена!</div>'; header('refresh:1; url=/nar'.$_GET['id']);
}
break;
case 'add':
if($_GET['id'] == $cms->us['id']){ header('location: /nar'.$_GET['id']); exit; }
if(isSet($_POST['submit'])){
$type = secure($_POST['type']);
$text = secure($_POST['text']);
if(!$text or !$type){
echo'<div class="list1">Вы не ввели тип или причину пенализации...</div>';
}else{
DB::$dbs->query("INSERT INTO `nar` set `us` = ?, `kem`=?, `why` = ?, `type` = ?, `time` = ?",array($_GET['id'],$cms->us['id'],$text,$type,time()));
DB::$dbs->query("INSERT INTO `action` set `value` = ?, `t` = ?, `us` = ?, `see` = ?",array('[url=/us'.$cms->us['id'].']'.$cms->us['nick'].'[/url] вписал вам [url=/nar'.$_GET['id'].']'.($type == 1 ? "предупреждение":"нарушение").'[/url]!',time(),$us['id'],1));
echo'<div class="list1">Пенализация добавлена!</div>'; header('refresh:1; url=/nar'.$_GET['id']);
}
}else{
echo '<div class="list1">
<form action="/nar'.$_GET['id'].'?mod=add" method="post">
Тип:<br/><select name="type"><option value="1">Предупреждение</option><option value="2">Нарушение</option></select></a><br>
Причниа:<br/><textarea name="text"></textarea><br/>
<input name="submit" type="submit" value="Добавить"/>
</form></div>';
}
break;
}
niz();
?>