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

if (!
$user) { header('Location: /'); exit; }
    
$title 'Общий чат';
    
$page = (isset($_GET['page']) AND is_numeric($_GET['page'])) ? (int)$_GET['page'] : 1;
    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';
    
    if (
$go == 'call_moderator')
    {
        if ((int) 
readcache('chat_call_moderator') + 600 time())
        {
            require_once 
'./element_function/element_function_mail.php';
            
$moder mysql_query("SELECT `lost_id` FROM `element_user` WHERE `lost_privilege`>'0'");
            while (
$m mysql_fetch_assoc($moder))
            {
                if (isset(
$online[$m['lost_id']]))
                {
                    
$mu cache_user($m['lost_id']);        
                    
$profile_other explode(' '$mu['lost_other']);
                    
$profile_other[2] = $profile_other[2] + 1;
                    
$mu['lost_other'] = implode(' '$profile_other);
                    
mysql_query("INSERT INTO `element_mail` SET `lost_out` = '0',`lost_in` = '$mu[lost_id]',`lost_sub_text` = '".$user['lost_login']." позвал тебя в чат',`lost_text` = '".$user['lost_login']." позвал тебя в чат, возможно там происходит что-то, что запрещено правилами игры.',`lost_user_out` = '0',`lost_user_in` = '$mu[lost_id]',`lost_time` = '".time()."',`lost_system` = 'Вызывалка',`lost_new` = '1'");        
                    
$count_in Cache_Count_Message($mu['lost_id']);
                    if (!empty(
$count_in['all'])) $count_in['all']++;
                    if (!empty(
$count_in['in'])) $count_in['in']++;
                    if (!empty(
$count_in['new'])) $count_in['new']++;
                    
writecache('element_count_message'.$mu['lost_id'], $count_in);
                    
writecache('element_users_id_'.$mu['lost_id'], $mu);
                }
            }
            
            if (isset(
$mu))
            {
                
writecache('chat_call_moderator'time());
                
                
header("Location: /chat");
                exit;
            }
            else
            {
            echo
'<div class="nfl p5 mt5 cntr mlra"><div class="small ml5 lngreen">Модераторы спят :(</div></div>';
            }
        }
        else
        {
            echo
'<div class="nfl p5 mt5 cntr mlra"><div class="small ml5 lngreen">Модератора можно позвать раз в 10 минут</div></div>';
        }
    }
    
    
    if (
$go == 'online')
    {
        
$i 1;
        
$query mysql_query("SELECT * FROM `element_chat_online` INNER JOIN `element_user` ON (`lost_id`=`user`) WHERE `time`>UNIX_TIMESTAMP()-600;");
        echo
'<div class="nfl p5 mb5 mt5 mlra"><div class="mb5 cntr small"><a class="button w50" href="/chat">Назад в чат</a></div><div class="mt5 mlra">';
    
        while (
$u mysql_fetch_assoc($query))
        {
            
$odd = (($i 2) ? ' odd' '');
            echo 
'<div class="ml5 mr5">
                    <a class="bl p5 block'
.$odd.'" href="/user?id='.$u['lost_id'].'">
                    <span class="small mb5 yellow1"><span class="white">'
.$i.'.</span> 
                    '
.ikonka_user($u['lost_race'], ((!empty($online[$u['lost_id']])) ? 'online' 'offline')).
                    '
.$u['lost_login'].'</span></a></div>';
            
$i++;
        }
        
        echo
'</div></div>';
        require_once 
'./element_include/element_foot_user_true.php';
        exit;
    }
    
if (
$page 2): ?>
<script type="text/javascript">
var _ajax, div = document.createElement("div");(function(){var e = !1;try{(e=new XMLHttpRequest)&&(_ajax=new XMLHttpRequest)}catch(a){try{(e=new ActiveXObject('Msxml2.XMLHTTP'))&&(_ajax=new ActiveXObject('Msxml2.XMLHTTP'))}catch(a){try{(e=new ActiveXObject('Microsoft.XMLHTTP'))&&(_ajax =new ActiveXObject('Microsoft.XMLHTTP'))}catch(a){_ajax=!1}}}_ajax.onreadystatechange=function(){div.innerHTML = _ajax.response;div.getElementsByClassName('ahah')[0] && (document.getElementById('ahah').innerHTML = div.getElementsByClassName('ahah')[0].innerHTML)};setInterval(function(){_ajax.open("GET", '/chat', true);_ajax.send(null)},15000);})();
</script>
<?php endif; ?>
<script language="javascript">
        function show_hide (element_id) {
            if (document.getElementById(element_id).style.display == 'none') {
                document.getElementById(element_id).style.display = 'block';
            } else {
                document.getElementById(element_id).style.display = 'none';
            }
        }
        function insert_smile (element_id,smile) {
            document.getElementById(element_id).value += smile;
            document.getElementById(element_id).focus();
        }        
    </script>
