Файл: chat.php
Строк: 126
<?php
include 'inc/mysql.php';
include 'inc/check.php';
include ("inc/gzip.php");
if(isset($_SESSION['auth']) && $_SESSION['auth']==1){
include 'inc/shapka.php';
if(isset($_POST['msg'])){
$_POST['msg'] = trim($_POST['msg']);
$faq = mysql_query("SELECT * FROM `config`");
$base = mysql_fetch_array($faq);
if($account[lvl]<$base[chat_lvl]){
$err[]='<center><img src="/pic/main/!.png" alt="*"/> Писать в чате доступно с '.$base[chat_lvl].' уровня.</center>';
}else{
if(!empty($_POST['msg'])){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `chat` WHERE `account`='".$account['id']."'"),0)>0 AND 5>(time()-mysql_result(mysql_query("SELECT `time` FROM `chat` WHERE `account`='".$account['id']."' ORDER BY `id` DESC LIMIT 1"),0)))$err[]='<center>Нельзя писать так часто!</center>';
if(strlen($_POST['msg'])>1000) $err[]='<center><img src="/pic/main/!.png" alt="*"/> Слишком длинное сообщение!</center>';
if(strlen($_POST['msg'])<2) $err[]='<center><img src="/pic/main/!.png" alt="*"/> Слишком короткое сообщение!</center>';
}else{
$err[]='<center><img src="/pic/main/!.png" alt="*"/> Пустое сообщение!</center>';
}}
if(!$err){
$req = mysql_query("SELECT * FROM `block` WHERE `usr`='$account[id]' and `ban_time`>'$time' and `tip` = '1'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
While($mag = mysql_fetch_array($req))
{
header("Location: chat.php"); exit;
}}
$msg=$_POST['msg'];
$msg=substr($msg, 0, 1000);
$msg=str_replace("<","",$msg);
$msg=str_replace(">","",$msg);
$msg = addslashes($msg);
$msg=preg_replace ("|[rn]+|si","",$msg);
include ("inc/antireklama.php");
mysql_query("INSERT INTO `chat`(`account`,`msg`,`time`) VALUES('".$account['id']."','$msg','".time()."')");
header("Location: chat.php"); exit;
}else{
foreach($err as $value){
echo '
<div class="help">'.$value.'</div>
';
}
}
}
$req = mysql_query("SELECT * FROM `block` WHERE `usr`='$account[id]' and `ban_time`>'$time' and `tip` = '1' ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
While($mag = mysql_fetch_array($req))
{
echo'<center><img src="/pic/main/!.png" alt="*"/> На вашего персонажа наложена молчанка, вы не можете писать сообщения в чате.</center>';
}}
echo '
<img src="/pic/main/chats.gif" alt="*"/> <a href="chat.php?">Обновить</a> <img src="/pic/main/smils.gif" alt="*"/> <a href="/smile.php">Смайлы</a>
';
if($_GET['go']=='delete' && ($account['status']=="moder" || $account['status']=="gm")){
if(isset($_GET['id'])){
$del = $_GET['id'];
}
if($del){
mysql_query("DELETE FROM `chat` WHERE `id`='".$del."'");
header ("Location: chat.php"); exit;
}else{
header ("Location: chat.php"); exit;
}}
if ($_GET['say']){
$say=mysql_result(mysql_query("SELECT `login` FROM `account` WHERE `id`='".intval($_GET['say'])."'"),0);
$say = str_replace("$say","$say, ",$say);
}else{
$say='';
}
echo '<form name="form" action="chat.php" method="post">'.bbpanel('form', 'msg').'<textarea name="msg" cols="30" rows="1">'.$say.'</textarea>
<br><input type="submit" class="submit" value="Отправить">
</form>
<hr>
';
$cop=10;
$ca=mysql_result(mysql_query("SELECT COUNT(*) FROM `chat`"),0);
$cp=ceil($ca/$cop);
if(isset($_GET['page']) && is_numeric($_GET['page'])){
$page = $_GET['page'];
if($_GET['page']>$cp) $page=$cp;
if($_GET['page']<1)$page=1;
}else{
$page=1;
}
$start=$page*$cop-$cop;
$dlist = 'list1';
$q=mysql_query("SELECT * FROM `chat` ORDER BY `id` DESC LIMIT $start,$cop");
while ($result=mysql_fetch_assoc($q)){
echo '<div class="'.$dlist.'">';
$_user = mysql_fetch_assoc(mysql_query("SELECT * FROM `account` WHERE `id`='".$result['account']."'"));
if($_user['status']=="gm"){
$nik = gradient(''.$_user[login].'','00FF00', '00CC00');
echo '<us><img src="pic/main/'.$_user[sex].'.png" alt="*"/> <a href="?say='.$_user['id'].'">'.$nik.'</us></a> <a href="infa.php?id='.$_user['id'].'"><img src="/pic/main/info.gif" alt="*"/></a>: ';
}else{
if($_user['status']=="moder"){
$nik = gradient(''.$_user[login].'','0066CC', 'AB82FF');
echo '<us><img src="pic/main/'.$_user[sex].'.png" alt="*"/> <a href="?say='.$_user['id'].'">'.$nik.'</us></a> <a href="infa.php?id='.$_user['id'].'"><img src="/pic/main/info.gif" alt="*"/></a>: ';
}else{
if($_user['status']=="bot"){
$nik = gradient(''.$_user[login].'','FFCC00', 'FF9933');
echo '<us><img src="pic/main/'.$_user[sex].'.png" alt="*"/> <a href="?say='.$_user['id'].'">'.$nik.'</us></a> <a href="infa.php?id='.$_user['id'].'"><img src="/pic/main/info.gif" alt="*"/></a>: ';
}else{
echo '
<img src="pic/main/'.$_user[sex].'.png" alt="*"/> <a href="?say='.$_user['id'].'">'.$_user['login'].'</a> <a href="infa.php?id='.$_user['id'].'"><img src="/pic/main/info.gif" alt="*"/></a>: ';
}}}
$koment = strip_tags($result['msg']);
$koment = smiles($koment);
if($result[tyrney]=="1"){
echo "$result[msg]";
}else{
echo "$koment";
}
$d = time()-$result['time'];
echo ' <small><font color=#999999>('.sec2day($d).' назад)</font></small>';
if ($account['status']=='moder' OR $account['status']=='gm'){
echo ' <a href="?go=delete&id='.$result['id'].'"><img src='pic/main/zon.png'></a>';
}
echo '<hr> ';
if ($dlist == 'list1'){
$dlist = 'list2';
}else{
$dlist = 'list1';
}
}
echo '
<center>
Навигация:
';
if($page-1>0){
echo '<a href="?page='.($page-1).'"><</a> ';
}
if($page-1>0){
echo '<a href="?page='.($page-1).'">'.($page-1).'</a> ';
}
echo '<b>'.$page.'</b>';
if($page+1<=$cp){
echo ' <a href="?page='.($page+1).'">'.($page+1).'</a>';
}
if($page+1<=$cp){
echo ' <a href="?page='.($page+1).'">></a>';
}
echo '</center>';
}else{
header ("Location: index.php"); exit;
}
include 'inc/nogi.php';
?>