Файл: comes.php
Строк: 72
<?php
define('ROOT','./');
define('GCMS',true);
require_once (ROOT.'system/power.php');
if ($aut) {
if ($id) {
$type = $db -> query("SELECT * FROM `load_files` WHERE `id`='".$id."");
if ($type -> num_rows > 0) $the = $type -> fetch_assoc(); else $the = false;
} else $the = false;
switch($mode) {
case 'write':
$text = shit($_POST['text']);
$te = $db -> query("SELECT * FROM `comes` WHERE `where`='load' and `idwh` = '".(int)$id."' and `user` = '".(int)$ya['id']."' LIMIT 1");
if (mb_strlen($text) < 3) {
$diz -> head('Ошибка');
$diz -> title('Ошибка');
$msg .= 'Короткий комментарий!';
header('refresh: 3; url=com'.$id.'');
$diz -> out($msg);
}else{
$db -> multi_query("INSERT INTO `comes` SET `where`='load', `user` = '".(int)$ya['id']."', `idwh` = '".$id."',`text` = '".$text."',`time` = '".time()."'");
header('location: comes.php?id='.(int)$id.'&page='.(int)$page);
}
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 `load_files` WHERE `id` = '".$id."' LIMIT 1")-> fetch_assoc();
$diz -> title("<a href='./view/$new[id]/'>".$new['name']."</a>/<b>Комментарии</b>");
$count = $db -> dbcount('COUNT(`id`)','comes',"`idwh` = '".(int)$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` = '".(int)$id."' and `where`='load' ORDER BY `id` DESC LIMIT ".$start.",".$num);
while ($assoc = $for -> fetch_assoc()) {
$arr = $db -> query("SELECT `login` FROM `users` WHERE `id` = '".(int)$assoc['user']."' LIMIT 1");
if ($arr -> num_rows > 0) {
$array = $arr -> fetch_assoc();
$array['login'] = '<a href="'.ROOT.'my/id'.$assoc['user'].'">'.$array['login'].'</a>';
}
$dop = null;
if ($aut) {
if ((int)$ya['level'] > 4) {
$dop = ' | <a href="comes.php?id='.$id.'&sid='.$assoc['id'].'&mode=del&page='.$page.'">[Удалить]</a>';
}
}
$msg .= '<div class="top">'.$array['login'].' ('.$func -> vremja($assoc['time']).') '.$dop.'</div>';
$text = $func -> tags($func -> smiles($assoc['text']));
$msg .=''.$text.'';
}
}else{$msg .= 'Комментариев пока нет!';}
if ($aut == true) {
$msg .= '<form action="comes.php?id='.$id.'&mode=write&page='.$page.'" method="post" enctype="multipart/form-data"><div>';
$msg .= '<hr>Комментарий:<br/>
<textarea name="text" rows="3" cols="15"></textarea><br/>
<input type="submit" value="Написать!"/>
</div></form>';}
$act = 'comes.php?id='.(int)$id;
$msg .= ''.$func -> pagenav($act,$page,$total).'';
$msg .= '<div class="levo">'.$diz -> img('home.png').'<a href="/index.php">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);
}
} else header('location: aut.php');
?>