Файл: BlogExl_v_3/modules/pages/chat.php
Строк: 31
<?
head('Мини-чат');
if($set['chat']==1){$func->msg('Раздел временно закрыт!');foot();exit();}
info();
if($user['id']==1){echo '<div class="post2"><a href="?delk">Очистить чат</a></div>';}
$id = $func->num($_GET['id']);
if(isset($user['id'])){
if(isset($_GET['delk']) AND $user['id']==1){
$dbs->query("DELETE FROM `chat`");
header('location:?');
}
if(isset($_GET['del']) AND $user['level']==2){
$dbs->query("DELETE FROM `chat` where `id` = '$id' limit 1");
header('location:?');
}
if(isset($_GET['ok'])){
$msg = $func->txt($_POST['msg']);
if(empty($msg)){
$func->msg('Сообщение не введено!');
}else{
$dbs->query("INSERT INTO `chat` SET `id_us` = '$user[id]', `msg` = '$msg', `time` = '$time'");
header('location:?');
}
}
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="post2"><form action="?ok" method="post">Сообщение:<br/><textarea rows="3" cols="20" name="msg">'.$otv.'</textarea><br/><input type="submit" value="Написать"/></form></div>';
}
$ram = $dbs->query("SELECT * FROM `chat`")->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;
$q = $dbs->query("SELECT * FROM `chat` order by `time` desc limit $start,$num");
if(!$q->num_rows){echo '<div class="post2">Сообщений нет!</div>';}
while($a = $q->fetch_assoc()){
echo '<div class="post2">'.$func->nik($a['id_us']).': '.$func->out($a['msg']).'('.times($a['time']).') '.(isset($user)?'[<a href="?uid='.$a['id_us'].'">отв</a>]':NULL).' '.($user['level']==2?'[<a href="?id='.$a['id'].'&del">del</a>]':NULL).'</div>';
}
str('?');
foot();
?>