Файл: BlogExl_v_3/modules/pages/kom.php
Строк: 56
<?
$id = $func->num($_GET['id']);
head('Комментарии');
info();
$news = $dbs->query("SELECT * FROM `news` where `id` = '$id' limit 1");
if(!$news->num_rows){$func->msg('Новость не найдена!');}
$n = $news->fetch_assoc();
if(isset($user['id'])){
if(isset($_GET['v'])){
if($user['level']>=2){
$x = $func->num($_GET['x']);
$dbs->query("UPDATE `news_komm` SET `activ` = '0' WHERE `id` = '$x' LIMIT 1");
header('location:/kom'.$id);
}
}
if(isset($_GET['del'])){
if($user['level']>=1){
$x = $func->num($_GET['x']);
$dbs->query("UPDATE `news_komm` SET `activ` = '1' WHERE `id` = '$x' LIMIT 1");
header('location:/kom'.$id);
}
}
if(isset($_GET['uid'])){
$uid = $func->num($_GET['uid']);
$q = $dbs->query("SELECT id,login FROM `blogger` WHERE `id` = '$uid'");
if(!$q->num_rows){$func->msg('Нет такого пользователя!');foot();exit();}
$a = $q->fetch_assoc();
$otv = '[b]'.$a['login'].'[/b], ';
} else
$otv = '';
echo '<div class="pod_razd"><form action="pages/kom.php?id='.$id.'&ok" method="post">Комментарий:<br/><textarea rows="7" cols="20" name="msg">'.$otv.'</textarea><br/><input type="submit" value="Добавить"/></form></div>';
if(isset($_GET['ok'])){
$msg = $func->txt($_POST['msg']);
if($dbs->query("SELECT * FROM `news_komm` where `msg` = '$msg'")->num_rows==1){$err .='Такой коммент уже есть!';}
if(empty($msg)){
echo '<div class="post2">Комментарий не введен!</div>';} else {
$dbs->query("INSERT INTO `news_komm` SET `id_us` = '$user[id]', `id_news` = '$id', `msg` = '$msg', `time` = '".time()."'");
header('location:/kom'.$id);
}
}
}
$ram = $dbs->query("SELECT * FROM `news_komm` where ".($user['level']>=2?NULL:'activ = 0 and')." `id_news` = '$id'")->num_rows;
$num = 10;
$total = intval(($ram - 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;
$komm = $dbs->query("SELECT * FROM `news_komm` where ".($user['level']>=2?NULL:'activ = 0 and')." `id_news` = '$id' order by `time` desc limit $start,$num");
if($ram == 0){$func->msg('Комментариев нет!');}
while($k = $komm->fetch_assoc()){
echo '<div class="pod_razd">'.$func->nik($k['id_us']).': '.$func->out($k['msg']).' ('.times($k['time']).')<br/>'.($k['activ']==1?'<font color="red">[deleted]</font><br/>':NULL).''.(isset($user)?'[<a href="?id='.$id.'&uid='.$k['id_us'].'">отв</a>]':NULL).''.(($user['level']>=1 and $k['activ']==0)?'[<a href="?id='.$id.'&del&x='.$k['id'].'">x</a>]':NULL).''.(($user['level']>=2 and $k['activ']==1)?'[<a href="?id='.$id.'&v&x='.$k['id'].'">v</a>]':NULL).'</div>';
}
str('pages/kom.php?id='.$id.'&');
foot();
?>