提交 0c4bff1a 编写于 作者: D devil_gong

安装程序优化

上级 a228b541
...@@ -79,6 +79,5 @@ ...@@ -79,6 +79,5 @@
</div> </div>
</div> </div>
</div> </div>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -28,7 +28,7 @@ if($c == 'agreement' || empty($c)) ...@@ -28,7 +28,7 @@ if($c == 'agreement' || empty($c))
// 环境检测页面 // 环境检测页面
if($c == 'test') if($c == 'test')
{ {
new behavior(array('msg'=>'环境检测')); new behavior(array('msg'=>'环境检测'));
exit(require './test.html'); exit(require './test.html');
} }
// 创建数据库页面 // 创建数据库页面
...@@ -44,57 +44,53 @@ if($c == 'success') ...@@ -44,57 +44,53 @@ if($c == 'success')
$mysql_ver = ''; $mysql_ver = '';
// 判断是否为post // 判断是否为post
if($_SERVER['REQUEST_METHOD']=='POST') if($_SERVER['REQUEST_METHOD'] == 'POST')
{ {
$data = $_POST; $data = $_POST;
// 连接数据库 // 连接数据库
$constr = "{$data['DB_HOST']}"; $link = @mysqli_connect($data['DB_HOST'], $data['DB_USER'], $data['DB_PWD'], null, $data['DB_PORT']);
if(!empty($data['DB_PORT']))
{
$constr .= ":{$data['DB_PORT']}";
}
$link = @new mysqli($constr, $data['DB_USER'], $data['DB_PWD']);
// 获取错误信息 // 获取错误信息
$error = $link->connect_error; if (!$link) {
if (!is_null($error)) {
// 转义防止和alert中的引号冲突 // 转义防止和alert中的引号冲突
$error = addslashes($error); $error = addslashes(mysqli_connect_error().'['.mysqli_connect_errno().']');
// 数据库连接失败上报 // 数据库连接失败上报
new behavior(array('msg'=>'数据库连接失败['.$error.']')); new behavior(array('msg'=>'数据库连接失败['.$error.']'));
die("<script>alert('数据库链接失败:$error');history.go(-1)</script>"); die("<script>alert('数据库链接失败:$error');history.go(-1)</script>");
} }
// 设置字符集 // 设置字符集
$link->query("SET NAMES 'utf8mb4'"); mysqli_query($link, "SET NAMES 'utf8mb4'");
// 数据库版本校验 // 数据库版本校验
if($link->server_info < 5.0) $mysql_ver = mysqli_get_server_info($link);
if($mysql_ver < 5.0)
{ {
// 数据库版本过低上报 // 数据库版本过低上报
new behavior(array('msg'=>'数据库版本过低['.$link->server_info.']', 'mysql_version'=>$link->server_info)); new behavior(array('msg'=>'数据库版本过低['.$mysql_ver.']', 'mysql_version'=>$mysql_ver));
die("<script>alert('请将您的mysql升级到5.0以上');history.go(-1)</script>"); die("<script>alert('请将您的mysql升级到5.0以上');history.go(-1)</script>");
} }
$mysql_ver = $link->server_info;
// 创建数据库并选中 // 创建数据库并选中
if(!$link->select_db($data['DB_NAME'])){ if(!mysqli_select_db($link, $data['DB_NAME'])){
$create_sql='CREATE DATABASE IF NOT EXISTS '.$data['DB_NAME'].' DEFAULT CHARACTER SET utf8mb4;'; $create_sql = 'CREATE DATABASE IF NOT EXISTS '.$data['DB_NAME'].' DEFAULT CHARACTER SET utf8mb4;';
if(!$link->query($create_sql)) if(!mysqli_query($link, $create_sql))
{ {
// 数据库创建失败上报 // 数据库创建失败上报
new behavior(array('msg'=>'创建数据库失败', 'mysql_version'=>$mysql_ver)); new behavior(array('msg'=>'创建数据库失败', 'mysql_version'=>$mysql_ver));
die('创建数据库失败'); die("<script>alert('创建数据库失败');history.go(-1)</script>");
} }
$link->select_db($data['DB_NAME']); mysqli_select_db($link, $data['DB_NAME']);
} }
// 导入sql数据并创建表 // 导入sql数据并创建表
$shopxo_str = file_get_contents('./shopxo.sql'); $sql_array = preg_split("/;[\r\n]+/", str_replace('`s_', '`'.$data['DB_PREFIX'], file_get_contents('./shopxo.sql')));
$sql_array = preg_split("/;[\r\n]+/", str_replace('s_', $data['DB_PREFIX'], $shopxo_str));
$success = 0; $success = 0;
$failure = 0; $failure = 0;
foreach ($sql_array as $k => $v) { foreach ($sql_array as $k => $v) {
if (!empty($v)) { if (!empty($v)) {
if($link->query($v)) if(mysqli_query($link, $v))
{ {
$success++; $success++;
} else { } else {
...@@ -102,7 +98,7 @@ if($c == 'success') ...@@ -102,7 +98,7 @@ if($c == 'success')
} }
} }
} }
$link->close(); mysqli_close($link);
// 数据表创建上报 // 数据表创建上报
new behavior(array('msg'=>'运行sql[成功'.$success.', 失败'.$failure.']', 'mysql_version'=>$mysql_ver)); new behavior(array('msg'=>'运行sql[成功'.$success.', 失败'.$failure.']', 'mysql_version'=>$mysql_ver));
...@@ -116,7 +112,7 @@ if($c == 'success') ...@@ -116,7 +112,7 @@ if($c == 'success')
* @author Devil * @author Devil
* @blog http://gong.gg/ * @blog http://gong.gg/
* @version 0.0.1 * @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800 * @datetime 2018-11-11T21:51:08+0800
*/ */
return array( return array(
// 数据库配置信息 // 数据库配置信息
......
文件模式从 100644 更改为 100755
...@@ -143,4 +143,11 @@ h2 { ...@@ -143,4 +143,11 @@ h2 {
.create .one input { .create .one input {
width: 70%; width: 70%;
} }
}
#out table tr.yes td {
background: #f8fff9;
}
#out table tr:not(.yes) td {
background: #ffbdb7;
color: #f00;
} }
\ No newline at end of file
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
<h2>恭喜您安装成功</h2> <h2>恭喜您安装成功</h2>
<p class="content"> <p class="content">
<a href="../admin.php" target="_blank">后台管理</a><br /> <a href="../admin.php" target="_blank">后台管理</a><br />
<a href="../index.php" target="_blank">首页</a><br />
<span class="admin_hint">默认账号:admin &emsp; 密码为:shopxo</span> <span class="admin_hint">默认账号:admin &emsp; 密码为:shopxo</span>
<br /><br /> <br /><br />
<a href="../index.php" target="_blank">访问首页</a> <a href="../index.php" target="_blank">访问首页</a>
......
...@@ -16,8 +16,10 @@ ...@@ -16,8 +16,10 @@
<![endif]--> <![endif]-->
<link rel="stylesheet" href="./static/css/install.css"> <link rel="stylesheet" href="./static/css/install.css">
<script> <script>
function testClick(){ function TestClick(){
if($('.yes').length!=7){ var count = $('#out table tr').length-3;
if($('#out .yes').length != count)
{
alert('您的配置或权限不符合要求'); alert('您的配置或权限不符合要求');
}else{ }else{
location.href='./index.php?c=create'; location.href='./index.php?c=create';
...@@ -50,27 +52,46 @@ function testClick(){ ...@@ -50,27 +52,46 @@ function testClick(){
<div id="out"> <div id="out">
<div class="inside"> <div class="inside">
<div class="box test"> <div class="box test">
<h2>环境监测</h2> <h2>环境检查</h2>
<table class="table table-border"> <table class="table table-border">
<tr> <tr>
<th width="25%">坏境</th> <th width="25%">坏境</th>
<th width="25%">最低配置</th> <th width="25%">程序所需</th>
<th width="25%">当前配置</th> <th width="25%">当前服务器</th>
<th width="25%">是否符合</th> <th width="25%">是否符合</th>
</tr> </tr>
<tr> <tr class="yes">
<td>操作系统</td> <td>操作系统</td>
<td>不限</td> <td>无限制</td>
<td><?php echo php_uname('s'); ?></td> <td><?php echo php_uname('s'); ?></td>
<td class="yes"></td> <td></td>
</tr> </tr>
<tr>
<td>php版本</td> <?php $php_version = explode('.', PHP_VERSION); ?>
<td>&gt;5.4</td> <tr class="<?php if(($php_version['0'] >= 7) || ($php_version['0'] >=5 && $php_version['1'] >=4 ))echo 'yes'; ?>">
<td>PHP版本</td>
<td>>=5.4</td>
<td><?php echo PHP_VERSION ?></td> <td><?php echo PHP_VERSION ?></td>
<?php $php_version=explode('.', PHP_VERSION); ?> <td>
<td class="<?php if(($php_version['0']>=7) || ($php_version['0']>=5 && $php_version['1']>=4))echo 'yes'; ?>"> <?php if(($php_version['0']>=7) || ($php_version['0']>=5 && $php_version['1']>=4)): ?>
<?php if (($php_version['0']>=7) || ($php_version['0']>=5 && $php_version['1']>=4)): ?>
<?php else: ?>
×
<?php endif ?>
</td>
</tr>
<?php
$tmp = function_exists('gd_info') ? gd_info() : array();
preg_match("/[\d.]+/", $tmp['GD Version'], $match);
unset($tmp);
?>
<tr class="<?php if($match[0] > 2)echo 'yes'; ?>">
<td>GD库</td>
<td>2.0</td>
<td><?php echo $match[0]; ?></td>
<td>
<?php if($match[0] > 2): ?>
<?php else: ?> <?php else: ?>
× ×
...@@ -78,15 +99,16 @@ function testClick(){ ...@@ -78,15 +99,16 @@ function testClick(){
</td> </td>
</tr> </tr>
</table> </table>
<h2>目录权限</h2>
<h2>目录/文件权限检查</h2>
<table class="table table-border"> <table class="table table-border">
<tr> <tr>
<th width="25%">坏境</th> <th width="25%">坏境</th>
<th width="25%">最低配置</th> <th width="25%">所需状态</th>
<th width="25%">当前配置</th> <th width="25%">当前状态</th>
<th width="25%">是否符合</th> <th width="25%">是否符合</th>
</tr> </tr>
<tr> <tr class="<?php if(is_writable('../'))echo 'yes'; ?>">
<td>./</td> <td>./</td>
<td>可写</td> <td>可写</td>
<td> <td>
...@@ -96,7 +118,7 @@ function testClick(){ ...@@ -96,7 +118,7 @@ function testClick(){
不可写 不可写
<?php endif ?> <?php endif ?>
</td> </td>
<td class="<?php if(is_writable('../'))echo 'yes'; ?>"> <td>
<?php if (is_writable('../')): ?> <?php if (is_writable('../')): ?>
<?php else: ?> <?php else: ?>
...@@ -104,7 +126,7 @@ function testClick(){ ...@@ -104,7 +126,7 @@ function testClick(){
<?php endif ?> <?php endif ?>
</td> </td>
</tr> </tr>
<tr> <tr class="<?php if(is_writable('../Application'))echo 'yes'; ?>">
<td>./Application</td> <td>./Application</td>
<td>可写</td> <td>可写</td>
<td> <td>
...@@ -114,7 +136,7 @@ function testClick(){ ...@@ -114,7 +136,7 @@ function testClick(){
不可写 不可写
<?php endif ?> <?php endif ?>
</td> </td>
<td class="<?php if(is_writable('../Application'))echo 'yes'; ?>"> <td>
<?php if (is_writable('../Application')): ?> <?php if (is_writable('../Application')): ?>
<?php else: ?> <?php else: ?>
...@@ -122,7 +144,7 @@ function testClick(){ ...@@ -122,7 +144,7 @@ function testClick(){
<?php endif ?> <?php endif ?>
</td> </td>
</tr> </tr>
<tr> <tr class="<?php if(is_writable('../Application/Common/Conf'))echo 'yes'; ?>">
<td>./Application/Common/Conf</td> <td>./Application/Common/Conf</td>
<td>可写</td> <td>可写</td>
<td> <td>
...@@ -132,7 +154,7 @@ function testClick(){ ...@@ -132,7 +154,7 @@ function testClick(){
不可写 不可写
<?php endif ?> <?php endif ?>
</td> </td>
<td class="<?php if(is_writable('../Application/Common/Conf'))echo 'yes'; ?>"> <td>
<?php if (is_writable('../Application/Common/Conf')): ?> <?php if (is_writable('../Application/Common/Conf')): ?>
<?php else: ?> <?php else: ?>
...@@ -140,25 +162,43 @@ function testClick(){ ...@@ -140,25 +162,43 @@ function testClick(){
<?php endif ?> <?php endif ?>
</td> </td>
</tr> </tr>
<tr> <tr class="<?php if(is_writable('../Application/Library/Payment'))echo 'yes'; ?>">
<td>./Application/Runtime/Cache</td> <td>./Application/Library/Payment</td>
<td>可写</td> <td>可写</td>
<td> <td>
<?php if (is_writable('../Application/Runtime/Cache')): ?> <?php if (is_writable('../Application/Library/Payment')): ?>
可写 可写
<?php else: ?> <?php else: ?>
不可写 不可写
<?php endif ?> <?php endif ?>
</td> </td>
<td class="<?php if(is_writable('../Application/Runtime/Cache'))echo 'yes'; ?>"> <td>
<?php if (is_writable('../Application/Runtime/Cache')): ?> <?php if (is_writable('../Application/Library/Payment')): ?>
<?php else: ?> <?php else: ?>
× ×
<?php endif ?> <?php endif ?>
</td> </td>
</tr> </tr>
<tr> <tr class="<?php if(is_writable('../Public'))echo 'yes'; ?>">
<td>./Public</td>
<td>可写</td>
<td>
<?php if (is_writable('../Public')): ?>
可写
<?php else: ?>
不可写
<?php endif ?>
</td>
<td>
<?php if (is_writable('../Public')): ?>
<?php else: ?>
×
<?php endif ?>
</td>
</tr>
<tr class="<?php if(is_writable('./'))echo 'yes'; ?>">
<td>./Install</td> <td>./Install</td>
<td>可写</td> <td>可写</td>
<td> <td>
...@@ -168,7 +208,7 @@ function testClick(){ ...@@ -168,7 +208,7 @@ function testClick(){
不可写 不可写
<?php endif ?> <?php endif ?>
</td> </td>
<td class="<?php if(is_writable('./'))echo 'yes'; ?>"> <td>
<?php if (is_writable('./')): ?> <?php if (is_writable('./')): ?>
<?php else: ?> <?php else: ?>
...@@ -177,9 +217,145 @@ function testClick(){ ...@@ -177,9 +217,145 @@ function testClick(){
</td> </td>
</tr> </tr>
</table> </table>
<h2>函数</h2>
<table class="table table-border">
<tr>
<th width="25%">坏境</th>
<th width="25%">所需状态</th>
<th width="25%">当前状态</th>
<th width="25%">是否符合</th>
</tr>
<tr class="<?php if(function_exists('curl_init'))echo 'yes'; ?>">
<td>curl_init</td>
<td>支持</td>
<td>
<?php if (function_exists('curl_init')): ?>
支持
<?php else: ?>
不支持
<?php endif ?>
</td>
<td>
<?php if (function_exists('curl_init')): ?>
<?php else: ?>
×
<?php endif ?>
</td>
</tr>
<tr class="<?php if(function_exists('fsockopen'))echo 'yes'; ?>">
<td>fsockopen</td>
<td>支持</td>
<td>
<?php if (function_exists('fsockopen')): ?>
支持
<?php else: ?>
不支持
<?php endif ?>
</td>
<td>
<?php if (function_exists('fsockopen')): ?>
<?php else: ?>
×
<?php endif ?>
</td>
</tr>
<tr class="<?php if(function_exists('mysqli_connect'))echo 'yes'; ?>">
<td>mysqli_connect</td>
<td>支持</td>
<td>
<?php if (function_exists('mysqli_connect')): ?>
支持
<?php else: ?>
不支持
<?php endif ?>
</td>
<td>
<?php if (function_exists('mysqli_connect')): ?>
<?php else: ?>
×
<?php endif ?>
</td>
</tr>
<tr class="<?php if(function_exists('file_get_contents'))echo 'yes'; ?>">
<td>file_get_contents</td>
<td>支持</td>
<td>
<?php if (function_exists('file_get_contents')): ?>
支持
<?php else: ?>
不支持
<?php endif ?>
</td>
<td>
<?php if (function_exists('file_get_contents')): ?>
<?php else: ?>
×
<?php endif ?>
</td>
</tr>
<tr class="<?php if(function_exists('mb_convert_encoding'))echo 'yes'; ?>">
<td>mb_convert_encoding</td>
<td>支持</td>
<td>
<?php if (function_exists('mb_convert_encoding')): ?>
支持
<?php else: ?>
不支持
<?php endif ?>
</td>
<td>
<?php if (function_exists('mb_convert_encoding')): ?>
<?php else: ?>
×
<?php endif ?>
</td>
</tr>
<tr class="<?php if(function_exists('json_encode'))echo 'yes'; ?>">
<td>json_encode</td>
<td>支持</td>
<td>
<?php if (function_exists('json_encode')): ?>
支持
<?php else: ?>
不支持
<?php endif ?>
</td>
<td>
<?php if (function_exists('json_encode')): ?>
<?php else: ?>
×
<?php endif ?>
</td>
</tr>
<tr class="<?php if(function_exists('json_decode'))echo 'yes'; ?>">
<td>json_decode</td>
<td>支持</td>
<td>
<?php if (function_exists('json_decode')): ?>
支持
<?php else: ?>
不支持
<?php endif ?>
</td>
<td>
<?php if (function_exists('json_decode')): ?>
<?php else: ?>
×
<?php endif ?>
</td>
</tr>
</table>
<p class="agree"> <p class="agree">
<a class="btn btn-primary" href="./index.php?c=agreement">上一步</a> <a class="btn btn-primary" href="./index.php?c=agreement">上一步</a>
<a class="btn btn-success" href="javascript:;" onclick="testClick()">下一步</a> <a class="btn btn-success" href="javascript:;" onclick="TestClick()">下一步</a>
</p> </p>
</div> </div>
</div> </div>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册