Файл: obmen/comes.php
Строк: 91
<?php
define('ROOT','../');
define('GCMS',true);
require_once (ROOT.'system/power.php');
if ($aut) {
if ($id) {
$type = $db -> query("SELECT * FROM `obmen_files` WHERE `id`='".$id."");
if ($type -> num_rows > 0) $the = $type -> fetch_assoc(); else $the = false;
} else $the = false;
switch($mode) {
case 'write':
if ($ya['balls']>=$nastr['obcom']) {
$text = shit($_POST['text']);
$te = $db -> query("SELECT * FROM `comes` WHERE `where`='obmen' and `idwh` = '".(int)$id."' and `user` = '".(int)$ya['id']."' LIMIT 1");
if (mb_strlen($func->delprobel($text)) < 3) {
$diz -> head('Ошибка');
$diz -> title('Ошибка');
echo '<div class="fon">Короткий комментарий!</div>';
header('refresh: 3; url=comments'.$id.'');
}else{
$mtime = $db -> query("SELECT * FROM `comes` WHERE `user` = '".$ya['id']."' order by `time` DESC")->fetch_assoc();
if($mtime['time']+$nastr['floodkom']<=time()){
$db -> query("UPDATE `users` SET `balls`=balls+'".$nastr['bcoms']."' WHERE `id` = '".(int)$ya['id']."'");
$db -> query("INSERT INTO `comes` SET `where`='obmen', `user` = '".(int)$ya['id']."', `idwh` = '".$id."',`text` = '".$text."',`time` = '".time()."'");
header('location: comes.php?id='.(int)$id.'&page='.(int)$page);
}else{
$diz -> head('Ошибка');
$diz -> title('Ошибка');
echo '<div class="fon">Следующий комментарий можно оставить через '.$nastr['floodkom'].' сек.</div>';
header('refresh: 3; url=comments'.$id.'');
}
}
}else{
$diz -> head('Ошибка');
$diz -> title('Ошибка');
echo '<div class="fon">Вам недоступна данная операция!</div>';
header('refresh: 3; url=comments'.$id.'');
}
break;
case 'del':
if ($aut == true and $id != false) {
$sql = $db -> query("SELECT * FROM `comes` WHERE `id` = '".$sid."' LIMIT 1");
if ($sql -> num_rows > 0) {
$ass = $sql -> fetch_assoc();
if ($ya['level']>4) {
$db -> query("DELETE FROM `comes` WHERE `id` = '".$sid."' LIMIT 1");
header('location: comes.php?id='.(int)$ass['idwh'].'&page='.(int)$page);
} else header('location: comes.php?id='.(int)$ass['idwh'].'&page='.(int)$page);
} else header('location: comes.php?id='.(int)$ass['idwh'].'&page='.(int)$page);
} else header('location: comes.php?id='.(int)$ass['idwh'].'&page='.(int)$page);
break;
default:
$diz -> head('Комментарии');
$new = $db -> query("SELECT * FROM `obmen_files` WHERE `id` = '".$id."' LIMIT 1")-> fetch_assoc();
$diz -> title("<a href='file$new[id]'>".$new['name']."</a>/<b>Комментарии</b>");
$count = $db -> dbcount('COUNT(`id`)','comes',"`idwh` = '".(int)$id."' and `where`='obmen'");
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1;
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
if ($count>0){
$for = $db -> query("SELECT * FROM `comes` WHERE `idwh` = '".(int)$id."' and `where`='obmen' ORDER BY `id` DESC LIMIT ".$start.",".$num);
while ($assoc = $for -> fetch_assoc()) {
$dop = null;
if ((int)$ya['level'] > 4) {
$dop = '<a href="comes.php?id='.$id.'&sid='.$assoc['id'].'&mode=del&page='.$page.'">[Удалить]</a>';
}
echo '<div class="fon">
<table><tr valign="top"><td>'.$func->avatar($assoc['user']).'</td>
<td style="padding-left:5px;">'.$func->nick($assoc['user']).' '.$func -> times(date('d m Y в H:i',$assoc['time'])).'</br>
'.$func -> tags($func -> smiles($assoc['text'])).'<br/>'.$dop.'</td>
</tr></table></div>';
}
}else{echo '<div class="fon">Комментариев пока нет!</div>';}
if ($aut == true) {
echo '<div class="fon"/><form action="comes.php?id='.$id.'&mode=write&page='.$page.'" method="post">
Комментарий:<br/>
<textarea name="text" rows="3" cols="15"></textarea><br/>
<input type="submit" value="Написать!"/></form></div>';}
$act = 'comes.php?id='.(int)$id;
echo ''.$func -> pagenav($act,$page,$total).'';
}
echo '<div class="levo"><a href="file'.$id.'" class="levo_tuch"> '.$diz -> img('back.png').' Назад</a></div>';
echo '<div class="levo"><a href="/index.php" class="levo_tuch"> '.$diz -> img('home.png').' На главную</a></div>';
#####Копирайт#######
$diz -> out($msg);
} else header('location: /aut.php');
?>