-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathchat.php
More file actions
executable file
·74 lines (69 loc) · 2.5 KB
/
Copy pathchat.php
File metadata and controls
executable file
·74 lines (69 loc) · 2.5 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
define('CURSCRIPT', 'chat');
define('LOAD_CORE_ONLY', TRUE);
require './include/common.inc.php';
if($sendmode != 'newspage' && (!$cuser || !defined('IN_GAME'))) {
exit('Not in game.');
}
$ctablecorrect = 1;
//如果拉取的房间号同账号不对应则进行游戏局数判定
if((isset($cgamenum) && $gamenum != $cgamenum) || (isset($croomid) && $groomid != $croomid)){
if(room_check_gamenum($croomid, $cgamenum)) {
//如果房间存在且局数有效,则修改当前聊天房间号
$ctablepre = room_get_tablepre(room_id2prefix($croomid));
}else{
$ctablecorrect = 0;//否则标记房间号错误
}
}
if($ctablecorrect && $sendmode == 'send' && $chatmsg ) {//发送聊天
if(strpos($chatmsg,'/') === 0) {
$result = $db->query("SELECT groupid FROM {$gtablepre}users WHERE username='$cuser'");
$groupid = $db->result($result,0);
if($groupid > 1) {
if(strpos($chatmsg,'/post') === 0) {
$chatmsg = substr($chatmsg,6);
if($chatmsg){
\sys\addchat(4, $chatmsg, $cuser);
//$db->query("INSERT INTO {$tablepre}chat (type,`time`,send,msg) VALUES ('4','$now','$cuser','$chatmsg')");
}
} else {
$showdata = array('lastcid' => $lastcid, 'msg' => Array('<span class="red">指令错误。<br></span>'));
}
} else {
$showdata = array('lastcid' => $lastcid, 'msg' => Array('<span class="red">聊天信息不能用 / 开头。<br></span>'));
}
} else {
if($chattype == 0) {
\sys\addchat(0, $chatmsg, $cuser);
} elseif($chattype == 1) {
\sys\addchat(1, $chatmsg, $cuser, $teamID);
}
}
}elseif($ctablecorrect && $sendmode == 'newspage'){//来自news.php的调用
$showdata['innerHTML']['newsinfo'] = '';
$chats = getchat(0,'',0,$chatinnews);
$chatmsg = $chats['msg'];
foreach($chatmsg as $val){
$showdata['innerHTML']['newsinfo'] .= $val;
}
}
//房间号错误,显示错误信息并停止轮询js运行
if(!$ctablecorrect && $lastcid >= 0 && $gamestate > 0) {
$lastcid = -1;
$showdata = array(
'lastcid' => $lastcid,
'msg' => Array('<span class="red">房间号错误,可能是新一局游戏已开始。<br></span>'),
'cmd' => 'chat-ref-stop'
);
}
//$sendmode=='ref'时没有特殊判断,直接作下列处理
if($ctablecorrect && !$showdata) {
if($chatpid) $showdata = getchat($lastcid,$teamID,$chatpid);
else $showdata = getchat($lastcid,$teamID);
}
if(isset($error)){$showdata['innerHTML']['error'] = $error;}
ob_clean();
$jgamedata = gencode($showdata);
echo $jgamedata;
ob_end_flush();
?>