View file chat.php

File size: 4.34Kb
<?php
include "ini3.php";
include "includes/header2.php";


$id=cyr(htmlspecialchars(stripslashes(trim($id))));
$pass=cyr(htmlspecialchars(stripslashes(trim($pass))));

if(!empty($id)) 
{
$q = mysql_query("select * from users where id='".$id."';"); 
}
else
{
die ($lang['empty_login']."</body></html>");
}


$data = mysql_fetch_array($q);

$id=$data['id'];
$login=$data['login'];
$band=$data['band'];
$cars=$data['cars'];
$guns=$data['guns'];
$money=$data['money'];
$admin=$data['admin'];
$verify=$data['verify'];
$ban=$data['ban'];

if(md5($pass)!=$data['pass'])
{
die ($lang['empty_login']."</body></html>");
}
if($ban==0)
{
switch($mode)
{
default:
$k=cyr(htmlspecialchars(stripslashes(trim($k))));
print "<a href=\"chat.php?id=$id&amp;pass=$pass&amp;k=1\">Общая комната</a> |";
print "<a href=\"chat.php?id=$id&amp;pass=$pass&amp;k=2\">Реклама</a> |";
if($admin>=4)print "<a href=\"chat.php?id=$id&amp;pass=$pass&amp;k=3\">Админ-чат</a> |<br/><br/>";
else print "Админ-чат |<br/><br/>";
if(empty($k) || $k<3)
{
if(empty($k))$k=1;
if(empty($messaga))
{
echo "<form action=\"chat.php?id=$id&amp;pass=$pass&amp;k=$k\" method=\"post\">
<postfield name=\"messaga\" value=\"$(who)\"/>";

print "Сообщение:<br/>";
print "<input name=\"messaga\"  value=\"$messaga\" maxlength=\"1000\"/><br/>";
echo "<input class=\"button\" type=\"submit\" value=\"".$lang['ok']."\"/></form><br/>";
print "<a href=\"chat.php?id=$id&amp;pass=$pass&amp;k=$k\">обновить</a><br/>";
if($k==1)print "<u>[Общая комната]</u><br/><br/>";
elseif($k==2)print "<u>[Реклама]</u><br/><br/>";
elseif($k==3)print "<u>[Админ-чат]</u><br/><br/>";
$pr_q = mysql_query("select * from chat where kom='$k' order by id desc limit 20;");
while($pr_ar=mysql_fetch_array($pr_q))
{
$alogin=$pr_ar['login'];
$aid=$pr_ar['id'];
$mtime=$pr_ar['time'];
$text=$pr_ar['text'];

if($alogin!="BUTTI")print "<b>$alogin</b>($mtime):$text<br/>";
else print "<b><font color='red'>Бутти</font></b>($mtime):$text<br/>";
if($admin>=5)print "<a href=\"chat.php?id=$id&amp;pass=$pass&amp;mode=del&amp;mid=$aid\">удалить</a><br/>";
}
}
else
{
$messaga2=htmlspecialchars(stripslashes(trim($messaga)));
$messaga2 = str_replace('И', 'и', $messaga2);
$messaga2 = str_replace('ш', 'Ш', $messaga2);
$time=date("H:i");
mysql_query("insert into chat values(0,'".$login."','".$time."','".$messaga2."','".$k."');");
print "Сообщение отправлено<br/>";
}
}
//Админ-чат
if($k==3 && $admin>=4)
{
if(empty($messaga))
{
echo "<form action=\"chat.php?id=$id&amp;pass=$pass&amp;k=$k\" method=\"post\">
<postfield name=\"messaga\" value=\"$(who)\"/>";

print "Сообщение:<br/>";
print "<input name=\"messaga\"  value=\"$messaga\" maxlength=\"1000\"/><br/>";
echo "<input class=\"button\" type=\"submit\" value=\"".$lang['ok']."\"/></form><br/>";
print "<a href=\"chat.php?id=$id&amp;pass=$pass&amp;k=$k\">обновить</a><br/>";
print "<u>[Админ-чат]</u><br/><br/>";
$pr_q = mysql_query("select * from chat where kom='$k' order by id desc limit 20;");
while($pr_ar=mysql_fetch_array($pr_q))
{
$alogin=$pr_ar['login'];
$aid=$pr_ar['id'];
$mtime=$pr_ar['time'];
$text=$pr_ar['text'];

if($alogin!="BUTTI")print "<b>$alogin</b>($mtime):$text<br/>";
else print "<b><font color='red'>Бутти</font></b>($mtime):$text<br/>";
print "<a href=\"chat.php?id=$id&amp;pass=$pass&amp;mode=del&amp;mid=$aid\">удалить</a><br/>";
}
}
else
{
$messaga2=htmlspecialchars(stripslashes(trim($messaga)));
$messaga2 = str_replace('И', 'и', $messaga2);
$messaga2 = str_replace('ш', 'Ш', $messaga2);
$time=date("H:i");
mysql_query("insert into chat values(0,'".$login."','".$time."','".$messaga2."','".$k."');");
print "Сообщение отправлено<br/>";
}
}
break;
case "del":
$mid=cyr(htmlspecialchars(stripslashes(trim($mid))));
mysql_query("delete from chat where id='".$mid."';");
print "Сообщение удалено<br/>";
break;
}
print "---<br/>&gt;<a href=\"chat.php?id=$id&amp;pass=$pass&amp;k=$k\">Чат</a>";
print "<br/>&gt;&gt;<a href=\"game.php?id=$id&amp;pass=$pass\">".$lang['menu']."</a>";
print "<br/>---";
print "</body></html>";
}
else{
if($ban==1)print "Вход в чат для тебя недоступен</body></html>";
}
?>