Файл: load/comes.php
Строк: 62
<?php
define('ROOT','../');
define('GCMS',true);
require_once (ROOT.'system/power.php');
if ($aut) {
if ($id) {
$type = $db -> query("SELECT * FROM `files` WHERE `id`='".$id."' and `what`='load'");
if ($type -> num_rows > 0) $the = $type -> fetch_assoc(); else $the = false;
} else $the = false;
if ($type -> num_rows == 0) {header('Location: ./'); exit;}
switch($mode) {
case 'write':
$text = shit($_POST['text']);
$te = $db -> query("SELECT * FROM `comes` WHERE `where`='load' and `idwh` = '".$id."' and `user` = '".$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` = '".$ya['id']."'");
$db -> query("INSERT INTO `comes` SET `where`='load', `user` = '".$ya['id']."', `idwh` = '".$id."',`text` = '".$text."',`time` = '".time()."'");
header('location: comes.php?id='.$id.'&page='.$page);
}else{
$diz -> head('Ошибка');
$diz -> title('Ошибка');
echo '<div class="fon">Следующий комментарий можно оставить через '.$nastr['floodkom'].' сек.</div>';
header('refresh: 3; url=comments'.$id.'');
}
}
break;
case 'del':
$sql = $db -> query("SELECT * FROM `comes` WHERE `id` = '".$sid."' and `where`='load' 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='.$ass['idwh'].'&page='.$page);
} else header('location: comes.php?id='.$ass['idwh'].'&page='.$page);
} else header('location: comes.php?id='.$ass['idwh'].'&page='.$page);
break;
default:
$diz -> head('Комментарии');
$diz -> title("Комментарии");
$count = $db -> dbcount('COUNT(`id`)','comes',"`idwh` = '".$id."' and `where`='load'");
$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` = '".$id."' and `where`='load' ORDER BY `id` DESC LIMIT ".$start.",".$num);
while ($assoc = $for -> fetch_assoc()) {
$dop = null;
if ($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->famname($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>';
echo '<div class="fon"><form action="comes.php?id='.$id.'&mode=write&page='.$page.'" method="post">
Комментарий:<br/>
<textarea name="text" rows="'.$ya['height'].'" cols="'.$ya['width'].'"></textarea><br/>
<input type="submit" value="Написать!"/></form></div>';
$act = 'comes.php?id='.$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');
?>