Skip to content

Commit

Permalink
update 2.19
Browse files Browse the repository at this point in the history
- แสดงข้อความแจ้งเตือน เวลาเน็ตหลุด
- แสดงแจ้งเตือนเมื่อมี แจ้งเตือน/ข้อความส่วนตัว ใหม่ ตรงรายชื่อออนไลน์
- แก้ไขปัญหาเรื่องการแก้ไขข้อความ ให้แสดงผลอย่างถูกต้อง
- แก้ไขปัญหาเรื่องการแบน และทำให้สามารถกำหนดระยะเวลาแบนได้
- แก้ไขปัญหาไม่สามารถใช้บางคำสั่งกับคนที่มีชื่อ ' ได้
- แก้ไข จำนวนข้อความที่จะแสดงเริ่มต้น ให้แสดงผลอย่างถูกต้อง
- แก้ไขข้อความ กระซิบถึง: แสดงเวลามีข้อความกระซิบเข้ามาเวลาส่งข้อความพอดี
- รองรับ Discuz! X3.5
- เอาระบบให้คะแนนออกไป
  • Loading branch information
popiazaza committed Aug 17, 2020
1 parent b374e76 commit cadfa68
Show file tree
Hide file tree
Showing 19 changed files with 224 additions and 266 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
2TH Chat
=======
Chatbox for Discuz X/X2/X3

## Changelog
### 1.12
- Fixed unable to send certain characters
- Fixed PHP open tag, now no longer require to enable short_open_tag
- Updated meta data and credit
Chatbox for Discuz! X
1 change: 1 addition & 0 deletions addon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2TH Chat DIY addon
26 changes: 26 additions & 0 deletions addon/block_thchat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}

require_once libfile('commonblock_html', 'class/block/html');

class block_thchat extends commonblock_html {

function name() {
return '2th Chat';
}

function block_forumtree() {}
function getsetting() {}

function getdata($style, $parameter) {
global $_G;
include DISCUZ_ROOT. './source/plugin/th_chat/include.php';
include template('th_chat:discuz');
return array('html' => $return, 'data' => null);
}
}

