File size: 4.61Kb
<?
require_once '../core/system.php';
echo only_reg();
echo ban();
$header = 'Чат Клана';
require_once H.'core/head.php';
mysql_query("DELETE FROM `clan_chat` WHERE timer<='$tm' ");
$clan = mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id` = ".intval($_GET['id']).""));
if($clan['id']!=$user['clan'] && $user['prava']<4){$_SESSION['err'] = 'Ошибка'; header('Location: /');}
switch($act) {
case 'post':
if(isset($_POST['msg'])){
$msg = check($_POST['msg']);
$lelfi = $_SERVER['REQUEST_TIME'] - 15;
$elfilox = mysql_result(mysql_query("SELECT COUNT(id) FROM `clan_chat` WHERE `msg` = '".$msg."' and `id_user` = '".$user['id']."' and `time`>".$lelfi.""),0);
if($elfilox > 0 ) {
$err = 'Сообщение повторяет предыдущее!';
header('Location: /forum/ ');
}
if($user['prava'] < 4)if(strlen($msg) < 2 or strlen($msg) > 400) $err = 'Длина сообщения должна быть от 2 до 400 символов';
if($user[level] < 3) $err = 'В чате можно писать только с 3 уровня!';
if(!isset($err)) {
mysql_query("INSERT INTO `clan_chat` SET `id_user` = '$user[id]', `clan`='$clan[id]', `msg` = '$msg', `time` = '".time()."', `timer` = 'timer'+".time()."+86400");
header('Location: ?id='.$clan['id'].'');
}else{
header('Location: ?id='.$clan['id'].'');
$_SESSION['err'] = $err;
}
}else{
header('Location: ?id='.$clan['id'].'');
$_SESSION['err'] = 'Введите текст';
}
break;
default:
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `clan_chat` WHERE `clan`='$user[clan]'"),0);
$k_page = k_page($k_post,10);
$page = page($k_page);
$start = 10*$page-10;
echo "<div class='foot'>";
echo "<a href='?id=$clan[id]'><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>";
if(isset($_GET['usr'])) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '".abs(intval($_GET['usr']))."' LIMIT 1"));
echo '<div class="player"><form method="post" action="?act=post&id='.$clan['id'].'">
<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="player"><form method="post" action="?act=post&id='.$clan['id'].'">
<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 `clan_chat` where `clan`='".intval($_GET['id'])."' ORDER BY `id` DESC LIMIT $start, 10");
while($post = mysql_fetch_array($q)) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
if($ank['prava']=="5"){$status="<font color='ffc22b'>[A]</font>";$tcolor='F7990D';}
if($ank['prava']=="4"){$status="<font color='ffc22b'>[a]</font>";$tcolor='EBC621';}
if($ank['prava']=="3"){$status="<font color='ffc22b'>[M]</font>";}
if($ank['prava']=="2"){$status="<font color='ffc22b'>[m]</font>";}
echo"<div class='player'>";
echo online($ank['id']);
echo " <a href='/user/?id=$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=$clan[id]&usr=$ank[id]'>(+)</a>";}
if(isset($_GET['del']) && ($user['prava']>=2 || $user['dolz']=='основатель')) {
$id_chmsg = intval($_GET['id_msg']);
$del_chat_msg = mysql_query("DELETE FROM `clan_chat` WHERE `id` = '".$id_chmsg."'");
header("Location: ?id=$clan[id]");
}
echo '<span class="mit">'.vremja($post['time']).'</span>';
if ($user['prava'] >= 2 || $user['dolz']=='основатель'){echo" <a href='?id=$clan[id]&del&id_msg=".$post['id']."'>[X]</a>";}
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="'.$tcolor.'">'.smiles(antimat($post['msg'])).'</font> ';}
else{echo'</br>'.smiles(antimat($post['msg'])).' ';}
echo"</div>";
echo "<hr>";
}
echo "</div></div>";
if ($k_page>1){
str('?id='.intval($_GET['id']).'&',$k_page,$page); // Вывод страниц
echo "<hr>";
}
echo "<div class='but-list-light'><a href='/chat'><img src='/images/icon/r.png'> Общий чат</a></div>";
}
require_once H.'core/foot.php';
?>