View file sdark.mobi/adm_root/chat.php

File size: 4.79Kb
<?
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['save'] < 1){
	header('Location: /');
}

if($user['prava'] < 2){
	header('Location: /');
	exit;
}
switch($act) {
case 'post':
if(isset($_POST['msg'])){
$msg = check($_POST['msg']);
$kol = mysql_result(mysql_query("SELECT COUNT(id)  FROM `chat` where `msg` = '".$msg."' and `id_user` = '".$user['id']."'"),0);
if($kol > 0) $err =  'Сообщение повторяет предыдущее!';
if(strlen($msg) < 1 or strlen($msg) > 400 and $user['prava'] < 4) $err =  'Длина сообщения должна быть от 1 до 400 символов';
if($user['level'] < 5) $err =  'Писать в чате можно только с 5 уровня!';
if(!isset($err)) {
$f = $_SERVER['REQUEST_TIME']+43200;
mysql_query("INSERT INTO `chat` SET `id_user` = '".$user['id']."', `msg` = '".$msg."', `timer` = '".$f."', `time` = '".$_SERVER['REQUEST_TIME']."', `elit`='1'");
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`='' and `elit`='1'"),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['id'])) {
$ank = mysql_fetch_array(mysql_query("SELECT nick FROM `user` WHERE `id` = '".abs(intval($_GET['id']))."' LIMIT 1"));
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`='' and `elit`='1' 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']." LIMIT 1"));
$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">'.vremja($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>
<?
} 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">
<?
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 ($ank['prava'] >= 4){
	
echo'</br>
<font color="'.$color.'">'.smiles(antimat($post['msg'])).'
</font>
</font> ';

} else {
	
echo'</br>'.smiles(antimat($post['msg'])).' ';

}

?>

</div><hr>

<?

}
}

?>

</div></div>

<?

if ($k_page > 1){
str('?',$k_page,$page);
}
}

require_once H.'core/foot.php';
?>