Файл: public_html/modules/alliance/chat.php
Строк: 40
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
allianceStatus(1);
$header = 'Чат альянса';
include_once ($root.'/core/head.php');
if(isset($_GET['send']))
{
$text = fl($_POST['text']);
if($ban->num_rows > 0) redirect('/', 'Вы заткнуты!');
$sql = $db->query("INSERT INTO `alliance_chat` (`alliance`,`user`,`message`,`time`) VALUES ('".$u['alliance_id']."', '".$u['id']."', '".$text."', '".time()."')");
header("Location: /alliance/chat");
exit;
}
$count = $db -> query("SELECT * FROM `alliance_chat` WHERE `alliance` = '".$u['alliance_id']."' ORDER BY `time` DESC") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10*$page-10;
$sql = $db -> query("SELECT * FROM `alliance_chat` WHERE `alliance` = '".$u['alliance_id']."' ORDER BY `time` DESC LIMIT $start, 10");
echo'<div class="b">';
echo '<center>
<form action="?send" method="post">
<textarea name="text" required></textarea><br>
<input type="submit" name="send" value="Отправить">
</form></center>';
if($count > 0)
{
while($q = $sql->fetch_object())
{
if($q->user == $u['id']) $div = "mail-chat2";
else $div = "mail-chat3";
echo '<dl class = "'.$div.'">
<small>'.tm($q->time).'</small><strong><big>'.who($q->user).'</big></strong>
<br><big>'.smiles($q->message).'</big></br></dl>';
}
echo"</div>";
if($count >= 10) echo str('/alliance/chat?',$k_page,$page);
}else{
echo '<center>Нет сообщений</center></div>';
}
include_once ($root.'/core/foot.php');