Файл: www-1/chat.php
Строк: 43
<?php
define('cms', 1);
require_once 'core.php';
if ($user)
{
Error_Reporting(E_ALL & ~E_NOTICE);
$u = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '".$user."'"));
if ($u['x'] == 3 AND $u['y'] == 1)
{
echo '<div class="menu">Таверна</div>';
echo '<div class="pt">';
switch($_GET['a'])
{
default:
echo 'Таверна, это тот же чат, в котором игроки общаются и переписываются!<br />';
echo '<img src="./img/portal_gate_blue.png" width="12" height="12" alt="*"> <a href="?a=chat">Зайти внутрь</a><br />
<img src="./img/portal.png" width="12" height="12" alt="*"> <a href="city1.php">Вернуться</a>';
break;
case 'chat':
if(isset($_POST['txtArea']) AND mb_strlen($_POST['txtArea']) > 1 AND mb_strlen($_POST['txtArea']) < 1000 AND $u['ban_chat'] < time()) {
mysql_query("INSERT INTO chat SET massage='".addslashes($_POST['txtArea'])."', time='".date("H:i")."', author='".htmlspecialchars($u['login'])."' ");
echo 'Сообщение добавленно'; Header("Location: chat.php?a=chat");}
echo '<form method=POST action=?a=chat>
<textarea name="txtArea" cols="15" rows="3">';
$allusers = mysql_fetch_array(mysql_query("SELECT `id` FROM `users` ORDER BY `id` DESC LIMIT 1"));
if (isset($_GET['to']) and abs($_GET['to']) > 0 AND abs($_GET['to']) <= $allusers)
{
$to = mysql_fetch_array(mysql_query("SELECT `login` FROM `users` WHERE `id` = '".abs($_GET['to'])."'"));
echo $to['login'].', ';
}
echo '</textarea>
<br /><input type="submit" value="Сказать">
</form>';
include('chat.n.php');
$allfield = mysql_result(mysql_query("select count(*) from `chat`"),0);
$newlist = new Navigation($allfield,
8,
true);
$query = mysql_query("select * from `chat` order by `id` DESC limit ". $newlist->limit().";");
while($res = mysql_fetch_assoc($query))
{
$i = mysql_fetch_array(mysql_query("SELECT `id`,`privilege` FROM `users` WHERE `login` = '".$res['author']."'"));
echo '<b><a href="user.php?id='.$i['id'].'">'.htmlspecialchars($res['author']).' <a href="?a=chat&to='.$i['id'].'">></a> ';
if ($i['privilege'] == 1) echo '<font color=green>(M)</font>';
if ($i['privilege'] == 2) echo '<font color="red">(A)</font>';
if ($u['privilege'] > 0) echo '<a href="?a=delete&m='.$res['id'].'">[x]</a>';
$massage = str_replace('=)', '<img src="./smile.gif">', htmlspecialchars($res['massage']));
echo '</a></b> ['.$res['time'].'] <br /> > '.$massage.'<br />';
}
echo $newlist->pagination();
echo '<br /><br /><img src="./img/portal.png" width="12" height="12" alt="*"> <a href="index.php">Вернуться</a>';
break;
case 'delete':
if ($u['privilege'] > 0)
{
mysql_query("DELETE FROM `chat` where `id`='".addslashes($_GET['m'])."'");
header('Location: ./chat.php?a=chat');
} else header('Location: ./chat.php?a=chat');
break;
}
} else header('Location: ./world.php');
echo '</div>';
}
else
{
header('Location: ./index.php');
}
include './include/foot.php';
?>