Commit e25bdc29 authored by tufengqi's avatar tufengqi

fix

parent 47e518fe
......@@ -7,75 +7,18 @@ require $app_package_path . 'LoadConfig.php';
$cookie_version = $_COOKIE[VERSION_KEY] ?? '';
$cookie_version = trim($cookie_version);
$version_val = $version_val_no_prefix = '';
if (defined('IS_FORCE_ONLINE') && true === IS_FORCE_ONLINE) {
$is_real_outer_access = true;
} else {
$is_real_outer_access = ConsoleInitAppHelper::isRealOuterAccess();
}
$cookie_flag = false;
if ($is_real_outer_access || (!$is_real_outer_access && 'ga' === $cookie_version)) {
// 外部用户或者内部设置cookie为ga,只允许访问文件定义的ga版本
$file_tag = 'ga';
$file_version = file_get_contents($version_path . VERSION_KEY . '_ga');
} elseif (!$is_real_outer_access && 'beta' === $cookie_version) {
// 内部设置cookie为beta,只允许访问文件定义的beta版本
if (defined('IS_FORCE_BATE') && true === IS_FORCE_BATE) {
$file_tag = 'beta';
$file_version = file_get_contents($version_path . VERSION_KEY . '_beta');
} else {
$is_online_host = ConsoleInitAppHelper::isOnlineHost();
if (true === $is_online_host) {
// 线上域名默认指向ga环境 即使设置cookie也无效
$file_tag = 'ga';
$file_version = file_get_contents($version_path . VERSION_KEY . '_ga');
} else {
// 其他来源查找cookie
if ($cookie_version && is_dir($base_path . $cookie_version)) {
$base_path = $base_path . $cookie_version . '/';
$version_val = 'cookie-' . $cookie_version;
$version_val_no_prefix = $cookie_version;
// header("fpf-version: " . $version_val);
}
}
$cookie_flag = true;
}
if (false === $cookie_flag) {
$file_version = trim($file_version);
if ($file_version && is_dir($base_path . $file_version)) {
$base_path = $base_path . $file_version . '/';
$version_val = $file_tag . '-' . $file_version;
$version_val_no_prefix = $file_version;
// header("fpf-version: " . $version_val);
}
}
$location_default_version = false;
if ($origin_base_path === $base_path) {
if ($is_real_outer_access || ConsoleInitAppHelper::isFromCompanyAccessOuterHost()) {
// 如果是外网用户或者公司访问公网域名且未定位到任何有效的代码目录,重新指向ga版本
$location_default_version = true;
} else {
// 没有读取任何版本目录
if ('test' === SERVICE_ENV) {
// 提测环境
$location_default_version = true;
} else {
// 本地开发环境
// header("fpf-version: local");
}
}
}
if (true === $location_default_version) {
// 如果是外网用户且未定位到任何有效的代码目录,重新指向ga版本
$file_tag = 'ga';
$file_version = file_get_contents($version_path . VERSION_KEY . '_ga');
$file_version = trim($file_version);
if ($file_version && is_dir($base_path . $file_version)) {
$base_path = $base_path . $file_version . '/';
$version_val = $file_tag . '-' . $file_version;
$version_val_no_prefix = $file_version;
// header("fpf-version: " . $version_val);
} else {
throw new Exception('服务器代码定位错误');
}
}
$file_version = trim($file_version);
if ($file_version && is_dir($base_path . $file_version)) {
$base_path = $base_path . $file_version . '/';
$version_val = $file_tag . '-' . $file_version;
$version_val_no_prefix = $file_version;
}
// 重载外层配置路径
require $app_package_path . 'LoadConfig.php';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment