Файл: vk.com_vhllam/games_xhata/sims/chat.php
Строк: 65
<?php
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/adm_check.php';
include_once '../../sys/inc/user.php';
$set['title']='The Sims';
include_once '../../sys/inc/thead.php';
title();
err();
aut();
if(!isset($user)){
echo 'Вы неавторизованы';
include_once '../../sys/inc/tfoot.php';
exit;
}
include_once 'inc/start.php';
if(isset($_POST['submit'])){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `sims_chat` WHERE `id_u`='".$user_id."' AND `time`>'".(time()-30)."'"),0)!=0)
sims_msg($diz['msg'],'Разрешено добавлять собщение не чаще, чем раз в пол минуты!');
else
{
if(mb_strlen($_POST['post'],'UTF-8')<5)
sims_msg($diz['msg'],'Сообщение не может короче 5 символов!');
else
{
if(mb_strlen($_POST['post'],'UTF-8')>512)
sims_msg($diz['msg'],'Сообщение не может длинее 512 символов!');
else
{
mysql_query("INSERT INTO `sims_chat`(`id_u`,`name`,`time`,`msg`) VALUES('".$user_id."','".$sims_user['name']." ".$sims_user['fam']."','".time()."','".mysql_real_escape_string($_POST['post'])."')");
header("Location:chat.php?msg=".rand(1,1000));
exit;
}
}
}
}
echo "
<div class='".$diz['post_1']."'>Чат</div>
";
$total=mysql_result(mysql_query("SELECT COUNT(*) FROM `sims_chat`"),0);
if($total>0){
$quert=mysql_query("SELECT * FROM `sims_chat` ORDER BY `id` DESC LIMIT ".$start.",5");
$i=0;
while($array=mysql_fetch_array($quert)){
$post=($i%2 ? $diz['post_1'] : $diz['post_2']);
echo '<div class="'.$post.'">
<table cellpadding="0">
<tr>
<td>
<img height="40" src="i/face_'.mysql_result(mysql_query("SELECT `face` FROM `sims_user` WHERE `id_u`='".$array['id_u']."'"),0).'.png"/>
</td>
<td>
<a href="profile.php?id='.$array['id_u'].'">'.$array['name'].'</a> ['.sims_date($array['time']).']
<br/>
'.sims_in($array['msg']).'
</td></tr></table></div>';
$i++;
}
if ($total > 5){
echo sims_pagenav('chat.php?', $start, $total, 5);
}
}
else
echo "Сообщений нет! Будь первым!";
echo "<br/><form method='post' action='chat.php?t=".mt_rand()."'>
Сообщение (5-512 сим.)<br/>
<textarea name='post'></textarea><br/>
<input type='submit' name='submit' value='Отправить'/></form>";
sims_ret($diz['ret'],'Назад','index.php');
include_once '../../sys/inc/tfoot.php';
?>