This commit is contained in:
3err0
2019-05-18 13:46:03 +08:00
commit 55e0adfa17
707 changed files with 55878 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?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');
}
?>

280
system/modules/chat/ajax.js Normal file
View File

@@ -0,0 +1,280 @@
var DMC_selField = "message";
var DMC_fombj = document.getElementById( 'chat-form' );
function Chat_UserMenu(a, b, c, d, e, f) {
var g = new Array();
g[0] = '<a onclick="Chat_QuoteName(\'' + e + '\'); return false;" href="javascript:quote(' + e + ');">Îòâåòèòü</a>';
g[1] = '<a ' + a + ' >' + menu_profile + '</a>';
g[2] = '<a href="' + dle_root + 'index.php?do=pm&doaction=newpm&user=' + b + '">' + menu_send + '</a>';
if (c == '1' || c == '2') {
g[3] = '<a onclick="return Chat_MessDel(' + d + ');" href="javascript:messages_delete(' + d + ');">Óäàëèòü</a>'
}
return g
}
function Chat_GastMenu(a, b, c, d, e) {
var f = new Array();
f[0] = '<a onclick="Chat_QuoteName(\'' + d + '\'); return false;" href="javascript:quote(' + d + ');">Îòâåòèòü</a>';
f[1] = '<a href="mailto:' + a + '">' + menu_send + '</a>';
if (b == '1' || b == '2') {
f[2] = '<a onclick="return Chat_MessDel(' + c + ');" href="javascript:messages_delete(' + c + ');">Óäàëèòü</a>'
}
return f
}
function Chat_MessDel(b) {
$.post(dle_root + "system/ajax/chat.php", { mdelete: b, refresh: 1, skin: dle_skin}, function(data){
$("#chat").html(data);
});
}
function Chat_Refresh() {
$.post(dle_root + "system/ajax/chat.php", { skin: dle_skin}, function(data){
$("#chat").html(data);
});
}
function Chat_QuoteName(a) {
document.getElementById('message').value += "[b]" + a + "[/b]:";
$("#message").focus()
}
function Chat_AddSmile(a, b, c) {
document.getElementById(b).value += ":" + a + ":";
$("#" + c).fadeOut("slow");
$("#" + b).focus()
}
function Chat_Display(a, b) {
if ($("#" + a).css("display") === "none") {
$("#" + a).show(b)
} else {
$("#" + a).hide(b)
}
}
function AWclear(a, b) {
var c = a.value;
if (c == b) {
a.value = ""
}
$(a).attr('onblur', "if(this.value=='')this.value='" + b + "';")
}
function SendMessage(){
if($.trim(document.chat_form.message.value) == ''){
alert('Ââåäèòå ñîîáùåíèå!');
return false;
};
var message = document.getElementById('message').value;
$.post(dle_root + "system/ajax/chat.php", { message: message, skin: dle_skin}, function(data){
$("#chat").html(data);
$('#message').attr('value', '');
});
return false;
};
//BBCOdes
var uagent = navigator.userAgent.toLowerCase();
var is_safari = ( (uagent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc.") );
var is_ie = ( (uagent.indexOf('msie') != -1) && (!is_opera) && (!is_safari) && (!is_webtv) );
var is_ie4 = ( (is_ie) && (uagent.indexOf("msie 4.") != -1) );
var is_moz = (navigator.product == 'Gecko');
var is_ns = ( (uagent.indexOf('compatible') == -1) && (uagent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_safari) );
var is_ns4 = ( (is_ns) && (parseInt(navigator.appVersion) == 4) );
var is_opera = (uagent.indexOf('opera') != -1);
var is_kon = (uagent.indexOf('konqueror') != -1);
var is_webtv = (uagent.indexOf('webtv') != -1);
var is_win = ( (uagent.indexOf("win") != -1) || (uagent.indexOf("16bit") !=- 1) );
var is_mac = ( (uagent.indexOf("mac") != -1) || (navigator.vendor == "Apple Computer, Inc.") );
var ua_vers = parseInt(navigator.appVersion);
var b_open = 0;
var i_open = 0;
var u_open = 0;
var s_open = 0;
var quote_open = 0;
var code_open = 0;
var sql_open = 0;
var html_open = 0;
var left_open = 0;
var center_open = 0;
var right_open = 0;
var hide_open = 0;
var color_open = 0;
var ie_range_cache = '';
var DMC_bbtags = new Array();
function DMC_stacksize(thearray)
{
for (i = 0; i < thearray.length; i++ )
{
if ( (thearray[i] == "") || (thearray[i] == null) || (thearray == 'undefined') )
{
return i;
}
}
return thearray.length;
};
function cstat()
{
var c = DMC_stacksize(DMC_bbtags);
if ( (c < 1) || (c == null) ) {
c = 0;
}
if ( ! DMC_bbtags[0] ) {
c = 0;
}
};
function DMC_simpletag(thetag)
{
var tagOpen = eval(thetag + "_open");
if (tagOpen == 0)
{
if(DMC_doInsert("[" + thetag + "]", "[/" + thetag + "]", true))
{
eval(thetag + "_open = 1");
document.getElementById( 'b_' + thetag ).className = 'editor_buttoncl';
pushstack(DMC_bbtags, thetag);
cstat();
}
}
else
{
lastindex = 0;
for (i = 0 ; i < DMC_bbtags.length; i++ )
{
if ( DMC_bbtags[i] == thetag )
{
lastindex = i;
}
}
while (DMC_bbtags[lastindex])
{
tagRemove = popstack(DMC_bbtags);
DMC_doInsert("[/" + tagRemove + "]", "", false);
if ( (tagRemove != 'font') && (tagRemove != 'size') )
{
eval(tagRemove + "_open = 0");
document.getElementById( 'b_' + tagRemove ).className = 'editor_button';
}
}
cstat();
}
};
function DMC_doInsert(ibTag, ibClsTag, isSingle)
{
var isClose = false;
var obj_ta = eval('DMC_fombj.'+ DMC_selField);
if ( (ua_vers >= 4) && is_ie && is_win)
{
if (obj_ta.isTextEdit)
{
obj_ta.focus();
var sel = document.selection;
var rng = ie_range_cache ? ie_range_cache : sel.createRange();
rng.colapse;
if((sel.type == "Text" || sel.type == "None") && rng != null)
{
if(ibClsTag != "" && rng.text.length > 0)
ibTag += rng.text + ibClsTag;
else if(isSingle)
ibTag += rng.text + ibClsTag;
rng.text = ibTag;
}
}
else
{
obj_ta.value += ibTag + ibClsTag;
}
rng.select();
ie_range_cache = null;
}
else if ( obj_ta.selectionEnd )
{
var ss = obj_ta.selectionStart;
var st = obj_ta.scrollTop;
var es = obj_ta.selectionEnd;
if (es <= 2)
{
es = obj_ta.textLength;
}
var start = (obj_ta.value).substring(0, ss);
var middle = (obj_ta.value).substring(ss, es);
var end = (obj_ta.value).substring(es, obj_ta.textLength);
if (obj_ta.selectionEnd - obj_ta.selectionStart > 0)
{
middle = ibTag + middle + ibClsTag;
}
else
{
middle = ibTag + middle + ibClsTag;
}
obj_ta.value = start + middle + end;
var cpos = ss + (middle.length);
obj_ta.selectionStart = cpos;
obj_ta.selectionEnd = cpos;
obj_ta.scrollTop = st;
}
else
{
obj_ta.value += ibTag + ibClsTag;
}
obj_ta.focus();
return isClose;
};
function getOffsetTop(obj)
{
var top = obj.offsetTop;
while( (obj = obj.offsetParent) != null )
{
top += obj.offsetTop;
}
return top;
};
function getOffsetLeft(obj)
{
var top = obj.offsetLeft;
while( (obj = obj.offsetParent) != null )
{
top += obj.offsetLeft;
}
return top;
};

View File

@@ -0,0 +1,38 @@
<?php
if(!defined('DATALIFEENGINE')) {die("Hacking Attempt!"); }
require_once SYSTEM_DIR.'/data/config.php';
require_once SYSTEM_DIR.'/data/chat.config.php';
require_once SYSTEM_DIR.'/modules/chat/chat.class.php';
$chat= new Chat();
$tpl->load_template('chat/block.tpl');
$tpl->copy_template .= '<script type="text/javascript" src="/system/modules/chat/ajax.js"></script>
<script type="text/javascript">
var Chat_RefInterval = '.$chatconfig['refresh'].'*1000;
setInterval(Chat_Refresh, Chat_RefInterval);
</script>';
if ($is_logged){
$tpl->set('[isloged]',"");
$tpl->set('[/isloged]',"");
$tpl->set_block("'\\[notloged\\].*?\\[/notloged\\]'si","");
} else {
$tpl->set_block("'\\[isloged\\].*?\\[/isloged\\]'si","");
$tpl->set('[notloged]',"");
$tpl->set('[/notloged]',"");
}
$tpl->set('[historylink]',"<a href=\"".$config['http_home_url']."chat/history/\" >");
$tpl->set('[/historylink]',"</a>");
$tpl->set('{chatmsg}', $chat->GetContent($chatconfig, $member_id, $config));
$tpl->copy_template = "<form method=\"post\" onsubmit=\"SendMessage(); return false;\" name=\"chat_form\" id=\"chat-form\">".$tpl->copy_template."
</form> ";
$tpl->compile('minichat');
$tpl->clear();
return $tpl->result['minichat'];
?>

View File

@@ -0,0 +1,65 @@
<?php
if(!defined('DATALIFEENGINE')) {die("Hacking Attempt!"); }
class Chat extends db{
function GetContent($chatconfig, $member_id, $config){
global $cache, $user_group;
$moder = false;
if ($member_id['user_group'] == 1) {
$flag = true;
$moder = true;
$m_group = 1;
}
elseif ($member_id['user_group'] == 2) {
$flag = true;
$moder = true;
$m_group = 2;
}
if (!$html = $cache->open('minichat')) $flag = true;
elseif(!$moder) $flag = false;
if ($flag){
$html = "";
require_once SYSTEM_DIR.'/classes/parse.class.php';
$parse = new ParseFilter();
$parse->safe_mode = true;
$result = $this->query("SELECT id, name as gast_name, message, date, ip, user_id, mgroup FROM ".PREFIX."_chat m ORDER BY date DESC LIMIT 0,".$chatconfig['limit']."");
if (!$moder){$m_group = 4;}
$PHP_SELF = $config['http_home_url'];
while ($row = $this->get_row($result)){
$lang['mchat_mess'] = "Ñîîáùåíèå";
$row['date'] = strtotime($row['date']);
$row['name'] = stripslashes($row['gast_name']);
$go_page = "href=\"".$config['http_home_url']."user/".urlencode($row['name'])."/\"";
$go_page .= "onClick=\"return dropdownmenu(this, event, Chat_UserMenu('".htmlspecialchars($go_page)."', '".$row['user_id']."', ".$m_group.", '".$row['id']."', '".$row['name']."', '".$lang['mchat_mess']."'), '170px')\"";
$color = $user_group[$row['mgroup']]['colour'];
$author = "<a {$go_page} href=\"".$config['http_home_url']."user/".urlencode($row['name'])."/\"><strong style='color:$color'>".$row['name']."</strong></a>";
$date = mcdate($chatconfig['timestamp'],$row['date']);
$message = stripslashes($row['message']);
$html .= "<div class=\"cmessage\"><b>".$author."</b><div style=\"float:right; color: #BBBBBB\">".$date."</div><br><span style=\"color:#2a2a2a\">".$message."</span></div>";
}
$this->free();
if (!$moder) $cache->save('minichat', $html);
}
else $html = $cache->open('minichat');
return $html;
}
}
?>

View File

@@ -0,0 +1,77 @@
<?php
if(!defined('DATALIFEENGINE')) { die("Hacking Attempt!"); }
require_once SYSTEM_DIR.'/classes/parse.class.php';
$parse = new ParseFilter();
$parse->safe_mode = true;
include(SYSTEM_DIR.'/data/chat.config.php');
if ($action == "mess_del") {
$db->query("DELETE FROM " . PREFIX . "_chat WHERE id = '$id'");
msgbox ($lang['all_info'], "Âûáðàííîå ñîîáùåíèå áûëî óñïåøíî óäàëåíî. <a href=\"$PHP_SELF?do=chat_history\">Âåðíóòüñÿ íàçàä...</a>");
} else {
$tpl->load_template('chat/message.tpl');
$limit = intval($chatconfig['messlimit']);
$sql_count = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_chat");
$count_all = $sql_count['count'];
$page = intval( $_REQUEST['cstart'] );
$total = intval( ( ( $count_all - 1 ) / $limit ) + 1 );
if( $page <= 0 ) $page = 1;
if( $page > $total ) $page = $total;
$start = $page * $limit - $limit;
$i = $start; $s = 0;
$result = $db->query("SELECT id, name as gast_name, message, date, ip, user_id, mgroup FROM " . PREFIX . "_chat ORDER BY date DESC LIMIT $start,".$limit);
while($row = $db->get_array($result)){ $i++;$s++;
$row['date'] = strtotime($row['date']);
$row['name'] = stripslashes($row['gast_name']);
$tpl->set('{author}', "<a href=\"".$config['http_home_url']."user/".urlencode($row['name'])."/\">".$row['name']."</a>");
if ($is_logged AND $member_id['user_group'] == '1')
$tpl->set('{ip}', "IP: <a onClick=\"return dropdownmenu(this, event, IPMenu('".$row['ip']."', '".$lang['ip_info']."', '".$lang['ip_tools']."', '".$lang['ip_ban']."'), '190px')\" onMouseout=\"delayhidemenu()\" href=\"http://www.nic.ru/whois/?ip={$row['ip']}\" target=\"_blank\">{$row['ip']}</a> ::");
else
$tpl->set('{ip}', '');
if ($config['comm_msort'] == "ASC")
$tpl->set('{mess-id}', $cstart+$i);
else
$tpl->set('{mess-id}', $comments_num-$cstart-$i+1);
if (($is_logged AND ($member_id['user_id'] == $row['userid'] AND ($row['is_reg'] == 1) AND $user_group[$member_id['user_group']]['allow_editc'])) OR $user_group[$member_id['user_group']]['edit_allc']){
$tpl->set('[mes-edit]',"<a href=\"".$config['http_home_url']."admin.php?mod=chat&action=messedit&id=".$row['id']."\" target=\"_blank\">");
$tpl->set('[/mes-edit]',"</a>");
} else $tpl->set_block("'\\[mes-edit\\](.*?)\\[/mes-edit\\]'si","");
if ($is_logged AND (($member_id['user_id'] == $row['userid'] AND ($row['is_reg'] == 1) AND $user_group[$member_id['user_group']]['allow_delc'] AND ($row['date'] == $date_max['MAX(date)'])) OR $member_id['user_group'] == '1' OR $user_group[$member_id['user_group']]['del_allc'])){
$tpl->set('[mes-del]',"<a href=\"javascript:confirmDelete('".$config['http_home_url']."?do=chat_history&action=mess_del&id=".$row['id']."')\">");
$tpl->set('[/mes-del]',"</a>");
} else $tpl->set_block("'\\[mes-del\\](.*?)\\[/mes-del\\]'si","");
$message = stripslashes($row['message']);
if (date(Ymd, $row['date']) == date(Ymd, $_TIME)) {
$tpl->set('{date}', $lang['time_heute'].langdate(", H:i", $row['date']));
} elseif (date(Ymd, $row['date']) == date(Ymd, ($_TIME - 86400))) {
$tpl->set('{date}', $lang['time_gestern'].langdate(", H:i", $row['date']));
} else {
$tpl->set('{date}', langdate($config['timestamp_comment'], $row['date']));
}
$tpl->set('{message}', $message);
$tpl->compile('content');
}
$nav = "/chat/history/page/{page}/";
CreateNavigation( $nav, $page, $total );
};
?>