forked from ksphp/webmis-codeigniter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·261 lines (256 loc) · 10.9 KB
/
index.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<?php
$api = $_GET['api'];
/* 判断文件读写 */
if($api == 'isWrite') {
$class = is_writable('../admin/config/database.php')?'suc':'err';
echo '<div class="'.$class.'"><em> </em>admin/app/config/database.php #后台数据库配置文件</div>';
$class = is_writable('../web/config/database.php')?'suc':'err';
echo '<div class="'.$class.'"><em> </em>web/config/database.php #网站数据库配置文件</div>';
$class = is_writable('webmis.sql')?'suc':'err';
echo '<div class="'.$class.'"><em> </em>install/webmis.sql #数据库文件</div>';
$class = is_writable('../upload')?'suc':'err';
echo '<div class="'.$class.'"><em> </em>upload #文件上传目录</div>';
/* 是否可以连接数据库 */
}elseif($api == 'isDB') {
try {
$dsn = $_GET['type'].':dbname='.$_GET['dbname'].';host='.$_GET['host'];
$uname = $_GET['uname'];
$passwd = $_GET['passwd'];
$db = new PDO($dsn,$uname,$passwd);
}catch (PDOException $e) {
echo $e->getMessage();
exit;
}
}elseif($api == 'config') {
try {
$type = $_GET['type'];
$host = $_GET['host'];
$uname = $_GET['uname'];
$passwd = $_GET['passwd'];
$dbname = $_GET['dbname'];
$admin = $_GET['admin'];
$adminPWD = md5($_GET['adminPWD']);
$db = new PDO($type.':dbname='.$dbname.';host='.$host,$uname,$passwd);
$db->query('set names utf8;');
echo '<p class="suc"><em> </em>连接数据库成功!</p>';
/* 导入数据库文件 */
$content = file_get_contents('webmis.sql');
if(!$content) {
echo '<p class="err"><em> </em>打开失败:webmis.sql</p>';
}else {
echo '<p class="suc"><em> </em>打开成功:webmis.sql</p>';
$content = preg_replace("/#\n# TABLE(.*)\s#\n/i","",$content);
$content = preg_replace("/'admin'/","'".$admin."'",$content);
$content = preg_replace("/'21232f297a57a5a743894a0e4a801fc3'/","'".$adminPWD."'",$content);
echo '<p class="suc"><em> </em>写入管理员信息!</p>';
$data = '<p class="suc"><em> </em>数据导入成功!</p>';
/* 导入数据 */
$sqls = array_filter(explode(";\n",$content));
foreach($sqls as $sql){
$sql = trim($sql);
if($sql) {
if(!$db->query($sql)) {
$err = $db->errorInfo();
$data = '<p class="err"><em> </em>数据导入失败:<br>'.$err[2].'</p>';
break;
}
}
}
echo $data;
}
/* CI数据库配置文件 */
$file1 = '../admin/config/database.php';
$file2 = '../web/config/database.php';
$ct1 = file_get_contents($file1);
$ct2 = file_get_contents($file2);
if(!$ct1) {
echo '<p class="err"><em> </em>打开失败:<br>'.$file1.'</p>';
}elseif(!$ct2) {
echo '<p class="err"><em> </em>打开失败:<br>'.$file2.'</p>';
}else {
echo '<p class="suc"><em> </em>打开成功:CI数据库配置文件</p>';
$pat = "/\['hostname'\] = '(.*)'/";
$rep = "['hostname'] = '".$host."'";
$ct1 = preg_replace($pat,$rep,$ct1);
echo '<p class="suc"><em> </em>配置:修改主机名</p>';
$pat = "/\['username'\] = '(.*)'/";
$rep = "['username'] = '".$uname."'";
$ct1 = preg_replace($pat,$rep,$ct1);
echo '<p class="suc"><em> </em>配置:修改用户名</p>';
$pat = "/\['password'\] = '(.*)'/";
$rep = "['password'] = '".$passwd."'";
$ct1 = preg_replace($pat,$rep,$ct1);
echo '<p class="suc"><em> </em>配置:修改密码</p>';
$pat = "/\['database'\] = '(.*)'/";
$rep = "['database'] = '".$dbname."'";
$ct1 = preg_replace($pat,$rep,$ct1);
echo '<p class="suc"><em> </em>配置:数据库名</p>';
$pat = "/\['dbdriver'\] = '(.*)'/";
$rep = "['dbdriver'] = '".$type."'";
$ct1 = preg_replace($pat,$rep,$ct1);
echo '<p class="suc"><em> </em>配置:'.$type.'</p>';
/* 写入后台配置文件 */
$fp=fopen($file1,'w');
if(fwrite($fp,$ct1)){
echo '<p class="suc"><em> </em>写入成功:'.$file1.'</p>';
}else {
echo '<p class="err"><em> </em>写入失败:'.$file1.'</p>';
};
fclose($fp);
/* 写入前台配置文件 */
$fp=fopen($file2,'w');
if(fwrite($fp,$ct1)){
echo '<p class="suc"><em> </em>写入成功:'.$file2.'</p>';
}else {
echo '<p class="err"><em> </em>写入失败:'.$file2.'</p>';
};
fclose($fp);
echo '<p class="suc"><em> </em>完成<br></p>';
echo '<p class="c666">注意:<br> 1、安装完成后,请删除“install”目录;<br> 2、为了安全考虑,请修改登录接口“admin”,同时配置目录下的“.htaccess”文件;</p>';
}
}catch (PDOException $e) {
echo '<p class="err"><em> </em>连接数据库失败:'.$e->getMessage().'</p>';
exit;
}
}else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="author" content="kingsoul" />
<title>WebMIS-安装向导</title>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link href="install.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="body">
<div class="top">
<div class="top_logo"> </div>
<span class="top_link">
<a href="http://www.ksphp.com" target="_black" >官方网站</a> |
<a href="http://webmis.ksphp.com" target="_black" >在线体验</a> |
<a href="http://www.ksphp.com" target="_black" >帮助</a>
</span>
</div>
<div class="ct">
<div id="tab" class="ct_top"><span id="tab1" class="tab">服务条款</span> > <span id="tab2">环境安装</span> > <span id="tab3">系统配置</span> > <span id="tab4">完成</span></div>
<!-- 安装说明 -->
<div class="ct_ct">
<div class="ct_ct_body">
<table id="install">
<tbody id="install1">
<tr>
<td class="in_show">WEBMIS是免费开源PHP开发CMS系统,基于CI的MVC模式开发的多用户、多权限解决方案,可以后台添加管理菜单,整合了Jquery,TinyMCE编辑器等插件、实现简洁、美观的弹框效果!</td>
</tr>
<tr>
<td>
<div class="code in_term"><?php echo file_get_contents('GPL.txt');?></div>
</td>
</tr>
</tbody>
<tbody id="install2" style="display: none;">
<tr>
<td><b>服务器环境配置:</b>必须开启重写</td>
</tr>
<tr>
<td>
<div class="left in_conf code">
<p><b>[ Apache ]</b><br>开启重写</p>
<p>方法一:<br>
[...]<br>
AllowOverride All #开启重写<br>
Options Indexes FollowSymLinks #浏览目录<br>
[...]</p>
<p>方法二:<br>
> a2enmod rewrite</p>
<p>然后配置“/”和“amin”下的 .htaccess 文件 </p>
</div>
<div class="right in_conf code">
<p><b>[ Nginx ]</b><br>去除index.php</p>
<p>location / {<br>
#Hide index.php<br>
if (!-e $request_filename) {<br>
rewrite ^/(.*) /index.php last;<br>
}<br>
}<br>
location /admin/ {<br>
#Hide index.php<br>
if (!-e $request_filename) {<br>
rewrite ^/admin/(.*) /admin/index.php last;<br>
}<br>
}</p>
</div>
</td>
</tr>
</tbody>
<tbody id="install3" style="display: none;">
<tr>
<td><b>文件是否可写:</b></td>
</tr>
<tr>
<td id="isWrite" class="code"> </td>
</tr>
<tr>
<td><b>数据库配置:</b> 1、采用PHP的PDO类; 2、创建数据库,编码“UTF-8”</td>
</tr>
<tr>
<td id="dataBase" class="code">
<div><span class="err"><em> </em>请填写数据库信息,并点击“连接”!</span></div>
<p>类 型:
<select style="width: 110px;">
<option value="mysql" >MySQL</option>
<option value="mssql" >SQL Server</option>
</select>
主机: <input type="text" class="input" style="width: 160px;" value="localhost"> </p>
<p>用户名: <input type="text" class="input" style="width: 100px;" value="root">
密码: <input type="password" class="input" style="width: 160px;"> </p>
<p>数据库: <input type="text" class="input" style="width: 100px;" value="webmis"></p>
<p><a href="#" id="isDB" class="an" style="margin-left: 60px;">连接</a></p>
</td>
</tr>
<tr>
<td><b>系统管理员:</b></td>
</tr>
<tr>
<td id="Admin" class="code">
<div><span class="err"><em> </em>请填写管理员信息!</span></div>
<p>用户名: <input type="text" class="input" style="width: 100px;" value="admin" maxlength="16"></p>
<p>密 码: <input type="password" class="input" style="width: 160px;" maxlength="16">
确认: <input type="password" class="input" style="width: 160px;" maxlength="16"></p>
</td>
</tr>
</tbody>
<tbody id="install4" style="display: none;">
<tr>
<td id="istallInfo"><p class="load"><em> </em>正在安装...</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 安装说明 End -->
<div id="button" class="ct_bt">
<font class="ct_bt_msg">提示:如果看不出“阴影”,请升级或更换浏览器!</font>
<span id="button1" class="ct_bt_an" style="display: block;">
<label><input type="checkbox" /> 同意服务条款</label>
<a href="#" class="an" onclick="Next(2);return false;" style="display: none;">下一步</a>
</span>
<span id="button2" class="ct_bt_an">
<a href="#" class="an" onclick="Next(1);return false;">上一步</a> <a href="#" class="an" onclick="Next(3);return false;">下一步</a>
</span>
<span id="button3" class="ct_bt_an">
<a href="#" class="an" onclick="Next(2);return false;">上一步</a> <a href="#" id="config" class="an" onclick="return false;">下一步</a>
</span>
<span id="button4" class="ct_bt_an">
<a href="../" class="an">完成</a>
</span>
</div>
</div>
<div class="copy">Built by KSPHP and the <b><a href="http://www.ksphp.com" >KSPHP.COM</a></b> community</div>
</div>
<script language="javascript" src="../webmis/plugin/jquery/jquery-1.min.js"></script>
<script language="javascript" src="install.js"></script>
</body>
</html>
<?php }?>