Файл: chat/index.php
Строк: 134
<?
require_once '../core/system.php';
echo only_reg();
echo ban();
$header = 'Общий чат';
require_once H.'core/head.php';
mysql_query("DELETE FROM `chat` WHERE `timer` <= ".$tm." ");
if($user['mesto'] != 'Общий чат') mysql_query("UPDATE `user` set `mesto` = 'Общий чат' where `id` = '".$user['id']."'");
if($user['save'] < 1){
header('Location: /');
}
switch($act) {
case 'post':
if(isset($_POST['msg'])){
$msg = check($_POST['msg']);
$lelfi = $_SERVER['REQUEST_TIME'] - 60;
$elfilox = mysql_result(mysql_query("SELECT COUNT(id) FROM `chat` WHERE `msg` = '".$msg."' and `id_user` = '".$user['id']."' and `time`>".$lelfi.""),0);
if($elfilox > 0 ) {
$err = 'Сообщение повторяет предыдущее!';
header('Location: ? ');
}
if($user['prava'] < 4) if(mb_strlen($msg) < 1 or mb_strlen($msg) > 400) $err = 'Длина сообщения должна быть от 1 до 400 символов';
if($user['prava'] > 3) if(mb_strlen($msg) < 1 or mb_strlen($msg) > 1000) $err = 'Длина сообщения должна быть от 1 до 1000 символов';
if($user['level'] < 10) $err = 'Писать в чате можно только с 10 уровня!';
if(!isset($err)) {
$f = $_SERVER['REQUEST_TIME']+43200;
if(!isset($_GET['edit'])) {
mysql_query("INSERT INTO `chat` SET `id_user` = '".$user['id']."', `msg` = '".$msg."', `timer` = '".$f."', `time` = '".$_SERVER['REQUEST_TIME']."'");
} else {
mysql_query("UPDATE `chat` SET `msg`='".$msg."' WHERE `id`='".intval($_GET['id_msg'])."'");
}
header('Location: ?');
exit();
} else {
header('Location: ?');
$_SESSION['err'] = $err;
exit();
}
} else {
header('Location: ?');
$_SESSION['err'] = 'Введите текст';
exit();
}
break;
default:
if(isset($_GET['del'])){
if($user['prava'] < 2){
$_SESSION['error'] = 'Ошибка!';
header("Location: ?");exit;}
$id_chmsg = intval($_GET['id_msg']);
$del_chat_msg = mysql_query("DELETE FROM `chat` WHERE `id` = '".$id_chmsg."'");
header("Location: ?");
}
$k_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `chat` WHERE `hiking`='0' and `elit`='0'"),0);
$k_page = k_page($k_post,10);
$page = page($k_page);
$start = 10*$page-10;
echo '<div class="foot">
<a href="?"><img src="/images/icon/reload.png"> Обновить
</a>
<span class="float-right">
<a href="/moduls/smiles">
<img src="/images/icon/smiley.png"> Смайлики</a>
</span>
</div>
<hr>';
$req = mysql_query("SELECT * from `ban` where `id_us` = '".$user['id']."' and `time`>'".$_SERVER['REQUEST_TIME']."'");
$ban = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto == 0){
if(isset($_GET['edit']) && $user['prava'] > 3) {
$uu = mysql_query("SELECT * FROM `chat` WHERE `id`='".intval($_GET['id_msg'])."'");
$edo = mysql_fetch_array($uu);
echo '<div class="head">
<div class="empty"></div>
<form method="post" action="?act=post&edit&id_msg='.intval($_GET['id_msg']).'">
<input class="chat-area" value="'.$edo['msg'].'" name="msg" />
</textarea>
<input type="submit" class="inpc-ar form-submit" value="Отправить">
</span>
</form>
</div>';
} else {
if(isset($_GET['id'])) {
$ank = mysql_fetch_array(mysql_query("SELECT `nick` FROM `user` WHERE `id` = '".abs(intval($_GET['id']))."'"));
echo '<div class="head">
<div class="empty"></div>
<form method="post" action="?act=post">
<input class="chat-area" value="'.$ank['nick'].', " name="msg" />
</textarea>
<input type="submit" class="inpc-ar form-submit" value="Отправить">
</span>
</form>
</div>';
} else {
echo'<div class="head">
<div class="empty"></div>
<form method="post" action="?act=post">
<textarea rows="3" class="chat-area" name="msg">
</textarea>
<input type="submit" class="inpc-ar form-submit" value="Отправить">
</span>
</form>
</div>';
}
}
echo '<hr>';
}
$q = mysql_query("SELECT * FROM `chat` WHERE `hiking`='0' and `elit`='0' ORDER BY `id` DESC LIMIT ".$start.", 10");
while($post = mysql_fetch_array($q)) {
$ank = mysql_fetch_array(mysql_query("SELECT `id`,`font`,`prava`,`nick` FROM `user` WHERE `id` = ".$post['id_user'].""));
$req = mysql_query("SELECT `id` from `ban` where `id_us` = '".$ank['id']."' and `time`>'".$_SERVER['REQUEST_TIME']."'");
$avto = mysql_num_rows($req);
if($avto > 0){
echo'<div class="player">';
echo online($ank['id']);
echo ' <a href="/user/'.$ank['id'].'/"><font color="'.$ank['font'].'">'.$ank['nick'].'</font></a>';
if($ank['nick'] != $user['nick']){
echo '<a href="?id='.$ank['id'].'"> (Ответить)</a>';
}
echo '<span class="mit">'.date("H:i:s", $post['time']).'</span>';
if ($user['prava'] >= 4){
echo'</br>'.smiles($post['msg']).' <font color="#FE2E2E">[BANED]</font>';
}
if ($user['prava'] >= 2){
echo' <a href="?del&id_msg='.$post['id'].'">[X]</a>';
}
echo'</br>
<font color="'.$color.'"> </font>';
?>
</div>
<hr>
</div>
<?php
} else {
if($ank['prava']==5){
$status="<font color='ffc22b'>[A]</font>"; $color="#F7990D";}
if($ank['prava']==4){
$status="<font color='ffc22b'>[a]</font>"; $color="EBC621";}
if($ank['prava']==3){
$status="<font color='ffc22b'>[M]</font>";
}
if($ank['prava']==2){
$status="<font color='ffc22b'>[m]</font>";
}
?>
<div class="player">
<?php
echo online($ank['id']);
echo ' <a href="/user/'.$ank['id'].'/">
<font color="'.$ank['font'].'">'.$ank['nick'].'</font>
</a>';
if($ank['prava'] > 1){
echo $status;
}
if($ank['nick'] != $user['nick']){
echo' <a href="?id='.$ank['id'].'">(Ответить)</a>';
}
echo '<span class="mit">'.date("H:i:s", $post['time']).' </span>';
if ($user['prava'] >= 2){
echo" <a href='?del&id_msg=".$post['id']."'>[X]</a>";
}
if ($user['prava'] > 3){
echo' <span class="float-right"><a href="?edit&id_msg='.$post['id'].'">[Изм.]</a></span>';
}
if ( preg_match('/'.$user['nick'].'/i', $post['msg']) )
{
$to = ["".$user['nick']."," =>'<font color="#EBCA46">'.$user['nick'].', </font>'];
$post['msg'] = strtr($post['msg'], $to);
}
if ($ank['prava'] >= 4){
echo'</br>
<font color="'.$color.'">'.smiles(antimat($post['msg'])).'</font>
</font> ';
} else {
echo'</br>'.smiles(antimat($post['msg'])).' ';
}
?>
</div>
<hr>
<?php
}
}
?>
</div>
</div>
<?php
if ($k_page > 1){
str('?',$k_page,$page);
?>
<hr>
<?php
}
$chat = mysql_result(mysql_query("SELECT COUNT(id) FROM `user` WHERE `mesto`='Общий чат' and `online` > '".($_SERVER['REQUEST_TIME']-10800)."'"),0);
?>
<div class="head">
<div class="empty2"></div>
<center> Сейчас в общем чате
<a href="info"><?=$chat?> игроков</a>
</center>
<div class="empty2"></div>
</div>
<?php
}
require_once H.'core/foot.php';
?>