- เครดิต
- 2
- เพื่อน
- ทักทาย
- บล็อก
- อัลบั้ม
- โพสต์
- กระทู้
- แชร์
- สำคัญ
- สิทธิ์อ่าน
- 10
- จำนวนผู้ติดตาม
- จำนวนผู้กำลังติดตาม
- เพศ
- ไม่บอก
|
ntf
โพสต์ 2007-11-15 13:08:58
shoutbox.js :
change to
function handle_response(request) {
var LastMsgInfo = '';
Element.hide('loading');
var response = request.responseText;
LastMsgInfo = response.substring(0, 10);
if (LastMsgInfo == 'shoutError') {
error = response.substring(10 , response.length);
Element.show('shout_error');
var shoutbox = $('shout_error_msg');
shoutbox.innerHTML = error + '\n';
Element.hide('shout_error');
shout_msg.innerHTML='System:'+error+'\n <br />'+shout_msg.innerHTML;
} else if (LastMsgInfo == 'PostedInDB') {
get_messages();
} else if (LastMsgInfo != LastMsg) {
LastMsg = LastMsgInfo;
messages = response.substring(10, response.length);
var shoutbox = $('shout_msg');
shout_display(shoutbox.innerHTML);
shoutbox.innerHTML = messages + shoutbox.innerHTML +'\n';
}
if (posting == true) {
setTimeout('input_disable(false)', 500);
if (LastMsgInfo != 'shoutError') $('req_message').value = '';
$('req_message').focus();
posting = false;
}
$('shout_msg').scrollTop = 0;
}
shoutbox.php- <?php
- // Designed by ROA
- // Edited by ntf
-
- require_once './include/common.inc.php';
- require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
- session_start();
- header('Expires: Thu, 21 Jul 1977 07:30:00 GMT+8');
- header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT+8');
- header('Cache-Control: post-check=0, pre-check=0', false);
- header('Pragma: no-cache');
- header('Content-type: text/html; charset='.$charset);
- $msg_max = 15;
- $msg_maxlength = 180;
- function utf8RawUrlDecode ($source) {
- $decodedStr = "";
- $pos = 0;
- $len = strlen ($source);
- while ($pos < $len) {
- $charAt = substr ($source, $pos, 1);
- if ($charAt == '%') {
- $pos++;
- $charAt = substr ($source, $pos, 1);
- if ($charAt == 'u') {
- $pos++;
- $unicodeHexVal = substr ($source, $pos, 4);
- $unicode = hexdec ($unicodeHexVal);
- $entity = "&#". $unicode . ';';
- $decodedStr .= utf8_encode ($entity);
- $pos += 4;
- }
- else {
- $hexVal = substr ($source, $pos, 2);
- $decodedStr .= chr (hexdec ($hexVal));
- $pos += 2;
- }
- } else {
- $decodedStr .= $charAt;
- $pos++;
- }
- }
- return $decodedStr;
- }
- function chatfunction($functioncode,$isforadmin=''){
- global $adminid,$req_message;
- if($adminid!='1' && $isforadmin=='1'){
- return false;
- }
-
- $codelong=strlen($functioncode);
- if(substr($req_message, 0,$codelong+1)=="/{$functioncode}"){
- return true;
- }else{
- return false;
- }
- }
- if (isset($ajax)) {
- if (!$discuz_uid){
- if(isset($_POST['ajax'])){
- exit('shoutError'.'??????????.');
- }else{
- exit;
- }
- }
- if (isset($_POST['ajax'])) {
- $uid = $discuz_uid;
- $timer = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);
- $deltime = $timestamp;
- $req_message = utf8RawUrlDecode($req_message);
-
- $req_message=mb_convert_encoding($req_message,"BIG5","UTF-8");
-
- $req_message = preg_replace('#(^|\s)([a-z]+://([^\s\w/]?[\w/])*)#is', '\\1[url]\\2[/url]', $req_message);
- $req_message = preg_replace('#(^|\s)((www|ftp)\.([^\s\w/]?[\w/])*)#is', '\\1[url]\\2[/url]', $req_message);
- $req_message = preg_replace('#(^|\s)(([a-z0-9._%+-]+)@(([.-]?[a-z0-9])*))#is', '\\1[email]\\2[/email]', $req_message);
- $req_message = preg_replace('#(^|\s)((www|ftp)\.([^\s\w/]?[\w/])*)#is', '\\1[url]\\2[/url]', $req_message);
- $req_message=dhtmlspecialchars($req_message);
- if (!$uid){
- exit('shoutError'.'You do not have enough posts required to use the Shoutbox.');
- }else if ($req_message == ''){
- exit('shoutError'.'???????????');
- }else if (strlen($req_message) > $msg_maxlength){
- exit('shoutError'.'??????????');
- }
-
- if(substr($req_message, 0, 1)=='/'){ // Chat Function
-
- if(chatfunction('PM')){ //PM
- $explodemessage=explode(' ',$req_message);
- $query = $db->query("SELECT uid FROM `{$tablepre}members` Where `username`='$explodemessage[1]' LIMIT 1");
- $sentuser = $db->fetch_array($query);
- if(!$sentuser[uid]){
- exit('shoutError'.'??????'); }
- $sqlmsg='';
- foreach($explodemessage as $key => $value){
- if(in_array($key,array('0','1'))){continue;}
- $sqlmsg.=' '.$value;
- }
- $db->query("INSERT INTO {$tablepre}shoutbox (uid, message, color, timer, deltime, msgtoid ) VALUES ('$uid', '$sqlmsg', 'blue', '$timer', '$deltime','$sentuser[uid]')");
-
- }elseif(chatfunction('SYSTEMECHO','1')){ // SYSTEM MESSAGE
- $explodemessage=explode(' ',$req_message);
- $sqlmsg='';
- foreach($explodemessage as $key => $value){
- if(in_array($key,array('0'))){continue;}
- $sqlmsg.=' '.$value;
- }
- $db->query("INSERT INTO {$tablepre}shoutbox (uid, message, color, timer, deltime, msgtoid ) VALUES ('0', '$sqlmsg', 'red', '$timer', '$deltime','-1')");
-
- }elseif(chatfunction('CLEAR','1')){ // SYSTEM MESSAGE
- $db->query("TRUNCATE TABLE `cdb_shoutbox` ");
-
- exit('shoutError'.'[??]????????');
-
- }elseif(chatfunction('DELETEUIDMSG','1')){ // SYSTEM MESSAGE
-
- $explodemessage=explode(' ',$req_message);
- $db->query("DELETE FROM `{$tablepre}shoutbox` WHERE `uid`='$explodemessage[1]' LIMIT 1");
-
- exit('shoutError'.'UID:'.$explodemessage[1].' Message clear.');
- }elseif(chatfunction('SHOWONLINE','1')){ // SHOW ONLINE
-
- $onlines=$comm='';
- $onlines='User Online List: ';
- $query = $db->query("SELECT s.*, m.uid, m.groupid,m.username, u.color AS groupcolor FROM {$tablepre}shoutbox s
- LEFT JOIN {$tablepre}members m ON m.uid=s.uid
- LEFT JOIN {$tablepre}usergroups u ON u.groupid=m.groupid GROUP BY m.uid");
- while($onlineuesr = $db->fetch_array($query)) {
- if($onlineuesr['username']==''){continue;}
- $onlines .=$comm;
- $onlines .=$onlineuesr['groupcolor'] ? '<font color="'.$onlineuesr['groupcolor'].'">'.$onlineuesr['username'].'</font>' : $onlineuesr['username'];
- $comm=',';
- }
- $db->query("INSERT INTO {$tablepre}shoutbox (uid, message, color, timer, deltime, msgtoid ) VALUES ('0', '$onlines', 'blue', '$timer', '$deltime','$discuz_uid')");
- }else{
-
- exit('shoutError'.'???????????` / `???????');
- }
- }else{ //FUNCTION END
-
- $db->query("INSERT INTO {$tablepre}shoutbox (uid, message, color, timer, deltime) VALUES ('$uid', '$req_message', '$req_color', '$timer', '$deltime')");
- }
คัดลอกไปที่คลิปบอร์ด
[ แก้ไขล่าสุด ntf เมื่อ 2007-11-15 14:10 ] |
|