added 完成第二个安装页面的适配

This commit is contained in:
zhaoxiang 2016-11-19 18:06:58 +08:00
parent e6bf89a2e4
commit c4ac54112b
7 changed files with 179 additions and 83 deletions

View File

@ -113,9 +113,9 @@ class Base extends Controller {
$sidNow = session_id();
$sidOld = cache($this->uid);
if( isset($sidOld) && !empty($sidOld) ){
if( $sidOld != $sidNow ){
$this->error("您的账号在别的地方登录了,请重新登录!", url('User/login'));
}else{
//if( $sidOld != $sidNow ){
// $this->error("您的账号在别的地方登录了,请重新登录!", url('User/login'));
//}else{
cache($this->uid, $sidNow, config('online_time'));
$this->userInfo = User::get([ $this->primaryKey => $this->uid ])->toArray();
// if( $this->userInfo['updateTime'] === 0 ){
@ -125,7 +125,7 @@ class Base extends Controller {
// $this->error('初次登录请设置用户昵称!', url('User/changeNickname'));
// }
// }
}
//}
}else{
$this->error("登录超时,请重新登录!", url('User/login'));
}

View File

@ -13,62 +13,45 @@
* @author jry <598821125@qq.com>
*/
function check_env(){
$items = array(
'os' => array(
$items = [
'os' => [
'title' => '操作系统',
'limit' => '不限制',
'current' => PHP_OS,
'icon' => 'am-text-success am-icon-check',
),
'php' => array(
'icon' => 'fa fa-check',
],
'php' => [
'title' => 'PHP版本',
'limit' => '5.3+',
'limit' => '5.6+',
'current' => PHP_VERSION,
'icon' => 'am-text-success am-icon-check',
),
'upload' => array(
'icon' => 'fa fa-check',
],
'upload' => [
'title' => '附件上传',
'limit' => '不限制',
'current' => ini_get('file_uploads') ? ini_get('upload_max_filesize'):'未知',
'icon' => 'am-text-success am-icon-check',
),
// 'gd' => array(
// 'title' => 'GD库',
// 'limit' => '2.0+',
// 'current' => '未知',
// 'icon' => 'am-text-success am-icon-check',
// ),
'disk' => array(
'icon' => 'fa fa-check',
],
'disk' => [
'title' => '磁盘空间',
'limit' => '100M+',
'current' => '未知',
'icon' => 'am-text-success am-icon-check',
),
);
'icon' => 'fa fa-check',
],
];
//PHP环境检测
if($items['php']['current'] < 5.3){
$items['php']['icon'] = 'am-text-danger am-icon-close';
if($items['php']['current'] < 5.6){
$items['php']['icon'] = 'fa fa-close';
session('error', true);
}
// //GD库检测
// $tmp = function_exists('gd_info') ? gd_info() : array();
// if(!$tmp['GD Version']){
// $items['gd']['current'] = '未安装';
// $items['gd']['icon'] = 'am-text-danger am-icon-close';
// session('error', true);
// }else{
// $items['gd']['current'] = $tmp['GD Version'];
// }
// unset($tmp);
//磁盘空间检测
if(function_exists('disk_free_space')){
$disk_size = floor(disk_free_space('./') / (1024*1024)).'M';
$items['disk']['current'] = $disk_size.'B';
if($disk_size < 100){
$items['disk']['icon'] = 'am-text-danger am-icon-close';
$items['disk']['icon'] = 'fa fa-close';
session('error', true);
}
}
@ -82,26 +65,20 @@ function check_env(){
* @author jry <598821125@qq.com>
*/
function check_dirfile(){
$items = array(
'0' => array(
$items = [
'0' => [
'type' => 'file',
'path' => APP_PATH . 'Common/Conf/db.php',
'path' => ROOT_PATH . 'application/database.php',
'title' => '可写',
'icon' => 'am-text-success am-icon-check',
),
'1' => array(
'type' => 'dir',
'path' => APP_PATH . 'Common/Conf',
'title' => '可写',
'icon' => 'am-text-success am-icon-check',
),
'2' => array(
'icon' => 'fa fa-check',
],
'2' => [
'type' => 'dir',
'path' => RUNTIME_PATH,
'title' => '可写',
'icon' => 'am-text-success am-icon-check',
)
);
'icon' => 'fa fa-check',
]
];
foreach ($items as &$val){
$path = $val['path'];
@ -109,11 +86,11 @@ function check_dirfile(){
if(!is_writable($path)){
if(is_dir($path)) {
$val['title'] = '不可写';
$val['icon'] = 'am-text-danger am-icon-close';
$val['icon'] = 'fa fa-close';
session('error', true);
}else{
$val['title'] = '不存在';
$val['icon'] = 'am-text-danger am-icon-close';
$val['icon'] = 'fa fa-close';
session('error', true);
}
}
@ -121,13 +98,13 @@ function check_dirfile(){
if(file_exists($path)){
if(!is_writable($path)){
$val['title'] = '不可写';
$val['icon'] = 'am-text-danger am-icon-close';
$val['icon'] = 'fa fa-close';
session('error', true);
}
}else{
if(!is_writable(dirname($path))){
$val['title'] = '不存在';
$val['icon'] = 'am-text-danger am-icon-close';
$val['icon'] = 'fa fa-close';
session('error', true);
}
}
@ -147,51 +124,59 @@ function check_func_and_ext(){
'name' => 'pdo',
'title' => '支持',
'current' => extension_loaded('pdo'),
'icon' => 'am-text-success am-icon-check',
'icon' => 'fa fa-check',
'isMust' => true
],
[
'type' => 'ext',
'name' => 'mongoDB',
'name' => 'mongoDB(不必须)',
'title' => '支持',
'current' => extension_loaded('mongo'),
'icon' => 'am-text-success am-icon-check',
'icon' => 'fa fa-check',
'isMust' => false
],
[
'type' => 'ext',
'name' => 'Redis',
'name' => 'Redis(不必须)',
'title' => '支持',
'current' => extension_loaded('redis'),
'icon' => 'am-text-success am-icon-check',
'icon' => 'fa fa-check',
'isMust' => false
],
[
'type' => 'func',
'name' => 'file_get_contents',
'title' => '支持',
'icon' => 'am-text-success am-icon-check',
'icon' => 'fa fa-check',
'isMust' => true
],
[
'type' => 'func',
'name' => 'mb_strlen',
'title' => '支持',
'icon' => 'am-text-success am-icon-check',
'icon' => 'fa fa-check',
'isMust' => true
],
[
'type' => 'func',
'name' => 'shell_exec',
'title' => '支持',
'icon' => 'am-text-success am-icon-check',
'icon' => 'fa fa-check',
'isMust' => true
],
[
'type' => 'com',
'name' => 'mongodump',
'name' => 'mongodump(不必须)',
'title' => '支持',
'icon' => 'am-text-success am-icon-check',
'icon' => 'fa fa-check',
'isMust' => false
],
[
'type' => 'com',
'name' => 'mongorestore',
'name' => 'mongorestore(不必须)',
'title' => '支持',
'icon' => 'am-text-success am-icon-check',
'icon' => 'fa fa-check',
'isMust' => false
]
];
foreach($items as &$val){
@ -199,23 +184,29 @@ function check_func_and_ext(){
case 'ext':
if(!$val['current']){
$val['title'] = '不支持';
$val['icon'] = 'am-text-danger am-icon-close';
session('error', true);
$val['icon'] = 'fa fa-close';
if( $val['isMust'] ){
session('error', true);
}
}
break;
case 'func':
if(!function_exists($val['name'])){
$val['title'] = '不支持';
$val['icon'] = 'am-text-danger am-icon-close';
session('error', true);
$val['icon'] = 'fa fa-close';
if( $val['isMust'] ){
session('error', true);
}
}
break;
case 'com':
$com = 'which '.$val['name'];
if(shell_exec($com) == null){
$val['title'] = '不支持';
$val['icon'] = 'am-text-danger am-icon-close';
session('error', true);
$val['icon'] = 'fa fa-close';
if( $val['isMust'] ){
session('error', true);
}
}
break;
}
@ -241,9 +232,9 @@ function write_config($config, $type){
}
//写入应用配置文件
if(file_put_contents(APP_PATH . 'Common/Conf/'.$type.'.php', $conf)){
show_msg('配置文件'.$type.'写入成功', 'am-text-success');
show_msg('配置文件'.$type.'写入成功', 'bg-success');
}else{
show_msg('配置文件'.$type.'写入失败!', 'am-text-danger');
show_msg('配置文件'.$type.'写入失败!', 'bg-danger');
session('error', true);
}
return true;

View File

@ -5,6 +5,37 @@ use think\Controller;
class Index extends Controller {
public function index() {
session('step', 1);
session('error', false);
return $this->fetch();
}
public function step2(){
if($this->request->isAjax()){
if(session('error')){
$this->error('环境检测没有通过,请调整环境后重试!');
}else{
$this->success('恭喜您环境检测通过', url('step3'));
}
}else{
$step = 1;
if($step != 1){
$this->error("请按顺序安装", url('step1'));
}else{
session('step', 2);
session('error', false);
//环境检测
$this->assign('check_env', check_env());
//目录文件读写检测
$this->assign('check_dirfile', check_dirfile());
//函数及扩展库检测
$this->assign('check_func_and_ext', check_func_and_ext());
return $this->fetch();
}
}
}
}

View File

@ -16,8 +16,8 @@
<p>本服务条款一旦发生变更, {:config('COMPANY_NAME')}将在官网上公布修改内容。修改后的服务条款一旦在网站公布即有效代替原来的服务条款。您可随时登陆官网查阅最新版服务条款。如果您选择接受本条款,即表示您同意接受协议各项条件的约束。如果您不同意本服务条款,则不能获得使用本服务的权利。您若有违反本条款规定,{:config('COMPANY_NAME')}有权随时中止或终止您对{:config('PRODUCT_NAME')}产品的使用资格并保留追究相关法律责任的权利。</p>
<p>在理解、同意、并遵守本协议的全部条款后,方可开始使用{:config('PRODUCT_NAME')}产品。您也可能与{:config('COMPANY_NAME')}直接签订另一书面协议,以补充或者取代本协议的全部或者任何部分。</p>
<p>{:config('COMPANY_NAME')}拥有{:config('PRODUCT_NAME')}的全部知识产权,包括商标和著作权。虽然在大部分情况下您都可以自由的进行修改、复制、下载、安装、使用或者以其他方式受益于本软件的功能或者知识产权。但是{:config('COMPANY_NAME')}还是希望您能在底部保留我们的链接和版权声明!</p>
<button type="button" class="btn btn-primary btn-block">同意安装协议</button>
<button type="button" class="btn btn-default btn-block">不同意</button>
<a type="button" href="{:url('step2')}" class="btn btn-primary btn-block">同意安装协议</a>
<a type="button" href="{:config('WEBSITE_DOMAIN')}" class="btn btn-default btn-block">不同意</a>
</div>
</div>
{/block}

View File

@ -0,0 +1,75 @@
{extend name="public/base" /}
{block name="title"}系统安装Step2{/block}
{block name="nav"}
<li><a href="javascript:;">安装协议</a></li>
<li class="active"><a href="javascript:;">环境检测</a></li>
<li><a href="javascript:;">参数设置</a></li>
<li><a href="javascript:;">开始安装</a></li>
<li><a href="javascript:;">安装完成</a></li>
{/block}
{block name="main"}
<div class="panel panel-default">
<div class="panel-heading">{:config('PRODUCT_NAME')} 环境检测</div>
<div class="panel-body" style="font-size: 14px">
<table class="table table-hover">
<caption><h4>运行环境检查</h4></caption>
<thead>
<tr>
<th>项目</th>
<th>所需配置</th>
<th>当前配置</th>
</tr>
</thead>
<tbody>
{volist name="check_env" id="item"}
<tr>
<td>{$item['title']}</td>
<td>{$item['limit']}</td>
<td><i class="{$item['icon']}"></i> {$item['current']}</td>
</tr>
{/volist}
</tbody>
</table>
<table class="table table-hover">
<caption><h4>目录、文件权限检查</h4></caption>
<thead>
<tr>
<th>目录/文件</th>
<th>所需状态</th>
<th>当前状态</th>
</tr>
</thead>
<tbody>
{volist name="check_dirfile" id="item"}
<tr>
<td>{$item['path']}</td>
<td>可写</td>
<td><i class="{$item['icon']}"></i> {$item['title']}</td>
</tr>
{/volist}
</tbody>
</table>
<table class="table table-hover">
<caption><h4>函数及扩展依赖性检查</h4></caption>
<thead>
<tr>
<th>名称</th>
<th>检查结果</th>
</tr>
</thead>
<tbody>
{volist name="check_func_and_ext" id="item"}
<tr>
<td>{$item['name']}</td>
<td><i class="{$item['icon']}"></i> {$item['title']}</td>
</tr>
{/volist}
</tbody>
</table>
<form action="{:url('step2')}" id="form-setup">
<a type="button" target-form="form-setup" class="ajax-post redirect btn btn-primary btn-block">下一步</a>
<a type="button" href="{:url('index')}" class="btn btn-default btn-block">上一步</a>
</form>
</div>
</div>
{/block}

View File

@ -58,7 +58,7 @@
</header>
<div class="content-wrapper">
<div class="container">
<section class="content" style="width: 70%">
<section class="content" style="width: 80%">
{block name="main"}{/block}
</section>
</div>
@ -88,5 +88,6 @@
<script src="__JS__/app.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="__JS__/demo.js"></script>
<script src="__JS__/template.js"></script>
</body>
</html>

2
runtime/.gitignore vendored
View File

@ -1,2 +0,0 @@
*
!.gitignore