Вход Регистрация
Файл: pages/social/chat.php
Строк: 488
<?php
// Physical module map v50.6: public URL stays clean while code lives in /pages.
if (!defined('GAME_ROOT')) define('GAME_ROOT'dirname(__DIR__2));
chdir(GAME_ROOT);
if (
PHP_SAPI !== 'cli') { $_SERVER['PHP_SELF']='/chat.php'$_SERVER['SCRIPT_NAME']='/chat.php'; }

/* Обновление игры под PHP 8.4 / PDO и усиление безопасности: by Метриум (Стэлп) */
$_SESSION['arena'] = 0;
include 
'./system/common.php';
    
include 
'./system/functions.php';
         
include 
'./system/user.php';
     include 
'./system/menu.php';
if(!
$user) { header('location: /'); exit; }

$isClanChat = !empty($_GET['clan']);
$title $isClanChat 'Клановый чат':'Общий чат';
$errors = [];
$_to null;

include 
'./system/h.php';  

echo 
'<div class="main">';

if(
$user['save'] == 0) {

  echo 
'<div class='block_zero'><font color='#909090'>Для общения в чате вам нужно сохранить своего персонажа</font></div>';

}
else
{

  echo 
'<div class='block_zero'>';


  if(
$user['level'] < 20) {

    echo 
'<font color='#909090'>Писать в чат можно с <img src='/images/icon/level.png' alt=''/> 20 уровня</font>';
echo"</div>";
  }
  else
  {

$text _string($_POST['text'] ?? '');
  
$to _string(_num($_GET['to'] ?? 0));

  if(
$to) {

      
$_to db_query('SELECT * FROM `users` WHERE `id` = "'.$to.'"');
      
$_to db_fetch_array($_to);
  
  if(!
$_to OR $_to['id'] == $user['id']) {
  
    
header('location: /chat/'.($isClanChat 'clan/':''));
    
  exit;
  
  }
  
  }

  if(
$text) {
    
security_require_csrf();
  
    
$antiflood db_fetch_array(db_query('SELECT * FROM `chat` WHERE `clan` = ''.($isClanChat ? (int)($clan['id'] ?? 0):0).'' AND `user` = ''.$user['id'].'' ORDER BY `time` DESC LIMIT 1'));
  
    if(
$antiflood && time() - (int)$antiflood['time'] < 2$errors[] = 'Писать можно только 1 раз в 1 секунду';
# ban chat
    
    
$BanChat db_query('SELECT * FROM `banned` WHERE `user` = "'.$user['id'].'" AND `chat` = "1"');
    while(
$BanChat db_fetch_array($BanChat))
    {
        if((int)
$BanChat['time'] > time()) $errors[] = 'Вам наложен бан на общение в чате на '._time((int)$BanChat['time'] - time()).'';
    }

    if(
$errors) {
    
      echo 
'<div class='block' align='center'>';
      
      foreach(
$errors as $error) {
        
        echo 
$error.'<br/>';
        
      }
    
      echo 
'</div>
      <div class='
mini-line'></div>';
    
    }
    else
    {

      if(
$_to) {
      
        
$text str_replace($_to['login'].', '''$text);
      
      }
      
$text preg_replace('~[a-z][a-z0-9+.-]*://[^<>s]+~iu''*'$text) ?? $text;
        
        
$arrReplace = array('.ru',
                                 
'.net',
                                 
'.com',
                                  
'.рф',
                                  
'.tk',
                                  
'ref=',
                                  
'.su',
                                  
'.us',

                                
'.mobi',
                                
'.X-com',
                                  
'.ua',
'.keo.su',
'.ру',
'aux.su',

'. r u',
'.доброзло.де',
'.доброзло. де',
'.доброзло.д е',
'.д оброзло.де',
'.д о брозло.де',
'.д о б р о з л о.де',
'.доброз ло.д е',
'.д обр озло.де',
'.до брозл о.де',
                                  
'vtutage',
                                  
'vipgame',
                             
                                 
'.ru',
                                 
'. tk',
                                 
'. t k',
                                 
'wart',
                                 
'.Ru',
                                
'.r U',
                                 
'.ру',
                                  
'.RU',
                              
                                  
'.RLDOFDA',
                                 
                            
                                  
                              
                                 
                                   
'доброзло',
                                   
'до бр оз ло',
                                   
'доброзло.де',
                                  
'.mir',
                                  
'.de',
                                  
'dobrozlo',
                                 
'.tk',
                                 
'. t k',
                                 
'.t-k',
                                          
'do br oz lo',
                                          
'dob',
                                  
'.d e',
                                  
'.d  e',
                                 
'.r',
'.zzz.com.ua',

'.net',
'.pro',
'pro',
'pr o',
                                
                                
'http');

$size count($arrReplace);
  while(
$size--)
{
if(
substr_count($text$arrReplace[$size]))
{
db_query("INSERT INTO `mail` SET `from`='0',`to`='1',`text`=' Пользователь ".$user['login']." | ID: ".$user['id']." нарушает правила игры! Сообщение: ".$text."',`time`='".time()."'");
db_query("INSERT INTO `ban` SET `user`='".$user['id']."',`time`='2147483647',`text`='Нарушение правил игры!',`who`='Система', `ip`='".$user['ip']."'");
break;
}
}

$text str_replace($arrReplace'*'$text);

      
        
$chatClan $isClanChat ? (int)($clan['id'] ?? 0) : 0;
        if(
$isClanChat && $chatClan<=0){
          
$errors[]='Вы не состоите в клане.';
        } else {
          
$toId=(int)($_to['id'] ?? 0);
          
db_execute('INSERT INTO `chat` (`clan`,`user`,`to`,`text`,`time`,`read`) VALUES (:clan,:user,:to,:text,:time,0)', [
            
'clan'=>$chatClan,'user'=>(int)$user['id'],'to'=>$toId,'text'=>$text,'time'=>time()
          ]);
          
db_execute('UPDATE `users` SET `chat_msg`=`chat_msg`+1 WHERE `id`=:id',['id'=>(int)$user['id']]);
          
$_SESSION['ok']='Сообщение отправлено.';
          
header('location: /chat/'.($isClanChat 'clan/':'')); exit;
        }
  
    }
  
  }

if(
$user['chat']==0) {
?><style>
.message_usr{
position:relative;
white-space:nowrap;
padding:6px 2px 6px 12px;
font:normal 16px arial,sans-serif;
overflow:hidden;
}
.yea_from{
color:#888;
font-size:12px;
padding-bottom:3px;
text-shadow:rgba(255,255,255,0.2) 0 0 12px;
transition:opacity 300ms;
-moz-transition:opacity 300ms;
-o-transition:opacity 300ms;
-webkit-transition:opacity 300ms;
}
.yea_from span{
display:block;
display:inline-block;
overflow:hidden;
text-overflow:ellipsis;
width:100%;
}

.user_avatar2{
-ms-box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
background-repeat:no-repeat;
background-size:cover;
background-position:0 0;
overflow:hidden;
}
.user_avatar{
vertical-align:top;
position:static;
margin-right:12px;
width:36px;
height:36px;
min-width:36px;
min-height:36px;
border-radius:18px;
display:none;
}

.block_avatar{
display:-moz-inline-box;
-moz-box-orient:vertical;
display:inline-block;
vertical-align:middle;    
}

.message_text_v3{
max-width:70%;
display:-moz-inline-box;
-moz-box-orient:vertical;
display:inline-block;
vertical-align:middle;
vertical-align:top;
text-align:left;
position:relative;
margin-right:103px;
margin-left:12px;
white-space:normal;
background-color:#3a3535;
border-radius:5px;
word-break:break-word;
-ms-box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
box-shadow:0 0 10px -1px rgba(24,24,24,0.14);
-webkit-box-shadow:    0 0 10px -1px rgba(24,24,24,0.14);
}
@media screen and (max-width: 1349px) and (min-device-width: 800px) and (min-width: 500px){
.message_text_v3{
max-width:80%;
}}
.message_text_v3{
margin-left:0;
}
.message_text_v3block{
word-wrap:break-word;
padding:9px 0 12px 14px;
display:inline-block;
-ms-box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
width:    100%;
}
.message_text_v3block{
padding-right:10px;
}
.message_dates{
color:#888;
font-size:12px;
position:absolute;
top:0;
right:auto;
bottom:auto;
left:100%;
white-space:nowrap;
padding:12px 7px;
}
.message_date_status{
display:none;
width:25px;
height:12px;
background-image:none;
background-position:100px 100px;
background-repeat:no-repeat;
background-attachment:scroll;
background-size:35px 5000px;
}
.message_date_time{
text-shadow:rgba(255,255,255,0.2) 0 0 12px;
transition:opacity 300ms;
-moz-transition:opacity 300ms;
-o-transition:opacity 300ms;
-webkit-transition:opacity 300ms;
}
.message_me_self{
text-align:right;
}
.message_me_from{
display:none;
}
.message_text_v2{
max-width:70%;
display:-moz-inline-box;
-moz-box-orient:vertical;
display:inline-block;
vertical-align:middle;
vertical-align:top;
text-align:left;
position:relative;
margin-right:103px;
margin-left:12px;
white-space:normal;
background-color:#3a3535;
border-radius:5px;
word-break:break-word;
-ms-box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
box-shadow:0 0 10px -1px rgba(24,24,24,0.14);
-webkit-box-shadow:    0 0 10px -1px rgba(24,24,24,0.14);
}
@media screen and (max-width: 1349px) and (min-device-width: 800px) and (min-width: 500px){
.message_text_v2{
max-width:80%;
}}
.message_text_v2{
margin-right:0;    
margin-left:65px;
background-color:rgba(220, 248, 198, 0.4);
}
.message_text_v2{
margin-left:65px;
}
.messages_date{
left:auto;
right:100%;
}
.button {


color:#666;
padding: 7px;

}
.button3 {
background-image:url(/images/smiles/blum.gif);
background-color: #666;
background-position:center;
background-repeat:no-repeat;
border-bottom:2px solid #330066;
border-left:2px solid #330066;
border-radius:50px;
border-right:2px solid #330066;
border-top:2px solid #330066;
width:35px;
height:35px;
}

.button4 {
    background-image: url(/images/smiles/bwink.gif);
    background-color: #666;
    background-position: center;
    background-repeat: no-repeat;
    border-bottom: 2px solid #330066;
    border-left: 2px solid #330066;
    border-radius: 50px;
    border-right: 2px solid #330066;
    border-top: 2px solid #330066;
    width: 35px;
    height: 35px;
}
</style>
<script>
    function showContent(link) {

        var cont = document.getElementById('contentBody');
        var loading = document.getElementById('loading');

        cont.innerHTML = loading.innerHTML;

        var http = createRequestObject();
        if( http ) {
            http.open('get', link);
            http.onreadystatechange = function () {
                if(http.readyState == 4) {
                    cont.innerHTML = http.responseText;    
                }
            }
            http.send(null);    
        } else {
            document.location = link;
        }
    }
    function createRequestObject() {
        try { return new XMLHttpRequest() }
        catch(e) {
            try { return new ActiveXObject('Msxml2.XMLHTTP') }
            catch(e) {
                try { return new ActiveXObject('Microsoft.XMLHTTP') }
                catch(e) { return null; }
            }
        }
    }
</script>


  <form action='/chat/<?=($isClanChat 'clan/':'')?>?to=<?=$to?>' method='post'><?=security_csrf_field()?>
  <center>  <input type="button" class="button3" onClick="showContent('/chat/page1.html')" value="">
   <input type="button" class="button4" onClick="showContent('/chat/page2.html')" value=""/></center>
  <div class='block_zero'><div> <input id='sml' name='text' style='width: 90%;' value="<?=($to && $_to security_html($_to['login']).', ':'')?>" class='text'/><input type='submit' class='cosmos' name='send_message' value=''/></td><td></a></td></tr></table> 
 <div class='float-left'><span class='btn'><span class='end'><input class='label' type='submit' value='Отправить'></span></span></div>
<a style='padding:0px 0px 0px 5px' class='grey ' href='/chat/'>Обновить</a>
  </div> 
  </form></li> </br></div></div>



 
 
 <script type='text/javascript'>
        /*<![CDATA[*/
        function sml(id, html) {
            var e = document.getElementById(id);
            if (e != null) {
                e.value += ' ' + html + ' ';
                e.focus();
            }
        }
        /*]]>*/
        </script>

<?php
echo "<div id='contentBody'>";
echo 
"</div>";
echo 
'<div id="loading" style="display: none">';
echo 
"Идет загрузка...";
echo 
"</div>";
 


}else{
echo 
"Вы забанены в чате";
}


}

?>
<div class="Chat_bg">
<div class='dot-line'></div>   
<?php
    $max 
10;
  
$count db_result(db_query('SELECT COUNT(*) FROM `chat` WHERE `clan` = "'.($isClanChat ? (int)($clan['id'] ?? 0):0).'"'),0);
  
$pages ceil($count/$max);
   
$page _string(_num($_GET['page'] ?? 1));

    if(
$page $pages) {
    
   
$page $pages;
    
    }
  
    if(
$page 1) {
    
   
$page 1;
    
    }
    
  
$start $page $max $max;

if(
$count 0) {



$msg _string(_num($_GET['msg'] ?? 0));

       if(
$msg) {

    
$i_msg db_query('SELECT * FROM `chat` WHERE `id` = "'.$msg.'"');
    
$i_msg db_fetch_array($i_msg);

    if(!
$i_msg) {
    
      
header('location: /chat/'.($isClanChat 'clan/':'').'?page='.$page);
      exit;
    
    }

    if((
$isClanChat && (int)($clan_memb['rank'] ?? 0) == 4) OR (int)$user['access'] > 0) {
        
      
db_query('DELETE FROM `chat` WHERE `clan` = "'.($isClanChat ? (int)($clan['id'] ?? 0):0).'" AND`id` = "'.$i_msg['id'].'"');

    }

    
header('location: /chat/'.($isClanChat 'clan/':'').'?page='.$page);

  }



$q db_query('SELECT * FROM `chat` WHERE `clan` = "'.($isClanChat ? (int)($clan['id'] ?? 0):0).'" ORDER BY `id` DESC LIMIT '.$start.', '.$max.'');
  while(
$row db_fetch_array($q)) {
  if(
$row['to'] == $user['id'] && $row['read'] == 0) {
  
    
db_query('UPDATE `chat` SET `read` = "1" WHERE `id` = "'.$row['id'].'"');
  
  }

  
$sender db_query('SELECT * FROM `users` WHERE `id` = "'.$row['user'].'"');
  
$sender db_fetch_array($sender);
  if(!
$sender){ $sender=['id'=>0,'login'=>'Система','r'=>0,'online'=>0,'sex'=>0,'access'=>0,'w_1'=>0,'w_2'=>0,'w_3'=>0,'w_4'=>0,'w_5'=>0,'w_6'=>0,'w_7'=>0,'w_8'=>0]; }
 
$w_1 db_query('SELECT * FROM `inv` WHERE `user` = "'.$sender['id'].'" AND `id` = "'.$sender['w_1'].'"');
$w_1 db_fetch_array($w_1) ?: ['item'=>0];

$w_2 db_query('SELECT * FROM `inv` WHERE `user` = "'.$sender['id'].'" AND `id` = "'.$sender['w_2'].'"');
$w_2 db_fetch_array($w_2) ?: ['item'=>0];


$w_3 db_query('SELECT * FROM `inv` WHERE `user` = "'.$sender['id'].'" AND `id` = "'.$sender['w_3'].'"');
$w_3 db_fetch_array($w_3) ?: ['item'=>0];

$w_4 db_query('SELECT * FROM `inv` WHERE `user` = "'.$sender['id'].'" AND `id` = "'.$sender['w_4'].'"');
$w_4 db_fetch_array($w_4) ?: ['item'=>0];

$w_5 db_query('SELECT * FROM `inv` WHERE `user` = "'.$sender['id'].'" AND `id` = "'.$sender['w_5'].'"');
$w_5 db_fetch_array($w_5) ?: ['item'=>0];

$w_6 db_query('SELECT * FROM `inv` WHERE `user` = "'.$sender['id'].'" AND `id` = "'.$sender['w_6'].'"');
$w_6 db_fetch_array($w_6) ?: ['item'=>0];

$w_7 db_query('SELECT * FROM `inv` WHERE `user` = "'.$sender['id'].'" AND `id` = "'.$sender['w_7'].'"');
$w_7 db_fetch_array($w_7) ?: ['item'=>0];


$w_8 db_query('SELECT * FROM `inv` WHERE `user` = "'.$sender['id'].'" AND `id` = "'.$sender['w_8'].'"');
$w_8 db_fetch_array($w_8) ?: ['item'=>0];

echo 
"<div class='block3'/>

"
;
  if(
$sender['id'] !=&& $sender['id'] !=2){
    
    echo
"<img src='/images/icon/race/".$sender['r'].($sender['online'] > (time() - 1200) ? '':'-off').".png' alt='*'/> ";
    
}else{
     echo
'<img src="/images/icon/race/bot.png" alt="*"> Система ';
}
  if(
$sender['id'] !=&& $sender['id'] !=2){


echo
"<a style='text-decoration:none;' href='/user/".$sender['id']."/'>".$sender['login']." </a>";

}

  if(
$sender['id'] != $user['id']) {
  if(
$sender['id'] !=&& $sender['id'] !=2){
echo
"<a style='text-decoration:none;' href='/chat/".($isClanChat 'clan/':'')."?to=".$sender['id']."'>(»)</a>";
}
  }

echo 
" <font color='#8B8B83'>".date('H:i:s'$row['time'])." | "._data(date('j M'$row['time']))."</font><br/>";
  if(
$sender['id'] !=&& $sender['id'] !=2){


echo
"<div class='user_avatar user_avatar2 block_avatar' style='background-image: url(/manekenImage/".$sender['sex']."/".$w_1['item']."/".$w_2['item']."/".$w_3['item']."/".$w_4['item']."/".$w_5['item']."/".$w_6['item']."/".$w_7['item']."/".$w_8['item']."/);'></div>";
}
echo
'<span class="message_text_v3"><span class="message_text_v3block">';

    if(
$row['to']) {

      
$__to db_query('SELECT * FROM `users` WHERE `id` = "'.$row['to'].'"');
      
$__to db_fetch_array($__to) ?: ['id'=>0,'login'=>'Игрок'];

if((int)
$__to['id'] == (int)$user['id']) {

?>

<font color='#90c090'>

<?php

    
}

?>

<?=$__to['login']?>,

<?php

if((int)$__to['id'] == (int)$user['id']) {

?>

</font>

<?php

    
}
    
    }

    if(
$sender['access'] == 1) {

?>

<font color='#f09060'>

<?php

    
}

?>

<?php

    
if($sender['access'] == 2) {

?>


<font color='#90c0c0'>
<?php

    
}
?>



<?php $__isSystem=((int)($row['user'] ?? 0)===|| (int)($row['user'] ?? 0)===|| mb_strtolower((string)($sender['login']??''),'UTF-8')==='система'); echo $__isSystem game_system_text(smiles((string)$row['text'])) : smiles(security_html($row['text'])); ?></span></span>

<?php

    
if($sender['access'] > 0) {

?>

</font>

<?php

    
}

  if(
$user['access'] > 0) {


?>

<a href='/chat/<?=($isClanChat 'clan/':'')?>?msg=<?=$row['id']?>'>(x)</a>

<?php

  
}
  
?>

<?php

  
}

  }
  else
  {
  
?>

<font color='#909090'>Сообщений нет</font>

<?php
  
  
}

?>

<?php

  
if($clan) {
  
     
$_chat db_query('SELECT COUNT(*) FROM `chat` WHERE `clan` = "0" AND `to` = "'.$user['id'].'" AND `read` = "0"');
     
$_chat db_result($_chat,0);

$_clan_chat db_query('SELECT COUNT(*) FROM `chat` WHERE `clan` = "'.(int)($clan['id'] ?? 0).'" AND `to` = "'.$user['id'].'" AND `read` = "0"');
$_clan_chat db_result($_clan_chat,0);

?>

<div class='main'>
 <div class="dot-line"></div>
<div class="block_zero medium">
<img src="/images/icon/chat.png" alt=""> <?=($isClanChat '<a href="/chat/">Титаны</a>':'<span class="grey">Титаны</span>')?><?=($_chat '<span class="green"> (+)</span>':'')?> | <?=($isClanChat '<span class="grey">Клан</span>':'<a href="/chat/clan/">Клан</a>')?><?=($_clan_chat '<span class="green"> (+)</span>':'')?>
</div>

<?php

  
}

?>


<div class="dot-line"></div>
<div class="block_zero"><?=pages('/chat/'.($isClanChat 'clan/':'').'?');?></div>
<div class="dot-line"></div>


<?php

  
if(!empty($_GET['read_all'])) {

    if(
$isClanChat && $clan){ db_execute('UPDATE `chat` SET `read`=1 WHERE `clan`=:c AND `to`=:u',['c'=>(int)$clan['id'],'u'=>(int)$user['id']]); } else { db_execute('UPDATE `chat` SET `read`=1 WHERE `to`=:u',['u'=>(int)$user['id']]); }
    
    
header('location: /chat/'.($isClanChat 'clan/':''));
  
  }

?>
<div class="menuList">
<li><a href="/smiles"><img src="/images/icon/user.png" alt="">Смайлы</a></li>
<li><a href="/moderators"><img src="/images/icon/user.png" alt="">Список модераторов</a></li>
<li><a href="/rules/"><img src="/images/icon/arrow.png" alt="">Правила чата</a></li>
</div>

<?php 




include 
'./system/f.php'

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