| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <?php
- /**
- * 洛阳赤炎鹰网络科技有限公司
- * https://www.cyyvip.com
- * Copyright (c) 2022 赤店商城 All rights reserved.
- */
- namespace Install\Controller;
- use Think\Controller;
- use Think\Db;
- set_time_limit(0);
- /**
- * 首页
- */
- class IndexController extends Controller {
-
- function _initialize(){
- if(file_exists_case("../install.lock.php")){
- redirect(__ROOT__."/");
- }
- }
- //首页
- public function index() {
- $this->display(":index");
- }
-
- public function step2(){
- $data=array();
- $data['os']=PHP_OS;
- $tmp = function_exists('gd_info') ? gd_info() : array();
- $server = $_SERVER["SERVER_SOFTWARE"];
- $host = (empty($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_HOST"] : $_SERVER["SERVER_ADDR"]);
- $name = $_SERVER["SERVER_NAME"];
- $max_execution_time = ini_get('max_execution_time');
- $allow_reference = (ini_get('allow_call_time_pass_reference') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
- $allow_url_fopen = (ini_get('allow_url_fopen') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
- $safe_mode = (ini_get('safe_mode') ? '<font color=red>[×]On</font>' : '<font color=green>[√]Off</font>');
-
- $err = 0;
- if (empty($tmp['GD Version'])) {
- $gd = '<font color=red>[×]Off</font>';
- $err++;
- } else {
- $gd = '<font color=green>[√]On</font> ' . $tmp['GD Version'];
- }
- if (extension_loaded('fileinfo')) {
- $data['fileinfo'] = '<i class="fa fa-check correct"></i> 已开启';
- } else {
- $data['fileinfo'] = '<i class="fa fa-remove error"></i> 未开启';
- $err++;
- }
- if (extension_loaded('SimpleXML')) {
- $data['SimpleXML'] = '<i class="fa fa-check correct"></i> 已开启';
- } else {
- $data['SimpleXML'] = '<i class="fa fa-remove error"></i> 未开启';
- $err++;
- }
- if (self::php_version()) {
- $data['phpversion'] = '<i class="fa fa-check correct"></i> ' . @ phpversion();
- } else {
- $data['phpversion'] = '<i class="fa fa-remove error"></i> ' . @ phpversion();
- $err++;
- }
- if (class_exists('pdo')) {
- $data['pdo'] = '<i class="fa fa-check correct"></i> 已开启';
- } else {
- $data['pdo'] = '<i class="fa fa-remove error"></i> 未开启';
- $err++;
- }
-
- if (extension_loaded('pdo_mysql')) {
- $data['pdo_mysql'] = '<i class="fa fa-check correct"></i> 已开启';
- } else {
- $data['pdo_mysql'] = '<i class="fa fa-remove error"></i> 未开启';
- $err++;
- }
-
- if (ini_get('file_uploads')) {
- $data['upload_size'] = '<i class="fa fa-check correct"></i> ' . ini_get('upload_max_filesize');
- } else {
- $data['upload_size'] = '<i class="fa fa-remove error"></i> 禁止上传';
- }
-
- if (function_exists('session_start')) {
- $data['session'] = '<i class="fa fa-check correct"></i> 支持';
- } else {
- $data['session'] = '<i class="fa fa-remove error"></i> 不支持';
- $err++;
- }
- if (function_exists('curl_init')) {
- $data['curl_init'] = '<i class="fa fa-check correct"></i> 支持';
- } else {
- $data['curl_init'] = '<i class="fa fa-remove error"></i> 不支持';
- $err++;
- }
- if (function_exists('openssl_decrypt')) {
- $data['php_openssl'] = '<i class="fa fa-check correct"></i> 支持';
- } else {
- $data['php_openssl'] = '<i class="fa fa-remove error"></i> 不支持';
- $err++;
- }
-
- $folders = array(
- '../',//根目录
- '../config/',
- '../runtime/',
- '../web/',
- );
- $new_folders=array();
- foreach($folders as $dir){
- $Testdir = "./".$dir;
- sp_dir_create($Testdir);
- if(sp_testwrite($Testdir)){
- $new_folders[$dir]['w']=true;
- }else{
- $new_folders[$dir]['w']=false;
- $err++;
- }
- if(is_readable($Testdir)){
- $new_folders[$dir]['r']=true;
- }else{
- $new_folders[$dir]['r']=false;
- $err++;
- }
- }
- $data['folders']=$new_folders;
- $data['err']=$err;
- $this->assign($data);
- $this->display(":step2");
- }
-
- public function step3(){
- $this->display(":step3");
- }
-
- public function step4(){
- if(IS_POST){
- //创建数据库
- $dbconfig['DB_TYPE']="mysql";
- $dbconfig['DB_HOST']=I('post.dbhost');
- $dbconfig['DB_USER']=I('post.dbuser');
- $dbconfig['DB_PWD']=I('post.dbpw');
- $db = Db::getInstance($dbconfig);
- $dbname=strtolower(I('post.dbname'));
- $sql = "CREATE DATABASE IF NOT EXISTS `{$dbname}` DEFAULT CHARACTER SET utf8mb4";
- $db->execute($sql) || $this->error($db->getError());
-
- $this->display(":step4");
-
- //创建数据表
- $dbconfig['DB_NAME']=$dbname;
- $dbconfig['DB_PREFIX']=trim(I('post.dbprefix'));
- $db = Db::getInstance($dbconfig);
-
- $table_prefix=I("post.dbprefix");
- sp_execute_sql($db, "sql.sql", $table_prefix);
-
- //生成网站配置文件
- sp_create_config($dbconfig);
- session("_install_step",4);
- sleep(1);
- $this->redirect("step5");
- }else{
- exit;
- }
- }
-
- public function step5(){
- if(session("_install_step")==4){
- @touch('../install.lock.php');
- $this->display(":step5");
- }else{
- $this->error("非法安装!");
- }
- }
-
- public function testdbpwd(){
- if(IS_POST){
- $dbconfig=I("POST.");
- $dbconfig['DB_TYPE']="mysql";
- $db = Db::getInstance($dbconfig);
- try{
- $db->query("show databases;");
- }catch (\Exception $e){
- die("");
- }
- exit("1");
- }else{
- exit("need post!");
- }
-
- }
- /**
- * 判断当前环境php版本是否大于大于等于指定的一个版本
- * @param string $version
- * @return boolean
- */
- public static function php_version( $version = '7.4.0' ) {
- $php_version = @ phpversion();
- // =0表示版本为7.4.0 =1表示大于7.4.0 =-1表示小于7.4.0
- $is_pass = strnatcasecmp( $php_version, $version ) >= 0 ? true : false;
- return $is_pass;
- }
- }
|