sibtracker/system/modules/chat/addmess.php
2019-05-18 13:46:03 +08:00

46 lines
1.6 KiB
PHP

<?php
if(!defined('DATALIFEENGINE')) { die("Hacking attempt!"); }
global $banned_info;
require_once SYSTEM_DIR.'/data/chat.config.php';
require_once SYSTEM_DIR.'/modules/functions.php';
require_once SYSTEM_DIR.'/classes/parse.class.php';
$parse = new ParseFilter();
$parse->safe_mode = true;
$_TIME = time()+($config['date_adjust']*60);
if ($is_logged) {$name = $db->safesql($member_id['name']);} else {$CN_HALT = TRUE;}
$_IP = $db->safesql($_SERVER['REMOTE_ADDR']);
$time = date ("Y-m-d H:i:s", $_TIME);
$message = $db->safesql($parse->BB_Parse($parse->process($mcadd['message'])), false);
if( strlen($message) > 3000) $CN_HALT = TRUE;
if ($message =='' OR $member_id['banned'] == "yes") $CN_HALT = TRUE;
$message = preg_replace("#(^|\s|>)((http|https|ftp)://\w+[^\s\[\]\<]+)#i", '\\1<a href="\\2" target="_blank" rel="nofollow">URL</a>', $message);
//* Àâòîïåðåíîñ äëèííûõ ñëîâ
if(intval($chatconfig['auto_wrap'])){
$message = preg_split('((>)|(<))', $message, -1, PREG_SPLIT_DELIM_CAPTURE);
$n = count($message);
for ($i = 0; $i < $n; $i++) {
if ($message[$i] == "<") {
$i++; continue;
}
$message[$i] = preg_replace("#([^\s<>'\"/\.\\-\?&\n\r\%]{".intval($chatconfig['auto_wrap'])."})#i", "\\1<br />", $message[$i]);
}
$message = join("", $message);
}
$data['skin'] = strtolower($_REQUEST['skin']);
// Äîáàâëåíèå
if ($CN_HALT) {
} else {
$db->query("INSERT INTO ".PREFIX."_chat (name, message, date, ip, `mgroup`, user_id) VALUES ('$name', '$message', '$time', '$_IP', '$member_id[user_group]', '$member_id[user_id]')");
$cache->del('minichat');
}
?>