2022-06-06 21:30:34 +00:00
< ? php
2022-12-19 18:26:14 +00:00
2023-01-12 00:58:26 +00:00
if ( ! defined ( 'GAME_VERSION' )) {
require_once '_incl_data/autoload.php' ;
}
2023-10-16 13:12:16 +00:00
use Clan\ClanInfo ;
2023-01-12 00:58:26 +00:00
use Core\Config ;
use Core\Database ;
2022-12-30 19:03:37 +00:00
use Core\Db ;
2023-01-18 11:51:06 +00:00
use DarksLight2\Training\TrainingManager ;
2024-05-15 13:42:28 +00:00
use Model\ActionModel ;
2022-12-19 18:26:14 +00:00
2023-01-12 00:58:26 +00:00
Config :: init ();
Database :: init ();
2022-12-19 18:26:14 +00:00
$u = User :: start ();
$filter = new Filter ();
$chat = new Chat ();
2022-07-01 12:45:43 +00:00
2023-02-13 17:24:48 +00:00
$code = PassGen :: intCode ();
2022-07-01 12:45:43 +00:00
if (
! isset ( $u -> info [ 'id' ]) ||
2023-08-15 22:48:29 +00:00
$u -> isBlocked () ||
! isset ( $_COOKIE [ 'login' ])
2022-07-01 12:45:43 +00:00
) {
exit ( json_encode ([ 'js' => 'top.location="bk?exit=' . $code . '";' ]));
}
if ( $u -> info [ 'bithday' ] == '01.01.1800' ) {
unset ( $_GET [ 'msg' ], $_POST [ 'msg' ], $_POST [ 'warnMsg' ]);
$_GET [ 'r3' ] = 1 ;
}
if ( $u -> info [ 'online' ] < time () - 60 ) {
2023-01-12 00:58:26 +00:00
Db :: sql ( 'update users set online = unix_timestamp() where id = ?' , [ $u -> info [ 'id' ]]);
2022-12-19 18:26:14 +00:00
$filter -> setOnline ( $u -> info [ 'online' ], $u -> info [ 'id' ]);
2022-07-01 12:45:43 +00:00
}
2023-10-16 10:58:02 +00:00
if ( isset ( $_POST [ 'delMsg' ]) && $u -> isModerator ()) {
2023-01-12 00:58:26 +00:00
$delmsgid = ( int ) $_POST [ 'delMsg' ];
if ( $delmsgid > 0 ) {
Db :: sql ( 'update chat set `delete` = ? where id = ?' , [ $u -> info [ 'id' ], $delmsgid ]);
2022-07-01 12:45:43 +00:00
} else {
2023-01-12 00:58:26 +00:00
Db :: sql ( 'update users set molch3 = unix_timestamp() + 3600 * 3 where id = ?' , [ - $delmsgid ]);
2022-07-01 12:45:43 +00:00
}
2023-01-12 00:58:26 +00:00
unset ( $delmsgid );
2022-07-01 12:45:43 +00:00
}
$r = [
'rnd' => $code ,
'rn' => null ,
'list' => null ,
'msg' => null ,
'js' => null ,
2022-12-19 18:26:14 +00:00
'xu' => 0 ,
2022-07-01 12:45:43 +00:00
];
2023-01-10 16:29:32 +00:00
2022-07-01 12:45:43 +00:00
if ( $u -> info [ 'battle' ] > 0 ) {
2023-02-13 17:24:48 +00:00
$btl = Db :: getValue ( 'select count(*) from battle where id = ? and time_over = 0' , [ $u -> info [ 'battle' ]]);
if ( empty ( $btl )) {
2022-07-01 12:45:43 +00:00
$r [ 'js' ] .= 'top.frames["main"].location="main.php";' ;
}
}
if ( isset ( $_POST [ 'msg' ]) && str_replace ( ' ' , '' , $_POST [ 'msg' ]) != '' ) {
$msg = [];
$_POST [ 'msg' ] = str_replace ( '\x3C' , '<' , $_POST [ 'msg' ]);
$_POST [ 'msg' ] = str_replace ( '\x3' , '>' , $_POST [ 'msg' ]);
2023-01-12 00:58:26 +00:00
function tolink ( $buf ) : string
2022-07-01 12:45:43 +00:00
{
$x = explode ( " " , $buf );
$newbuf = '' ;
for ( $j = 0 ; $j < count ( $x ); $j ++ ) {
2023-01-10 16:29:32 +00:00
$uname = '<Внутренняя ссылка>' ;
2022-07-01 12:45:43 +00:00
//
2023-08-15 22:48:29 +00:00
if ( strripos ( $x [ $j ], Config :: get ( 'host' ) . '/info' )) {
2022-07-01 12:45:43 +00:00
$ulogin = explode ( '/info/' , $x [ $j ]);
$ulogin = $ulogin [ 1 ];
2023-02-13 17:24:48 +00:00
$ulogin = Db :: getValue ( 'select login from users where id = ? or login = ?' , [ $ulogin , $ulogin ]);
if ( ! empty ( $ulogin )) {
$uname = '<span style="color: #831db7; "><Информация о "' . $ulogin . '"></span>' ;
2022-07-01 12:45:43 +00:00
}
2023-01-10 16:29:32 +00:00
} elseif ( strripos ( $x [ $j ], 'audio_1610649509.mp3' )) { //Т У Т аудио
2023-02-13 17:24:48 +00:00
$uname = '<span style="color: #FF851B; "><Голосовое сообщение></span>' ;
2022-07-01 12:45:43 +00:00
} elseif ( strripos ( $x [ $j ], 'new-combats.com/item/' )) {
$ulogin = explode ( '/item/' , $x [ $j ]);
$ulogin = $ulogin [ 1 ];
2023-02-13 17:24:48 +00:00
$ulogin = Db :: getValue ( 'select name from items_main where id = ?' , [ $ulogin ]);
if ( isset ( $ulogin )) {
$uname = '<span style="color: #5f9b00; "><Предмет "' . $ulogin . '"></span>' ;
2022-07-01 12:45:43 +00:00
} else {
2023-02-13 17:24:48 +00:00
$uname = '<span style="color: #5f9b00; "><Библиотека предметов></span>' ;
2022-07-01 12:45:43 +00:00
}
2023-08-15 22:48:29 +00:00
} elseif ( strripos ( $x [ $j ], Config :: get ( 'host' ) . '/news' )) {
2022-07-01 12:45:43 +00:00
$ulogin = explode ( '/news' , $x [ $j ]);
$ulogin = $ulogin [ 1 ];
$ulogin = ltrim ( $ulogin , '/' );
2023-02-13 17:24:48 +00:00
$ulogin = Db :: getValue ( 'select title from events_news where id = ?' , [ $ulogin ]);
if ( isset ( $ulogin )) {
$uname = '<span style="color: #b57300; "><Новость "' . $ulogin . '"></span>' ;
2022-07-01 12:45:43 +00:00
} else {
2023-02-13 17:24:48 +00:00
$uname = '<span style="color: #b57300; "><Новостная лента></span>' ;
2022-07-01 12:45:43 +00:00
}
2023-08-15 22:48:29 +00:00
} elseif ( strripos ( $x [ $j ], Config :: get ( 'host' ) . '/lib' )) {
2022-07-01 12:45:43 +00:00
$ulogin = explode ( '/lib' , $x [ $j ]);
$ulogin = $ulogin [ 1 ];
$ulogin = ltrim ( $ulogin , '/' );
$ulogin = rtrim ( $ulogin , '/' );
2023-02-13 17:24:48 +00:00
$ulogin = Db :: getValue ( 'select title from library_content where url_name = ? and moder > 0' , [ $ulogin ]);
if ( isset ( $ulogin )) {
$uname = '<span style="color: #4c6e00; "><Библиотека "' . $ulogin . '"></span>' ;
2022-07-01 12:45:43 +00:00
} else {
2023-02-13 17:24:48 +00:00
$uname = '<span style="color: #4c6e00; "><Библиотека></span>' ;
2022-07-01 12:45:43 +00:00
}
2023-08-15 22:48:29 +00:00
} elseif ( strripos ( $x [ $j ], Config :: get ( 'host' ) . '/forum' )) {
2022-07-01 12:45:43 +00:00
$ulogin = explode ( '/forum?read=' , $x [ $j ]);
$ulogin = $ulogin [ 1 ];
$ulogin = explode ( '&' , $ulogin );
$ulogin = $ulogin [ 0 ];
2023-02-13 17:24:48 +00:00
$ulogin = Db :: getValue ( 'select title from forum_msg where id = ? and `delete` = 0' , [ $ulogin ]);
if ( isset ( $ulogin )) {
$uname = '<span style="color: #0055b5; "><Форум "' . $ulogin . '"></span>' ;
2022-07-01 12:45:43 +00:00
} else {
$ulogin = explode ( '/forum?r=' , $x [ $j ]);
$ulogin = $ulogin [ 1 ];
$ulogin = explode ( '&' , $ulogin );
$ulogin = $ulogin [ 0 ];
2023-02-13 17:24:48 +00:00
$ulogin = Db :: getValue ( 'select name from forum_menu where id = ?' , [ $ulogin ]);
if ( isset ( $ulogin )) {
$uname = '<span style="color: #0055b5; "><Конференция форума "' . $ulogin . '"></span>' ;
2022-07-01 12:45:43 +00:00
} else {
2023-02-13 17:24:48 +00:00
$uname = '<span style="color: #0055b5; "><Форум проекта></span>' ;
2022-07-01 12:45:43 +00:00
}
}
}
//
2023-01-12 00:58:26 +00:00
$newbuf .= preg_match (
2023-08-15 22:48:29 +00:00
" /(https: \\ / \\ /)?(new-combats+ \\ .tech(([ \" '> \r \n \t ])|( \\ /([^ \" '> \r \n \t ]*)?)))/ " ,
2023-01-12 00:58:26 +00:00
$x [ $j ],
$ok
2023-02-13 17:24:48 +00:00
) ? str_replace ( $ok [ 2 ], " <small><a href=https:// $ok[2] target=_blank ><i> " . $uname . " </i></a></small> " , str_replace ( " https:// " , " " , $x [ $j ])) . " " : $x [ $j ] . " " ;
2022-07-01 12:45:43 +00:00
}
return $newbuf ;
}
2023-10-16 13:12:16 +00:00
$strSearch = [
[ '\\' , '"' , " ' " , '<' , '>' , ' ' , '>' , '<' , '\r' , '\b' , ' ' , ' ' ],
[ '::' , '[s1;]' , '[s2;]' , '[s3;]' , '[s4;]' , ' ' ,],
];
$strReplace = [
[ '\\\\' , '[s1;]' , '[s2;]' , '[s3;]' , '[s4;]' , ' ' , '[s4;]' , '[s3;]' ],
[ '' , '"' , '"' , '<' , '>' , ' ' ,],
];
2022-07-01 12:45:43 +00:00
2023-10-16 13:12:16 +00:00
$_POST [ 'msg' ] = $chat -> expworld ( $_POST [ 'msg' ], 120 );
$_POST [ 'msg' ] = str_replace ( $strSearch [ 0 ], $strReplace [ 0 ], $_POST [ 'msg' ]);
2023-08-16 00:05:57 +00:00
$_POST [ 'msg' ] = htmlspecialchars ( $_POST [ 'msg' ]);
2022-07-01 12:45:43 +00:00
$_POST [ 'msg' ] = str_replace ( '%usersmile%' , '' , $_POST [ 'msg' ]);
$_POST [ 'msg' ] = tolink ( $_POST [ 'msg' ]);
2023-10-16 13:12:16 +00:00
$_POST [ 'msg' ] = str_replace ( $strSearch [ 1 ], $strReplace [ 1 ], $_POST [ 'msg' ]);
2022-07-01 12:45:43 +00:00
2023-02-13 17:24:48 +00:00
$smg = Db :: getRow ( 'select * from chat where login = ? and time > unix_timestamp() - 20 order by time desc limit 1' , [ $u -> info [ 'login' ]]);
2022-07-01 12:45:43 +00:00
if ( $u -> info [ 'exp' ] < 499999999 ) {
2023-02-13 17:24:48 +00:00
$lmg = Db :: getValue ( 'select count(id) from chat where login = ? and time = unix_timestamp() - 5 limit 2' , [ $u -> info [ 'login' ]]);
2022-07-01 12:45:43 +00:00
} else {
2023-02-13 17:24:48 +00:00
$lmg = 0 ;
2022-07-01 12:45:43 +00:00
}
$testsmg = ' ' . $_POST [ 'msg' ] . ' ' ;
2023-08-16 00:05:57 +00:00
if ( ! empty ( $smg ) && $testsmg == $smg [ 'text' ] && $u -> info [ 'exp' ] > 100000 ) {
2022-07-01 12:45:43 +00:00
if ( $u -> info [ 'molch1' ] < time ()) {
2023-01-10 16:29:32 +00:00
//Молчанка за флуд на 5 минут
2022-07-01 12:45:43 +00:00
$u -> info [ 'molch1' ] = time () + 1200 ;
2023-07-31 17:06:51 +00:00
$r [ 'js' ] .= 'chat.sendMsg(["new","' . time () . '","6","","' . $u -> info [ 'login' ] . '","<small>Вы наказаны за спам на 20 минут </small>","Black","1","1","0"]);' ;
2022-07-01 12:45:43 +00:00
2023-02-13 17:24:48 +00:00
Db :: sql ( 'update users set molch1 = ? where id = ?' , [ $u -> info [ 'molch1' ], $u -> info [ 'id' ]]);
Db :: sql ( 'update chat set `delete` = 1 where login = ?' , [ $u -> info [ 'login' ]]);
2022-07-01 12:45:43 +00:00
2023-03-31 18:30:14 +00:00
$_POST [ 'msg' ] = 'Я спамер ' . $u -> info [ 'login' ] . ' и меня нужно заблокировать!' ;
2023-01-18 11:51:06 +00:00
2023-02-13 19:13:01 +00:00
$training_manager = TrainingManager :: getInstance ();
2023-01-18 11:51:06 +00:00
$training_manager -> addPoint ( 'chat_first_quest' );
2023-07-31 17:06:51 +00:00
if ( preg_match ( " /to \ [(.*?) \ ]/ " , $_POST [ 'msg' ])) {
2023-01-18 11:51:06 +00:00
$training_manager -> addPoint ( 'chat_second_quest' );
}
2023-07-31 17:06:51 +00:00
if ( preg_match ( " /private \ [(.*?) \ ]/ " , $_POST [ 'msg' ])) {
2023-01-18 11:51:06 +00:00
$training_manager -> addPoint ( 'chat_third_quest' );
}
2023-01-28 02:24:37 +00:00
$cmsg = new ChatMessage ();
$cmsg -> setInvis ( $u -> info [ 'invis' ]);
$cmsg -> setDa ( 1 );
$cmsg -> setType ( 6 );
$cmsg -> setColor ( '#f00' );
$cmsg -> setText ( " Я спамер { $u -> info [ 'login' ] } и меня нужно заблокировать " . Config :: get ( 'https' ) . '/info/' . $u -> info [ 'id' ]);
$chat -> sendMsg ( $cmsg );
$cmsg -> setLogin ( $u -> info [ 'login' ]);
$cmsg -> setType ( 6 );
$cmsg -> setText ( 'Это супер проект! Всем успехов!' );
$cmsg -> setColor ( '#000' );
$chat -> sendMsg ( $cmsg );
2022-07-01 12:45:43 +00:00
}
2023-02-13 17:24:48 +00:00
} elseif ( $lmg > 0 ) {
2023-07-31 17:06:51 +00:00
$r [ 'js' ] .= 'chat.sendMsg(["new","' . time () . '","6","","' . $u -> info [ 'login' ] . '","<small>Вы не можете отправлять так часто сообщения... </small>","Black","1","1","0"]);' ;
2022-07-01 12:45:43 +00:00
if ( $u -> info [ 'molch1' ] < time ()) {
if ( $u -> info [ 'molch1' ] < - 5 ) {
$u -> info [ 'molch1' ] = time () + 300 ;
2023-07-31 17:06:51 +00:00
$r [ 'js' ] .= 'chat.sendMsg(["new","' . time () . '","6","","' . $u -> info [ 'login' ] . '","<small>Вы наказаны за флуд на 5 минут </small>","Black","1","1","0"]);' ;
2022-07-01 12:45:43 +00:00
} elseif ( $u -> info [ 'molch1' ] < 0 ) {
$u -> info [ 'molch1' ] -- ;
} else {
$u -> info [ 'molch1' ] = - 1 ;
}
2023-08-15 22:48:29 +00:00
Db :: sql ( 'update users set molch1 = ? where id = ?' , [ $u -> info [ 'molch1' ], $u -> info [ 'id' ]]);
2022-07-01 12:45:43 +00:00
}
2022-12-19 18:26:14 +00:00
} elseif (( preg_match ( " /private \ [(.*?) \ ]/ " , $_POST [ 'msg' ], $msg [ 'to' ]) || preg_match (
" /private \ [(.*?) \ ]/ " , $_POST [ 'msg' ], $msg [ 'to' ]
2023-08-15 22:48:29 +00:00
)) && $u -> info [ 'exp' ] < 150000 && ! $u -> isAdmin ()) {
2023-07-31 17:06:51 +00:00
$r [ 'js' ] .= 'chat.sendMsg(["new","' . time () . '","6","","' . $u -> info [ 'login' ] . '","<small>Вы не можете отправлять приват до достижения 150000 опыта.</small>","Black","1","1","0"]);' ;
2022-07-01 12:45:43 +00:00
} else {
2023-01-10 16:29:32 +00:00
//Записываем данные
2022-07-01 12:45:43 +00:00
$msg [ 'spam' ] = 0 ;
$msg [ 'type' ] = 1 ;
$msg [ 'molch' ] = 0 ;
2023-02-02 15:39:42 +00:00
2022-07-01 12:45:43 +00:00
$msg [ 'cancel' ] = 0 ;
$msg [ 'delete' ] = 0 ;
$msg [ 'to' ] = '' ;
$msg [ 'da' ] = 0 ;
2023-01-10 16:29:32 +00:00
//Нормируем типы сообщений
2022-07-01 12:45:43 +00:00
if ( preg_match ( " /private \ [(.*?) \ ]/ " , $_POST [ 'msg' ], $msg [ 'to' ])) {
$msg [ 'to' ] = $msg [ 'to' ][ 1 ];
$_POST [ 'msg' ] = str_replace ( 'private[' . $msg [ 'to' ] . ']' , 'private [' . $msg [ 'to' ] . ']' , $_POST [ 'msg' ]);
$msg [ 'to' ] = '' ;
} elseif ( preg_match ( " /to \ [(.*?) \ ]/ " , $_POST [ 'msg' ], $msg [ 'to' ])) {
$msg [ 'to' ] = $msg [ 'to' ][ 1 ];
$_POST [ 'msg' ] = str_replace ( 'to[' . $msg [ 'to' ] . ']' , 'to [' . $msg [ 'to' ] . ']' , $_POST [ 'msg' ]);
$msg [ 'to' ] = '' ;
}
if ( preg_match ( " /private \ [(.*?) \ ]/ " , $_POST [ 'msg' ], $msg [ 'to' ])) {
$msg [ 'to' ] = trim ( $msg [ 'to' ][ '1' ], ' ' );
$msg [ 'type' ] = 3 ;
$_POST [ 'msg' ] = str_replace ( 'private [' . $msg [ 'to' ] . ']' , ' ' , $_POST [ 'msg' ]);
} elseif ( preg_match ( " /to \ [(.*?) \ ]/ " , $_POST [ 'msg' ], $msg [ 'to' ])) {
$msg [ 'to' ] = trim ( $msg [ 'to' ][ '1' ], ' ' );
$msg [ 'type' ] = 2 ;
$_POST [ 'msg' ] = str_replace ( 'to [' . $msg [ 'to' ] . ']' , ' ' , $_POST [ 'msg' ]);
}
2023-01-10 16:29:32 +00:00
if ( $u -> info [ 'admin' ] == 0 ) { //Т У Т SPAM
2023-08-15 22:48:29 +00:00
if ( $msg [ 'to' ] != '' && ! isset ( $admq ) && $msg [ 'type' ] == 3 ) {
$admq = Db :: getValue ( 'select id from users where login = ? and admin > 0' , [ $msg [ 'to' ]]);
2022-07-01 12:45:43 +00:00
}
2023-08-15 22:48:29 +00:00
if ( ! isset ( $admq )) {
2023-01-10 16:29:32 +00:00
$msg [ 'fspam' ] = $filter -> spamFiltr ( str_replace ( 'точка' , '.' , str_replace ( 'р у ' , 'ru' , $_POST [ 'msg' ])));
2022-07-01 12:45:43 +00:00
if ( $msg [ 'fspam' ] != '0' ) {
$msg [ 'spam' ] = 1 ;
$msg [ 'delete' ] = 1 ;
2023-10-16 13:12:16 +00:00
$r [ 'js' ] .= 'chat.sendMsg(["new","' . time () . '","6","","' . $u -> info [ 'login' ] . ' " , " < small > В нашем чате запрещается сообщать ссылки на атльтернативные проекты .
Повторные попытки могут привести к блокировке персонажа .</ small > " , " Black " , " 1 " , " 1 " , " 0 " ]);';
2022-07-01 12:45:43 +00:00
}
if ( $msg [ 'spam' ] == 1 && $u -> info [ 'molch1' ] < time () && $u -> info [ 'admin' ] == 0 ) {
2024-05-15 13:42:28 +00:00
$mban = ActionModel :: get ([ " uid = { $u -> info [ 'id' ] } " , 'time >= ' . strtotime ( 'now 00:00:00' ), 'vars = msg_bans' ], 'id, vals' );
2022-07-01 12:45:43 +00:00
if ( ! isset ( $mban [ 'id' ])) {
$u -> addAction ( time (), 'msg_bans' , '1' );
$mban [ 'vals' ] = 0 ;
} else {
2023-08-15 22:48:29 +00:00
Db :: sql ( 'update actions set vals = vals + 1 where id = ?' , [ $mban [ 'id' ]]);
2022-07-01 12:45:43 +00:00
$msg [ 'delete' ] = time ();
}
if ( $mban [ 'vals' ] + 1 < 2 ) {
$msg [ 'fspam' ] = str_replace ( '%' , '</b>,<b>' , $msg [ 'fspam' ]);
$msg [ 'fspam' ] = '<b>' . ltrim ( $msg [ 'fspam' ], '0</b>,<b>' ) . '</b>' ;
2023-10-16 13:12:16 +00:00
$r [ 'js' ] .= 'chat.sendMsg(["new","' . time () . '","6","","' . $u -> info [ 'login' ] . ' " , " < small > В нашем чате запрещается сообщать ссылки на атльтернативные проекты .
Запрещенные слова : ' . $msg[' fspam '] . ' . Предупреждения [ ' . ($mban[' vals '] + 1) . ' / 1 ] </ small > " , " Black " , " 1 " , " 1 " , " 0 " ]);';
2022-07-01 12:45:43 +00:00
} else {
2023-10-16 13:12:16 +00:00
$r [ 'js' ] .= 'chat.sendMsg(["new","' . time () . '","6","","' . $u -> info [ 'login' ] . ' " , " < small > В нашем чате запрещается сообщать ссылки на атльтернативные проекты .
Вы наказаны за нарушение правил общения .</ small > " , " Black " , " 1 " , " 1 " , " 0 " ]);';
2023-01-28 02:24:37 +00:00
$cmsg = new ChatMessage ();
$cmsg -> setLogin ( 'Комментатор' );
$cmsg -> setText ( " Персонаж { $u -> info [ 'login' ] } [ { $u -> info [ 'level' ] } ] был наказан за нарушение правил общения. " );
$cmsg -> setType ( 6 );
$chat -> sendMsg ( $cmsg );
$molchTime = time () + 60 * 60 ;
2023-08-15 22:48:29 +00:00
Db :: sql ( 'update users set molch1 = ?, molch2 = ?, info_delete = ? where id = ?' , [ $molchTime , $molchTime , $molchTime , $u -> info [ 'id' ]]);
$rtxt = ' "' . $u -> info [ 'login' ] . '" <small style="color: red;">Автоинформатор</small>: ' . $msg [ 'text' ] . ' [' . $msg [ 'fspam' ] . '].' ;
Delo :: add ( 0 , $u -> info [ 'login' ], $u -> info [ 'id' ], $rtxt );
2022-07-01 12:45:43 +00:00
}
}
}
2023-02-01 10:21:36 +00:00
unset ( $admq );
2022-07-01 12:45:43 +00:00
}
2023-08-16 00:05:57 +00:00
if ( ! empty ( $pl [ 'login' ])) {
$qix = Db :: getValue ( 'select id from friends where ignor > 0 and login_ignor = ? and (user_ignor = ? or user = ?)' , [ $pl [ 'login' ], $u -> info [ 'login' ], $u -> info [ 'id' ]]);
}
2023-08-15 22:48:29 +00:00
if ( isset ( $qix )) {
2023-08-16 00:05:57 +00:00
if ( is_array ( $msg [ 'to' ])) { // каким хером тут массив?
$msg [ 'to' ] = '' ;
}
2023-10-16 13:12:16 +00:00
$r [ 'js' ] .= 'chat.sendMsg(["new","' . time () . '","6","","' . $u -> info [ 'login' ] . ' " , " < b > В а с добавили в игнор </ b >:
Вы не можете отправлять сообщения персонажу & quot ; ' . htmlspecialchars($msg[' to ']) . ' & quot ; . " , " Black " , " 1 " , " 1 " , " 0 " ]);';
2022-07-01 12:45:43 +00:00
$msg [ 'cancel' ] ++ ;
}
if ( $msg [ 'type' ] == 3 && $msg [ 'to' ] == 'klan' ) {
if ( $u -> info [ 'clan' ] == 0 ) {
2023-10-16 13:12:16 +00:00
$r [ 'js' ] .= 'chat.sendMsg(["new","' . time () . '","6","","' . $u -> info [ 'login' ] . ' " , " < small > Вы не являетесь частью одного из < b > Кланов </ b >
и не можете общаться по этому каналу .</ small > " , " Black " , " 1 " , " 1 " , " 0 " ]);';
2022-07-01 12:45:43 +00:00
$msg [ 'cancel' ] ++ ;
} else {
$msg [ 'to' ] = 'k' . $u -> info [ 'clan' ];
$msg [ 'da' ] = 1 ;
}
}
if ( $u -> info [ 'molch1' ] > time ()) {
2023-08-15 22:48:29 +00:00
if ( $msg [ 'to' ] != '' && ! isset ( $admq ) && $msg [ 'type' ] === 3 ) {
$admq = Db :: getValue ( 'select id from users where login = ? and admin > 0' , [ $msg [ 'to' ]]);
2022-07-01 12:45:43 +00:00
}
2023-08-15 22:48:29 +00:00
if ( ! isset ( $admq )) {
2022-07-01 12:45:43 +00:00
$msg [ 'molch' ] = 1 ;
}
}
if ( $msg [ 'cancel' ] == 0 ) {
if ( is_array ( $msg [ 'to' ])) {
$msg [ 'to' ] = '' ;
}
if ( $msg [ 'type' ] == 3 && $msg [ 'da' ] > 0 ) {
$msg [ 'type' ] = - 3 ;
}
2023-10-16 10:52:58 +00:00
$msw = $chat -> smileText ( $_POST [ 'msg' ], $msg [ 'to' ], $u -> info [ 'room' ]);
2022-07-01 12:45:43 +00:00
$nosend = 0 ;
if ( $msw ) {
$_POST [ 'msg' ] = $msw ;
$msg [ 'to' ] = '' ;
$msg [ 'type' ] = 21 ;
if ( $msw == 'USER IS FALSE' ) {
2023-07-31 17:06:51 +00:00
$r [ 'js' ] .= 'chat.sendMsg(["new","' . time () . '","6","","' . $u -> info [ 'login' ] . '","<small>Персонажа нет в данной комнате.</small>","Black","1","1","0"]);' ;
2022-07-01 12:45:43 +00:00
$nosend = 1 ;
}
2023-10-16 10:52:58 +00:00
} elseif ( str_starts_with ( $_POST [ 'msg' ], '/e ' )) {
2022-07-01 12:45:43 +00:00
$msg [ 'type' ] = 21 ;
$_POST [ 'msg' ] = ltrim ( $_POST [ 'msg' ], '/e ' );
2023-10-16 10:52:58 +00:00
} elseif ( str_starts_with ( $_POST [ 'msg' ], '/е ' )) { // это кириллица!!
2022-07-01 12:45:43 +00:00
$msg [ 'type' ] = 21 ;
2023-01-10 16:29:32 +00:00
$_POST [ 'msg' ] = ltrim ( $_POST [ 'msg' ], '/е ' );
2023-10-16 10:52:58 +00:00
} elseif ( str_starts_with ( $_POST [ 'msg' ], ' /e ' )) {
2022-07-01 12:45:43 +00:00
$msg [ 'type' ] = 21 ;
$_POST [ 'msg' ] = ltrim ( $_POST [ 'msg' ], ' /e ' );
2023-10-16 10:52:58 +00:00
} elseif ( str_starts_with ( $_POST [ 'msg' ], ' /е ' )) { // это кириллица!!
2022-07-01 12:45:43 +00:00
$msg [ 'type' ] = 21 ;
2023-01-10 16:29:32 +00:00
$_POST [ 'msg' ] = ltrim ( $_POST [ 'msg' ], ' /е ' );
2022-07-01 12:45:43 +00:00
}
if ( $nosend == 0 ) {
2023-01-10 18:14:47 +00:00
//Именные смайлики
2023-01-10 16:29:32 +00:00
$_POST [ 'msg' ] = str_replace ( '%usersmile%-' , '%usе rsmilе %-' , $_POST [ 'msg' ]);
2022-07-01 12:45:43 +00:00
$usml = explode ( ',' , $u -> info [ 'add_smiles' ]);
$i = 0 ;
while ( $i < count ( $usml )) {
2022-12-19 18:26:14 +00:00
$_POST [ 'msg' ] = str_replace (
':' . $usml [ $i ] . ':' , ':%usersmile%-' . $usml [ $i ] . ':' , $_POST [ 'msg' ]
);
2022-07-01 12:45:43 +00:00
$i ++ ;
}
2023-01-28 02:24:37 +00:00
$cmsg = new ChatMessage ();
$cmsg -> setInvis ( $u -> info [ 'invis' ]);
$cmsg -> setDa ( $msg [ 'da' ]);
$cmsg -> setDelete ( $msg [ 'delete' ]);
$cmsg -> setMolch ( $msg [ 'molch' ]);
2023-02-02 15:39:42 +00:00
$cmsg -> setLogin ( $u -> info [ 'login' ]);
2023-01-28 02:24:37 +00:00
$cmsg -> setTo ( $msg [ 'to' ]);
$cmsg -> setRoom ( $u -> info [ 'room' ]);
$cmsg -> setType ( $msg [ 'type' ]);
$cmsg -> setSpam ( $msg [ 'spam' ]);
$cmsg -> setText ( $_POST [ 'msg' ]);
2023-02-02 15:39:42 +00:00
$cmsg -> setColor ( $u -> info [ 'chatColor' ]);
2023-01-28 02:24:37 +00:00
$chat -> sendMsg ( $cmsg );
2022-07-01 12:45:43 +00:00
}
}
2023-01-10 16:29:32 +00:00
if ( $msg [ 'type' ] == 2 && mb_convert_case ( $msg [ 'to' ], MB_CASE_LOWER ) == 'комментатор' ) {
2023-01-28 02:24:37 +00:00
$cmsg = new ChatMessage ();
2023-01-10 16:29:32 +00:00
if ( preg_match ( " /анекдот/i " , mb_convert_case ( $_POST [ 'msg' ], MB_CASE_LOWER ))) {
2022-07-01 12:45:43 +00:00
$text_com = '' ;
2023-10-16 13:12:16 +00:00
$sp_all = Db :: getRow ( 'select * from a_com_anekdot order by rand() limit 1' );
if ( isset ( $sp_all [ 'id' ])) {
$text_com = $sp_all [ 'text' ];
$text_com = str_replace ( " <br> " , " <br> " , $text_com );
$text_com = str_replace ( " <br /> " , " <br /> " , $text_com );
$text_com = str_ireplace ( " \r \n " , " " , $text_com );
$text_com = str_replace ( " " , " " , $text_com );
$text_com = '<b style="color: red">Анекдот</b>:<br> ' . $text_com . '<br>' ;
2022-07-01 12:45:43 +00:00
} else {
2023-10-16 13:12:16 +00:00
$text_com = 'Анекдот из головы вылетел...' ;
2022-07-01 12:45:43 +00:00
}
2023-10-16 13:12:16 +00:00
Db :: sql ( 'insert into a_com_act (act, time, uid) values (0, unix_timestamp() + 60, ?)' , [ $u -> info [ 'id' ]]);
2022-07-01 12:45:43 +00:00
if ( $text_com != '' ) {
2023-01-28 02:24:37 +00:00
$cmsg -> setText ( $text_com );
2022-07-01 12:45:43 +00:00
}
} else {
2023-04-15 19:18:30 +00:00
include_once 'commentator.php' ;
2023-10-16 13:12:16 +00:00
if ( ! empty ( $comment )) {
2023-01-28 02:24:37 +00:00
$cmsg -> setText ( $comment );
2022-07-01 12:45:43 +00:00
}
}
2023-01-28 02:24:37 +00:00
if ( $cmsg -> getText ()) {
$cmsg -> setLogin ( 'Комментатор' );
$cmsg -> setTo ( $u -> info [ 'login' ]);
$cmsg -> setRoom ( $u -> info [ 'room' ]);
$cmsg -> setType ( 2 );
$chat -> sendMsg ( $cmsg );
}
2022-07-01 12:45:43 +00:00
}
2023-04-15 19:18:30 +00:00
Db :: sql ( 'update users set afk = default, dnd = default, timeMain = unix_timestamp() where id = ?' , [ $u -> info [ 'id' ]]);
2022-07-01 12:45:43 +00:00
}
}
2023-08-16 00:05:57 +00:00
$ar_id = 0 ;
$ar_lvl = 0 ;
$ar_all = '0' ;
2023-01-10 16:29:32 +00:00
//Получаем список онлайн
2023-08-16 00:05:57 +00:00
if ( ! empty ( $_GET [ 'r1' ])) {
2023-02-13 17:24:48 +00:00
// $_GET['r3'] передаётся из onlineList.js как переключатель "все пользователи\пользователи в комнате".
define ( 'BOT_ROOM' , 303 );
2023-08-16 00:05:57 +00:00
2022-07-01 12:45:43 +00:00
$usl = [];
$cw = [];
$usid = [];
2023-08-15 22:48:29 +00:00
2023-02-13 17:24:48 +00:00
$onlineListQuery = ' select
users . id , pass , sex , dnow , timeMain , bot , atack , afk , dnd , banned , molch1 ,
room , city , cityreg , online , align , clan , login , level , inTurnir , battle , invis , inUser , x , y
from users left join stats on users . id = stats . id
where
(
( room = ? and ' . (int)$_GET[' r3 '] . ' != 1 ) or
( ' . (int)$_GET[' r3 '] . ' = 1 and pass not like ? )
) and
mail != ? and
room != ?
order by inUser desc , online desc , login desc ' ;
2023-08-15 22:48:29 +00:00
$usersOnline = Db :: getRows ( $onlineListQuery , [ $u -> info [ 'room' ], '%saint%' , '' , BOT_ROOM ]);
foreach ( $usersOnline as $onlineUser ) {
2022-07-01 12:45:43 +00:00
$ysee = 1 ;
2023-08-15 22:48:29 +00:00
if ( $onlineUser [ 'inUser' ] > 0 ) {
if ( $onlineUser [ 'inTurnir' ] == 0 ) {
2022-07-01 12:45:43 +00:00
$ysee = 0 ;
} else {
2023-08-15 22:48:29 +00:00
if ( $onlineUser [ 'online' ] < time () - 120 ) {
User :: setOnline ( $onlineUser [ 'id' ]);
2022-07-01 12:45:43 +00:00
}
}
} else {
2023-08-15 22:48:29 +00:00
if ( $onlineUser [ 'inTurnir' ] > 0 ) {
2022-07-01 12:45:43 +00:00
$ysee = 0 ;
}
}
2023-08-15 22:48:29 +00:00
if ( ! isset ( $usl [ $onlineUser [ 'login' ]])) {
2022-07-01 12:45:43 +00:00
$ysee = 1 ;
}
if (
(
( int ) $_GET [ 'r3' ] != 1 &&
2023-08-15 22:48:29 +00:00
$u -> info [ 'dnow' ] != $onlineUser [ 'dnow' ]
2022-07-01 12:45:43 +00:00
) ||
(
2023-08-15 22:48:29 +00:00
$onlineUser [ 'room' ] >= 362 &&
$onlineUser [ 'room' ] <= 366 &&
2022-07-01 12:45:43 +00:00
( int ) $_GET [ 'r3' ] != 1 &&
(
2023-08-15 22:48:29 +00:00
$onlineUser [ 'x' ] != $u -> info [ 'x' ] ||
$onlineUser [ 'y' ] != $u -> info [ 'y' ] ||
$onlineUser [ 'room' ] != $u -> info [ 'room' ]
2022-07-01 12:45:43 +00:00
)
) ||
2023-08-15 22:48:29 +00:00
! empty ( $usid [ $onlineUser [ 'login' ]])
2022-07-01 12:45:43 +00:00
) {
$ysee = 0 ;
}
2023-08-15 22:48:29 +00:00
if ( isset ( $onlineUser [ 'login' ])) {
$usl [ $onlineUser [ 'login' ]] = $onlineUser [ 'id' ];
}
2022-07-01 12:45:43 +00:00
if (
(
2023-08-15 22:48:29 +00:00
$onlineUser [ 'online' ] > time () - 520 ||
$onlineUser [ 'inUser' ] > 0
2022-07-01 12:45:43 +00:00
) &&
(
2023-08-15 22:48:29 +00:00
$onlineUser [ 'bot' ] != 1 ||
$onlineUser [ 'pass' ] == '212121q'
2022-07-01 12:45:43 +00:00
) &&
2023-08-15 22:48:29 +00:00
$onlineUser [ 'banned' ] == 0 &&
2022-07-01 12:45:43 +00:00
$ysee == 1
) {
2023-08-15 22:48:29 +00:00
$usid [ $onlineUser [ 'login' ]] = true ;
if ( $onlineUser [ 'invis' ] != 1 && $onlineUser [ 'invis' ] < time ()) {
if ( $onlineUser [ 'clan' ] > 0 ) {
if ( $u -> info [ 'clan' ] > 0 && $onlineUser [ 'clan' ] != $u -> info [ 'clan' ]) {
if ( ! isset ( $cw [ 'war' ][ $onlineUser [ 'clan' ]][ $u -> info [ 'clan' ]])) {
2023-10-16 13:12:16 +00:00
$onlineUser [ 'cwar' ] = Db :: getRow ( 'select id, type from clan_wars where clan1 in (?,?) and clan2 in (?,?) and clan1 != clan2 and time_finish > unix_timestamp()' ,
[ $u -> info [ 'clan' ], $onlineUser [ 'clan' ], $u -> info [ 'clan' ], $onlineUser [ 'clan' ],]);
2023-08-15 22:48:29 +00:00
if ( isset ( $onlineUser [ 'cwar' ][ 'id' ])) {
$cw [ 'war' ][ $onlineUser [ 'clan' ]][ $u -> info [ 'clan' ]] = $onlineUser [ 'cwar' ][ 'type' ];
2022-07-01 12:45:43 +00:00
} else {
2023-08-15 22:48:29 +00:00
$cw [ 'war' ][ $onlineUser [ 'clan' ]][ $u -> info [ 'clan' ]] = 0 ;
2022-07-01 12:45:43 +00:00
}
}
2023-08-15 22:48:29 +00:00
if ( $cw [ 'war' ][ $onlineUser [ 'clan' ]][ $u -> info [ 'clan' ]] > 0 ) {
$onlineUser [ 'atack' ] = $cw [ 'war' ][ $onlineUser [ 'clan' ]][ $u -> info [ 'clan' ]];
2022-07-01 12:45:43 +00:00
}
}
2023-08-15 22:48:29 +00:00
if ( ! isset ( $cw [ $onlineUser [ 'clan' ]])) {
2023-10-16 13:12:16 +00:00
$onlineUser [ 'clan' ] = ClanInfo :: getNameById ( $onlineUser [ 'clan' ]);
2022-07-01 12:45:43 +00:00
} else {
2023-08-15 22:48:29 +00:00
$onlineUser [ 'clan' ] = $cw [ $onlineUser [ 'clan' ]];
2022-07-01 12:45:43 +00:00
}
}
2023-08-15 22:48:29 +00:00
if ( $onlineUser [ 'atack' ] > time () || $onlineUser [ 'atack' ] == 1 || $onlineUser [ 'atack' ] == 2 ) {
if ( $onlineUser [ 'atack' ] != 2 ) {
$onlineUser [ 'atack' ] = 1 ;
2022-07-01 12:45:43 +00:00
}
} else {
2023-08-15 22:48:29 +00:00
$onlineUser [ 'atack' ] = 0 ;
2022-07-01 12:45:43 +00:00
}
2023-08-15 22:48:29 +00:00
$trvm = Db :: getValue ( 'select name from eff_users where uid = ? and id_eff in (4,6) order by id_eff limit 1' , [ $onlineUser [ 'id' ]]);
$r [ 'list' ] .= '"' . $r [ 'xu' ] . '":["' . $onlineUser [ 'id' ] . '","' . $onlineUser [ 'login' ] . '","' . $onlineUser [ 'level' ] . '","' . $onlineUser [ 'align' ] .
'","' . $onlineUser [ 'clan' ] . '","' . $onlineUser [ 'cityreg' ] . '","' . $onlineUser [ 'city' ] . '","' . $onlineUser [ 'room' ] .
'","' . $onlineUser [ 'afk' ] . '","' . $onlineUser [ 'dnd' ] . '","' . $onlineUser [ 'banned' ] . '","' . $onlineUser [ 'molch1' ] . '","' .
$onlineUser [ 'battle' ] . '","' . $onlineUser [ 'atack' ] . '","' . $trvm . '","' . ( $onlineUser [ 'sex' ] * 0 ) . '"],' ;
$ar_id += $onlineUser [ 'id' ];
$ar_lvl += $onlineUser [ 'level' ];
$ar_all .= $onlineUser [ 'align' ] . $onlineUser [ 'clan' ] . $onlineUser [ 'molch1' ] . $onlineUser [ 'banned' ] . $onlineUser [ 'battle' ] . 1 ;
2022-12-19 18:26:14 +00:00
2022-07-01 12:45:43 +00:00
}
$r [ 'xu' ] ++ ;
}
}
2023-08-15 22:48:29 +00:00
unset ( $onlineUser , $sp );
2022-07-01 12:45:43 +00:00
$r [ 'list' ] = rtrim ( $r [ 'list' ], ',' );
$r [ 'list' ] = '{' . $r [ 'list' ] . '}' ;
}
2023-01-10 16:29:32 +00:00
//Получаем сообщения
2022-07-01 12:45:43 +00:00
if ( isset ( $_GET [ 'mid' ]) && ! isset ( $_POST [ 'mid' ])) {
$_POST [ 'mid' ] = $_GET [ 'mid' ];
}
$i = 0 ;
$l = 0 ;
2023-10-16 13:12:16 +00:00
foreach ( $chat -> getMessages (( int ) $_POST [ 'mid' ], $u -> info [ 'login' ]) as $pl ) {
2022-07-01 12:45:43 +00:00
if ( $pl [ 'delete' ] > 0 ) {
$r [ 'msg' ] .= ',"m' . $i . '":["' . $pl [ 'id' ] . '","","delete","","","","","","","0","0","0","1","",""]' ;
}
$see = 1 ;
2023-10-16 10:58:02 +00:00
if ( $pl [ 'type' ] == 8 && $u -> isModerator ()) {
2022-07-01 12:45:43 +00:00
$see = 0 ;
}
if (( $pl [ 'type' ] > 0 && $pl [ 'type' ] < 4 ) || $pl [ 'type' ] == - 3 ) {
$pl [ 'room' ] = $u -> info [ 'room' ];
}
2023-10-16 13:12:16 +00:00
//fixme $pl['global'] - глобалка по всем городам. Если нет городов, то не нужна и глобалка. Теоретически.
2023-01-10 16:29:32 +00:00
//Проверки на доступ к просмотру
2022-07-01 12:45:43 +00:00
if (
2023-10-16 13:12:16 +00:00
(
(( $pl [ 'type' ] == 3 || $pl [ 'type' ] == 4 ) && $pl [ 'global' ] == 1 ) ||
(( $pl [ 'type' ] == 5 || $pl [ 'type' ] == 6 || $pl [ 'type' ] == 8 && $u -> isModerator ()) && $pl [ 'global' ] == 1 ) ||
( $pl [ 'type' ] == 7 && $pl [ 'room' ] == $u -> info [ 'room' ]) ||
( $pl [ 'type' ] == 6 && $pl [ 'global' ] == 1 ) ||
2022-07-01 12:45:43 +00:00
$pl [ 'type' ] == 9 ||
$pl [ 'type' ] == 10
) &&
2023-10-16 13:12:16 +00:00
$pl [ 'to' ] != '' && $pl [ 'login' ] != $u -> info [ 'login' ] && $pl [ 'to' ] != $u -> info [ 'login' ]
2022-07-01 12:45:43 +00:00
) {
$n = 0 ;
$ex = explode ( ',' , $pl [ 'to' ]);
$j = 0 ;
while ( $j < count ( $ex )) {
if ( trim ( $ex [ $j ], ' ' ) == $u -> info [ 'login' ]) {
$n ++ ;
}
$j ++ ;
}
if ( $n == 0 ) {
$see = 0 ;
}
unset ( $n , $j , $ex );
}
2023-01-10 16:29:32 +00:00
//Клановое сообщение (по всем городам)
2023-10-16 13:12:16 +00:00
if ( $pl [ 'type' ] == - 3 && ( $pl [ 'to' ] == 'k' . $u -> info [ 'clan' ] || $u -> isAdmin ())) {
2022-07-01 12:45:43 +00:00
$pl [ 'type' ] = 3 ;
if ( $pl [ 'to' ] == 'k' . $u -> info [ 'clan' ]) {
$pl [ 'to' ] = 'klan' ;
}
$see = 1 ;
} elseif ( $pl [ 'type' ] == - 3 ) {
$see = 0 ;
}
2023-01-10 16:29:32 +00:00
//Системное сообщение только в этой комнате
2022-07-01 12:45:43 +00:00
if (
$pl [ 'type' ] == 6 &&
$pl [ 'room' ] > 0 &&
$pl [ 'room' ] != $u -> info [ 'room' ] &&
$pl [ 'to' ] == ''
) {
$see = 0 ;
}
2023-01-10 16:29:32 +00:00
//Сообщение с молчанкой
2022-07-01 12:45:43 +00:00
if ( $pl [ 'molch' ] > 0 ) {
$see = 0 ;
}
2023-01-10 16:29:32 +00:00
//Сообщение отправлено в другой комнате
2022-07-01 12:45:43 +00:00
if (
2023-10-16 13:12:16 +00:00
( $pl [ 'type' ] == 1 || $pl [ 'type' ] == 2 ) &&
( $pl [ 'room' ] != $u -> info [ 'room' ]) &&
( $pl [ 'global' ] == 0 || $_COOKIE [ 'chatCfg11' ] == 0 )
2022-07-01 12:45:43 +00:00
) {
$see = 0 ;
}
2023-01-10 16:29:32 +00:00
//Глобал
2023-10-16 13:12:16 +00:00
if ( $pl [ 'global' ] == 1 && $pl [ 'type' ] != - 3 ) {
2022-07-01 12:45:43 +00:00
$see = 1 ;
}
2023-01-10 16:29:32 +00:00
//Пещерное сообщение
2022-07-01 12:45:43 +00:00
if ( $pl [ 'dn' ] > 0 && $u -> info [ 'dnow' ] != $pl [ 'dn' ]) {
$see = 0 ;
}
2023-10-16 13:12:16 +00:00
if ( $pl [ 'login' ] != $u -> info [ 'login' ] && $pl [ 'nosee' ] != 0 && $u -> info [ 'id' ] != $pl [ 'nosee' ] && ! $u -> isModerator ()) {
2022-07-01 12:45:43 +00:00
$see = 0 ;
} else {
if ( $pl [ 'nosee' ] != 0 && $pl [ 'login' ] != $u -> info [ 'login' ]) {
2023-01-10 16:29:32 +00:00
$noseein = 'скрыто' ;
2022-07-01 12:45:43 +00:00
if ( $u -> info [ 'id' ] == $pl [ 'nosee' ]) {
2023-01-10 16:29:32 +00:00
$noseein = 'ваш реферал' ;
2022-07-01 12:45:43 +00:00
}
2023-10-16 13:12:16 +00:00
$pl [ 'text' ] = '<span style="padding:0 5px 0 5px;background-color:#FFC;"><small style="color: red;">[' . $noseein . ']</small> ' . $pl [ 'text' ] . '</span>' ;
if ( $u -> isModerator ()) {
2022-07-01 12:45:43 +00:00
$see = 1 ;
}
}
}
2023-10-16 13:12:16 +00:00
if ( $see == 1 && $pl [ 'login' ] != '' ) {
2022-07-01 12:45:43 +00:00
2023-08-15 22:48:29 +00:00
$qix = Db :: getValue ( 'select id from friends where ignor > 0 and login_ignor = ? and (user_ignor = ? or user = ?)' , [ $pl [ 'login' ], $u -> info [ 'login' ], $u -> info [ 'id' ]]);
if ( isset ( $qix )) {
2022-07-01 12:45:43 +00:00
$see = 0 ;
}
unset ( $qix );
}
2023-11-02 13:57:39 +00:00
$see = 1 ; //временно.
2023-10-16 13:12:16 +00:00
if ( $see == 1 ) {
2022-07-01 12:45:43 +00:00
if ( $pl [ 'time' ] < 0 ) {
if ( $pl [ 'to' ] == '' ) {
2023-10-16 13:12:16 +00:00
$lmsch = Chat :: getLastMessageId ();
if ( $lmsch > 0 ) {
$lmsch ++ ;
Chat :: setCurrentTimeAndIdById ( $pl [ 'id' ], $lmsch );
$pl [ 'id' ] = $lmsch ;
2022-07-01 12:45:43 +00:00
} else {
2023-10-16 13:12:16 +00:00
Chat :: setCurrentTimeById ( $pl [ 'id' ]);
2022-07-01 12:45:43 +00:00
}
} else {
2023-10-16 13:12:16 +00:00
Chat :: setCurrentTimeById ( $pl [ 'id' ]);
2022-07-01 12:45:43 +00:00
}
$pl [ 'time' ] = time ();
}
if ( $pl [ 'spam' ] > 0 ) {
$r [ 'msg' ] .= ',"' . $i . '":{"s":"' . $pl [ 'id' ] . '"}' ;
} else {
$reimg = [];
2022-12-19 18:26:14 +00:00
if ( preg_match_all (
" / \ [img \ [(.*?) \ ] \ ] \ [1 \ ]/ " , $pl [ 'text' ], $reimg
2023-10-16 13:12:16 +00:00
) && ( $u -> isAdmin () || $pl [ 'type' ] == 5 || $pl [ 'type' ] == 6 || $pl [ 'type' ] == 10 || $pl [ 'type' ] == 11 )) {
2022-07-01 12:45:43 +00:00
$k = 0 ;
while ( $k <= count ( $reimg [ 1 ])) {
2022-12-19 18:26:14 +00:00
$pl [ 'text' ] = str_replace (
'[img[' . $reimg [ 1 ][ $k ] . ']][1]' ,
2023-10-16 13:12:16 +00:00
'<img src=' . Config :: img () . '/i/' . $reimg [ 1 ][ $k ] . ' height=19>' , $pl [ 'text' ]
2022-12-19 18:26:14 +00:00
);
2022-07-01 12:45:43 +00:00
$k ++ ;
}
}
2022-12-19 18:26:14 +00:00
if ( preg_match_all (
" / \ [img \ [(.*?) \ ] \ ]/ " , $pl [ 'text' ], $reimg
) && ( $u -> info [ 'admin' ] > 0 || $pl [ 'type' ] == 5 || $pl [ 'type' ] == 6 || $pl [ 'type' ] == 10 || $pl [ 'type' ] == 11 )) {
2022-07-01 12:45:43 +00:00
$k = 0 ;
while ( $k <= count ( $reimg [ 1 ])) {
2022-12-19 18:26:14 +00:00
$pl [ 'text' ] = str_replace (
2023-10-16 13:12:16 +00:00
'[img[' . $reimg [ 1 ][ $k ] . ']]' , '<img src=' . Config :: img () . '/i/' . $reimg [ 1 ][ $k ] . '>' ,
2022-12-19 18:26:14 +00:00
$pl [ 'text' ]
);
2022-07-01 12:45:43 +00:00
$k ++ ;
}
}
if ( preg_match_all ( " /item \ [(.*?) \ ]/ " , $pl [ 'text' ], $reimg )) {
$k = 0 ;
while ( $k <= count ( $reimg [ 1 ])) {
2022-12-19 18:26:14 +00:00
$pl [ 'text' ] = str_replace (
'item[' . $reimg [ 1 ][ $k ] . ']' ,
2023-01-10 16:29:32 +00:00
'<b oncontextmenu=\"return false;\" onClick=\"alert(\'Функция временно недоступна!\');\" style=\"cursor:pointer;\" class=\"itemsInfo\">Предмет</b>' ,
2022-12-19 18:26:14 +00:00
$pl [ 'text' ]
);
2022-07-01 12:45:43 +00:00
$k ++ ;
}
}
2023-01-10 16:29:32 +00:00
if ( preg_match_all ( " / \ .(?:mp3) $ /i " , $pl [ 'text' ], $reimg )) //Т У Т аудио audio
2022-07-01 12:45:43 +00:00
{
$k = 0 ;
while ( $k <= count ( $reimg [ 1 ])) {
2022-12-19 18:26:14 +00:00
$pl [ 'text' ] = str_replace (
'item[' . $reimg [ 1 ][ $k ] . ']' ,
2023-01-10 16:29:32 +00:00
'<b oncontextmenu=\"return false;\" onClick=\"alert(\'Функция временно недоступна!\');\" style=\"cursor:pointer;\" class=\"itemsInfo\">Аудио запись</b>' ,
2022-12-19 18:26:14 +00:00
$pl [ 'text' ]
);
2022-07-01 12:45:43 +00:00
$k ++ ;
}
}
if ( preg_match_all ( " /item \ [(.*?) \ ]/ " , $pl [ 'text' ], $reimg )) {
$k = 0 ;
while ( $k <= count ( $reimg [ 1 ])) {
2022-12-19 18:26:14 +00:00
$pl [ 'text' ] = str_replace (
'item [' . $reimg [ 1 ][ $k ] . ']' ,
2023-01-10 16:29:32 +00:00
'<b oncontextmenu=\"return false;\" onClick=\"alert(\'Функция временно недоступна!\');\" style=\"cursor:pointer;\" class=\"itemsInfo\">Предмет</b>' ,
2022-12-19 18:26:14 +00:00
$pl [ 'text' ]
);
2022-07-01 12:45:43 +00:00
$k ++ ;
}
}
if ( $pl [ 'type' ] != 3 && ( $pl [ 'invis' ] == 1 || $pl [ 'invis' ] > time ())) {
2023-10-16 13:12:16 +00:00
$pl [ 'login' ] = '<b><i>Невидимка</i></b>' ;
if ( $u -> isAdmin ()) {
$pl [ 'login' ] .= '</a> <small>(' . $pl [ 'login' ] . ')</small>' ;
2022-07-01 12:45:43 +00:00
}
}
if ( $pl [ 'invis' ] > 0 && ( $pl [ 'type' ] == 1 || $pl [ 'type' ] == 2 )) {
$pl [ 'color' ] = 'Black' ;
}
2023-10-16 13:12:16 +00:00
$r [ 'msg' ] .= ',"m' . $i . '":["' . $pl [ 'id' ] . '","' . $pl [ 'time' ] . '","' . $pl [ 'type' ] . '","' . $pl [ 'login' ] . '","' .
$pl [ 'to' ] . '","' . $pl [ 'text' ] . '","' . $pl [ 'color' ] . '","' . $pl [ 'toChat' ] . '","' . $pl [ 'typeTime' ] . '","' . $pl [ 'sound' ] .
'","' . $pl [ 'global' ] . '","' . $pl [ 'molch' ] . '","' . $pl [ 'active' ] . '","' . date ( 'H:i' , $pl [ 'time' ]) . '","' .
date ( 'd.m.Y H:i' , $pl [ 'time' ]) . '","' . $pl [ 'frv' ] . '","' . $pl [ 'invis' ] . '"]' ;
2022-07-01 12:45:43 +00:00
}
}
if ( $l < $pl [ 'id' ]) {
$l = $pl [ 'id' ];
}
$i ++ ;
}
$r [ 'msg' ] = '{"ld":"' . ( 0 + $l ) . '","id":"' . $i . '"' . $r [ 'msg' ] . '}' ;
2022-12-19 18:26:14 +00:00
2023-01-10 16:29:32 +00:00
//Генерируем ключ
2022-07-01 12:45:43 +00:00
$r [ 'key' ] = md5 ( $u -> room [ 'name' ] . '+' . $ar_id . '+' . $ar_lvl . '+' . $ar_all );
unset ( $ar_id , $ar_lvl );
2023-08-15 22:48:29 +00:00
if ( empty ( $_COOKIE [ 'chatCfg12' ])) {
2022-07-01 12:45:43 +00:00
$_GET [ 'key' ] = time ();
}
if ( $r [ 'key' ] == $_GET [ 'key' ]) {
2023-01-10 16:29:32 +00:00
//Список онлайн остается неизменным
2022-07-01 12:45:43 +00:00
unset ( $r [ 'rn' ], $r [ 'list' ], $r [ 'key' ], $r [ 'xu' ]);
2023-08-16 00:05:57 +00:00
} elseif ( ! empty ( $_GET [ 'r1' ])) {
2023-01-10 17:26:14 +00:00
$r [ 'rn' ] = $u -> room [ 'name' ];
2022-07-01 12:45:43 +00:00
}
2023-10-16 13:12:16 +00:00
$posts = Db :: getValue ( 'select count(id) from items_users where uid = ? and inOdet = 0 and inShop = 0 and lastUPD < unix_timestamp()' , [ '-51' . $u -> info [ 'id' ]]);
2022-07-01 12:45:43 +00:00
if ( $posts > 0 ) {
$r [ 'js' ] .= ' $("#postdiv").show();' ;
} else {
$r [ 'js' ] .= ' $("#postdiv").hide();' ;
}
2023-01-10 16:29:32 +00:00
//Предложение на обмен
2023-10-16 13:12:16 +00:00
$transfer = Db :: getRow ( 'select id, uid1 from transfers where uid2 = ? and start2 = 0 and cancel1 = 0 and cancel2 = 0' , [ $u -> info [ 'id' ]]);
if ( isset ( $transfer [ 'id' ])) {
$utf = User :: getLoginById ( $transfer [ 'uid1' ]);
if ( ! empty ( $utf ) && $u -> info [ 'battle' ] == 0 ) {
$r [ 'js' ] .= 'top.intransferNew(' . $transfer [ 'id' ] . ',"' . $utf . '");' ;
2022-07-01 12:45:43 +00:00
} else {
2023-10-16 13:12:16 +00:00
Db :: sql ( 'update transfers set cancel2 = unix_timestamp() where id = ?' , [ $transfer [ 'id' ]]);
2022-07-01 12:45:43 +00:00
}
}
2023-01-10 18:14:47 +00:00
unset ( $c , $u , $db );
echo json_encode ( $r );