?>
29 changes: 1 addition & 28 deletions th_chat/discuz_plugin_th_chat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<item id="datatables"><![CDATA[]]></item>
<item id="directory"><![CDATA[th_chat/]]></item>
<item id="copyright"><![CDATA[newz]]></item>
<item id="version"><![CDATA[2.18e]]></item>
<item id="version"><![CDATA[2.19]]></item>
<item id="__modules">
<item id="0">
<item id="name"><![CDATA[chat]]></item>
Expand Down Expand Up @@ -118,24 +118,6 @@
2 = ทำซ้ำแนวนอน
3 = ทำซ้ำแนวตั้ง
4 = ทำซ้ำแนวนอนและแนวตั้ง]]></item>
</item>
<item id="9">
<item id="displayorder"><![CDATA[9]]></item>
<item id="title"><![CDATA[ระบบ chatpoint]]></item>
<item id="description"><![CDATA[สามารถใช้คำสั่ง !point UID|POINT|REASON]]></item>
<item id="variable"><![CDATA[chat_point]]></item>
<item id="type"><![CDATA[select]]></item>
<item id="value"><![CDATA[0]]></item>
<item id="extra"><![CDATA[0 = ปิดใช้งาน
1 = ใช้ extcredits1
2 = ใช้ extcredits2
3 = ใช้ extcredits3
4 = ใช้ extcredits4
5 = ใช้ extcredits5
6 = ใช้ extcredits6
7 = ใช้ extcredits7
8 = ใช้ extcredits8
9 = ใช้ POINT สำหรับห้องแชท]]></item>
</item>
<item id="10">
<item id="displayorder"><![CDATA[10]]></item>
Expand Down Expand Up @@ -186,15 +168,6 @@
<item id="value"><![CDATA[500]]></item>
<item id="extra"><![CDATA[]]></item>
</item>
<item id="16">
<item id="displayorder"><![CDATA[16]]></item>
<item id="title"><![CDATA[UID ที่ห้ามใช้งานห้องแชท]]></item>
<item id="description"><![CDATA[คั่นด้วย , เช่น 221,223,119 หรือสามารถพิมพ์ !ban/!unban ตามด้วย UID เพื่อแบนได้จาก Chatbox]]></item>
<item id="variable"><![CDATA[chat_ban]]></item>
<item id="type"><![CDATA[text]]></item>
<item id="value"><![CDATA[]]></item>
<item id="extra"><![CDATA[]]></item>
</item>
<item id="17">
<item id="displayorder"><![CDATA[17]]></item>
<item id="title"><![CDATA[ใช้งาน HTML]]></item>
Expand Down
29 changes: 8 additions & 21 deletions th_chat/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ function getat($attextn){
global $config;
if(preg_match_all('/@(.*?)(\s|\z)/',$attextn,$atmatch)) {
foreach ($atmatch[1] as $atvalue) {
$atuser = DB::query("SELECT m.uid,m.groupid,g.color FROM ".DB::table('common_member')." m LEFT JOIN ".DB::table('common_usergroup')." g ON m.groupid=g.groupid WHERE m.username='{$atvalue}' LIMIT 1");
$atuser = DB::fetch($atuser);
$atuser = DB::fetch_first("SELECT m.uid,m.groupid,g.color FROM ".DB::table('common_member')." m LEFT JOIN ".DB::table('common_usergroup')." g ON m.groupid=g.groupid WHERE m.username='{$atvalue}' LIMIT 1");
if($atuser){
$attext = paddslashes('<a class="nzuserat nzat_'.$atuser['uid'].'" onclick="nzAt(\''.$atvalue.'\');"'.($atuser['color']?' style="color:'.$atuser['color'].'"':'').'>@'.$atvalue.'</a> ');
$attext = addslashes('<a class="nzuserat nzat_'.$atuser['uid'].'" onclick="nzAt(\''.($atvalue).'\');"'.($atuser['color']?' style="color:'.$atuser['color'].'"':'').'>@'.stripslashes($atvalue).'</a> ');
}else{
$attext = '@'.$atvalue;
}
Expand All @@ -17,16 +16,14 @@ function getat($attextn){
}
function getat2($uid){
global $config;
$atuser = DB::query("SELECT m.uid,m.username,m.groupid,g.color FROM ".DB::table('common_member')." m LEFT JOIN ".DB::table('common_usergroup')." g ON m.groupid=g.groupid WHERE m.uid='{$uid}' LIMIT 1");
$atuser = DB::fetch($atuser);
$atuser = DB::fetch_first("SELECT m.uid,m.username,m.groupid,g.color FROM ".DB::table('common_member')." m LEFT JOIN ".DB::table('common_usergroup')." g ON m.groupid=g.groupid WHERE m.uid='{$uid}' LIMIT 1");
$attext = '<a class="nzuserat2 nzat_'.$atuser['uid'].'" onclick="showWindow(\'th_chat_profile\', \'plugin.php?id=th_chat:profile&uid='.$uid.'\');return false;"'.($atuser['color']?' style="color:'.$atuser['color'].'"':'').'>'.$atuser['username'].'</a>';
return $attext;
}
function getat3($uid){
global $config;
$atuser = DB::query("SELECT m.uid,m.username,m.groupid,g.color FROM ".DB::table('common_member')." m LEFT JOIN ".DB::table('common_usergroup')." g ON m.groupid=g.groupid WHERE m.uid='{$uid}' LIMIT 1");
$atuser = DB::fetch($atuser);
$attext = '<a class="nzuserat nzat_'.$atuser['uid'].'" onclick="nzAt(\''.$atuser['username'].'\');"'.($atuser['color']?' style="color:'.$atuser['color'].'"':'').'>'.$atuser['username'].'</a>';
$atuser = DB::fetch_first("SELECT m.uid,m.username,m.groupid,g.color FROM ".DB::table('common_member')." m LEFT JOIN ".DB::table('common_usergroup')." g ON m.groupid=g.groupid WHERE m.uid='{$uid}' LIMIT 1");
$attext = '<a class="nzuserat nzat_'.$atuser['uid'].'" onclick="nzAt(\''.addslashes($atuser['username']).'\');"'.($atuser['color']?' style="color:'.$atuser['color'].'"':'').'>'.$atuser['username'].'</a>';
return $attext;
}
function getquota($quota){
Expand All @@ -36,7 +33,7 @@ function getquota($quota){
$quo = DB::fetch($quo);
$quo['text'] = preg_replace('/\[quota\](.*?)\[\/quota\]/', '', $quo['text']);
$attext = getat3($quo['uid']);
$text = '[quota]'.paddslashes('<div class="nzblockquote">'.$attext.': '.$quo['text'].'</div>').'[/quota]';
$text = '[quota]'.addslashes('<div class="nzblockquote">'.$attext.': '.$quo['text'].'</div>').'[/quota]';
}
return $text;
}
Expand All @@ -60,7 +57,7 @@ function chatrow($id,$text,$uid_p,$username,$time,$touid,$icon,$mod){
<a href="javascript:void(0);" onclick="showWindow(\'th_chat_profile\', \'plugin.php?id=th_chat:profile&uid='.$uid_p.'\');return false;"><img src="'.avatar($uid_p,'small',1).'" title="'.$username.'" class="nzchatavatar" onError="this.src=\'uc_server/images/noavatar_small.gif\';" /></a>
</td>
<td class="nzcontentt">
'.getat2($uid_p).'<span class="nztime" title="'.date("c",$time).'">'.get_date($time).'</span> <span id="nzchatquota'.$id.'" class="nzcq"><a href="javascript:void(0);" onClick="nzQuota('.$id.')">อ้างอิง</a>'.($uid!=$uid_p?' <a href="javascript:void(0);" onclick="nzAt(\''.$username.'\')">@</a> <a href="javascript:void(0);" onclick="nzTouid('.$uid_p.')">กระซิบ</a> ':'').((($config['editmsg']==1)&&$mod)||(($config['editmsg']==2)&&$mod&&($uid==$uid_p))||(($config['editmsg']==3)&&($uid==$uid_p))?' <a href="javascript:;" onClick=\'nzCommand("edit","'.$id.'");\'>แก้ไข</a>':'').($mod?' <a href="javascript:;" onClick=\'nzCommand("del","'.$id.'");\'>ลบ</a>':'').'</span>
'.getat2($uid_p).'<span class="nztime" title="'.date("c",$time).'">'.get_date($time).'</span> <span id="nzchatquota'.$id.'" class="nzcq"><a href="javascript:void(0);" onClick="nzQuota('.$id.')">อ้างอิง</a>'.($uid!=$uid_p?' <a href="javascript:void(0);" onclick="nzAt(\''.addslashes($username).'\')">@</a> <a href="javascript:void(0);" onclick="nzTouid('.$uid_p.')">กระซิบ</a> ':'').((($config['editmsg']==1)&&$mod)||(($config['editmsg']==2)&&$mod&&($uid==$uid_p))||(($config['editmsg']==3)&&($uid==$uid_p))?' <a href="javascript:;" onClick=\'nzCommand("edit","'.$id.'");\'>แก้ไข</a>':'').($mod?' <a href="javascript:;" onClick=\'nzCommand("del","'.$id.'");\'>ลบ</a>':'').'</span>
<br>
<div class="nzinnercontent">'.$tag.$text.'</div>
</td>
Expand All @@ -79,15 +76,5 @@ function get_date($timestamp)
$strMonthThai=$strMonthCut[$strMonth];
return "$strDay $strMonthThai $strYear $strHour:$strMinute";
}
function paddslashes($data) {
if(is_array($data)) {
foreach($data as $key => $val) {
$data[paddslashes($key)] = paddslashes($val);
}
} else {
$data = str_replace(array('\\','\''),array('\\\\','\\\''),$data);
}
return $data;
}
$time = time();
$time = TIMESTAMP;
?>
3 changes: 1 addition & 2 deletions th_chat/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
`uid` mediumint(8) unsigned NOT NULL,
`total` tinyint(1) unsigned NOT NULL DEFAULT '0',
`time` int(10) unsigned NOT NULL DEFAULT '0',
`point_time` int(10) unsigned NOT NULL DEFAULT '0',
`point_total` smallint(3) NOT NULL DEFAULT '0',
`sound_1` int(1) NOT NULL DEFAULT '0',
`sound_2` int(1) NOT NULL DEFAULT '1',
`ban` INT(10) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
Expand Down
85 changes: 42 additions & 43 deletions th_chat/js/th_chat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var nzchatobj = jQuery.noConflict();

var nzsid = getcookie('sid', true);
var nztime1 = new Date().getTime();
var nztime2 = 0;
Expand All @@ -21,11 +22,20 @@ function nzolout() {

function nzalert(text) {
nzchatobj('#nzalertbox').text(text);
nzchatobj('#nzalertbox').slideDown();
nzchatobj('#nzalertbox').slideDown(200);
setTimeout(function () {
nzchatobj('#nzalertbox').slideUp();
}, 3000);
nzchatobj('#nzalertbox').slideUp(200);
}, 2000);
}

nzchatobj.ajaxSetup({
timeout: 2000,
error: function(jqXHR, textStatus, errorThrown) {
nzalert('เกิดข้อผิดพลาด: ไม่สามารถเชื่อมต่อกับเซิฟเวอร์ได้');
setTimeout(nzLoadText, nzsetting.reload);
}
});

nzchatobj(function () {
nzchatobj("#nzchatmessage").keydown(function (event) {
if (event.keyCode == '13') {
Expand Down Expand Up @@ -199,14 +209,13 @@ function nzSend() {
'quota': nzquota,
'command': nzcommandz
}, function (data) {

if (nzquota > 0 || nzcommandz == 'notice' || nzcommandz.substr(0, 4) == 'edit') {
nzTouid(0);
}
data = JSON.parse(data);
if (data.type == 1) {
nzalert(data.error);
if (data.script_add == 1) {
if (data.script == 1) {
eval(data.script);
}
} else {
Expand Down Expand Up @@ -248,10 +257,14 @@ function nzCommand(command, xid) {
nzcommandz = 'edit ' + xid;
nzchatobj(".nzquoteboxi").html('<div><div class="nzquoteboxh">แก้ไขข้อความ</div>' + nzchatobj("#nzrows_" + xid + " .nzinnercontent")[0].outerHTML + '</div><div class="nzcancel" onclick="nzTouid(0)" title="ยกเลิก"></div>');
nzchatobj(".nzquoteboxi .nzcq").remove();
nzchatobj(".nzquoteboxi .nzblockquote").remove();
nzchatobj(".nzquoteboxi .nztag").remove();
nzchatobj(".nzquoteboxi .nztag2").remove();
nzchatobj(".nzquoteboxi .nztag3").remove();
nzchatobj(".nzquoteboxo").show();
nzchatobj("#nzchatcontent").css('height',nzchatheight - nzchatobj(".nzquoteboxo").height() - 2);
nzScrollChat(true);
nzchatobj("#nzchatmessage").val(nzchatobj("#nzchatcontent" + xid).text());
nzchatobj("#nzchatmessage").val(nzchatobj(".nzquoteboxi .nzinnercontent").text());
nzchatobj("#nzchatmessage").focus();
return;
} else if (command == 'ban') {
Expand All @@ -260,10 +273,6 @@ function nzCommand(command, xid) {
} else if (command == 'unban') {
var show = 'ปลดแบน';
var showid = ' ' + nzchatobj("#nzolpro_" + xid).text() + '(UID: ' + xid + ')';
} else if (command == 'point') {
var show = 'ให้คะแนน';
var n = xid.split("|");
var showid = ' ' + n[1] + ' แก่ ' + nzchatobj("#nzolpro_" + n[0]).text() + '(UID: ' + xid + ')';
} else if (command == 'clear') {
var show = 'ล้างห้องแชท';
var showid = '';
Expand Down Expand Up @@ -323,36 +332,34 @@ function nzLoadText() {
nzchatobj.post("plugin.php?id=th_chat:new", {
'lastid': nzlastid
}, function (data) {
if (data != 'not') {
data = JSON.parse(data);
var listmess = sortObject(data.chat_row);
nzReadyForScroll();
nzchatobj.each(listmess, function (k, v) {
k = parseInt(k);
if (k > nzlastid) {
nzlastid = k;
nzchatobj("#afterme").before(v);
nzScrollChat();
}
});
nzchatobj('.nzinnercontent img').one('load', function () {
data = JSON.parse(data);
var listmess = sortObject(data.chat_row);
nzReadyForScroll();
nzchatobj.each(listmess, function (k, v) {
k = parseInt(k);
if (k > nzlastid) {
nzlastid = k;
nzchatobj("#afterme").before(v);
nzScrollChat();
});
if (nzsetting.iscleardata == 1) {
var nzchatrr = nzchatobj(".nzchatrow");
if (nzchatrr.size() > nzsetting.chatrowmax) {
nzchatrr.first().remove();
}
}
if (data.chat_online) {
if (!nzonol) {
nzchatobj("#nzchatolcontent").html(data.chat_online);
}
nzchatobj("#nzoltotal").html(data.chat_online_total);
});
nzchatobj('.nzinnercontent img').one('load', function () {
nzScrollChat();
});
if (nzsetting.iscleardata == 1) {
var nzchatrr = nzchatobj(".nzchatrow");
if (nzchatrr.size() > nzsetting.chatrowmax) {
nzchatrr.first().remove();
}
}
if (data.chat_online) {
if (!nzonol) {
nzchatobj("#nzchatolcontent").html(data.chat_online);
}
nzchatobj("#nzoltotal").html(data.chat_online_total);
}
setTimeout(nzLoadText, nzsetting.reload);
});
setTimeout(nzLoadText, nzsetting.reload);
}

function nzQuota(i) {
Expand Down Expand Up @@ -450,14 +457,6 @@ function nzCheckImg(i) {
}
}

function nzPlusone(nz_uid, nz_type) {
var nz_res = prompt('เหตุผล');
if (nz_res == null) {
nz_res = "";
}
nzCommand('point', nz_uid + '|' + nz_type + '|' + nz_res);
}

function sortObject(a) {
var b = {},
c, d = [];
Expand Down
Loading

0 comments on commit cadfa68

Please sign in to comment.