|
1
|
<?php
|
1
|
<?php
|
|
2
|
|
2
|
|
|
|
|
3
|
+use App\Helper\Translate;
|
|
3
|
use App\Models\File\Image;
|
4
|
use App\Models\File\Image;
|
|
4
|
use App\Models\File\File as FileModel;
|
5
|
use App\Models\File\File as FileModel;
|
|
5
|
use App\Models\Project\DeployOptimize;
|
6
|
use App\Models\Project\DeployOptimize;
|
|
@@ -1237,4 +1238,159 @@ function getDomain($url) { |
|
@@ -1237,4 +1238,159 @@ function getDomain($url) { |
|
1237
|
}
|
1238
|
}
|
|
1238
|
|
1239
|
|
|
1239
|
|
1240
|
|
|
|
|
1241
|
+/**
|
|
|
|
1242
|
+ * 解析url的 route
|
|
|
|
1243
|
+ * @param $pathInfo
|
|
|
|
1244
|
+ * @return array
|
|
|
|
1245
|
+ * @author zbj
|
|
|
|
1246
|
+ * @date 2025/5/24
|
|
|
|
1247
|
+ */
|
|
|
|
1248
|
+function analysisRoute($pathInfo): array
|
|
|
|
1249
|
+{
|
|
|
|
1250
|
+ $language = '';
|
|
|
|
1251
|
+ $router = "";
|
|
|
|
1252
|
+ $page = null;
|
|
|
|
1253
|
+ $routeType = "";
|
|
|
|
1254
|
+ $source = "";
|
|
|
|
1255
|
+
|
|
|
|
1256
|
+ if (strpos($pathInfo, '_catalog') !== false) {
|
|
|
|
1257
|
+ $source = "module_category";
|
|
|
|
1258
|
+ }
|
|
|
|
1259
|
+ if (strpos($pathInfo, 'news_catalog') !== false) {
|
|
|
|
1260
|
+ $source = "news_category";
|
|
|
|
1261
|
+ }
|
|
|
|
1262
|
+ if (strpos($pathInfo, 'blog_catalog') !== false) {
|
|
|
|
1263
|
+ $source = "blog_category";
|
|
|
|
1264
|
+ }
|
|
|
|
1265
|
+ if (strpos($pathInfo, 'top-blog') !== false) {
|
|
|
|
1266
|
+ $source = "ai_blog_list";
|
|
|
|
1267
|
+ }
|
|
|
|
1268
|
+
|
|
|
|
1269
|
+ $pathArr = explode("/", $pathInfo);
|
|
|
|
1270
|
+ $pathArr = array_filter($pathArr);
|
|
|
|
1271
|
+ $first = array_shift($pathArr);
|
|
|
|
1272
|
+ $last = array_pop($pathArr);
|
|
|
|
1273
|
+ $other = implode("/", $pathArr);
|
|
|
|
1274
|
+
|
|
|
|
1275
|
+ $first = $first == "zh-ct" ? "zh-TW" : $first;
|
|
|
|
1276
|
+ $tlsLang = Translate::getTls();
|
|
|
|
1277
|
+ if (in_array($first, $tlsLang)) {
|
|
|
|
1278
|
+ $language = $first;
|
|
|
|
1279
|
+ $first = '';
|
|
|
|
1280
|
+ }
|
|
|
|
1281
|
+ $lastIsRoute = RouteMap::select("id")->where("route", $last)->first();
|
|
|
|
1282
|
+ if (is_numeric($last) && empty($lastIsRoute)) {
|
|
|
|
1283
|
+ $page = $last;
|
|
|
|
1284
|
+ $last = '';
|
|
|
|
1285
|
+ }
|
|
|
|
1286
|
+ $router_array = compact('first', 'other', 'last');
|
|
|
|
1287
|
+ $router_array = array_filter($router_array);
|
|
|
|
1288
|
+
|
|
|
|
1289
|
+ //解析路由5.0 + 6.0
|
|
|
|
1290
|
+ $keyword = new \App\Models\Product\Keyword();
|
|
|
|
1291
|
+ $topSearchRoute = $keyword->product_keyword_route;
|
|
|
|
1292
|
+ if (isset($router_array['first'])) {
|
|
|
|
1293
|
+ if (isset($router_array['other'])) {
|
|
|
|
1294
|
+ if ($router_array['other'] == "page") {
|
|
|
|
1295
|
+ $router = $router_array['first'];
|
|
|
|
1296
|
+ } else {
|
|
|
|
1297
|
+ $otherArr = explode("/", $router_array['other']);
|
|
|
|
1298
|
+ $otherArr = array_filter($otherArr);
|
|
|
|
1299
|
+ if (count($otherArr) >= 1) {
|
|
|
|
1300
|
+ $router = $otherArr[0];
|
|
|
|
1301
|
+ }
|
|
|
|
1302
|
+ }
|
|
|
|
1303
|
+ } else {
|
|
|
|
1304
|
+ if (isset($router_array['last'])) {
|
|
|
|
1305
|
+ if ($router_array['first']) {
|
|
|
|
1306
|
+ if ($router_array['first'] == "news" || $router_array['first'] == "blogs") {
|
|
|
|
1307
|
+ $routeType = $router_array['first'];
|
|
|
|
1308
|
+ }
|
|
|
|
1309
|
+ if ($router_array['first'] == "user"){
|
|
|
|
1310
|
+ $source = "ai_blog_author";
|
|
|
|
1311
|
+ }
|
|
|
|
1312
|
+ }
|
|
|
|
1313
|
+ if (in_array($router_array['first'], $topSearchRoute)) {
|
|
|
|
1314
|
+ $router = $router_array['first'];
|
|
|
|
1315
|
+ $page = (int)$router_array['last'];
|
|
|
|
1316
|
+ } else {
|
|
|
|
1317
|
+ $router = $router_array['last'];
|
|
|
|
1318
|
+ }
|
|
|
|
1319
|
+ } else {
|
|
|
|
1320
|
+ $router = $router_array['first'];
|
|
|
|
1321
|
+ }
|
|
|
|
1322
|
+ }
|
|
|
|
1323
|
+ } else {
|
|
|
|
1324
|
+ if (isset($router_array['last'])) {
|
|
|
|
1325
|
+ if (isset($router_array['other'])) {
|
|
|
|
1326
|
+ if ($router_array['other'] == "news" || $router_array['other'] == "blogs") {
|
|
|
|
1327
|
+ $routeType = $router_array['other'];
|
|
|
|
1328
|
+ }
|
|
|
|
1329
|
+ }
|
|
|
|
1330
|
+ if ($router_array['last'] != "page") {
|
|
|
|
1331
|
+ if (isset($router_array['other']) && in_array($router_array['other'], $topSearchRoute)) {
|
|
|
|
1332
|
+ $router = $router_array['other'];
|
|
|
|
1333
|
+ $page = (int)$router_array['last'];
|
|
|
|
1334
|
+ } else {
|
|
|
|
1335
|
+ $router = $router_array['last'];
|
|
|
|
1336
|
+ }
|
|
|
|
1337
|
+ } else {
|
|
|
|
1338
|
+ $otherArr = explode("/", $router_array['other']);
|
|
|
|
1339
|
+ $otherArr = array_filter($otherArr);
|
|
|
|
1340
|
+ if (count($otherArr) == 1) {
|
|
|
|
1341
|
+ $router = $otherArr[0];
|
|
|
|
1342
|
+ } else {
|
|
|
|
1343
|
+ $router = $otherArr[1];
|
|
|
|
1344
|
+ }
|
|
|
|
1345
|
+ }
|
|
|
|
1346
|
+ } else {
|
|
|
|
1347
|
+ if (!empty($router_array)) {
|
|
|
|
1348
|
+ $otherArr = explode("/", $router_array['other']);
|
|
|
|
1349
|
+ $otherArr = array_filter($otherArr);
|
|
|
|
1350
|
+ if (count($otherArr) == 3) {
|
|
|
|
1351
|
+ $router = $otherArr[1];
|
|
|
|
1352
|
+ } else {
|
|
|
|
1353
|
+ $router = $otherArr[0];
|
|
|
|
1354
|
+ }
|
|
|
|
1355
|
+ }
|
|
|
|
1356
|
+ }
|
|
|
|
1357
|
+ }
|
|
1240
|
|
1358
|
|
|
|
|
1359
|
+ //路由算法处理,路由只有一级,route_map表中route(规定),不考虑小语种
|
|
|
|
1360
|
+ //新增考虑小语种,判断是否小语种访问,有页面不说,当nginx 404页面之后进程序,生成当前小语种页面
|
|
|
|
1361
|
+ $lang = $language;
|
|
|
|
1362
|
+ if ($page == null) {
|
|
|
|
1363
|
+ if ($router != null) {
|
|
|
|
1364
|
+ if ($lang != null) {
|
|
|
|
1365
|
+ $tlsLang = Translate::getTls();
|
|
|
|
1366
|
+ $isLang = in_array($lang, $tlsLang);
|
|
|
|
1367
|
+ if (!$isLang) {
|
|
|
|
1368
|
+ $page = (int)$router;
|
|
|
|
1369
|
+ $router = $lang;
|
|
|
|
1370
|
+ $lang = "";
|
|
|
|
1371
|
+ }
|
|
|
|
1372
|
+ }
|
|
|
|
1373
|
+ } else {
|
|
|
|
1374
|
+ $tlsLang = Translate::getTls();
|
|
|
|
1375
|
+ $isLang = in_array($lang, $tlsLang);
|
|
|
|
1376
|
+ if (!$isLang) {
|
|
|
|
1377
|
+ $router = $lang;
|
|
|
|
1378
|
+ $lang = "";
|
|
|
|
1379
|
+ }
|
|
|
|
1380
|
+ }
|
|
|
|
1381
|
+ }
|
|
|
|
1382
|
+
|
|
|
|
1383
|
+ if ($routeType == "news") {
|
|
|
|
1384
|
+ $source = "news";
|
|
|
|
1385
|
+ }
|
|
|
|
1386
|
+ if ($routeType == "blogs") {
|
|
|
|
1387
|
+ $source = "blog";
|
|
|
|
1388
|
+ }
|
|
|
|
1389
|
+
|
|
|
|
1390
|
+ $routeArr["lang"] = $lang;
|
|
|
|
1391
|
+ $routeArr["router"] = $router;
|
|
|
|
1392
|
+ $routeArr["page"] = (int)$page;
|
|
|
|
1393
|
+ $routeArr["routeType"] = $routeType;
|
|
|
|
1394
|
+ $routeArr["source"] = $source;
|
|
|
|
1395
|
+ return $routeArr;
|
|
|
|
1396
|
+} |