mirror of https://github.com/1099438829/apeblog
修正缺少env的问题
This commit is contained in:
parent
30d7147b05
commit
8007517225
|
|
@ -2,7 +2,7 @@
|
|||
/.vscode
|
||||
*.log
|
||||
*/.DS_Store
|
||||
.env
|
||||
/.env
|
||||
/runtime
|
||||
/composer.lock
|
||||
/public/install/install.lock
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
APP_DEBUG = false
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME = #DB_HOST#
HOSTPORT = #DB_PORT#
USERNAME = #DB_USER#
PASSWORD = #DB_PWD#
DATABASE = #DB_NAME#
PREFIX = #DB_PREFIX#
CHARSET = utf8
DEBUG = #DB_DEBUG#
[LANG]
default_lang = zh-cn
|
||||
|
|
@ -29,13 +29,10 @@ error_reporting(E_ALL & ~E_NOTICE);
|
|||
header('Content-Type: text/html; charset=UTF-8');
|
||||
define('SITE_DIR', _dir_path(substr(dirname(__FILE__), 0, -8)));//入口文件目录
|
||||
define('APP_DIR', _dir_path(substr(dirname(__FILE__), 0, -15)));//项目目录
|
||||
//define('SITEDIR2', substr(SITEDIR,0,-7));
|
||||
//echo SITEDIR;
|
||||
//exit;SITE_DIR
|
||||
//数据库
|
||||
$sqlFile = 'ape_blog.sql';
|
||||
$configFile = '.env';
|
||||
if (!file_exists(SITE_DIR . 'install/' . $sqlFile) || !file_exists(SITE_DIR . 'install/' . $configFile)) {
|
||||
$sqlFile = SITE_DIR . 'install/ape_blog.sql';
|
||||
$configFile = SITE_DIR . 'install/.env';
|
||||
if (!file_exists($sqlFile) || !file_exists($configFile)) {
|
||||
echo '缺少必要的安装文件!';
|
||||
exit;
|
||||
}
|
||||
|
|
@ -210,8 +207,7 @@ switch ($step) {
|
|||
$arr['msg'] = "请安装 mysqli 扩展!";
|
||||
echo json_encode($arr);
|
||||
exit;
|
||||
}
|
||||
;
|
||||
};
|
||||
$conn = @mysqli_connect($dbHost, $dbUser, $dbPwd, NULL, $_POST['dbport']);
|
||||
if (mysqli_connect_errno($conn)) {
|
||||
$arr['msg'] = "连接数据库失败!" . mysqli_connect_error($conn);
|
||||
|
|
@ -243,7 +239,7 @@ switch ($step) {
|
|||
}
|
||||
|
||||
//读取数据文件
|
||||
$sqldata = file_get_contents(SITE_DIR . 'install/' . $sqlFile);
|
||||
$sqldata = file_get_contents($sqlFile);
|
||||
$sqlFormat = sql_split($sqldata, $dbPrefix);
|
||||
//创建写入sql数据库文件到库中 结束
|
||||
|
||||
|
|
@ -280,8 +276,7 @@ switch ($step) {
|
|||
// 清理掉管理员表
|
||||
mysqli_query($conn, "truncate table " . str_replace('ape_', $dbPrefix, 'ape_admin'));
|
||||
// 清空测试数据
|
||||
if(!$_POST['demo'])
|
||||
{
|
||||
if (!$_POST['demo']) {
|
||||
$bl_table = array('ape_admin'
|
||||
, 'ape_admin_log'
|
||||
, 'ape_admin_notify'
|
||||
|
|
@ -301,19 +296,18 @@ switch ($step) {
|
|||
, 'ape_url_log'
|
||||
, 'ape_user'
|
||||
, 'ape_uv_log');
|
||||
foreach($bl_table as $k => $v)
|
||||
{
|
||||
foreach ($bl_table as $k => $v) {
|
||||
$bl_table[$k] = str_replace('ape_', $dbPrefix, $v);
|
||||
}
|
||||
|
||||
foreach($bl_table as $key => $val)
|
||||
{
|
||||
foreach ($bl_table as $key => $val) {
|
||||
mysqli_query($conn, "truncate table " . $val);
|
||||
}
|
||||
delFile(APP_DIR . '/public/upload'); // 清空测试图片
|
||||
}
|
||||
//读取配置文件,并替换真实配置数据1
|
||||
$strConfig = file_get_contents(SITE_DIR . 'install/' . $configFile);
|
||||
|
||||
$strConfig = file_get_contents($configFile);
|
||||
$strConfig = str_replace('#DB_HOST#', $dbHost, $strConfig);
|
||||
$strConfig = str_replace('#DB_NAME#', $dbName, $strConfig);
|
||||
$strConfig = str_replace('#DB_USER#', $dbUser, $strConfig);
|
||||
|
|
@ -322,8 +316,16 @@ switch ($step) {
|
|||
$strConfig = str_replace('#DB_PREFIX#', $dbPrefix, $strConfig);
|
||||
$strConfig = str_replace('#DB_CHARSET#', 'utf8', $strConfig);
|
||||
$strConfig = str_replace('#DB_DEBUG#', 'false', $strConfig);
|
||||
@file_put_contents(APP_DIR . '.env', $strConfig); //数据库配置文件的地址
|
||||
@chmod(APP_DIR . '.env',0777); //数据库配置文件的地址//
|
||||
//检查文件是否存在
|
||||
$newConfigFile = APP_DIR . '.env';
|
||||
if (!file_exists($newConfigFile)) {
|
||||
@copy($configFile, $newConfigFile);
|
||||
} else if (is_dir($newConfigFile)) {
|
||||
@rmdir($newConfigFile);
|
||||
@copy($configFile, $newConfigFile);
|
||||
}
|
||||
@file_put_contents($newConfigFile, $strConfig); //数据库配置文件的地址
|
||||
@chmod($newConfigFile, 0777); //数据库配置文件的地址//
|
||||
//更新网站配置信息2
|
||||
//插入管理员表字段ape_admin表
|
||||
$time = time();
|
||||
|
|
@ -341,11 +343,13 @@ switch ($step) {
|
|||
if ($res) {
|
||||
$message = '成功添加管理员<br />成功写入配置文件<br>安装完成.';
|
||||
$arr = array('n' => 999999, 'msg' => $message);
|
||||
echo json_encode($arr);exit;
|
||||
echo json_encode($arr);
|
||||
exit;
|
||||
} else {
|
||||
$message = '添加管理员失败<br />成功写入配置文件<br>安装完成.';
|
||||
$arr = array('n' => 999999, 'msg' => $message);
|
||||
echo json_encode($arr);exit;
|
||||
echo json_encode($arr);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
include_once("./templates/step4.php");
|
||||
|
|
@ -361,13 +365,16 @@ switch ($step) {
|
|||
}
|
||||
|
||||
//写入安装信息
|
||||
function installlog(){
|
||||
function installlog()
|
||||
{
|
||||
$mt_rand_str = sp_random_string(6);
|
||||
$str_constant = "<?php" . PHP_EOL . "define('INSTALL_DATE'," . time() . ");" . PHP_EOL . "define('SERIALNUMBER','" . $mt_rand_str . "');";
|
||||
@file_put_contents(APP_DIR . '.constant', $str_constant);
|
||||
}
|
||||
|
||||
//判断权限
|
||||
function testwrite($d) {
|
||||
function testwrite($d)
|
||||
{
|
||||
if (is_file($d)) {
|
||||
if (is_writeable($d)) {
|
||||
return true;
|
||||
|
|
@ -391,7 +398,8 @@ function testwrite($d) {
|
|||
}
|
||||
|
||||
|
||||
function sql_split($sql, $tablepre) {
|
||||
function sql_split($sql, $tablepre)
|
||||
{
|
||||
|
||||
if ($tablepre != "tp_")
|
||||
$sql = str_replace("tp_", $tablepre, $sql);
|
||||
|
|
@ -417,7 +425,8 @@ function sql_split($sql, $tablepre) {
|
|||
return $ret;
|
||||
}
|
||||
|
||||
function _dir_path($path) {
|
||||
function _dir_path($path)
|
||||
{
|
||||
$path = str_replace('\\', '/', $path);
|
||||
if (substr($path, -1) != '/')
|
||||
$path = $path . '/';
|
||||
|
|
@ -425,7 +434,8 @@ function _dir_path($path) {
|
|||
}
|
||||
|
||||
// 获取客户端IP地址
|
||||
function get_client_ip() {
|
||||
function get_client_ip()
|
||||
{
|
||||
static $ip = NULL;
|
||||
if ($ip !== NULL)
|
||||
return $ip;
|
||||
|
|
@ -445,7 +455,8 @@ function get_client_ip() {
|
|||
return $ip;
|
||||
}
|
||||
|
||||
function dir_create($path, $mode = 0777) {
|
||||
function dir_create($path, $mode = 0777)
|
||||
{
|
||||
if (is_dir($path))
|
||||
return TRUE;
|
||||
$ftp_enable = 0;
|
||||
|
|
@ -463,20 +474,23 @@ function dir_create($path, $mode = 0777) {
|
|||
return is_dir($path);
|
||||
}
|
||||
|
||||
function dir_path($path) {
|
||||
function dir_path($path)
|
||||
{
|
||||
$path = str_replace('\\', '/', $path);
|
||||
if (substr($path, -1) != '/')
|
||||
$path = $path . '/';
|
||||
return $path;
|
||||
}
|
||||
|
||||
function sp_password($pw, $pre){
|
||||
function sp_password($pw, $pre)
|
||||
{
|
||||
$decor = md5($pre);
|
||||
$mi = md5($pw);
|
||||
return substr($decor, 0, 12) . $mi . substr($decor, -4, 4);
|
||||
}
|
||||
|
||||
function sp_random_string($len = 8) {
|
||||
function sp_random_string($len = 8)
|
||||
{
|
||||
$chars = array(
|
||||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
|
||||
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
|
||||
|
|
@ -493,8 +507,10 @@ function sp_random_string($len = 8) {
|
|||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
// 递归删除文件夹
|
||||
function delFile($dir,$file_type='') {
|
||||
function delFile($dir, $file_type = '')
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
$files = scandir($dir);
|
||||
//打开目录 //列出目录中的所有文件并去掉 . 和 ..
|
||||
|
|
@ -526,4 +542,5 @@ function delFile($dir,$file_type='') {
|
|||
if (file_exists($dir)) unlink($dir);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue