HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/bb.cwoyt.com/Application/Install/Controller/InstallController.class.php
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 赛脑 <2233759493@qq.com> <http://www.sn.com>
// +----------------------------------------------------------------------
namespace Install\Controller;
use Think\Controller;
use Think\Db;
class InstallController extends Controller
{
	protected function _initialize()
	{
		if(session('step') === null)
		{
			$this->redirect('step1');
		}
		if(is_file(MODULE_PATH . 'Data/install.lock'))
		{
			$this->error('已经成功安装了赛脑订单系统,请不要重复安装!', U('Index/index'));
		}
	}
	public function step1()
	{
		session('error', false);
		$env = check_env();
		$dirfile = check_dirfile();
		$func = check_func();
		session('step', 1);
		$this->assign('env', $env);
		$this->assign('dirfile', $dirfile);
		$this->assign('func', $func);
		$this->display();
	}
	public function step2($db = null, $admin = null)
	{
		if(IS_POST)
		{
			include 'function.php';
			$u = domain($_SERVER['HTTP_HOST']);
			if($u == 3)
			{
				$this->error('当前域名未授权');
			}
			else if($u == 2)
			{
				$this->error('当前域名正常使用中');
			}
			$info = array( 'username' => 'admin', 'password' => 'admin', 'repassword' => 'admin', 'email' => 'admin@qq.com', );
			session('admin_info', $info);
			if(!is_array($db) || empty($db[0]) || empty($db[1]) || empty($db[2]) || empty($db[3]))
			{
				$this->error('请填写完整的数据库配置');
			}
			else 
			{
				$conn = mysql_connect($db[1], $db[3], $db[4]);
				if($conn)
				{
					$DB = array();
					list($DB['DB_TYPE'], $DB['DB_HOST'], $DB['DB_NAME'], $DB['DB_USER'], $DB['DB_PWD'], $DB['DB_PORT'], $DB['DB_PREFIX']) = $db;
					session('db_config', $DB);
					$dbname = $DB['DB_NAME'];
					unset($DB['DB_NAME']);
					$db = Db::getInstance($DB);
					$sql = "CREATE DATABASE IF NOT EXISTS `{$dbname}
				` DEFAULT CHARACTER SET utf8";
				$db->execute($sql) || $this->error($db->getError());
			}
			//else
			//{
			//	$this->error('数据库链接失败!');
			//}
		}
		$this->success('跳转到数据库安装页面!',U('step3'));
	}
	else 
	{
		//session('error') && $this->error('环境检测没有通过,请调整环境后重试!');
		$step = session('step');
		if($step != 1 && $step != 2)
		{
			$this->redirect('step1');
		}
		session('step', 2);
		$this->display();
	}
}
public function step3()
{
	if(session('step') != 2)
	{
		$this->redirect('step2');
	}
	$this->display();
	$dbconfig = session('db_config');
	$db = Db::getInstance($dbconfig);
	create_tables($db, $dbconfig['DB_PREFIX']);
	$auth = build_auth_key();
	$admin = session('admin_info');
	register_administrator($db, $dbconfig['DB_PREFIX'], $admin, $auth);
	write_config($dbconfig, $auth);
	if(session('error'))
	{
		delDirAndFile('Runtime');
		session('step', 3);
		$this->redirect('Install/Index/complete');
	}
	else 
	{
		delDirAndFile('Runtime');
		session('step', 3);
		$this->redirect('Install/Index/complete');
	}
}
}
?>