Файл: tankon.mobi/tanks/chat.php
Строк: 208
<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
include_once '../sys/inc/thead.php';
title();
err();
aut();
include_once 'function.php';
mysql_query("UPDATE `tanks` SET `chat`='0' where `id_u`='".$tanks_code['id']."'");
if (isset($_GET['chist']) && $tanks_code['status']>0){
if (isset($_GET['ok']) ){
mysql_query("TRUNCATE `tanks_chat` ;");
header("Location: /chat");
}
echo ' <div class="bot" ><table ><tbody><tr>';
echo'<td class="w50"><a class="simple-but border" href="/chat?chist&ok">
<span><span>Очистить</span></span></a></td>
<td class="w50"><a class="simple-but border" href="/chat">
<span><span>Нет, не надо</span></span></a></td>
</tr></tbody></table></div></div></div>';
}
if (isset($_POST['msg']) && isset($user))
{
mysql_query("UPDATE `tanks` SET `chat`='1'");
$msg=$_POST['msg'];
if (strlen2($msg)>256){$errs=1;
err_game("Слишком длинное сообщение");
}
elseif (strlen2($msg)<2){
$errs=1;
err_game("Короткое сообщение");}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_chat` WHERE `id_user` = '$user[id]' AND `msg` = '".my_esc($msg)."' LIMIT 1"),0)!=0){
$errs=1;
err_game("Ваше сообщение повторяет предущее");
}
elseif ($tanks_code['level']<6 && $tanks_code['chaty_time']!=0 && $tanks_code['status']<1)
{
$time_c=time();
$chat_time=time_left($tanks_code['chaty_time']-$time_c);
$errs=1;
err_game("Вы можете писать через ".$chat_time."");
}
elseif ($tanks_code['level']<2){
$errs=1;
err_game("Вы не достигли 2 ур.");}
elseif ($tanks_code['bans']>0){
$errs=1;
err_game("Вы находетесь в бане");}
elseif(!isset($errs)){
if($tanks_code['status']<1){
$c_time=time()+20;
mysql_querll("UPDATE `tanks` SET `chaty_time` = '".$c_time."' WHERE `id`='".$user['id']."'");}
mysql_query("INSERT INTO `tanks_chat` (id_user, time, msg, otvet) values('$user[id]', '$time', '".my_esc($msg)."', '".$_POST['otv']."')");
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_chat`"), 0)>=35){
$rds=mysql_query("SELECT * FROM `tanks_chat` ORDER BY time ASC LIMIT 1");
while ($del_post = mysql_fetch_array($rds)){
mysql_query("DELETE FROM `tanks_chat` WHERE `id` = '".$del_post['id']."'");
}
}
header("Location:/chat?yes");
}
}
if (isset($_GET['yes'])){err_games('Сообщение успешно добавлено');}
err();
echo '<div style="margin-bottom:3px;">';
echo "<form method="post" name='message' action="?$passgen">n";
echo ' <div class="bot" ><table ><tbody><tr>';
echo'<td class="w100 pr1"><a class="simple-but border" href="/chat">
<span><span>Обновить</span></span>
</a></td></a></tr></tbody></table></div></div>';
?>
<script language="JavaScript" type="text/javascript">
function tag(text1, text2) {
if ((document.selection)) {
document.message.msg.focus();
document.message.document.selection.createRange().text = text1+document.message.document.selection.createRange().text+text2;
} else if(document.forms['message'].elements['msg'].selectionStart!=undefined) {
var element = document.forms['message'].elements['msg'];
var str = element.value;
var start = element.selectionStart;
var length = element.selectionEnd - element.selectionStart;
element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
document.forms['message'].elements['msg'].focus();
} else document.message.msg.value += text1+text2;
document.forms['message'].elements['msg'].focus();}
</script>
<?
include_once 'smailes.php';
$poster= mysql_fetch_array(mysql_query("SELECT * FROM `tanks_chat` WHERE `id`='".intval($_GET['otv'])."'"));
$post=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`='".$poster['id_user']."'"));
echo'</div></div></div> ';
echo'<table class="chat-msg-panel mt10 mb6">
<tbody><tr>
<td class="msg">
<div class="trnt-block mb0">
<div class="wrap1"><div class="wrap2"><div class="wrap3"><div class="wrap4"><div class="wrap5"><div class="wrap6"><div class="wrap7"><div class="wrap8">
<div class="p5">';
if (isset($_GET['otv']) && $post['id']!=$tanks_code['id'])
{echo'<input type="hidden" name="otv" required="required" value="'.$post['id'].'">';
echo'<input w:id="postText" class="chat-msg bold sh_b small lh1 cyan1" value="'.$post['nick'].', " type="text" size="20" maxlength="250" name="msg">';
}else {
echo'<input w:id="postText" class="chat-msg bold sh_b small lh1 cyan1" value="" type="text" size="20" maxlength="250" name="msg">';
}
echo'</div>
</div></div></div></div></div><div></div></div></div></div>
</div>
</td>
<td class="btn"><span ><span><input class="simple-but mb0 inbl" style="height:28px;" type="submit" value="Отправить"></span></span></td>
</tr>
</tbody></table>';
echo "</form>n";
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_chat`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0)
{
err_game ('Чат очистился');
}
$q=mysql_query("SELECT * FROM `tanks_chat` ORDER BY id DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q))
{
if ($post['id_user']==0)
{
$ank['id']=0;
$ank['pol']='guest';
$ank['level']=0;
}
else
$ank=get_user($post['id_user']);
//$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
if ($tanks_code['status']>=1){
if (isset($_GET['dellmsg']))
{
mysql_query("DELETE FROM `tanks_chat` WHERE `id` = '".intval($_GET['dellmsg'])."' LIMIT 1");
header("Location: /chat");
}
} if (isset($_GET['dell']))
{
mysql_query("DELETE FROM `tanks_chat` WHERE `id` = '".intval($_GET['dell'])."' AND `id_user`='".$tanks_code['id']."' LIMIT 1");
header("Location: /chat");
}
$tankss_code = mysql_fetch_array(mysql_query("SELECT * FROM `tanks` WHERE `id_u`='".$ank['id']."'"));
$avatar = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_ava` WHERE `id`='".$tankss_code['ava']."'"));
echo '<div class="trnt-blocks p5" style="margin-bottom:3px;">';
if($_SESSION['style']!='wap.css'){
echo' <div class="mb0 inbl">
<div class="thumb fl">
<img src="/images/avatar/'.$avatar['screen'].'" alt="" title="">
<span class="mask2"> </span>
</div>
<div class="ml58 small white sh_b bold">';
}else{
echo'<div class="small white sh_b bold">';
}
echo'<span class="green2">';
echo "<a href='/profile?id=$ank[id]'>".ansc($ank['id'])."</a>";
if($_SESSION['style']!='wap.css'){
echo"<span class='white bold'>(".vremja($post['time']).")</span>";
}
echo"<span style='background-position: right bottom;'>";
if ($tanks_code['status']>=1){echo ' <a href="/ban?id='.$ank['id'].'"><img src="images/del_chat.png"></a>';
if ($tanks_code['id']!=$post['id_user']){echo ' <a href="/chat?dellmsg='.$post['id'].'"><img src="images/el_msg.png"></a>'; }}
if ($tanks_code['id']!=$post['id_user']){echo ' <a href="/chat?otv='.$post['id'].'"><img src="images/otvet.png"></a>'; }
if ($tanks_code['id']==$post['id_user']){echo ' <a href="/chat?dell='.$post['id'].'"><img src="images/el_msg.png"></a>';}
echo'</span></span>';
if ($post['otvet']==$tanks_code['id']){echo '<br><font color="orange">'.output_text($post['msg'])."</font><br />";}
else{echo '<br>'.output_text($post['msg'])."<br />";}
echo '</div></div></div></div></div></div>';
}
if ($k_page>1)str('?',$k_page,$page); // Вывод страниц
if($tanks_code['status']>0){
echo'
</div>
<a class="simple-but gray " href="/chat?chist">
<span>
<span>Очистить чат</span>
</span>
</a>
</div>';}
echo'
</div>
<a class="simple-but gray " href="/moder">
<span>
<span>Модераторы</span>
</span>
</a>
</div>';
include_once 'foots.php';
?>