Файл: chat.php
Строк: 160
<?
define('PROTECTOR', 1);
$textl='Общий чат';
include('files/db.php');
include('files/auth.php');
if ($user_id==0){
header('location: index.php');exit;
}
if(isset($_GET['say']))
{
$bans = mysql_query("SELECT * FROM `ban` WHERE `usr` = '".$udata['id']."' and `place`='1'");
$banq=mysql_num_rows($bans);
if($banq!=0)
{
header('location: ?');exit;
}
else
{
if($udata['lvl']<5)
{
header('location: ?');exit;
}
else
{
$text=htmlspecialchars($_POST['text']);
if($text=='')
{
header('location: ?');exit;
}
else
{
$msg=$_POST['text'];
$msg=substr($msg, 0, 1000);
$msg=$_POST['text'];
$msg = addslashes($msg);
if($udata['admin']==6)
{
$msg=nl2br($msg);
if($udata['admin']==6)
{
$msg=html_entity_decode($msg);
}
}
$time_chat=time();
if($msg != "")
{
mysql_query("INSERT INTO chat SET usr = '".$udata['id']."',
text = '$msg',
time = '$time_chat'");
header('location: ?');exit;
}
}}
}
}
if(isset($_GET['del']))
{
if($udata['admin']<2 or $udata['admin']==3)
{
header('location: ?');exit;
}
mysql_query("UPDATE `chat` SET
`del`='".$udata['id']."'
WHERE `id`='".mysql_real_escape_string($_GET['id'])."'");
header('location: ?');exit;
}
include($path.'files/head.php');
include($path.'files/zag.php');
echo '<table width=100%>
<tr>
<td width=35%>
<a href=game.php><div style="background: #882222; border-radius: 7px 0 0 7px" class="m p bts bbs brs bls" align=center>Главная</div></a>
</td><td>';
echo '<a href=?><div class="line bts brs bls bbs p m" style="border-radius: 0 7px 7px 0">
<font color=#ffffff>Общий Чат
</font>
</div></a></td></tr></table>';
echo '<div class="bat bts brs bls bbs p">';
if($udata['lvl']<5)
{
echo '<font color=#ff0000>Отправлять сообщения в чат доступно с 5 уровня!</font>';
}
else
{
$bans = mysql_query("SELECT * FROM `ban` WHERE `usr` = '".$udata['id']."' and `place`='1'");
$banq=mysql_num_rows($bans);
if($banq!=0)
{
echo '<a href=?><div><img src=img/main/e22.png> Обновить</div></a>';
echo '<font color=#ff0000>У вас бан чата! Вы не можете тут писать!</font>';
}
else
{
if(isset($_GET['talk']))
{
$usersza=mysql_query("SELECT * FROM `users` WHERE `id`='".mysql_real_escape_string($_GET['id'])."'");
$usa=mysql_fetch_array($usersza);
echo '<form action=?say method=POST>
<center><textarea name=text rows=3 style="width: 90%">'.$usa['usr'].', </textarea></center>
<div align=center><input type=submit value=отправить></div>
</form>';
}
else
{
echo '<form action=?say method=POST>
<center><textarea name=text rows=3 style="width: 90%"></textarea></center>
<div align=center><input type=submit value=отправить></div>
</form>';
}
}
}
echo'</div></div><div class="v8">
<div class="line m bts brs bls b p v12">чат</div><div class="bat bts brs bls bbs p">
';
if ($_GET['page'] == "" || $_GET['page'] < 0 || $_GET['page'] == "0")
{
$_GET['page'] = 0;
}
$next = $_GET['page'] + 1;
$back = $_GET['page'] - 1;
$num = $_GET['page'] * 10;
if($_GET['page'] == "0")
{$i = 1;}
else{$i = ($_GET['page']*10)+1;}
$viso = mysql_num_rows(mysql_query("SELECT * FROM chat"));
$puslap = floor($viso/10);
$chat=mysql_query("SELECT * FROM `chat` ORDER BY `time` DESC LIMIT $num,10");
while($ch=mysql_fetch_array($chat))
{
$ch['text']=$ch['text'];
//$ch['text']=str_replace('AvTor',"<font color=#00ffff><i>Великий и Могучий AvTor</i></font>",$ch['text']);
$users=mysql_query("SELECT * FROM `users` WHERE `id`='".$ch['usr']."'");
$us=mysql_fetch_array($users);
echo '<div class="p bbda">';
echo '<table width=100%>';
echo '<tr>';
echo '<td width=70%>';
if($us['admin']>0 and $us['admin']<6)
{
echo '<img src=img/main/md.png> ';
$col='#00ee00';
}
elseif($us['admin']>5)
{
echo '<img src=img/main/admin.png> ';
$col='#00ee00';
}
else
{
$col='#cccccc';
}
echo '<img src=img/main/c'.$us['klass'].'.png> <img src=img/main/r'.$us['rasa'].'.png>
<a href=info.php?id='.$us['id'].'>'.$us['usr'].'</a> ';
echo '(<a href=?talk&id='.$us['id'].'><font color=#ff9900>отв.</font></a>) ';
if($us['admin']==0 and $udata['admin']>1 and $udata['admin']!=3)
{
echo '<a href=?del&id='.$ch['id'].'><font color=#ff0000>[x]</font></a>';
}
elseif($us['admin']>0 and $udata['admin']>4)
{
echo '<a href=?del&id='.$ch['id'].'><font color=#ff0000>[x]</font></a>';
}
echo '</td><td>';
$time=time()-$ch['time'];
$h=floor($time/3600);
$m=floor(($time-($h*3600))/60);
$s=$time-($h*3600)-($m*60);
$tim=$h.':'.$m.':'.$s;
echo '<div align=right><font color=#0099ff>'.$tim.'</font></color>';
echo '</td></tr></table>';
if($ch['del']==0)
{
echo ' <font color='.$col.'>'.$ch['text'].'</font>';
}
else
{
$usersz=mysql_query("SELECT * FROM `users` WHERE `id`='".$ch['del']."'");
$usz=mysql_fetch_array($usersz);
if($usz['admin']>0 and $usz['admin']<6)
{
$mdz= '<img src=img/main/md.png> ';
}
elseif($usz['admin']==6)
{
$mdz= '<img src=img/main/admin.png> ';
}
echo ' <font color=#ff0000>Сообщение удалено </font>'.$mdz.' <img src=img/main/c'.$usz['klass'].'.png> <img src=img/main/r'.$usz['rasa'].'.png>
<a href=info.php?id='.$usz['id'].'>'.$usz['usr'].'</a> ';
//
if($udata['admin']>3)
{
echo '(<font color=#888888>'.$ch['text'].'</font>)';
}
}
echo '</div>';
}
$kol_us=mysql_num_rows(mysql_query("SELECT * FROM `chat`"));
$pag=ceil($kol_us/10);
$m_p=$_GET['page']-2;
$mx_p=$_GET['page']+6;
echo '<table width=100%><tr>';
for($k=0; $k<=$pag; $k++)
{
if($k>=$m_p and $k<=$mx_p and $k>0)
{
$i=$k-1;
if($_GET['page']==''){$_GET['page']=0;}
if($_GET['page']!=$i)
{
echo '<td><a href=?page='.$i.'><div style="background: #000044; padding: 3px; margin-top: 3px;" class="bts bbs brs bls" align=center>'.$k.'</div></a></td>';
}
else
{
echo '<td><a href=?page='.$i.'><div style="background: #044440; padding: 3px; margin-top: 3px;" class="bts bbs brs bls" align=center>'.$k.'</div></a></td>';
}
}
}
echo'</tr></table>';
$lv=time()-1800;
$chqz=mysql_query("SELECT * FROM `users` WHERE `mesto`='Общий чат' and `lv`>'".$lv."'");
$chatqsz=mysql_num_rows($chqz);
echo'<div><font color=#00dede>Сейчас в чате</font> <a href=chat_usr.php>'.$chatqsz.' игроков</a></div>';
//echo '<img src=img/main/i25.png> <a href=smiles.php>Смайлики</a><br>';
echo '<a href=chat_r.php><div class="v2s">
<img src=img/main/i25.png class="menu"> <font color=#00cc00>Торговый Чат</font></div></a>';
if($udata['admin']>0)
{
echo '<a href=chat_md.php><div class="v2s">
<img src=img/main/i25.png class="menu"> <font color=#00cc00>Мд Чат</font></div></a>';
}
if($udata['clan']>0)
{
echo '<a href=clan.php?chat><div class="v2s">
<img src=img/main/i25.png class="menu"> <font color=#00cc00>Чат Гильдии</font></div></a>';
}
echo '</div></div>';
include($path.'files/down.php');
?>