|
|
|
<?php
|
|
|
|
|
|
|
|
use App\Helper\Translate;
|
|
|
|
use App\Models\File\Image;
|
|
|
|
use App\Models\File\File as FileModel;
|
|
|
|
use App\Models\Project\DeployOptimize;
|
|
...
|
...
|
@@ -1237,4 +1238,159 @@ function getDomain($url) { |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 解析url的 route
|
|
|
|
* @param $pathInfo
|
|
|
|
* @return array
|
|
|
|
* @author zbj
|
|
|
|
* @date 2025/5/24
|
|
|
|
*/
|
|
|
|
function analysisRoute($pathInfo): array
|
|
|
|
{
|
|
|
|
$language = '';
|
|
|
|
$router = "";
|
|
|
|
$page = null;
|
|
|
|
$routeType = "";
|
|
|
|
$source = "";
|
|
|
|
|
|
|
|
if (strpos($pathInfo, '_catalog') !== false) {
|
|
|
|
$source = "module_category";
|
|
|
|
}
|
|
|
|
if (strpos($pathInfo, 'news_catalog') !== false) {
|
|
|
|
$source = "news_category";
|
|
|
|
}
|
|
|
|
if (strpos($pathInfo, 'blog_catalog') !== false) {
|
|
|
|
$source = "blog_category";
|
|
|
|
}
|
|
|
|
if (strpos($pathInfo, 'top-blog') !== false) {
|
|
|
|
$source = "ai_blog_list";
|
|
|
|
}
|
|
|
|
|
|
|
|
$pathArr = explode("/", $pathInfo);
|
|
|
|
$pathArr = array_filter($pathArr);
|
|
|
|
$first = array_shift($pathArr);
|
|
|
|
$last = array_pop($pathArr);
|
|
|
|
$other = implode("/", $pathArr);
|
|
|
|
|
|
|
|
$first = $first == "zh-ct" ? "zh-TW" : $first;
|
|
|
|
$tlsLang = Translate::getTls();
|
|
|
|
if (in_array($first, $tlsLang)) {
|
|
|
|
$language = $first;
|
|
|
|
$first = '';
|
|
|
|
}
|
|
|
|
$lastIsRoute = RouteMap::select("id")->where("route", $last)->first();
|
|
|
|
if (is_numeric($last) && empty($lastIsRoute)) {
|
|
|
|
$page = $last;
|
|
|
|
$last = '';
|
|
|
|
}
|
|
|
|
$router_array = compact('first', 'other', 'last');
|
|
|
|
$router_array = array_filter($router_array);
|
|
|
|
|
|
|
|
//解析路由5.0 + 6.0
|
|
|
|
$keyword = new \App\Models\Product\Keyword();
|
|
|
|
$topSearchRoute = $keyword->product_keyword_route;
|
|
|
|
if (isset($router_array['first'])) {
|
|
|
|
if (isset($router_array['other'])) {
|
|
|
|
if ($router_array['other'] == "page") {
|
|
|
|
$router = $router_array['first'];
|
|
|
|
} else {
|
|
|
|
$otherArr = explode("/", $router_array['other']);
|
|
|
|
$otherArr = array_filter($otherArr);
|
|
|
|
if (count($otherArr) >= 1) {
|
|
|
|
$router = $otherArr[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (isset($router_array['last'])) {
|
|
|
|
if ($router_array['first']) {
|
|
|
|
if ($router_array['first'] == "news" || $router_array['first'] == "blogs") {
|
|
|
|
$routeType = $router_array['first'];
|
|
|
|
}
|
|
|
|
if ($router_array['first'] == "user"){
|
|
|
|
$source = "ai_blog_author";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (in_array($router_array['first'], $topSearchRoute)) {
|
|
|
|
$router = $router_array['first'];
|
|
|
|
$page = (int)$router_array['last'];
|
|
|
|
} else {
|
|
|
|
$router = $router_array['last'];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$router = $router_array['first'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (isset($router_array['last'])) {
|
|
|
|
if (isset($router_array['other'])) {
|
|
|
|
if ($router_array['other'] == "news" || $router_array['other'] == "blogs") {
|
|
|
|
$routeType = $router_array['other'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($router_array['last'] != "page") {
|
|
|
|
if (isset($router_array['other']) && in_array($router_array['other'], $topSearchRoute)) {
|
|
|
|
$router = $router_array['other'];
|
|
|
|
$page = (int)$router_array['last'];
|
|
|
|
} else {
|
|
|
|
$router = $router_array['last'];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$otherArr = explode("/", $router_array['other']);
|
|
|
|
$otherArr = array_filter($otherArr);
|
|
|
|
if (count($otherArr) == 1) {
|
|
|
|
$router = $otherArr[0];
|
|
|
|
} else {
|
|
|
|
$router = $otherArr[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!empty($router_array)) {
|
|
|
|
$otherArr = explode("/", $router_array['other']);
|
|
|
|
$otherArr = array_filter($otherArr);
|
|
|
|
if (count($otherArr) == 3) {
|
|
|
|
$router = $otherArr[1];
|
|
|
|
} else {
|
|
|
|
$router = $otherArr[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//路由算法处理,路由只有一级,route_map表中route(规定),不考虑小语种
|
|
|
|
//新增考虑小语种,判断是否小语种访问,有页面不说,当nginx 404页面之后进程序,生成当前小语种页面
|
|
|
|
$lang = $language;
|
|
|
|
if ($page == null) {
|
|
|
|
if ($router != null) {
|
|
|
|
if ($lang != null) {
|
|
|
|
$tlsLang = Translate::getTls();
|
|
|
|
$isLang = in_array($lang, $tlsLang);
|
|
|
|
if (!$isLang) {
|
|
|
|
$page = (int)$router;
|
|
|
|
$router = $lang;
|
|
|
|
$lang = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$tlsLang = Translate::getTls();
|
|
|
|
$isLang = in_array($lang, $tlsLang);
|
|
|
|
if (!$isLang) {
|
|
|
|
$router = $lang;
|
|
|
|
$lang = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($routeType == "news") {
|
|
|
|
$source = "news";
|
|
|
|
}
|
|
|
|
if ($routeType == "blogs") {
|
|
|
|
$source = "blog";
|
|
|
|
}
|
|
|
|
|
|
|
|
$routeArr["lang"] = $lang;
|
|
|
|
$routeArr["router"] = $router;
|
|
|
|
$routeArr["page"] = (int)$page;
|
|
|
|
$routeArr["routeType"] = $routeType;
|
|
|
|
$routeArr["source"] = $source;
|
|
|
|
return $routeArr;
|
|
|
|
} |
...
|
...
|
|