forked from sillycross/dts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
modulemng.php
executable file
·200 lines (187 loc) · 7.9 KB
/
modulemng.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
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
197
198
199
200
<?php
header('Content-Type: text/HTML; charset=utf-8');
define('IN_MODULEMNG', TRUE);
define('IN_GAME', TRUE);
define('GAME_ROOT', dirname(__FILE__).'/');
error_reporting(0);
$magic_quotes_gpc = get_magic_quotes_gpc();
require GAME_ROOT.'./include/global.func.php';
check_authority();
include GAME_ROOT.'./include/modulemng/modulemng.config.php';
require GAME_ROOT.'./include/modulemng/modulemng.func.php';
require GAME_ROOT.'./include/modules/modules.func.php';
register_shutdown_function('shutDownFunction');
function shutDownFunction() {
$error = error_get_last();
global $faillog;
if ($faillog!='')
{
echo $faillog;
echo '<br>或者因为如下原因:';
var_dump($error);
echo '<br><a href="modulemng.php?mode=edit" style="text-decoration: none"><span><font color="blue">[返回编辑模式]</font></span></a><br>';
die();
}
}
if (file_exists(GAME_ROOT.'./gamedata/modules.list.pass.php'))
{
unlink(GAME_ROOT.'./gamedata/modules.list.pass.php');
}
if (!file_exists(GAME_ROOT.'./gamedata/modules.list.temp.php'))
{
copy(GAME_ROOT.'./gamedata/modules.list.php',GAME_ROOT.'./gamedata/modules.list.temp.php');
}
$page = 'index';
if($_GET['mode']=='advmng')
{
//$edfmt = Array('___MOD_CODE_ADV1'=>'int','___MOD_CODE_ADV2'=>'int','___MOD_CODE_ADV3'=>'int','___MOD_SRV'=>'int');
if($_GET['action'] == 'turn_on') $edvar = 1;
elseif($_GET['action'] == 'turn_off') $edvar = 0;
if($_GET['type'] == 1) {
if ($edvar) $edcfg = array('___MOD_CODE_ADV1' => 1);
else $edcfg = array('___MOD_CODE_ADV1' => 0, '___MOD_CODE_ADV2' => 0, '___MOD_CODE_ADV3' => 0, '___MOD_SRV' => 0);
} elseif($_GET['type'] == 2) {
if ($edvar) $edcfg = array('___MOD_CODE_ADV1' => 1, '___MOD_CODE_ADV2' => 1);
else $edcfg = array('___MOD_CODE_ADV2' => 0, '___MOD_CODE_ADV3' => 0, '___MOD_SRV' => 0);
} elseif($_GET['type'] == 3) {
if ($edvar) $edcfg = array('___MOD_CODE_ADV1' => 1, '___MOD_CODE_ADV2' => 1, '___MOD_CODE_ADV3' => 1);
else $edcfg = array('___MOD_CODE_ADV3' => 0);
} elseif($_GET['type'] == 4) {
if ($edvar) $edcfg = array('___MOD_CODE_ADV1' => 1, '___MOD_CODE_ADV2' => 1, '___MOD_SRV' => 1);
else $edcfg = array('___MOD_SRV' => 0);
}
if(isset($edcfg) && isset($edvar)){
foreach($edcfg as $ek => $ev){
$mf=GAME_ROOT.'./include/modulemng/modulemng.config.php';
$config_cont = file_get_contents($mf);
$config_cont = preg_replace("/[$]{$ek}\s*\=\s*-?[0-9]+;/is", "\${$ek} = {$ev};", $config_cont);
file_put_contents($mf,$config_cont);
}
}
include GAME_ROOT.'./include/modulemng/modulemng.config.php';
}
if ($_GET['mode']=='edit' || $_GET['action']=='reset')
{
$page = 'edit';
if ($_GET['action']=='reset')
{
copy(GAME_ROOT.'./gamedata/modules.list.php',GAME_ROOT.'./gamedata/modules.list.temp.php');
$res = "<span><font color=\"green\">成功重置到原先状态。</font></span><br><br>";
}
}
elseif ($_GET['action']=='enable')
{
$sid=(int)$_GET['sid'];
$file=GAME_ROOT.'./gamedata/modules.list.temp.php';
$content=openfile($file);
$in=sizeof($content); $n=0;
if (0<=$sid && $sid<$in)
{
$a = explode(',',$content[$sid]);
$a[2]=1;
$content[$sid]=implode(',',$a);
writeover_array($file,$content);
}
$page = 'edit';
$res = '<br>点击保存后修改才能生效!<br><br>';
}
elseif ($_GET['action']=='disable')
{
$sid=(int)$_GET['sid'];
$file=GAME_ROOT.'./gamedata/modules.list.temp.php';
$content=openfile($file);
$in=sizeof($content); $n=0;
if (0<=$sid && $sid<$in)
{
$a = explode(',',$content[$sid]);
$a[2]=0;
$content[$sid]=implode(',',$a);
writeover_array($file,$content);
}
$page = 'edit';
$res = '<br>点击保存后修改才能生效!<br><br>';
}
elseif ($_GET['action']=='save')
{
$res=module_validity_check(GAME_ROOT.'./gamedata/modules.list.temp.php');
echo '<br><span><font size=5>模块管理系统</font></span><br><br>';
$page = 'checking';
if ($res === 1)
{
echo "<span>没有发现致命错误,请阅读以下日志,如没有问题,请点击“<font color=\"red\">应用更改</font>”按钮令更改生效。</span><br><br>";
echo "<span><font color=\"green\">没有发现问题。</font></span><br><br>";
echo "<span>应用更改可能会花费几秒钟,请耐心等待。</span><br><br>";
if(isset($_GET['mode']) && 'quick'==$_GET['mode']) $href = 'modulemng_activate.php?mode=quick';
else $href = 'modulemng_activate.php';
echo '<a href="'.$href.'" style="text-decoration: none"><span><font color="red">[应用更改]</font></span></a> <a href="modulemng.php?mode=edit" style="text-decoration: none"><span><font color="blue">[返回编辑模式]</font></span></a><br>';
copy(GAME_ROOT.'./gamedata/modules.list.php',GAME_ROOT.'./gamedata/modules.list.temp.php');
die();
}
else
{
echo $res;
echo '<br><a href="modulemng.php?mode=edit" style="text-decoration: none"><span><font color="blue">[返回编辑模式]</font></span></a><br>';
die();
}
}
elseif ($_GET['moduleaction']=='activate')
{
$page = 'activating';
$res=module_change_apply();
}
elseif ($_GET['action']=='remove')
{
$page = 'edit';
$sid=(int)$_GET['sid'];
$file=GAME_ROOT.'./gamedata/modules.list.php';
$content=openfile($file);
$in=sizeof($content); $n=0;
if (0<=$sid && $sid<$in)
{
$a = explode(',',$content[$sid]);
if ($a[2]==0)
{
$content2=Array();
for ($i=0; $i<$in; $i++) if ($i!=$sid) array_push($content2,$content[$i]);
$content=$content2;
writeover_array($file,$content);
copy(GAME_ROOT.'./gamedata/modules.list.php',GAME_ROOT.'./gamedata/modules.list.temp.php');
}
}
}
elseif ($_POST['action']=='add')
{
$file=GAME_ROOT.'./gamedata/modules.list.php';
$content=openfile($file);
if ($_POST['modpath'][strlen($_POST['modpath'])-1]!='/') $_POST['modpath'].='/';
$s=$_POST['modname'].','.$_POST['modpath'].',0';
$in=sizeof($content); $content[$in]=$s;
writeover_array($file,$content);
copy(GAME_ROOT.'./gamedata/modules.list.php',GAME_ROOT.'./gamedata/modules.list.temp.php');
$page = 'edit';
}
if($page == 'index') {
echo '<br><span><font size=5>模块管理系统</font></span><br><br>';
echo show_adv_state().'<br>';
echo '<a href="modulemng.php?mode=edit" style="text-decoration: none"><span><font color="red">[进入编辑模式]</font></span></a> 添加或修改模块可用性。<br>';
echo '<a href="modulemng.php?action=save" style="text-decoration: none"><span><font color="green">[重设代码缓存]</font></span></a> 整体重设模块结构和adv模式代码。<br>';
echo '<a href="modulemng.php?action=save&mode=quick" style="text-decoration: none"><span><font color="green">[重设代码缓存(快速)]</font></span></a> 只重设有改动的代码函数。新增模块或函数时切勿使用。<br><br>';
//printmodtable(GAME_ROOT.'./gamedata/modules.list.php',1);
}elseif($page == 'edit'){
echo '<br><span><font size=5>模块管理系统<font size=4 color="red"> 编辑模式</font></font></span><br><br>';
if(isset($res)) echo $res;
echo '<a href="modulemng.php?action=reset" style="text-decoration: none"><span><font color="red">[重置]</font></span></a>
<a href="modulemng.php?action=save" style="text-decoration: none"><span><font color="green">[保存]</font></span></a>
<a href="modulemng.php" style="text-decoration: none"><span><font color="blue">[返回]</font></span></a><br><br>';
echo '<font color="green">添加模块:</font><br>
<form method="post" name="addmodule" action="modulemng.php">
<input name="action" value="add" type="hidden">
模块名<input name="modname" size="20" maxlength="100" value="" type="text">
路径<input name="modpath" size="20" maxlength="100" value="" type="text">
<input name="enter" value="添加" type="submit">
</form>模块名务必不要打错,这个系统是不检查的。<br>路径基准位置是./include/modules<br>
例: 添加位于./include/modules/core/sys的sys模块,应填写路径“core/sys”和模块名“sys”<br><br>';
printmodtable(GAME_ROOT.'./gamedata/modules.list.temp.php');
}
/* End of file modulemng.php */
/* Location: /modulemng.php */