Файл: moduls/chat.php
Строк: 173
<script type="text/javascript">
setTimeout("window.location.reload()",120000);//Обновление раз в 120 секунд
</script>
<body>
<?
require_once '../core/system.php';
echo only_reg();
echo ban();
$header = 'Общий Чат';
require_once H.'core/head.php';
switch($act) {
case 'post':
if(isset($_POST['msg'])){
$msg = check($_POST['msg']);
if(strlen($msg) < 3 or strlen($msg) > 400) $err = 'Длина сообщения должна быть в пределах 3 - 400 символов';
if($user[level] < 5) $err = 'В чате можно писать только с 5 уровня!';
if(!isset($err)) {
mysql_query("INSERT INTO `chat` SET `id_user` = '$user[id]', `msg` = '$msg', `komu` = '$komu', `time` = '".time()."'");
mysql_query("UPDATE `user` SET `silver`='".($user[silver]+1)."' WHERE `id`='$user[id]'");
header('Location: ?');
$_SESSION['message'] = 'Сообщение добавлено! +1 серебра!';
exit();
}else{
header('Location: ?');
$_SESSION['err'] = $err;
// Вывод ошибки
exit();
}
}else{
header('Location: ?');
$_SESSION['err'] = 'Введите текст';
exit();
}
break;
default:
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `chat`"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = 20*$page-20;
echo '</textarea><br><span class="end">
<a href="/common/rules2.php">Правила</a> | <a href="/smiles.php">Смайлы</a> | <a href="/bb_code.php">BB-коды</a> | <a href="chat.php">Обновить</a></span></div></div>';
$us = mysql_fetch_assoc(mysql_query("SELECT * FROM `us_ban` where `usid` = '".$user['id']."' and `type` = 'chat' and `time`>'".time()."' "));
$nick = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` where `id` = '".$us['usban']."'"));
if($us['time'] > time())
{
$ban_time=$us['time']-time();
echo '</div><div class="line"></div><b><span class="red">Вам выдан бан на общение в чате<br><div class="dot-line"></div>До конца осталось:</span>
'.(int)($ban_time/3600).' час. '.($ban_time/60%60).' мин. '.($ban_time%60).' сек.
<br/><div class="dot-line"></div><span class="blue">Заблокировал:<a href="/user/'.$nick['id'].'/"><img src="/images/icon/user.png"/>'.$nick['nick'].' </span></a><br/><div class="dot-line"></div><span class="blue">Причина: </span>'.htmlentities($us['prich']).'</b><div class="line"></div>';
echo "</div>";
}else{
echo "</div>";
echo "<div class='mini-line'></div>";
if($user[chat]>time()){
$t=$user[chat]-time();
echo "До отправки следующего сообщени ".($t%60)." секунд";
}else{
if(isset($_GET['id'])) {
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $_GET[id] LIMIT 1"));
echo '<form class="player" method="post" action="?act=post">
<textarea name="msg" rows = "2" cols ="15" class = "text large">'.$ank[nick].', </textarea><br />
<span class="btn"><span class="end"><input class="label" type="submit" value="Отправить">Отправить</span></span>
</form>';
}else{
echo '<form class="player" method="post" action="?act=post">
<textarea name="msg" rows = "2" cols ="15" class = "text large"></textarea><br />
<span class="btn"><span class="end"><input class="label" type="submit" value="Отправить">Отправить</span></span>
</form>';
}
}
}
$q = mysql_query("SELECT * FROM `chat` ORDER BY `id` DESC LIMIT $start, 20");
echo "<div class='dot-line'></div>";
echo "<div class='player' style = 'color: #d3e2ed;'>";
while($post = mysql_fetch_assoc($q)) {
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
if($ank[prava] >= 5 ){
$color = 'yellow';
}
if($ank[prava] == 7 ){
$color = 'green';
}
if($ank[id] == 995 || $ank[id] == 1 ){
$color = 'quality-0';
}
if($ank[id] == 13){
$color = 'green';
}
if($ank[prava] == 4 ){
$color = 'blue';
}
if($ank[prava] == 0 ){
$color = 'quality-0';
}
if($ank[prava] == 3 ){
$color = 'Vip';
}
if ($user['prava'] >= 4){
echo "<a style='text-decoration:none;' href='?del=msg&id_msg=".$post['id']."'>[<span class='red'>X</span>]</a>";}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '".$ank['id']."' AND `online` > '".(time()-600)."' LIMIT 1"),0)==1){
if ($ank['pol'] == 1 AND $ank['storona'] == 1) echo '<img src="/images/icon/hero_on_red_1.png" alt="d"/>';
if ($ank['pol'] == 1 AND $ank['storona'] == 0) echo '<img src="/images/icon/hero_on_blue_1.png" alt="d"/>';
if ($ank['pol'] == 0 AND $ank['storona'] == 1) echo '<img src="/images/icon/hero_on_red_0.png" alt="d"/>';
if ($ank['pol'] == 0 AND $ank['storona'] == 0) echo '<img src="/images/icon/hero_on_blue_0.png" alt="d"/>';
} else {
if ($ank['pol'] == 1) echo '<img src="/images/icon/hero_off_1.png" alt="d"/>';
if ($ank['pol'] == 0) echo '<img src="/images/icon/hero_off_0.png" alt="d"/>';
}
$nick = ($ank[prava] == 3) ? '<span style="color: #blue">'.$ank['nick'].'</span>' : $ank['nick'];
$nick = ($ank[prava] == 7) ? '<span style="color: #FF0000">'.$ank['nick'].'</span>' : $ank['nick'];
if($ank[id] == 995 || $ank[id] == 1 ){
$nick = '<span style = "color: #FFF8DC;">'.$ank['nick'].'</span>';
}
echo " <a href='/user/?id=$ank[id]'><b><span style = 'color: #FFF8DC;'>$nick</span></b></a>";
if($ank[prava] == 7 AND $ank[id] != 995 AND $ank[id] != 1){
echo "[<font color='red'>Созд</font>]";
}
if($ank[prava] == 5 ){
echo "[<font color='red'>Адм</font>]";
}
if($ank[prava] == 4 ){
echo "[<font color='green'>Мод</font>]";
}
echo "<span class='yellow'></span><span class='quality-0'>[".vremja($post['time'])."][<a href='?id=$ank[id]'>отв.</a>]</span>";
if(htmlspecialchars($_GET['del']) == 'msg') {
$id_chmsg = intval($_GET['id_msg']);
$del_chat_msg = mysql_query("DELETE FROM `chat` WHERE `id` = '".$id_chmsg."'");
header("Location: ?");
}
if($post['msg'] ) {
$str = str_replace("".$user['nick']."", "<b>".$user['nick']."</b>", ': <span class="'.$color.'">'.smiles($post['msg']).'</span><br>');
echo $str;
}
}
echo "</div>";
if ($k_page>1){
echo "<div class='dot-line'></div>";
str('?',$k_page,$page); // Вывод страниц
}
echo "<div class='mini-line'></div>";
echo "<div class='player menuList'>";
echo "<li><a href='/user/moder.php'><img src='/images/icon/user.png'>Список Модераторов</a></li>";
echo "</div></div>";
}
require_once H.'core/foot.php';
?>