Вход Регистрация
Файл: public_html/element_torg_chat.php
Строк: 120
<?php
require_once './element_options/element_options.php';

if (!
$user) { header('Location: /'); exit; }
    
$title 'Торговый чат';
    if (
readcache('element_user_mesto'.$user['lost_id']) != $titlewritecache('element_user_mesto'.$user['lost_id'], $title);
    
writecache('element_chat_lost_post_'.$user['lost_id'], time());
    require_once 
'./element_include/element_head.php';
    require_once 
'./element_include/element_header_user_true.php';

$posts mysql_result(mysql_query("SELECT COUNT(*) FROM `tor_chat`"), 0);    
    
    
$ban BanUserCountActive($user['lost_id']);
    
$chat_lvl element_settings_game('lost_chat_min_level');
    
        if (
$go == 'add') {
        
$error '';
        
$text trim($_POST['text']);
        if (empty(
$text)) $error 'Поле 'text' обязательно для ввода';
        if (
$user['lost_level'] < $chat_lvl$error 'Вы не можете комментировать чат';
        if (
$ban 0$error 'Вы не можете комментировать чат';
        
            if (empty(
$error)) {
            
$text mysql_real_escape_string(addslashes(htmlspecialchars($text)));
            
//if (count($element_chat) > element_settings_game('lost_chat_max_count')) array_shift($element_chat);
            
mysql_query("INSERT INTO `tor_chat` (`user_id`, `text`, `time`) VALUES ('{$user['lost_id']}', '{$text}', UNIX_TIMESTAMP())");
            
writecache('element_chat_lost_post'time());
            
header('Location: /torg');
            exit;
            } else echo 
'<div class="nfl p5 mb5 mt5 small cntr mlra"><span class="error1">'.$error.'</span></div>'
        }    

        if (isset(
$_GET['delete'])) {
            if (
$user['lost_privilege'] > 0) {
                
$delete = ($_GET['delete']) ? (int)$_GET['delete'] : 0;
                if (
$delete)
                {
                    
mysql_query("DELETE FROM `tor_chat` WHERE `chat`='".mysql_real_escape_string($delete)."' LIMIT 1");
                }
            }
        }
        
        
    
$chat_to_user = (isset($_GET['to'])) ? $_GET['to'].', ' '';

    echo 
'<div class="nfl p5 mt5 mb5 mlra">';

    if (
$user['lost_level'] < $chat_lvl) {
        echo 
'<div class="cntr small mb5 error1">Комментировать чат можно с '.$chat_lvl.' уровня</div>';
    } else if (
$ban 0) {
        echo 
'<div class="cntr small mb5"><a class="error1" href="/ban/list?id='.$user['lost_id'].'">Вы не можете комментировать чат, так как находитесь в бане</a></div>';
    } else {
        echo 
'<form method="post" action="/torg?go=add">
                <input class="fdark w98 mb10" type="text" name="text" value="'
.$chat_to_user.'" size="20" maxlength="255">
                    <span class="button w30 mt5"><input type="submit" class="ttl" name="submit" value="Отправить"/></span>
                    <span class="button w30 mt5"><a class="ttl" href="/torg">Обновить</a></span>
                    <span class="button w30 mt5"><a class="ttl" href="/smiles.php">Смайлы</a></span>
            </form>'
;
    }

    if (
$posts 1
    {
    echo 
'<div class="p5 cntr"><span class="small ccc">В чате нету сообщений</span></div>';
    echo 
'</div>';
    } else {
        require_once 
'./element_function/element_function_pagination.php';
        
$page = (isset($_GET['page']) AND is_numeric($_GET['page'])) ? (int)$_GET['page'] : 1;
        
$pagination pagination(10$page$posts);
        
$element_chat mysql_query("SELECT * FROM `tor_chat` ORDER BY `time` DESC LIMIT {$pagination['start']}{$pagination['num']}");
        while(
$massiv mysql_fetch_assoc($element_chat)) {
            
$chat_user cache_user($massiv['user_id']);
            
$on_off = (!empty($online[$massiv['user_id']])) ? 'online' 'offline';
            
//Antispam
            
$massiv['text'] = str_replace("ti-war","OOOPS",$massiv['text']);
            
$massiv['text'] = str_replace("ru","OOOPS",$massiv['text']);
            
$massiv['text'] = str_replace("com","OOOPS",$massiv['text']);
            
$massiv['text'] = str_replace("mobi","OOOPS",$massiv['text']);
            
//Antispam
            
$text Color_Privilege($chat_user['lost_privilege'], ReplaceText($user['lost_login'], $massiv['text']));
            
$text Smiles($texttrue);
            
            echo 
'
            <div class="mt5">
            <a class="yellow1 sndr bl" href="/user?id='
.$massiv['user_id'].'">
                <span class="small fr pt2 lngreen">'
.Timer($massiv['time']).'</span>
                '
.ikonka_user($chat_user['lost_race'], $on_off).' <span class="small">'.$chat_user['lost_login'].'</span>
            </a>'
;
            echo 
'<span class="small">'.$text.'</span>';
            echo 
'<br/><a class="ccc small" href="/torg?to='.$chat_user['lost_login'].'">[Ответить]</a>';
            echo (
$user['lost_privilege'] > 0) ? ' <a class="red small" href="/torg?delete='.$massiv['chat'].'">[X]</a> <a class="red small" href="/ban/list?id='.$massiv['user_id'].'&to='.$massiv['text'].'">[Бан]</a>' '';
            echo 
'<br/> </div>';
        }
        
        echo 
'</div>';
        echo 
pagination_echo($pagination['page'],$pagination['total'],'/torg?page=');
    }
    
    echo 
'<div class="nfl p5 mb5 mt5 mlra">';
    
        echo 
'<div class="cntr small"><a class="yellow1" href="/chat">Общий чат</a></div></div>';

    require_once 
'./element_include/element_foot_user_true.php';
?>
Онлайн: 1
Реклама