切换导航条
此项目
正在载入...
登录
何书鹏
/
anttest
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
Karson
4 years ago
提交
eca3ae7086166f929352132001bcd5b260fe7836
1 个父辈
346f6eab
优化在非80端口下的跨域判断
优化安装脚本
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
18 行增加
和
12 行删除
application/admin/command/Install.php
application/common.php
application/config.php
application/admin/command/Install.php
查看文件 @
eca3ae7
...
...
@@ -199,19 +199,23 @@ class Install extends Command
// 后台入口文件
$adminFile
=
ROOT_PATH
.
'public'
.
DS
.
'admin.php'
;
// 生成数据库Env配置文件
$envFile
=
ROOT_PATH
.
'.env.sample'
;
$envStr
=
@
file_get_contents
(
$envFile
);
// 数据库配置文件
$dbConfigFile
=
APP_PATH
.
'database.php'
;
$config
=
@
file_get_contents
(
$dbConfigFile
);
$callback
=
function
(
$matches
)
use
(
$mysqlHostname
,
$mysqlHostport
,
$mysqlUsername
,
$mysqlPassword
,
$mysqlDatabase
,
$mysqlPrefix
)
{
$field
=
"mysql"
.
ucfirst
(
$matches
[
1
]);
$replace
=
$$field
;
return
"
{
$matches
[
1
]}
=
{
$replace
}
"
.
PHP_EOL
;
if
(
$matches
[
1
]
==
'hostport'
&&
$mysqlHostport
==
3306
)
{
$replace
=
''
;
}
return
"'
{
$matches
[
1
]}
'{$matches[2]}=>{$matches[3]}Env::get('
database
.
{
$matches
[
1
]}
', '
{
$replace
}
'),"
;
};
$
envConf
=
preg_replace_callback
(
'/(hostname|database|username|password|hostport|prefix)\s*=\s*(.*?)\n/'
,
$callback
,
$envStr
);
$
config
=
preg_replace_callback
(
"/'(hostname|database|username|password|hostport|prefix)'(\s+)=>(\s+)Env::get\((.*)\)\,/"
,
$callback
,
$config
);
$result
=
@
file_put_contents
(
ROOT_PATH
.
'.env'
,
$envConf
);
// 检测能否成功写入数据库配置
$result
=
@
file_put_contents
(
$dbConfigFile
,
$config
);
if
(
!
$result
)
{
throw
new
Exception
(
__
(
'The current permissions are insufficient to write the file %s'
,
'
.env
'
));
throw
new
Exception
(
__
(
'The current permissions are insufficient to write the file %s'
,
'
application/database.php
'
));
}
// 变更默认管理员密码
...
...
@@ -275,15 +279,17 @@ class Install extends Command
'public'
.
DS
.
'assets'
.
DS
.
'libs'
];
//数据库配置文件
$dbConfigFile
=
APP_PATH
.
'database.php'
;
if
(
version_compare
(
PHP_VERSION
,
'7.0.0'
,
'<'
))
{
throw
new
Exception
(
__
(
"The current version %s is too low, please use PHP 7.0 or higher"
,
PHP_VERSION
));
}
if
(
!
extension_loaded
(
"PDO"
))
{
throw
new
Exception
(
__
(
"PDO is not currently installed and cannot be installed"
));
}
$envConfFile
=
ROOT_PATH
.
'.env'
;
if
(
is_file
(
$envConfFile
)
&&
!
is_really_writable
(
$envConfFile
))
{
throw
new
Exception
(
__
(
'The current permissions are insufficient to write the file %s'
,
'.env'
));
if
(
!
is_really_writable
(
$dbConfigFile
))
{
throw
new
Exception
(
__
(
'The current permissions are insufficient to write the configuration file application/database.php'
));
}
foreach
(
$checkDirs
as
$k
=>
$v
)
{
if
(
!
is_dir
(
ROOT_PATH
.
$v
))
{
...
...
application/common.php
查看文件 @
eca3ae7
...
...
@@ -370,7 +370,7 @@ if (!function_exists('check_cors_request')) {
if
(
isset
(
$_SERVER
[
'HTTP_ORIGIN'
])
&&
$_SERVER
[
'HTTP_ORIGIN'
])
{
$info
=
parse_url
(
$_SERVER
[
'HTTP_ORIGIN'
]);
$domainArr
=
explode
(
','
,
config
(
'fastadmin.cors_request_domain'
));
$domainArr
[]
=
request
()
->
host
();
$domainArr
[]
=
request
()
->
host
(
true
);
if
(
in_array
(
"*"
,
$domainArr
)
||
in_array
(
$_SERVER
[
'HTTP_ORIGIN'
],
$domainArr
)
||
(
isset
(
$info
[
'host'
])
&&
in_array
(
$info
[
'host'
],
$domainArr
)))
{
header
(
"Access-Control-Allow-Origin: "
.
$_SERVER
[
'HTTP_ORIGIN'
]);
}
else
{
...
...
application/config.php
查看文件 @
eca3ae7
...
...
@@ -290,7 +290,7 @@ return [
//允许跨域的域名,多个以,分隔
'cors_request_domain'
=>
'localhost,127.0.0.1'
,
//版本号
'version'
=>
'1.2.0.2020100
1
_beta'
,
'version'
=>
'1.2.0.2020100
8
_beta'
,
//API接口地址
'api_url'
=>
'https://api.fastadmin.net'
,
],
...
...
请
注册
或
登录
后发表评论