'.$tag.$text.'
diff --git a/th_chat/img.inc.php b/th_chat/img.inc.php
index 6916de4..72eb91f 100644
--- a/th_chat/img.inc.php
+++ b/th_chat/img.inc.php
@@ -2,9 +2,7 @@
if (!defined('IN_DISCUZ')) {exit('Access Denied');}
loadcache('plugin');
$config = $_G['cache']['plugin']['th_chat'];
-$uid = $_G['uid'];
-$is_mod = in_array($_G['adminid'], array(1, 2, 3));
-if ($uid < 1) {
+if ($_G['uid'] < 1) {
die('Login');
}
@@ -14,7 +12,6 @@
{
unlink(__DIR__ . '/img_up/' . $file->getFilename());
}
-
}
$files = glob(__DIR__ . '/img_up/' . $_G['uid'] . '_*');
diff --git a/th_chat/js/th_chat.js b/th_chat/js/th_chat.js
index 96f3e64..79b1408 100644
--- a/th_chat/js/th_chat.js
+++ b/th_chat/js/th_chat.js
@@ -34,7 +34,7 @@ function nzalert(text) {
nzchatobj.ajaxSetup({
timeout: 2000,
error: function (jqXHR, textStatus, errorThrown) {
- nzalert('เกิดข้อผิดพลาด: ไม่สามารถเชื่อมต่อกับเซิฟเวอร์ได้');
+ nzalert('ขาดเชื่อมต่อกับเซิฟเวอร์ กำลังลองใหม่...');
nzResetInterval();
}
});
@@ -200,7 +200,7 @@ function nzSend() {
data = JSON.parse(data);
if (data.type == 1) {
nzalert(data.error);
- if (data.script == 1) {
+ if (data.script) {
eval(data.script);
}
} else {
diff --git a/th_chat/js/th_chat.min.js b/th_chat/js/th_chat.min.js
index fa559da..1599e8a 100644
--- a/th_chat/js/th_chat.min.js
+++ b/th_chat/js/th_chat.min.js
@@ -1 +1 @@
-var nzchatobj=jQuery.noConflict(),nzsid=getcookie("sid",!0),nztime1=(new Date).getTime(),nztime2=0,nztouid=0,nzquota=0,nzlastid=0,nzonol=!1,nzcommandz="",formhash="",nzChatPopupContent="",nzscroll=!0,nzChatRoom=0,nzChatList=0,nzInterval;function nzolover(){nzonol=!0}function nzolout(){nzonol=!1}function nzalert(n){nzchatobj("#nzalertbox").text(n),nzchatobj("#nzalertbox").slideDown(200),setTimeout(function(){nzchatobj("#nzalertbox").slideUp(200)},2e3)}function nzNotice(){nzcommandz="notice",nzchatobj(".nzquoteboxi").html('
แก้ไขประกาศ : '+nzchatobj("#nzchatnotice").html()+'
'),nzchatobj(".nzquoteboxo").show(),nzchatobj("#nzchatcontent").css("height",nzsetting.chatheight-nzchatobj(".nzquoteboxo").height()),nzScrollChat(!0),nzchatobj("#nzchatmessage").val(nzchatobj("#nzchatnotice").text()),nzchatobj("#nzchatmessage").focus()}function nzChatPopup(n){nzChatPopupContent=nzchatobj(n).next(".nzchatpopuph").html(),nzchatobj("#th_chat_popup_box").html(nzChatPopupContent),showWindow("th_chat_popup","plugin.php?id=th_chat:popup")}function nzSend(){var data=nzchatobj.trim(nzchatobj("#nzchatmessage").val());if(""===data)return!1;nztime1=(new Date).getTime(),nztime1>nztime2?(nzchatobj("#nzchatmessage").val(""),nztime2=nztime1+nzsetting.delay,nzchatobj.post("plugin.php?id=th_chat:post"+formhash,{text:data,lastid:nzlastid,touid:nztouid,quota:nzquota,command:nzcommandz,room:nzChatRoom},function(data){if((nzquota>0||"notice"==nzcommandz||"edit"==nzcommandz.substr(0,4))&&nzTouid(0),data=JSON.parse(data),1==data.type)nzalert(data.error),1==data.script&&eval(data.script);else if(nztouid==nzChatRoom){var listmess=sortObject(data);if(nzReadyForScroll(),nzchatobj.each(listmess,function(n,t){(n=parseInt(n))>nzlastid&&(nzlastid=n,nzchatobj("#afterme").before(t),nzScrollChat())}),nzchatobj(".nzinnercontent img").one("load",function(){nzScrollChat()}),1==nzsetting.iscleardata){var nzchatrr=nzchatobj(".nzchatrow");nzchatrr.size()>nzsetting.chatrowmax&&nzchatrr.first().remove()}}else nzChangeChatRoom(nztouid)})):nzalert("ส่งข้อความบ่อยไป")}function nzCommand(n,t){if(""==n)nzalert("คำสั่งผิดพลาด");else{if("del"==n)var o="ลบข้อความ",a=" "+nzchatobj("#nzchatcontent"+t).text();else{if("edit"==n)return nzTouid(0),nzcommandz="edit "+t,nzchatobj(".nzquoteboxi").html('
แก้ไขข้อความ
'+nzchatobj("#nzrows_"+t+" .nzinnercontent")[0].outerHTML+'
'),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",nzsetting.chatheight-nzchatobj(".nzquoteboxo").height()),nzScrollChat(!0),nzchatobj("#nzchatmessage").val(nzchatobj(".nzquoteboxi .nzinnercontent").text()),void nzchatobj("#nzchatmessage").focus();if("ban"==n)o="แบน",a=" "+nzchatobj("#nzolpro_"+t).text()+"(UID: "+t+")";else if("unban"==n)o="ปลดแบน",a=" "+nzchatobj("#nzolpro_"+t).text()+"(UID: "+t+")";else if("clear"==n)o="ล้างห้องแชท",a=""}1==confirm("คุณต้องการที่จะ"+o+a+" ?")&&(nzchatobj("#nzchatmessage").val("!"+n+" "+t),nzSend())}}function nzLoadTextInit(){nzchatobj.post("plugin.php?id=th_chat:newinit",{room:nzChatRoom,list:nzChatList},function(n){n=JSON.parse(n),nzlastid=n.lastid,nzchatobj("#nzchatcontent").html('
'),nzScrollChat(!0),nzchatobj(".nzinnercontent img").one("load",function(){nzScrollChat()}),nzonol||nzchatobj("#nzchatolcontent").html(n.datachatonline),nzchatobj("#nzoltotal").html(n.chat_online_total),n.chat_unread&&n.chat_unread>0?(nzchatobj("#nzunread").html(n.chat_unread),nzchatobj("#nzunread").show()):nzchatobj("#nzunread").hide(),nzchatobj("#nzchatnotice").html(n.welcometext),nzResetInterval()})}function nzResetInterval(){clearInterval(nzInterval),nzInterval=setInterval(nzLoadText,nzsetting.reload)}function nzChangeChatRoom(n){nzChatRoom!==n&&(nzChatRoom=n,nzLoadTextInit())}function nzScrollChat(n=!1){var t=document.getElementById("nzchatcontent");n&&(nzscroll=!0,nzchatobj("#nznewmessage").hide()),nzscroll?t.scrollTop=t.scrollHeight:nzchatobj("#nznewmessage").show()}function nzReadyForScroll(){var n=document.getElementById("nzchatcontent");nzscroll=!!nzchatobj(".nzquoteboxo:visible")||n.scrollHeight-n.scrollTop==nzsetting.chatheight}function nzLoadText(){nzchatobj.post("plugin.php?id=th_chat:new",{room:nzChatRoom,list:nzChatList,lastid:nzlastid},function(n){var t=sortObject((n=JSON.parse(n)).chat_row);if(nzReadyForScroll(),nzchatobj.each(t,function(n,t){(n=parseInt(n))>nzlastid&&(nzlastid=n,nzchatobj("#afterme").before(t),nzScrollChat())}),nzchatobj(".nzinnercontent img").one("load",function(){nzScrollChat()}),1==nzsetting.iscleardata){var o=nzchatobj(".nzchatrow");o.size()>nzsetting.chatrowmax&&o.first().remove()}n.chat_online&&(nzonol||nzchatobj("#nzchatolcontent").html(n.chat_online),nzchatobj("#nzoltotal").html(n.chat_online_total)),n.chat_unread&&n.chat_unread>0?(nzchatobj("#nzunread").html(n.chat_unread),nzchatobj("#nzunread").show()):nzchatobj("#nzunread").hide(),nzResetInterval()})}function nzQuota(n){nzTouid(0),nzchatobj("#nzrows_"+n+" .nzuserat2")[0]?nzchatobj(".nzquoteboxi").html('
'+nzchatobj("#nzrows_"+n+" .nzuserat2")[0].outerHTML+": "+nzchatobj("#nzchatcontent"+n).html()+'
'):nzchatobj(".nzquoteboxi").html('
'+nzchatobj("#nzchatcontent"+n).html()+'
'),nzchatobj(".nzquoteboxi .nzcq").remove(),nzchatobj(".nzquoteboxi .nzuserat2").toggleClass("nzuserat2 nzuserat"),nzchatobj(".nzquoteboxo").show(),nzchatobj("#nzchatcontent").css("height",nzsetting.chatheight-nzchatobj(".nzquoteboxo").height()),nzScrollChat(!0),nzquota=n,nzchatobj("#nzchatmessage").focus()}function nzAt(n){seditor_insertunit("nzchat","@"+n+" ",""),nzchatobj("#nzchatmessage").focus()}function nzTouid(n){n>0?(nzTouid(0),nzchatobj(".nzquoteboxi").html('
แชทส่วนตัวกับ '+nzchatobj(".nzat_"+n).last()[0].outerHTML+'
'),nzchatobj(".nzquoteboxi .nzcq").remove(),nzchatobj(".nzquoteboxi .nzinnercontent").remove(),nzchatobj(".nzquoteboxo").show(),nzchatobj("#nzchatcontent").css("height",nzsetting.chatheight-nzchatobj(".nzquoteboxo").height()),nztouid=n,nzChatRoom!==n&&nzChangeChatRoom(n)):(nzchatobj("#nzchatcontent").css("height",nzsetting.chatheight),"edit"==nzcommandz.substr(0,4)?nzchatobj(".nzquoteboxi .nzinnercontent").text()==nzchatobj("#nzchatmessage").val()&&nzchatobj("#nzchatmessage").val(""):"notice"==nzcommandz&&nzchatobj("#nzchatmessage").val()==nzchatobj("#nzchatnotice").text()&&nzchatobj("#nzchatmessage").val(""),nzchatobj(".nzquoteboxi").html(""),nzchatobj("#nztouid").html(""),nzchatobj(".nzquoteboxo").hide(),nztouid=0,nzquota=0,nzcommandz="",nzChatRoom>0&&nzChangeChatRoom(0))}function nzReload(){nzTouid(0),nzchatobj("#nzchatolcontent").html(""),nzchatobj("#nzchatnotice").html("กำลังโหลดประกาศล่าสุด..."),nzchatobj("#nzchatcontent").html('
'),nzchatobj.post("plugin.php?id=th_chat:newinit",function(n){n=JSON.parse(n),nzlastid=n.lastid,nzchatobj("#nzchatcontent").html('
'),nzScrollChat(!0),nzchatobj(".nzinnercontent img").one("load",function(){nzScrollChat()}),nzchatobj("#nzchatolcontent").html(n.datachatonline),nzchatobj("#nzchatnotice").html(n.welcometext)})}function nzClean(){nzchatobj(".nzchatrow").fadeOut("slow")}function nzCheckImg(n){var t=parseInt(n.width),o=parseInt(n.height);t>500&&(n.style.cursor="pointer",n.onclick=function(){window.open(this.src,"ImageViewer","resizable=1").focus()},o*=500/t,t=500,n.height=o,n.width=t),o>240&&(n.style.cursor="pointer",n.onclick=function(){window.open(this.src,"ImageViewer","resizable=1").focus()},n.width=240/o*t,n.height=240)}function sortObject(n){var t,o={},a=[];for(t in n)n.hasOwnProperty(t)&&a.push(t);for(a.sort(),t=0;t
{nzchatobj("#nzchatmessage").val(nzchatobj("#nzchatmessage").val()+n)}),nzchatobj("#nzemoji").click(function(){n.togglePicker(this)}),nzchatobj("#nznewmessage").click(function(){nzScrollChat(!0)}),nzchatobj("#nzchatmessage").keydown(function(n){"13"==n.keyCode&&nzSend()}),nzchatobj("#nzchatcontent").scroll(function(){var n=document.getElementById("nzchatcontent");n.scrollHeight-n.scrollTop==nzsetting.chatheight&&(nzchatobj("#nznewmessage").hide(),n.scrollTop=n.scrollHeight)})});
\ No newline at end of file
+var nzchatobj=jQuery.noConflict(),nzsid=getcookie("sid",!0),nztime1=(new Date).getTime(),nztime2=0,nztouid=0,nzquota=0,nzlastid=0,nzonol=!1,nzcommandz="",formhash="",nzChatPopupContent="",nzscroll=!0,nzChatRoom=0,nzChatList=0,nzInterval;function nzolover(){nzonol=!0}function nzolout(){nzonol=!1}function nzalert(n){nzchatobj("#nzalertbox").text(n),nzchatobj("#nzalertbox").slideDown(200),setTimeout(function(){nzchatobj("#nzalertbox").slideUp(200)},2e3)}function nzNotice(){nzcommandz="notice",nzchatobj(".nzquoteboxi").html('แก้ไขประกาศ : '+nzchatobj("#nzchatnotice").html()+'
'),nzchatobj(".nzquoteboxo").show(),nzchatobj("#nzchatcontent").css("height",nzsetting.chatheight-nzchatobj(".nzquoteboxo").height()),nzScrollChat(!0),nzchatobj("#nzchatmessage").val(nzchatobj("#nzchatnotice").text()),nzchatobj("#nzchatmessage").focus()}function nzChatPopup(n){nzChatPopupContent=nzchatobj(n).next(".nzchatpopuph").html(),nzchatobj("#th_chat_popup_box").html(nzChatPopupContent),showWindow("th_chat_popup","plugin.php?id=th_chat:popup")}function nzSend(){var data=nzchatobj.trim(nzchatobj("#nzchatmessage").val());if(""===data)return!1;nztime1=(new Date).getTime(),nztime1>nztime2?(nzchatobj("#nzchatmessage").val(""),nztime2=nztime1+nzsetting.delay,nzchatobj.post("plugin.php?id=th_chat:post"+formhash,{text:data,lastid:nzlastid,touid:nztouid,quota:nzquota,command:nzcommandz,room:nzChatRoom},function(data){if((nzquota>0||"notice"==nzcommandz||"edit"==nzcommandz.substr(0,4))&&nzTouid(0),data=JSON.parse(data),1==data.type)nzalert(data.error),data.script&&eval(data.script);else if(nztouid==nzChatRoom){var listmess=sortObject(data);if(nzReadyForScroll(),nzchatobj.each(listmess,function(n,t){(n=parseInt(n))>nzlastid&&(nzlastid=n,nzchatobj("#afterme").before(t),nzScrollChat())}),nzchatobj(".nzinnercontent img").one("load",function(){nzScrollChat()}),1==nzsetting.iscleardata){var nzchatrr=nzchatobj(".nzchatrow");nzchatrr.size()>nzsetting.chatrowmax&&nzchatrr.first().remove()}}else nzChangeChatRoom(nztouid)})):nzalert("ส่งข้อความบ่อยไป")}function nzCommand(n,t){if(""==n)nzalert("คำสั่งผิดพลาด");else{if("del"==n)var o="ลบข้อความ",a=" "+nzchatobj("#nzchatcontent"+t).text();else{if("edit"==n)return nzTouid(0),nzcommandz="edit "+t,nzchatobj(".nzquoteboxi").html('แก้ไขข้อความ
'+nzchatobj("#nzrows_"+t+" .nzinnercontent")[0].outerHTML+'
'),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",nzsetting.chatheight-nzchatobj(".nzquoteboxo").height()),nzScrollChat(!0),nzchatobj("#nzchatmessage").val(nzchatobj(".nzquoteboxi .nzinnercontent").text()),void nzchatobj("#nzchatmessage").focus();if("ban"==n)o="แบน",a=" "+nzchatobj("#nzolpro_"+t).text()+"(UID: "+t+")";else if("unban"==n)o="ปลดแบน",a=" "+nzchatobj("#nzolpro_"+t).text()+"(UID: "+t+")";else if("clear"==n)o="ล้างห้องแชท",a=""}1==confirm("คุณต้องการที่จะ"+o+a+" ?")&&(nzchatobj("#nzchatmessage").val("!"+n+" "+t),nzSend())}}function nzLoadTextInit(){nzchatobj.post("plugin.php?id=th_chat:newinit",{room:nzChatRoom,list:nzChatList},function(n){n=JSON.parse(n),nzlastid=n.lastid,nzchatobj("#nzchatcontent").html(''),nzScrollChat(!0),nzchatobj(".nzinnercontent img").one("load",function(){nzScrollChat()}),nzonol||nzchatobj("#nzchatolcontent").html(n.datachatonline),nzchatobj("#nzoltotal").html(n.chat_online_total),n.chat_unread&&n.chat_unread>0?(nzchatobj("#nzunread").html(n.chat_unread),nzchatobj("#nzunread").show()):nzchatobj("#nzunread").hide(),nzchatobj("#nzchatnotice").html(n.welcometext),nzResetInterval()})}function nzResetInterval(){clearInterval(nzInterval),nzInterval=setInterval(nzLoadText,nzsetting.reload)}function nzChangeChatRoom(n){nzChatRoom!==n&&(nzChatRoom=n,nzLoadTextInit())}function nzScrollChat(n=!1){var t=document.getElementById("nzchatcontent");n&&(nzscroll=!0,nzchatobj("#nznewmessage").hide()),nzscroll?t.scrollTop=t.scrollHeight:nzchatobj("#nznewmessage").show()}function nzReadyForScroll(){var n=document.getElementById("nzchatcontent");nzscroll=!!nzchatobj(".nzquoteboxo:visible")||n.scrollHeight-n.scrollTop==nzsetting.chatheight}function nzLoadText(){nzchatobj.post("plugin.php?id=th_chat:new",{room:nzChatRoom,list:nzChatList,lastid:nzlastid},function(n){var t=sortObject((n=JSON.parse(n)).chat_row);if(nzReadyForScroll(),nzchatobj.each(t,function(n,t){(n=parseInt(n))>nzlastid&&(nzlastid=n,nzchatobj("#afterme").before(t),nzScrollChat())}),nzchatobj(".nzinnercontent img").one("load",function(){nzScrollChat()}),1==nzsetting.iscleardata){var o=nzchatobj(".nzchatrow");o.size()>nzsetting.chatrowmax&&o.first().remove()}n.chat_online&&(nzonol||nzchatobj("#nzchatolcontent").html(n.chat_online),nzchatobj("#nzoltotal").html(n.chat_online_total)),n.chat_unread&&n.chat_unread>0?(nzchatobj("#nzunread").html(n.chat_unread),nzchatobj("#nzunread").show()):nzchatobj("#nzunread").hide(),nzResetInterval()})}function nzQuota(n){nzTouid(0),nzchatobj("#nzrows_"+n+" .nzuserat2")[0]?nzchatobj(".nzquoteboxi").html(''+nzchatobj("#nzrows_"+n+" .nzuserat2")[0].outerHTML+": "+nzchatobj("#nzchatcontent"+n).html()+'
'):nzchatobj(".nzquoteboxi").html(''+nzchatobj("#nzchatcontent"+n).html()+'
'),nzchatobj(".nzquoteboxi .nzcq").remove(),nzchatobj(".nzquoteboxi .nzuserat2").toggleClass("nzuserat2 nzuserat"),nzchatobj(".nzquoteboxo").show(),nzchatobj("#nzchatcontent").css("height",nzsetting.chatheight-nzchatobj(".nzquoteboxo").height()),nzScrollChat(!0),nzquota=n,nzchatobj("#nzchatmessage").focus()}function nzAt(n){seditor_insertunit("nzchat","@"+n+" ",""),nzchatobj("#nzchatmessage").focus()}function nzTouid(n){n>0?(nzTouid(0),nzchatobj(".nzquoteboxi").html('แชทส่วนตัวกับ '+nzchatobj(".nzat_"+n).last()[0].outerHTML+'
'),nzchatobj(".nzquoteboxi .nzcq").remove(),nzchatobj(".nzquoteboxi .nzinnercontent").remove(),nzchatobj(".nzquoteboxo").show(),nzchatobj("#nzchatcontent").css("height",nzsetting.chatheight-nzchatobj(".nzquoteboxo").height()),nztouid=n,nzChatRoom!==n&&nzChangeChatRoom(n)):(nzchatobj("#nzchatcontent").css("height",nzsetting.chatheight),"edit"==nzcommandz.substr(0,4)?nzchatobj(".nzquoteboxi .nzinnercontent").text()==nzchatobj("#nzchatmessage").val()&&nzchatobj("#nzchatmessage").val(""):"notice"==nzcommandz&&nzchatobj("#nzchatmessage").val()==nzchatobj("#nzchatnotice").text()&&nzchatobj("#nzchatmessage").val(""),nzchatobj(".nzquoteboxi").html(""),nzchatobj("#nztouid").html(""),nzchatobj(".nzquoteboxo").hide(),nztouid=0,nzquota=0,nzcommandz="",nzChatRoom>0&&nzChangeChatRoom(0))}function nzReload(){nzTouid(0),nzchatobj("#nzchatolcontent").html(""),nzchatobj("#nzchatnotice").html("กำลังโหลดประกาศล่าสุด..."),nzchatobj("#nzchatcontent").html(' '),nzchatobj.post("plugin.php?id=th_chat:newinit",function(n){n=JSON.parse(n),nzlastid=n.lastid,nzchatobj("#nzchatcontent").html(''),nzScrollChat(!0),nzchatobj(".nzinnercontent img").one("load",function(){nzScrollChat()}),nzchatobj("#nzchatolcontent").html(n.datachatonline),nzchatobj("#nzchatnotice").html(n.welcometext)})}function nzClean(){nzchatobj(".nzchatrow").fadeOut("slow")}function nzCheckImg(n){var t=parseInt(n.width),o=parseInt(n.height);t>500&&(n.style.cursor="pointer",n.onclick=function(){window.open(this.src,"ImageViewer","resizable=1").focus()},o*=500/t,t=500,n.height=o,n.width=t),o>240&&(n.style.cursor="pointer",n.onclick=function(){window.open(this.src,"ImageViewer","resizable=1").focus()},n.width=240/o*t,n.height=240)}function sortObject(n){var t,o={},a=[];for(t in n)n.hasOwnProperty(t)&&a.push(t);for(a.sort(),t=0;t{nzchatobj("#nzchatmessage").val(nzchatobj("#nzchatmessage").val()+n)}),nzchatobj("#nzemoji").click(function(){n.togglePicker(this)}),nzchatobj("#nznewmessage").click(function(){nzScrollChat(!0)}),nzchatobj("#nzchatmessage").keydown(function(n){"13"==n.keyCode&&nzSend()}),nzchatobj("#nzchatcontent").scroll(function(){var n=document.getElementById("nzchatcontent");n.scrollHeight-n.scrollTop==nzsetting.chatheight&&(nzchatobj("#nznewmessage").hide(),n.scrollTop=n.scrollHeight)})});
\ No newline at end of file
diff --git a/th_chat/new.inc.php b/th_chat/new.inc.php
index 3cd76e7..08e8d4e 100644
--- a/th_chat/new.inc.php
+++ b/th_chat/new.inc.php
@@ -11,28 +11,32 @@
DB::update('newz_data', array(
'unread' => 0,
), "`id`>'$id' AND `unread`=1 AND `uid`='$room' AND `touid`='$uid'");
- $re = DB::query("SELECT n.*,m.username AS name,mt.username AS toname,g.color,gt.color AS tocolor
+ $re = DB::query("SELECT n.*,m.username AS name,mt.username AS toname,g.color,gt.color AS tocolor
FROM " . DB::table('newz_data') . " n
LEFT JOIN " . DB::table('common_member') . " m ON n.uid=m.uid
LEFT JOIN " . DB::table('common_member') . " mt ON n.touid=mt.uid
LEFT JOIN " . DB::table('common_usergroup') . " g ON m.groupid=g.groupid
LEFT JOIN " . DB::table('common_usergroup') . " gt ON mt.groupid=gt.groupid
-WHERE id>{$id} AND ((n.uid='$room' AND n.touid='$uid') OR (n.uid='$uid' AND n.touid='$room'))
+WHERE id>{$id} AND ((n.touid='$uid') OR (n.uid='$uid' AND n.touid!=0) OR (n.uid='$uid' AND n.touid!=0))
ORDER BY id DESC LIMIT {$config['chat_init']}");
-} else {
- $re = DB::query("SELECT n.*,m.username AS name,mt.username AS toname,g.color,gt.color AS tocolor
+$setting_data = DB::fetch_first("SELECT setting FROM ".DB::table('newz_nick')." WHERE uid='{$_G['uid']}'");
+}else{
+ $re = DB::query("SELECT n.*,m.username AS name,mt.username AS toname,g.color,gt.color AS tocolor
FROM " . DB::table('newz_data') . " n
LEFT JOIN " . DB::table('common_member') . " m ON n.uid=m.uid
LEFT JOIN " . DB::table('common_member') . " mt ON n.touid=mt.uid
LEFT JOIN " . DB::table('common_usergroup') . " g ON m.groupid=g.groupid
LEFT JOIN " . DB::table('common_usergroup') . " gt ON mt.groupid=gt.groupid
-WHERE id>{$id} AND (n.touid='0' OR n.touid='$uid')
+WHERE id>{$id} AND ((n.touid='$uid') OR (n.touid=0))
ORDER BY id DESC LIMIT {$config['chat_init']}");
-}
$setting_data = DB::fetch_first("SELECT setting FROM ".DB::table('newz_nick')." WHERE uid='{$_G['uid']}'");
-$setting = json_decode($setting_data['setting'],1);
-$setting['sound_general'] = $setting['sound_general'] == 0 ? 0 : 1;
-$setting['sound_private'] = $setting['sound_private'] == 0 ? 0 : 1;
+}
+if($setting_data){
+ $setting = json_decode($setting_data['setting'],1);
+}else{
+ $setting['sound_general'] = 1;
+ $setting['sound_private'] = 1;
+}
$body = array();
while ($c = DB::fetch($re)) {
$c['text'] = preg_replace('/\[quota\](.*?)\[\/quota\]/', '$1', $c['text']);
@@ -46,20 +50,29 @@
$body[$c['id']] .= '';
continue;
} elseif ($room != $c['uid'] && $c['touid'] == $uid) {
- if ($config['pm_sound'] && $sounddata['sound_2']) {
+ if ($config['pm_sound'] && $setting['sound_private']) {
$body[$c['id']] .= ' ';
- }
+ }else{
+ $body[$c['id']] = '';
+ }
continue;
- }
+ } elseif ($room && $c['touid'] == 0) {
+ if($config['pm_sound'] && $setting['sound_general']){
+ $body[$c['id']] .= ' ';
+ }else{
+ $body[$c['id']] = '';
+ }
+ continue;
+ }
if ($c['ip'] == 'clear') {
$seedd = $time . '_' . $uid . '_' . rand(1, 999);
$c['text'] = 'แจ้งเตือน: ล้างข้อมูล ';
} elseif ($c['icon'] == 'alert') {
$c['text'] = '' . $c['text'] . ' ';
} elseif ($c['touid'] == 0) {
- $c['text'] = (($config['pm_sound'] && $setting['sound_general']) ? ' ' : '') . '' . $c['text'] . ' ';
+ $c['text'] = (($config['pm_sound'] && $setting['sound_general']) ? ' ' : '') . '' . $c['text'] . ' ';
} elseif ($c['touid'] == $uid) {
- $c['text'] = (($config['pm_sound'] && $setting['sound_private']) ? ' ' : '') . '' . $c['text'] . ' ';
+ $c['text'] = (($config['pm_sound'] && $setting['sound_private']) ? ' ' : '') . '' . $c['text'] . ' ';
} elseif ($c['uid'] == $uid) {
$c['text'] = '' . $c['text'] . ' ';
}
diff --git a/th_chat/newinit.inc.php b/th_chat/newinit.inc.php
index 2a09e79..a61ed25 100644
--- a/th_chat/newinit.inc.php
+++ b/th_chat/newinit.inc.php
@@ -29,13 +29,10 @@
ORDER BY id DESC LIMIT {$config['chat_init']}");
}
$body = array();
-$lastid = 0;
+$lastid = DB::fetch_first("SELECT max(id) as lastid FROM ".DB::table('newz_data'));
+$lastid = $lastid['lastid'];
while ($c = DB::fetch($re)) {
$c['text'] = preg_replace('/\[quota\](.*?)\[\/quota\]/', '$1', $c['text']);
- if ($c['id'] > $lastid) {
- $lastid = $c['id'];
- }
-
if ($c['ip'] == 'delete') {
continue;
} elseif ($c['ip'] == 'edit') {
diff --git a/th_chat/online.php b/th_chat/online.php
index 206759a..64e7472 100644
--- a/th_chat/online.php
+++ b/th_chat/online.php
@@ -53,7 +53,7 @@
if ($_POST['list']) {
$chatgroup = array();
- $re = DB::query("SELECT n.*,MAX(n.id) as maxid,SUM(n.unread) as count,m.username AS name,mt.username AS toname,g.color,gt.color AS tocolor
+ $re = DB::query("SELECT n.*,MAX(n.id) as maxid,MAX(n.time) as maxtime,SUM(n.unread) as count,m.username AS name,mt.username AS toname,g.color,gt.color AS tocolor
FROM " . DB::table('newz_data') . " n
LEFT JOIN " . DB::table('common_member') . " m ON n.uid=m.uid
LEFT JOIN " . DB::table('common_member') . " mt ON n.touid=mt.uid
@@ -77,7 +77,7 @@