-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.php
More file actions
196 lines (181 loc) · 5.35 KB
/
index.php
File metadata and controls
196 lines (181 loc) · 5.35 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
define('CURSCRIPT', 'index');
require './include/common.inc.php';
$timing = 0;
if($gamestate > 10) {
$timing = $now - $starttime;
} else {
if($starttime > $now) {
$timing = $starttime - $now;
} else {
$timing = 0;
}
}
$adminmsg = file_get_contents('./gamedata/adminmsg.htm') ;
$systemmsg = file_get_contents('./gamedata/systemmsg.htm') ;
if(!empty($roomact))
{
$rindex = Array();
if(!$cuser||!$cpass) {$rerror = 'no_login'; goto roommng_flag; }
if(!$udata) {$rerror = 'login_check'; goto roommng_flag;}
if($udata['password'] != $cpass) {$rerror = 'wrong_pw'; goto roommng_flag;}
if($udata['groupid'] <= 0) {$rerror = 'user_ban'; goto roommng_flag;}
if($roomact == 'create')
{
$ruleset_id = isset($ruleset) ? $ruleset : '';
roommng_create_new_room($udata, $ruleset_id);
}
elseif($roomact == 'create_ruleset')
{
$ruleset_id = isset($ruleset) ? $ruleset : '';
if (empty($ruleset_id)) {
$rerror = 'invalid_ruleset';
goto roommng_flag;
}
roommng_create_new_room($udata, $ruleset_id);
}
elseif(strpos($roomact,'join') !== false)
{
$join_id = (int)str_replace("join","",$roomact);
roommng_join_room($join_id,$udata);
}
elseif($roomact == 'exit')
{
roommng_exit_room($udata);
}
elseif($roomact == 'close')
{
roommng_close_own_room($udata);
}
unset($roomact);
roommng_flag:
if(!empty($rerror) && isset($_ERROR[$rerror])) $rindex['innerHTML']['roomerror'] = $_ERROR[$rerror];
else $rindex['url'] = 'index.php';
ob_clean();
echo compatible_json_encode($rindex);
ob_end_flush();
exit();
}
else
{
if (isset($_GET['is_new'])) {
$now_rooms = !empty($roomlist) ? count($roomlist) : 0;
$rooms = array();
// 加载RuleSet配置
include_once GAME_ROOT.'./gamedata/ruleset/ruleset_config.php';
$available_rulesets = array();
if (get_ruleset_config()) {
foreach (get_ruleset_config() as $ruleset_id => $config) {
if (!empty($cuser) && !empty($cpass) && can_create_ruleset_room($ruleset_id, $udata)) {
$available_rulesets[] = array(
'id' => $ruleset_id,
'name' => $config['name'],
'description' => $config['description'],
'cost' => $config['credits_cost'],
'admin_free' => $config['admin_free'] && $udata['groupid'] >= 2
);
}
}
}
foreach ($roomlist as $rkey => $rinfo) {
$room = array();
$room['id'] = $rkey;
$room['status'] = $gstate[$rinfo['gamestate']];
$room['owner'] = $rinfo['groomownid'];
$room['nums'] = $rinfo['groomnums'];
// 添加RuleSet信息
if (!empty($rinfo['gruleset'])) {
$ruleset_config = get_ruleset_config($rinfo['gruleset']);
$room['ruleset'] = $ruleset_config ? $ruleset_config['name'] : $rinfo['gruleset'];
} else {
$room['ruleset'] = '';
}
$action = array();
if (!empty($cuser) && !empty($cpass)) {
if (!empty($groomid)) {
if ($groomid == $rkey) {
$action[] = '退出';
if (!empty($rinfo['groomownid']) && $rinfo['groomownid'] == $cuser) {
$action[] = '解散';
}
} else {
$action[] = '-';
}
} else {
$action[] = '加入';
}
} else {
$action[] = '-';
}
$room['action'] = $action;
$rooms[] = $room;
}
echo json_encode(array(
// 当前回合数
"num" => $gamenum,
// 当前游戏状态
"state" => $gstate[$gamestate],
// 当前游戏时间
"timing" => $timing,
// 显示当前游戏时间
"showNowTime" => $gamestate > 10,
// 显示下局游戏时间
"showNextTime" => $starttime > $now,
// 最高伤害玩家
"maxDamagePlayer" => $hplayer,
// 最高伤害值
"maxDamage" => $hdamage,
// 上局结果
"lastResult" => $gwin[$winmode],
// 上局优胜者
"lastWinner" => $winner,
// 禁区
"areaHour" => $areahour,
"areaLimit" => $arealimit,
"areaAdd" => $areaadd,
"areaNum" => $areanum,
// 自动逃避禁区
"areaAutoHide" => $areaesc && $gamestate < 40,
// 人数
"validNum" => $validnum,
"aliveNum" => $alivenum,
"deathNum" => $deathnum,
// 当前房间号:
"roomID" => $groomid,
// 最大房间数
"maxRooms" => $max_rooms,
// 是否可创建房间
"canCreateRoom" => $now_rooms < $max_rooms && !$groomid && (!empty($cuser) && !empty($cpass)),
// 房间
"rooms" => $rooms,
// 可用的RuleSet
"availableRulesets" => $available_rulesets,
// RuleSet系统是否启用
"rulesetEnabled" => get_ruleset_config() !== false,
// 站长留言
"news" => $adminmsg,
// 用户名
"username" => $cuser,
// 用户切糕数量
"credits2" => !empty($udata) ? $udata['credits2'] : 0,
));
return;
} else {
include template('index');
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-9744745-2");
pageTracker._trackPageview();
} catch(err) {}</script>
</head>
</html>