diff --git a/application/config.php b/application/config.php index 9f57a65..27d3427 100644 --- a/application/config.php +++ b/application/config.php @@ -12,8 +12,8 @@ return [ 'PRODUCT_VERSION' => 'V1.0.0', //项目版本 'PRODUCT_NAME' => 'ApiAdmin', //产品名称 - 'WEBSITE_DOMAIN' => 'http://www.our-dream.cn', //官方网址 - 'COMPANY_NAME' => 'XXXXXXXX有限公司', //公司名称 + 'WEBSITE_DOMAIN' => 'http://zxblog.our-dream.cn', //官方网址 + 'COMPANY_NAME' => 'ApiAdmin开发维护团队', //公司名称 'SQL_PRIMARY_KEY' => 'id', 'USER_ADMINISTRATOR' => 4, diff --git a/application/install/common.php b/application/install/common.php new file mode 100644 index 0000000..3c58804 --- /dev/null +++ b/application/install/common.php @@ -0,0 +1,262 @@ + +// +---------------------------------------------------------------------- + +/** + * 系统环境检测 + * @return array 系统环境数据 + * @author jry <598821125@qq.com> + */ +function check_env(){ + $items = array( + 'os' => array( + 'title' => '操作系统', + 'limit' => '不限制', + 'current' => PHP_OS, + 'icon' => 'am-text-success am-icon-check', + ), + 'php' => array( + 'title' => 'PHP版本', + 'limit' => '5.3+', + 'current' => PHP_VERSION, + 'icon' => 'am-text-success am-icon-check', + ), + 'upload' => array( + '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( + 'title' => '磁盘空间', + 'limit' => '100M+', + 'current' => '未知', + 'icon' => 'am-text-success am-icon-check', + ), + ); + + //PHP环境检测 + if($items['php']['current'] < 5.3){ + $items['php']['icon'] = 'am-text-danger am-icon-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'; + session('error', true); + } + } + + return $items; +} + +/** + * 目录,文件读写检测 + * @return array 检测数据 + * @author jry <598821125@qq.com> + */ +function check_dirfile(){ + $items = array( + '0' => array( + 'type' => 'file', + 'path' => APP_PATH . 'Common/Conf/db.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( + 'type' => 'dir', + 'path' => RUNTIME_PATH, + 'title' => '可写', + 'icon' => 'am-text-success am-icon-check', + ) + ); + + foreach ($items as &$val){ + $path = $val['path']; + if('dir' === $val['type']){ + if(!is_writable($path)){ + if(is_dir($path)) { + $val['title'] = '不可写'; + $val['icon'] = 'am-text-danger am-icon-close'; + session('error', true); + }else{ + $val['title'] = '不存在'; + $val['icon'] = 'am-text-danger am-icon-close'; + session('error', true); + } + } + }else{ + if(file_exists($path)){ + if(!is_writable($path)){ + $val['title'] = '不可写'; + $val['icon'] = 'am-text-danger am-icon-close'; + session('error', true); + } + }else{ + if(!is_writable(dirname($path))){ + $val['title'] = '不存在'; + $val['icon'] = 'am-text-danger am-icon-close'; + session('error', true); + } + } + } + } + return $items; +} + +/** + * 函数检测 + * @return array 检测数据 + */ +function check_func_and_ext(){ + $items = [ + [ + 'type' => 'ext', + 'name' => 'pdo', + 'title' => '支持', + 'current' => extension_loaded('pdo'), + 'icon' => 'am-text-success am-icon-check', + ], + [ + 'type' => 'ext', + 'name' => 'mongoDB', + 'title' => '支持', + 'current' => extension_loaded('mongo'), + 'icon' => 'am-text-success am-icon-check', + ], + [ + 'type' => 'ext', + 'name' => 'Redis', + 'title' => '支持', + 'current' => extension_loaded('redis'), + 'icon' => 'am-text-success am-icon-check', + ], + [ + 'type' => 'func', + 'name' => 'file_get_contents', + 'title' => '支持', + 'icon' => 'am-text-success am-icon-check', + ], + [ + 'type' => 'func', + 'name' => 'mb_strlen', + 'title' => '支持', + 'icon' => 'am-text-success am-icon-check', + ], + [ + 'type' => 'func', + 'name' => 'shell_exec', + 'title' => '支持', + 'icon' => 'am-text-success am-icon-check', + ], + [ + 'type' => 'com', + 'name' => 'mongodump', + 'title' => '支持', + 'icon' => 'am-text-success am-icon-check', + ], + [ + 'type' => 'com', + 'name' => 'mongorestore', + 'title' => '支持', + 'icon' => 'am-text-success am-icon-check', + ] + ]; + foreach($items as &$val){ + switch($val['type']){ + case 'ext': + if(!$val['current']){ + $val['title'] = '不支持'; + $val['icon'] = 'am-text-danger am-icon-close'; + session('error', true); + } + break; + case 'func': + if(!function_exists($val['name'])){ + $val['title'] = '不支持'; + $val['icon'] = 'am-text-danger am-icon-close'; + 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); + } + break; + } + } + + return $items; +} + +/** + * 写入配置文件 + * @param $config + * @param $type string 配置类型 + * @return bool + */ +function write_config($config, $type){ + if(is_array($config)){ + show_msg('开始写入'.$type.'配置文件'); + //读取配置内容 + $conf = file_get_contents(MODULE_PATH . 'Data/'.$type.'.tpl'); + //替换配置项 + foreach ($config as $name => $value) { + $conf = str_replace("[{$name}]", $value, $conf); + } + //写入应用配置文件 + if(file_put_contents(APP_PATH . 'Common/Conf/'.$type.'.php', $conf)){ + show_msg('配置文件'.$type.'写入成功', 'am-text-success'); + }else{ + show_msg('配置文件'.$type.'写入失败!', 'am-text-danger'); + session('error', true); + } + return true; + } +} + +/** + * @param $msg + * @param string $class + */ +function show_msg($msg, $class = ''){ + usleep(20000); + echo ""; + ob_flush(); + flush(); +} diff --git a/application/install/config.php b/application/install/config.php new file mode 100644 index 0000000..3779064 --- /dev/null +++ b/application/install/config.php @@ -0,0 +1,5 @@ +fetch(); + } +} diff --git a/application/install/view/index/index.html b/application/install/view/index/index.html new file mode 100644 index 0000000..e13089c --- /dev/null +++ b/application/install/view/index/index.html @@ -0,0 +1,23 @@ +{extend name="public/base" /} +{block name="title"}系统安装Step1{/block} +{block name="nav"} +
  • 安装协议
  • +
  • 环境检测
  • +
  • 参数设置
  • +
  • 开始安装
  • +
  • 安装完成
  • +{/block} +{block name="main"} +
    +
    {:config('PRODUCT_NAME')} 安装协议
    +
    +

    感谢您选择{:config('PRODUCT_NAME')},希望我们的努力能为您提供一个简单、高效、卓越的轻量级产品开发框架。

    +

    用户须知:本协议是您与{:config('COMPANY_NAME')}之间关于您使用{:config('PRODUCT_NAME')}产品及服务的法律协议。本产品是一个对商业友好的开源项目,您可以随意的进行二次开发,修改和发布。

    +

    本服务条款一旦发生变更, {:config('COMPANY_NAME')}将在官网上公布修改内容。修改后的服务条款一旦在网站公布即有效代替原来的服务条款。您可随时登陆官网查阅最新版服务条款。如果您选择接受本条款,即表示您同意接受协议各项条件的约束。如果您不同意本服务条款,则不能获得使用本服务的权利。您若有违反本条款规定,{:config('COMPANY_NAME')}有权随时中止或终止您对{:config('PRODUCT_NAME')}产品的使用资格并保留追究相关法律责任的权利。

    +

    在理解、同意、并遵守本协议的全部条款后,方可开始使用{:config('PRODUCT_NAME')}产品。您也可能与{:config('COMPANY_NAME')}直接签订另一书面协议,以补充或者取代本协议的全部或者任何部分。

    +

    {:config('COMPANY_NAME')}拥有{:config('PRODUCT_NAME')}的全部知识产权,包括商标和著作权。虽然在大部分情况下您都可以自由的进行修改、复制、下载、安装、使用或者以其他方式受益于本软件的功能或者知识产权。但是{:config('COMPANY_NAME')}还是希望您能在底部保留我们的链接和版权声明!

    + + +
    +
    +{/block} \ No newline at end of file diff --git a/application/install/view/public/base.html b/application/install/view/public/base.html new file mode 100644 index 0000000..69d5321 --- /dev/null +++ b/application/install/view/public/base.html @@ -0,0 +1,92 @@ + + + + + + ApiAdmin | {block name="title"}{/block} + + + + + + + + + + + + +
    + +
    + +
    +
    +
    +
    + {block name="main"}{/block} +
    +
    +
    +
    +
    + + Copyright © 2015-{:date('Y')} Copyright © 2014-{:date('Y')} {:config('COMPANY_NAME')}. All rights + reserved. +
    +
    +
    + + + + + + + + + + + + + + + + + diff --git a/public/admin/install.php b/public/admin/install.php new file mode 100644 index 0000000..be11443 --- /dev/null +++ b/public/admin/install.php @@ -0,0 +1,17 @@ + +// +---------------------------------------------------------------------- + +// [ 应用入口文件 ] +define('BIND_MODULE','install'); +// 定义应用目录 +define('APP_PATH', __DIR__ . '/../../application/'); +// 加载框架引导文件 +require __DIR__ . '/../../thinkphp/start.php';