-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathchat.php
52 lines (46 loc) · 1.56 KB
/
chat.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
define('CURSCRIPT', 'chat');
require './include/common.inc.php';
//require_once GAME_ROOT.'./include/JSON.php';
if(!$cuser || !defined('IN_GAME')) {
exit('Not in game.');
}
if(($sendmode == 'send')&&$chatmsg) {
$result = $db->query("SELECT pid FROM {$tablepre}players WHERE name='$cuser' AND type='0'");
if(!$db->num_rows($result)) exit('Not in game.');
if(strpos($chatmsg,'/') === 0) {
$result = $db->query("SELECT groupid FROM {$gtablepre}users WHERE username='$cuser'");
$groupid = $db->result($result);
if($groupid > 1) {
if(strpos($chatmsg,'/post') === 0) {
$chatmsg = substr($chatmsg,6);
if($chatmsg){
$db->query("INSERT INTO {$tablepre}chat (type,`time`,send,msg) VALUES ('4','$now','$cuser','$chatmsg')");
}
} else {
$chatdata = array('lastcid' => $lastcid, 'msg' => Array('<span class="red">指令错误。</span><br>'));
}
} else {
$chatdata = array('lastcid' => $lastcid, 'msg' => Array('<span class="red">聊天信息不能用 / 开头。</span><br>'));
}
} else {
if($chattype == 0) {
$db->query("INSERT INTO {$tablepre}chat (type,`time`,send,msg) VALUES ('0','$now','$cuser','$chatmsg')");
} elseif($chattype == 1) {
$db->query("INSERT INTO {$tablepre}chat (type,`time`,send,recv,msg) VALUES ('1','$now','$cuser','$teamID','$chatmsg')");
}
}
}
if(!$chatdata) {
$chatdata = getchat($lastcid,$teamID);
}
if(!$emdata) {
$emdata = get_emdata();
}
ob_clean();
//$json = new Services_JSON();
//$jgamedata = $json->encode($chatdata);
$jgamedata = compatible_json_encode($chatdata);
echo $jgamedata;
ob_end_flush();
?>