Файл: BlogExl_v_3/modules/pages/komm.php
Строк: 42
<?
$id = $func->num($_GET['id']);
head('Комментарии');
info();
$blogs = $dbs->query("SELECT * FROM `blog` where `id` = '$id' limit 1");
if(!$blogs->num_rows){$func->msg('Запись не найдена!');foot();exit();}
$bl = $blogs->fetch_assoc();
echo '<div class="pod_razd"><a href="/read'.$bl['id'].'">К статье '.$bl['name'].'</a> | <a href="/komm'.$id.'">Обновить</a></div>';
if(isset($user['id'])){
if(isset($_GET['v'])){
if($user['level']>=1){
$x = abs(intval($_GET['x']));
$dbs->query("UPDATE `komm` SET `type` = '0' WHERE `id` = '$x' LIMIT 1");
header('location:/komm'.$id);
}
}
if(isset($_GET['del'])){
if($user['level']>=1){
$x = abs(intval($_GET['x']));
$dbs->query("UPDATE `komm` SET `type` = '1' WHERE `id` = '$x' LIMIT 1");
header('location:/komm'.$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/komm.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(empty($msg)){
echo '<div class="post2">Комментарий не введен!</div>';} else {
$dbs->query("INSERT INTO `komm` SET `id_us` = '$user[id]', `id_blog` = '$id', `msg` = '$msg', `time` = '".time()."'");
header('location:/komm'.$id);
}
}
}
$ram = $dbs->query("SELECT * FROM `komm` where ".($user['level']>=2?NULL:'type = 0 and')." `id_blog` = '$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 `komm` where ".($user['level']>=2?NULL:'type = 0 and')." `id_blog` = '$id' order by `time` desc limit $start,$num");
if(!$komm->num_rows){$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['type']==1?'<font color="red">[deleted]</font><br/>':null).''.(isset($user)?'[<a href="pages/komm.php?id='.$id.'&uid='.$k['id_us'].'">отв</a>]':NULL).''.(($user['level']>=1 and $k['type']==0)?'[<a href="pages/komm.php?id='.$id.'&del&x='.$k['id'].'">x</a>]':NULL).''.(($user['level']>=2 and $k['type']==1)?'[<a href="?id='.$id.'&v&x='.$k['id'].'">v</a>]':NULL).'</div>';
}
str('/pages/komm.php?id='.$id.'&');
foot();
?>