Файл: youtube/comes.php
Строк: 68
<?php
define('ROOT','../');
define('GCMS',true);
require_once (ROOT.'system/power.php');
if ($aut) {
$youtube = $db -> query("SELECT * FROM `youtube` WHERE `id` = '".$id."' LIMIT 1");
if ($youtube -> num_rows == 0) header('Location: ./');
$new =$youtube-> fetch_assoc();
switch($mode) {
case 'write':
$text = shit($_POST['text']);
$te = $db -> query("SELECT * FROM `comes` WHERE `where`='youtube' and `idwh` = '".$id."' and `user` = '".$ya['id']."' LIMIT 1");
if (mb_strlen($text) < 3) {
$diz -> head('Ошибка');
$diz -> title('Ошибка');
echo '<div class="fon">Короткий комментарий!</div>';
header('refresh: 3; url=comments'.$id.'');
$diz -> out($msg);
}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']."'");
$text_sys=''.$ya['login'].' прокомментировал ваше видео [url=http://'.shit($_SERVER['SERVER_NAME']).'/youtube/video'.$id.']'.$new['name'].'[/url]';
if($ya['id']!=$new['user'])$func->sysmail($text_sys,$new['user']);
$db -> query("INSERT INTO `comes` SET `where`='youtube', `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.'');
$diz -> out($msg);
}
}
break;
case 'del':
$sql = $db -> query("SELECT * FROM `comes` WHERE `id` = '".$sid."' and `where`='youtube' LIMIT 1");
if ($sql -> num_rows > 0) {
$ass = $sql -> fetch_assoc();
if ($ya['level']>4) {
$db -> query("DELETE FROM `comes` WHERE `id` = '".$sid."' and `where`='youtube' 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`='youtube'");
if ($count>0){
$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;
$for = $db -> query("SELECT * FROM `comes` WHERE `idwh` = '".$id."' and `where`='youtube' ORDER BY `id` DESC LIMIT ".$start.",".$num);
while ($assoc = $for -> fetch_assoc()) {
$dop = null;
if ($aut) {
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>';
}
$act = 'comes.php?id='.$id;
echo ''.$func -> pagenav($act,$page,$total).'';
}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="3" cols="15"></textarea><br/>
<input type="submit" value="Написать!"/>
</div></form>';
}
echo '<div class="levo"><a href="video'.$new['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: '.ROOT.'aut.php');
?>