<?php 
mysql_query
("INSERT INTO `element_chat_online` (`user`, `time`) VALUES ('{$user['lost_id']}', UNIX_TIMESTAMP()) ON DUPLICATE KEY UPDATE `time`=UNIX_TIMESTAMP();");
$conline mysql_result(mysql_query("SELECT COUNT(*) FROM `element_chat_online` WHERE `time`>UNIX_TIMESTAMP()-600;"), 0);

    
$posts mysql_result(mysql_query("SELECT COUNT(*) FROM `other_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 `other_chat` (`user_id`, `text`, `time`) VALUES ('{$user['lost_id']}', '{$text}', UNIX_TIMESTAMP())");
            
writecache('element_chat_lost_post'time());
            
header('Location: /chat');
            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 `other_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="/chat?go=add">
                <input  class="fdark w98 mb10" type="text" id="chat_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="/chat">Обновить</a></span> '
;
                    
?>
                    <a class="button w30 mt5 small" style="text-align:center;" href="#" onclick="show_hide('smiles'); return false;">Смайлы</a>
<div id="smiles" style="display:none;overflow:auto;">
<div style="overflow:auto;" class="mlra cntr mt5 mb5">
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5">
<a href="#" onclick="insert_smile('chat_text',':)'); return false;"><img src="/images/smiles/1.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',';)'); return false;"><img src="/images/smiles/2.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':-)'); return false;"><img src="/images/smiles/3.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':-o'); return false;"><img src="/images/smiles/4.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':-O'); return false;"><img src="/images/smiles/5.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':good:'); return false;"><img src="/images/smiles/6.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':-~'); return false;"><img src="/images/smiles/7.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':evil:'); return false;"><img src="/images/smiles/8.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text','xD'); return false;"><img src="/images/smiles/9.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':huh:'); return false;"><img src="/images/smiles/10.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':ok:'); return false;"><img src="/images/smiles/11.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':emm:'); return false;"><img src="/images/smiles/12.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':l:'); return false;"><img src="/images/smiles/13.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':green'); return false;"><img src="/images/smiles/14.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':stone'); return false;"><img src="/images/smiles/15.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':('); return false;"><img src="/images/smiles/16.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':D'); return false;"><img src="/images/smiles/17.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':p'); return false;"><img src="/images/smiles/18.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':-*'); return false;"><img src="/images/smiles/19.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':mad:'); return false;"><img src="/images/smiles/20.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text','8)'); return false;"><img src="/images/smiles/21.gif" alt="" /></a></div>
<div style="display:inline-block;" class="mt5 mb5 ml5 mr5"><a href="#" onclick="insert_smile('chat_text',':cry:'); return false;"><img src="/images/smiles/22.gif" alt="" /></a></div>

 </div></div>
        <?php    
                    
echo '</form>';
    }
?>

<?php
    
echo '<div class="ahah" id="ahah">';
    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';
        
$pagination pagination(10$page$posts);
        
$element_chat mysql_query("SELECT * FROM `other_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("","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 
'<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="/chat?to='.$chat_user['lost_login'].'">[Ответить]</a>';
            echo (
$user['lost_privilege'] > 0) ? ' <a class="red small" href="/chat?delete='.$massiv['chat'].'">[X]</a> <a class="red small" href="/ban/list?id='.$massiv['user_id'].'&to='.$massiv['text'].'">[Бан]</a>' '';
            echo 
'<br/>  ';

        }
        echo 
'</div>';
        echo 
pagination_echo($pagination['page'],$pagination['total'],'/chat?page=');
    }

    echo 
'</div>';

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

        echo 
'<div class="cntr small"><a class="yellow1" href="?go=call_moderator">Вызвать модератора</a>  <a class="yellow1" href="?go=online">В чате '.$conline.'</a>  <a class="yellow1" href="/torg">Торговый чат</a></div></div>';

    require_once 
'./element_include/element_foot_user_true.php';

?>
Онлайн: 2
Реклама