正在显示
28 个修改的文件
包含
2995 行增加
和
284 行删除
| @@ -196,7 +196,56 @@ if (!function_exists('checkDomain')) { | @@ -196,7 +196,56 @@ if (!function_exists('checkDomain')) { | ||
| 196 | } | 196 | } |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | +if (!function_exists('page_init')) { | ||
| 200 | + /** | ||
| 201 | + * amp分页初始化 | ||
| 202 | + * @param $page | ||
| 203 | + * @param $total | ||
| 204 | + * @author Akun | ||
| 205 | + * @date 2024/01/29 15:43 | ||
| 206 | + */ | ||
| 207 | + function page_init($page, $total) | ||
| 208 | + { | ||
| 209 | + //中间页处理 | ||
| 210 | + $center_page = []; | ||
| 211 | + if ($total <= 5) { | ||
| 212 | + for ($i = 1; $i <= $total; $i++) { | ||
| 213 | + $center_page[] = $i; | ||
| 214 | + } | ||
| 215 | + } else { | ||
| 216 | + if ($page < 5) { | ||
| 217 | + for ($i = 1; $i <= 5; $i++) { | ||
| 218 | + $center_page[] = $i; | ||
| 219 | + } | ||
| 220 | + } else { | ||
| 221 | + if ($page == $total) { | ||
| 222 | + for ($i = $total - 5; $i <= $total; $i++) { | ||
| 223 | + $center_page[] = $i; | ||
| 224 | + } | ||
| 225 | + } else if ($page <= $total) { | ||
| 226 | + if ($total - $page <= 5) { | ||
| 227 | + if ($total - $page == 1) { | ||
| 228 | + for ($i = $total - 4; $i <= $total; $i++) { | ||
| 229 | + $center_page[] = $i; | ||
| 230 | + } | ||
| 231 | + } else { | ||
| 232 | + for ($i = $page - 2; $i <= $page + 2; $i++) { | ||
| 233 | + $center_page[] = $i; | ||
| 234 | + } | ||
| 235 | + } | ||
| 236 | + } else { | ||
| 237 | + for ($i = $page - 2; $i <= $page + 2; $i++) { | ||
| 238 | + $center_page[] = $i; | ||
| 239 | + } | ||
| 240 | + } | ||
| 241 | + } | ||
| 199 | 242 | ||
| 243 | + } | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + return $center_page; | ||
| 247 | + } | ||
| 248 | +} | ||
| 200 | /** | 249 | /** |
| 201 | * 把返回的数据集转换成Tree | 250 | * 把返回的数据集转换成Tree |
| 202 | * @param $list array 数据列表 | 251 | * @param $list array 数据列表 |
| @@ -240,6 +289,37 @@ function list_to_tree($list, $pk = 'id', $pid = 'pid', $child = '_child', $root | @@ -240,6 +289,37 @@ function list_to_tree($list, $pk = 'id', $pid = 'pid', $child = '_child', $root | ||
| 240 | return $tree; | 289 | return $tree; |
| 241 | } | 290 | } |
| 242 | 291 | ||
| 292 | +if (!function_exists('special2str')) { | ||
| 293 | + /** | ||
| 294 | + * 特殊字符串替换 | ||
| 295 | + * @param $str | ||
| 296 | + * @return string|string[] | ||
| 297 | + * @author Akun | ||
| 298 | + * @date 2024/01/30 17:46 | ||
| 299 | + */ | ||
| 300 | + function special2str($str) | ||
| 301 | + { | ||
| 302 | + if (strpos($str, ';') === false) { | ||
| 303 | + return $str; | ||
| 304 | + } | ||
| 305 | + | ||
| 306 | + $list = [ | ||
| 307 | + '<' => '<', | ||
| 308 | + '>' => '>', | ||
| 309 | + '&' => '&', | ||
| 310 | + '´' => '´', | ||
| 311 | + '"' => '“', | ||
| 312 | + ' ' => ' ' | ||
| 313 | + ]; | ||
| 314 | + | ||
| 315 | + foreach ($list as $k => $v) { | ||
| 316 | + $str = str_replace($k, $v, $str); | ||
| 317 | + } | ||
| 318 | + | ||
| 319 | + return $str; | ||
| 320 | + } | ||
| 321 | +} | ||
| 322 | + | ||
| 243 | /** | 323 | /** |
| 244 | * tree数据转list | 324 | * tree数据转list |
| 245 | * @param $tree | 325 | * @param $tree |
| @@ -7,4 +7,32 @@ use App\Models\Base; | @@ -7,4 +7,32 @@ use App\Models\Base; | ||
| 7 | class Notify extends Base | 7 | class Notify extends Base |
| 8 | { | 8 | { |
| 9 | protected $table = 'gl_notify'; | 9 | protected $table = 'gl_notify'; |
| 10 | + /** | ||
| 11 | + * 状态 0:待处理, 1:路由生成完成, 2:页面生成完成 | ||
| 12 | + */ | ||
| 13 | + const STATUS_INIT = 0; | ||
| 14 | + const STATUS_FINISH_ROUTE = 1; | ||
| 15 | + const STATUS_FINISH_PAGE = 2; | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 类型 1:主站, 2:小语种 | ||
| 19 | + */ | ||
| 20 | + const TYPE_MASTER = 1; | ||
| 21 | + const TYPE_MINOR = 2; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 路由 | ||
| 25 | + * 1:所有路由,整站生成, | ||
| 26 | + * 2:修改过内容的路由,按需生成, | ||
| 27 | + * 3:指定路由,按url生成 | ||
| 28 | + * 4:生成聚合页生成 | ||
| 29 | + * 5:生成漏翻页面 | ||
| 30 | + * 6:生成视频聚合页 | ||
| 31 | + */ | ||
| 32 | + const ROUTE_ALL = 1; | ||
| 33 | + const ROUTE_NEED = 2; | ||
| 34 | + const ROUTE_URL = 3; | ||
| 35 | + const ROUTE_PRODUCT_KEYWORD = 4; | ||
| 36 | + const ROUTE_NOT_TRANSLATE = 5; | ||
| 37 | + const ROUTE_PRODUCT_VIDEO_KEYWORD = 6; | ||
| 10 | } | 38 | } |
| @@ -10,10 +10,27 @@ | @@ -10,10 +10,27 @@ | ||
| 10 | namespace App\Models\CustomModule; | 10 | namespace App\Models\CustomModule; |
| 11 | 11 | ||
| 12 | use App\Models\Base; | 12 | use App\Models\Base; |
| 13 | +use App\Models\Module\ModuleCategory; | ||
| 13 | 14 | ||
| 14 | class CustomModule extends Base | 15 | class CustomModule extends Base |
| 15 | { | 16 | { |
| 16 | protected $table = 'gl_custom_module'; | 17 | protected $table = 'gl_custom_module'; |
| 17 | //连接数据库 | 18 | //连接数据库 |
| 18 | protected $connection = 'custom_mysql'; | 19 | protected $connection = 'custom_mysql'; |
| 20 | + /** | ||
| 21 | + * 根据模块查找自定义模块分类数据 | ||
| 22 | + */ | ||
| 23 | + public static function getModuleCategory($projectId,$modules) | ||
| 24 | + { | ||
| 25 | + $moduleCategoryInfo = null; | ||
| 26 | + if (isset($modules->category_id) && !empty($modules->category_id) && $modules->category_id != ",,"){ | ||
| 27 | + $cateArr = explode(",",$modules->category_id); | ||
| 28 | + $cateArr = array_filter($cateArr); | ||
| 29 | + if (!empty($cateArr)){ | ||
| 30 | + $cateId = (int)array_shift($cateArr); | ||
| 31 | + $moduleCategoryInfo = CustomModuleCategory::getModuleCategoryAndExtendById($projectId,$cateId); | ||
| 32 | + } | ||
| 33 | + } | ||
| 34 | + return $moduleCategoryInfo; | ||
| 35 | + } | ||
| 19 | } | 36 | } |
| @@ -16,4 +16,20 @@ class CustomModuleCategory extends Base | @@ -16,4 +16,20 @@ class CustomModuleCategory extends Base | ||
| 16 | protected $table = 'gl_custom_module_category'; | 16 | protected $table = 'gl_custom_module_category'; |
| 17 | //连接数据库 | 17 | //连接数据库 |
| 18 | protected $connection = 'custom_mysql'; | 18 | protected $connection = 'custom_mysql'; |
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 根据路由获取模块分类及模块信息 | ||
| 22 | + */ | ||
| 23 | + public static function getModuleCategoryAndExtendByRoute($projectId,$route) | ||
| 24 | + { | ||
| 25 | + return self::with("getExtend")->where("project_id",$projectId)->where("route",$route)->where("status",0)->first(); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 根据路由获取模块分类及模块信息 | ||
| 30 | + */ | ||
| 31 | + public static function getModuleCategoryAndExtendById($projectId,$id) | ||
| 32 | + { | ||
| 33 | + return self::with("getExtend")->where("project_id",$projectId)->where("id",$id)->where("status",0)->first(); | ||
| 34 | + } | ||
| 19 | } | 35 | } |
| @@ -21,6 +21,9 @@ class Category extends Base | @@ -21,6 +21,9 @@ class Category extends Base | ||
| 21 | protected $connection = 'custom_mysql'; | 21 | protected $connection = 'custom_mysql'; |
| 22 | 22 | ||
| 23 | const STATUS_ACTIVE = 1; | 23 | const STATUS_ACTIVE = 1; |
| 24 | + //新闻产品分类列表分页条数 | ||
| 25 | + public static $productCategoryPagePercent = 15; | ||
| 26 | + public static $productSearchPagePercent = 12; | ||
| 24 | 27 | ||
| 25 | /** | 28 | /** |
| 26 | * 获取指定分类的所有子分类IDS(包括自己) | 29 | * 获取指定分类的所有子分类IDS(包括自己) |
| @@ -72,4 +75,33 @@ class Category extends Base | @@ -72,4 +75,33 @@ class Category extends Base | ||
| 72 | $count = count($productArr); | 75 | $count = count($productArr); |
| 73 | return $count; | 76 | return $count; |
| 74 | } | 77 | } |
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * 根据分类ID查询下面所有子级ID,递归 | ||
| 81 | + */ | ||
| 82 | + public static function getAllSonCategoryById($projectId,$id): array | ||
| 83 | + { | ||
| 84 | + $ids = []; | ||
| 85 | + $ids[] = $id; | ||
| 86 | + self::getProductCategoryList($projectId,$id,$ids); | ||
| 87 | + return $ids; | ||
| 88 | + | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * 获取分类 | ||
| 93 | + */ | ||
| 94 | + public static function getProductCategoryList($projectId,$id,&$ids) | ||
| 95 | + { | ||
| 96 | + $categoryListPid = self::where("project_id",$projectId)->where("pid",$id)->get(); | ||
| 97 | + if (!empty($categoryListPid)){ | ||
| 98 | + foreach ($categoryListPid as $item){ | ||
| 99 | + $ids[] = $item->id; | ||
| 100 | + self::getProductCategoryList($projectId,$item->id,$ids); | ||
| 101 | + } | ||
| 102 | + }else{ | ||
| 103 | + $ids[] = $categoryListPid->id; | ||
| 104 | + } | ||
| 105 | + return $ids; | ||
| 106 | + } | ||
| 75 | } | 107 | } |
| @@ -55,4 +55,13 @@ class Keyword extends Base | @@ -55,4 +55,13 @@ class Keyword extends Base | ||
| 55 | } | 55 | } |
| 56 | return $value ?: []; | 56 | return $value ?: []; |
| 57 | } | 57 | } |
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 随机获取关键词列表 | ||
| 61 | + */ | ||
| 62 | + public function getProductsKeywordsList($project) | ||
| 63 | + { | ||
| 64 | + return Keyword::where("project_id",$project->id)->where("status",1)->inRandomOrder()->take(10)->get(); | ||
| 65 | + } | ||
| 66 | + | ||
| 58 | } | 67 | } |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Models\Project; | 3 | namespace App\Models\Project; |
| 4 | 4 | ||
| 5 | use App\Models\Base; | 5 | use App\Models\Base; |
| 6 | +use App\Models\WebSetting\WebSetting; | ||
| 6 | use Illuminate\Database\Eloquent\SoftDeletes; | 7 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 7 | 8 | ||
| 8 | class CountryCustom extends Base | 9 | class CountryCustom extends Base |
| @@ -10,4 +11,14 @@ class CountryCustom extends Base | @@ -10,4 +11,14 @@ class CountryCustom extends Base | ||
| 10 | use SoftDeletes; | 11 | use SoftDeletes; |
| 11 | 12 | ||
| 12 | protected $table = 'gl_project_country_custom'; | 13 | protected $table = 'gl_project_country_custom'; |
| 14 | + | ||
| 15 | + | ||
| 16 | + public static function getCountryCustomByProjectId($projectId){ | ||
| 17 | + if (Redis::get("project_" . $projectId . "_country_custom") == null) { | ||
| 18 | + $countryCustomInfo = self::with("countryCustomLanguage")->where("project_id",$projectId)->where("status",1)->where("is_create",1)->get(); | ||
| 19 | + Redis::set("project_" . $projectId . "_country_custom", json_encode($countryCustomInfo)); | ||
| 20 | + Redis::expire("project_" . $projectId . "_country_custom", WebSetting::$redisExpireTime); | ||
| 21 | + } | ||
| 22 | + return json_decode(Redis::get("project_".$projectId."_country_custom")); | ||
| 23 | + } | ||
| 13 | } | 24 | } |
| @@ -14,7 +14,25 @@ class Project extends Base | @@ -14,7 +14,25 @@ class Project extends Base | ||
| 14 | { | 14 | { |
| 15 | //设置关联表名 | 15 | //设置关联表名 |
| 16 | protected $table = 'gl_project'; | 16 | protected $table = 'gl_project'; |
| 17 | - | 17 | + public static $domainEndSlash = 1; //斜杠结尾 |
| 18 | + public static $projectLocationZero = 0; //普通项目 | ||
| 19 | + public static $projectLocationDangerous = 1; //危险项目 | ||
| 20 | + public static $storageTypeZero = 0; //默认腾讯压缩存储桶 | ||
| 21 | + public static $storageTypeOne = 1; //非压缩存储桶 | ||
| 22 | + | ||
| 23 | + public static $storageTypeZeroFileFix = "ecdn6.globalso.com"; //非压缩存储桶 | ||
| 24 | + public static $storageTypeOneFileFix = "ecdn6-nc.globalso.com"; //压缩存储桶 | ||
| 25 | + public static $projectLocationDangerousFileFix = "globalso-v6.s3.us-west-2.amazonaws.com"; //危险项目存储桶 | ||
| 26 | + | ||
| 27 | + //项目标识集合 | ||
| 28 | + public static $blockItems = "blockitems"; //html循环项父级标识 | ||
| 29 | + public static $blockAttrItems = "[blockitems]"; //html循环项父级属性标识 | ||
| 30 | + public static $blockItem = "blockitem"; //html循环项标识 | ||
| 31 | + public static $blockAttrItem = "[blockitem]"; //html循环项属性标识 | ||
| 32 | + public static $productListBlock = "productlistblock"; //html产品列表标识 | ||
| 33 | + public static $newListBlock = "newlistblock"; //html新闻列表标识 | ||
| 34 | + public static $blogListBlock = "bloglistblock"; //html博客列表标识 | ||
| 35 | + public static $productCategoryListBlock = "productcategorylistblock"; //html产品分类列表标识 | ||
| 18 | const DATABASE_NAME_FIX = 'gl_data_'; | 36 | const DATABASE_NAME_FIX = 'gl_data_'; |
| 19 | 37 | ||
| 20 | const CUSTOMIZED_ONE = 1;//定制项目 | 38 | const CUSTOMIZED_ONE = 1;//定制项目 |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Project; | ||
| 4 | + | ||
| 5 | +use Illuminate\Database\Eloquent\Model; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * @method static where(string $string, int $param) | ||
| 9 | + * @method static find($id) | ||
| 10 | + * @method static get() | ||
| 11 | + * @method static insertGetId() | ||
| 12 | + * @method static create(array $array) | ||
| 13 | + * @method static offset(float|int $param) | ||
| 14 | + * @method static select(string $string) | ||
| 15 | + * @method static orderBy(string $string, string $string1) | ||
| 16 | + */ | ||
| 17 | +class UpdateMasterWebsiteModel extends Model | ||
| 18 | +{ | ||
| 19 | + protected $connection = "custom_mysql"; | ||
| 20 | + protected $table = 'gl_update_master_website'; | ||
| 21 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Project; | ||
| 4 | + | ||
| 5 | +use Illuminate\Database\Eloquent\Model; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * @method static where(string $string, int $param) | ||
| 9 | + * @method static find($id) | ||
| 10 | + * @method static get() | ||
| 11 | + * @method static insertGetId() | ||
| 12 | + * @method static create(array $array) | ||
| 13 | + * @method static select(string $string) | ||
| 14 | + * @method static orderBy(string $string, string $string1) | ||
| 15 | + */ | ||
| 16 | +class UpdateMinorLanguagesModel extends Model | ||
| 17 | +{ | ||
| 18 | + protected $connection = "custom_mysql"; | ||
| 19 | + protected $table = 'gl_update_minor_languages'; | ||
| 20 | +} |
| @@ -25,4 +25,9 @@ class SettingNum extends Base | @@ -25,4 +25,9 @@ class SettingNum extends Base | ||
| 25 | protected $table = 'gl_setting_num'; | 25 | protected $table = 'gl_setting_num'; |
| 26 | //连接数据库 | 26 | //连接数据库 |
| 27 | protected $connection = 'custom_mysql'; | 27 | protected $connection = 'custom_mysql'; |
| 28 | + | ||
| 29 | + //列表页种类 | ||
| 30 | + public static $productListType = 1; | ||
| 31 | + public static $blogListType = 2; | ||
| 32 | + public static $newsListType = 3; | ||
| 28 | } | 33 | } |
| @@ -16,4 +16,8 @@ class Translate extends Base | @@ -16,4 +16,8 @@ class Translate extends Base | ||
| 16 | protected $table = 'gl_translate'; | 16 | protected $table = 'gl_translate'; |
| 17 | //连接数据库 | 17 | //连接数据库 |
| 18 | protected $connection = 'custom_mysql'; | 18 | protected $connection = 'custom_mysql'; |
| 19 | + | ||
| 20 | + public static $textType = 1; | ||
| 21 | + public static $imageType = 2; | ||
| 22 | + | ||
| 19 | } | 23 | } |
| @@ -48,4 +48,31 @@ class WebLanguage extends Base | @@ -48,4 +48,31 @@ class WebLanguage extends Base | ||
| 48 | } | 48 | } |
| 49 | return $id; | 49 | return $id; |
| 50 | } | 50 | } |
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 获取项目主语种 | ||
| 54 | + */ | ||
| 55 | + public static function getProjectMainLang($mainLangId = 1) | ||
| 56 | + { | ||
| 57 | + $mainLang = self::find($mainLangId); | ||
| 58 | + if (empty($mainLang)){ | ||
| 59 | + return null; | ||
| 60 | + } | ||
| 61 | + return $mainLang; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 关键词17种语种IDS | ||
| 66 | + */ | ||
| 67 | + public static function getKeywordsCountryIds($project = null): array | ||
| 68 | + { | ||
| 69 | + $languageIds = [1,4,5,6,7,8,9,10,11,14,15,18,22,26,40,68,78,95,99]; | ||
| 70 | + //加入项目主语种 | ||
| 71 | + if (!empty($project)){ | ||
| 72 | + $mainLangId = $project->main_lang_id; | ||
| 73 | + array_unshift($languageIds,(int)$mainLangId); | ||
| 74 | + } | ||
| 75 | + return array_unique($languageIds); | ||
| 76 | + } | ||
| 77 | + | ||
| 51 | } | 78 | } |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Models\WebSetting; | 3 | namespace App\Models\WebSetting; |
| 4 | 4 | ||
| 5 | use App\Models\Base; | 5 | use App\Models\Base; |
| 6 | +use Illuminate\Support\Facades\Redis; | ||
| 6 | 7 | ||
| 7 | class WebSetting extends Base | 8 | class WebSetting extends Base |
| 8 | { | 9 | { |
| @@ -12,5 +13,26 @@ class WebSetting extends Base | @@ -12,5 +13,26 @@ class WebSetting extends Base | ||
| 12 | //连接数据库 | 13 | //连接数据库 |
| 13 | protected $connection = 'custom_mysql'; | 14 | protected $connection = 'custom_mysql'; |
| 14 | 15 | ||
| 16 | + //网站缓存过期时间 | ||
| 17 | + public static $redisExpireTime = 600; | ||
| 18 | + public static $redisUpdateHtmlExpireTime = 60; | ||
| 19 | + public static $okStatus = 200; | ||
| 20 | + public static $errStatus = 500; | ||
| 15 | 21 | ||
| 22 | + /** | ||
| 23 | + * 网站设置 | ||
| 24 | + */ | ||
| 25 | + public static function getWebSetting($project) | ||
| 26 | + { | ||
| 27 | + if (Redis::get("project_".$project->id."_web_setting") == null) { | ||
| 28 | + $webSetting = self::where("project_id", $project->id)->first(); | ||
| 29 | + if (!empty($webSetting)) { | ||
| 30 | + Redis::set("project_".$project->id."_web_setting", json_encode($webSetting->toArray())); | ||
| 31 | + } else { | ||
| 32 | + Redis::set("project_".$project->id."_web_setting", null); | ||
| 33 | + } | ||
| 34 | + Redis::expire("project_".$project->id."_web_setting", WebSetting::$redisExpireTime); | ||
| 35 | + } | ||
| 36 | + return json_decode(Redis::get("project_".$project->id."_web_setting")); | ||
| 37 | + } | ||
| 16 | } | 38 | } |
app/Models/WebSetting/WebSettingCountry.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\WebSetting; | ||
| 4 | + | ||
| 5 | +use Illuminate\Database\Eloquent\Model; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * @method static whereIn(string $string, false|string[] $explode) | ||
| 9 | + * @method static where(string $string, mixed|string $lang) | ||
| 10 | + */ | ||
| 11 | +class WebSettingCountry extends Model | ||
| 12 | +{ | ||
| 13 | + protected $table = 'gl_web_setting_country'; | ||
| 14 | +} |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Models\WebSetting; | 3 | namespace App\Models\WebSetting; |
| 4 | 4 | ||
| 5 | use App\Models\Base; | 5 | use App\Models\Base; |
| 6 | +use Illuminate\Support\Facades\Redis; | ||
| 6 | 7 | ||
| 7 | class WebSettingText extends Base | 8 | class WebSettingText extends Base |
| 8 | { | 9 | { |
| @@ -27,4 +28,21 @@ class WebSettingText extends Base | @@ -27,4 +28,21 @@ class WebSettingText extends Base | ||
| 27 | self::TYPE_NEWS=>'新闻页', | 28 | self::TYPE_NEWS=>'新闻页', |
| 28 | self::TYPE_BLOG=>'博客页', | 29 | self::TYPE_BLOG=>'博客页', |
| 29 | ]; | 30 | ]; |
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 网站锚文本 | ||
| 34 | + */ | ||
| 35 | + public static function getWebSettingText($project) | ||
| 36 | + { | ||
| 37 | + if (Redis::get("project_".$project->id."_web_setting_text") == null) { | ||
| 38 | + $webSettingText = WebSettingText::where("project_id",$project->id)->get(); | ||
| 39 | + if (!empty($webSettingText)) { | ||
| 40 | + Redis::set("project_".$project->id."_web_setting_text", json_encode($webSettingText->toArray())); | ||
| 41 | + } else { | ||
| 42 | + Redis::set("project_".$project->id."_web_setting_text", null); | ||
| 43 | + } | ||
| 44 | + Redis::expire("project_".$project->id."_web_setting_text", WebSetting::$redisExpireTime); | ||
| 45 | + } | ||
| 46 | + return json_decode(Redis::get("project_".$project->id."_web_setting_text")); | ||
| 47 | + } | ||
| 30 | } | 48 | } |
app/Repositories/Bt/Bt.php
0 → 100644
| 1 | +<?php | ||
| 2 | +namespace App\Repositories\Bt; | ||
| 3 | +/** | ||
| 4 | + * 宝塔面板站点操作类库 | ||
| 5 | + * @author 阿良 or Youngxj(二次开发) | ||
| 6 | + * @link https://www.bt.cn/api-doc.pdf | ||
| 7 | + * @link https://gitee.com/youngxj0/Bty1.0 | ||
| 8 | + * @version 1.0 | ||
| 9 | + * @example | ||
| 10 | + * $bt = new Bt('http://127.0.0.1/8888','xxxxxxxxxxxxxxxx'); | ||
| 11 | + * echo $bt->GetSystemTotal();//获取系统基础统计 | ||
| 12 | + * @return Array | ||
| 13 | + */ | ||
| 14 | +class Bt | ||
| 15 | +{ | ||
| 16 | + private $BT_KEY = ""; //接口密钥 | ||
| 17 | + private $BT_PANEL = "http://127.0.0.1/8888"; //面板地址 | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * 初始化 | ||
| 21 | + * @param [type] $bt_panel 宝塔接口地址 | ||
| 22 | + * @param [type] $bt_key 宝塔Api密钥 | ||
| 23 | + */ | ||
| 24 | + public function __construct($bt_panel = null,$bt_key = null){ | ||
| 25 | + if($bt_panel) $this->BT_PANEL = $bt_panel; | ||
| 26 | + if($bt_key) $this->BT_KEY = $bt_key; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 获取系统基础统计 | ||
| 31 | + */ | ||
| 32 | + public function GetSystemTotal(){ | ||
| 33 | + $url = $this->BT_PANEL.$this->config("GetSystemTotal"); | ||
| 34 | + | ||
| 35 | + $p_data = $this->GetKeyData(); | ||
| 36 | + | ||
| 37 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 38 | + | ||
| 39 | + $data = json_decode($result,true); | ||
| 40 | + return $data; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 获取磁盘分区信息 | ||
| 45 | + */ | ||
| 46 | + public function GetDiskInfo(){ | ||
| 47 | + $url = $this->BT_PANEL.$this->config("GetDiskInfo"); | ||
| 48 | + | ||
| 49 | + $p_data = $this->GetKeyData(); | ||
| 50 | + | ||
| 51 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 52 | + | ||
| 53 | + $data = json_decode($result,true); | ||
| 54 | + return $data; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * 获取实时状态信息 | ||
| 59 | + * (CPU、内存、网络、负载) | ||
| 60 | + */ | ||
| 61 | + public function GetNetWork(){ | ||
| 62 | + $url = $this->BT_PANEL.$this->config("GetNetWork"); | ||
| 63 | + | ||
| 64 | + $p_data = $this->GetKeyData(); | ||
| 65 | + | ||
| 66 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 67 | + | ||
| 68 | + $data = json_decode($result,true); | ||
| 69 | + return $data; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 检查是否有安装任务 | ||
| 74 | + */ | ||
| 75 | + public function GetTaskCount(){ | ||
| 76 | + $url = $this->BT_PANEL.$this->config("GetTaskCount"); | ||
| 77 | + | ||
| 78 | + $p_data = $this->GetKeyData(); | ||
| 79 | + | ||
| 80 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 81 | + | ||
| 82 | + $data = json_decode($result,true); | ||
| 83 | + return $data; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * 检查面板更新 | ||
| 88 | + */ | ||
| 89 | + public function UpdatePanel($check=false,$force=false){ | ||
| 90 | + $url = $this->BT_PANEL.$this->config("UpdatePanel"); | ||
| 91 | + | ||
| 92 | + $p_data = $this->GetKeyData(); | ||
| 93 | + $p_data['check'] = $check; | ||
| 94 | + $p_data['force'] = $force; | ||
| 95 | + | ||
| 96 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 97 | + | ||
| 98 | + $data = json_decode($result,true); | ||
| 99 | + return $data; | ||
| 100 | + } | ||
| 101 | + /** | ||
| 102 | + * 申请ssl | ||
| 103 | + */ | ||
| 104 | + public function ApplyCert($domains,$id){ | ||
| 105 | + $url = $this->BT_PANEL.$this->config("ApplyCert"); | ||
| 106 | + $p_data = $this->GetKeyData(); | ||
| 107 | + $p_data['domains'] = $domains; | ||
| 108 | + $p_data['auth_type'] = "http"; | ||
| 109 | + $p_data['auth_to'] = $id; | ||
| 110 | + $p_data['auto_wildcard'] = 0; | ||
| 111 | + $p_data['id'] = $id; | ||
| 112 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 113 | + | ||
| 114 | + $data = json_decode($result,true); | ||
| 115 | + return $data; | ||
| 116 | + } | ||
| 117 | + /** | ||
| 118 | + * 续签ssl | ||
| 119 | + */ | ||
| 120 | + public function RenewCert($index){ | ||
| 121 | + $url = $this->BT_PANEL.$this->config("RenewCert"); | ||
| 122 | + $p_data = $this->GetKeyData(); | ||
| 123 | + | ||
| 124 | + $p_data['index'] = $index; | ||
| 125 | + | ||
| 126 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 127 | + $data = json_decode($result,true); | ||
| 128 | + return $data; | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + | ||
| 132 | + | ||
| 133 | + /** | ||
| 134 | + * 获取网站列表 | ||
| 135 | + * @param string $page 当前分页 | ||
| 136 | + * @param string $limit 取出的数据行数 | ||
| 137 | + * @param string $type 分类标识 -1: 分部分类 0: 默认分类 | ||
| 138 | + * @param string $order 排序规则 使用 id 降序:id desc 使用名称升序:name desc | ||
| 139 | + * @param string $tojs 分页 JS 回调,若不传则构造 URI 分页连接 | ||
| 140 | + * @param string $search 搜索内容 | ||
| 141 | + */ | ||
| 142 | + public function Websites($search='',$page='1',$limit='15',$type='-1',$order='id desc',$tojs=''){ | ||
| 143 | + $url = $this->BT_PANEL.$this->config("Websites"); | ||
| 144 | + | ||
| 145 | + $p_data = $this->GetKeyData(); | ||
| 146 | + $p_data['p'] = $page; | ||
| 147 | + $p_data['limit'] = $limit; | ||
| 148 | + $p_data['type'] = $type; | ||
| 149 | + $p_data['order'] = $order; | ||
| 150 | + $p_data['tojs'] = $tojs; | ||
| 151 | + $p_data['search'] = $search; | ||
| 152 | + | ||
| 153 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 154 | + | ||
| 155 | + $data = json_decode($result,true); | ||
| 156 | + return $data; | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + /** | ||
| 160 | + * 获取网站FTP列表 | ||
| 161 | + * @param string $page 当前分页 | ||
| 162 | + * @param string $limit 取出的数据行数 | ||
| 163 | + * @param string $type 分类标识 -1: 分部分类 0: 默认分类 | ||
| 164 | + * @param string $order 排序规则 使用 id 降序:id desc 使用名称升序:name desc | ||
| 165 | + * @param string $tojs 分页 JS 回调,若不传则构造 URI 分页连接 | ||
| 166 | + * @param string $search 搜索内容 | ||
| 167 | + */ | ||
| 168 | + public function WebFtpList($search='',$page='1',$limit='15',$type='-1',$order='id desc',$tojs=''){ | ||
| 169 | + $url = $this->BT_PANEL.$this->config("WebFtpList"); | ||
| 170 | + | ||
| 171 | + $p_data = $this->GetKeyData(); | ||
| 172 | + $p_data['p'] = $page; | ||
| 173 | + $p_data['limit'] = $limit; | ||
| 174 | + $p_data['type'] = $type; | ||
| 175 | + $p_data['order'] = $order; | ||
| 176 | + $p_data['tojs'] = $tojs; | ||
| 177 | + $p_data['search'] = $search; | ||
| 178 | + | ||
| 179 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 180 | + | ||
| 181 | + $data = json_decode($result,true); | ||
| 182 | + return $data; | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + /** | ||
| 186 | + * 获取网站SQL列表 | ||
| 187 | + * @param string $page 当前分页 | ||
| 188 | + * @param string $limit 取出的数据行数 | ||
| 189 | + * @param string $type 分类标识 -1: 分部分类 0: 默认分类 | ||
| 190 | + * @param string $order 排序规则 使用 id 降序:id desc 使用名称升序:name desc | ||
| 191 | + * @param string $tojs 分页 JS 回调,若不传则构造 URI 分页连接 | ||
| 192 | + * @param string $search 搜索内容 | ||
| 193 | + */ | ||
| 194 | + public function WebSqlList($search='',$page='1',$limit='15',$type='-1',$order='id desc',$tojs=''){ | ||
| 195 | + $url = $this->BT_PANEL.$this->config("WebSqlList"); | ||
| 196 | + | ||
| 197 | + $p_data = $this->GetKeyData(); | ||
| 198 | + $p_data['p'] = $page; | ||
| 199 | + $p_data['limit'] = $limit; | ||
| 200 | + $p_data['type'] = $type; | ||
| 201 | + $p_data['order'] = $order; | ||
| 202 | + $p_data['tojs'] = $tojs; | ||
| 203 | + $p_data['search'] = $search; | ||
| 204 | + | ||
| 205 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 206 | + | ||
| 207 | + $data = json_decode($result,true); | ||
| 208 | + return $data; | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + /** | ||
| 212 | + * 获取所有网站分类 | ||
| 213 | + */ | ||
| 214 | + public function Webtypes(){ | ||
| 215 | + $url = $this->BT_PANEL.$this->config("Webtypes"); | ||
| 216 | + | ||
| 217 | + $p_data = $this->GetKeyData(); | ||
| 218 | + | ||
| 219 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 220 | + | ||
| 221 | + $data = json_decode($result,true); | ||
| 222 | + return $data; | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + /** | ||
| 226 | + * 获取已安装的 PHP 版本列表 | ||
| 227 | + */ | ||
| 228 | + public function GetPHPVersion(){ | ||
| 229 | + //拼接URL地址 | ||
| 230 | + $url = $this->BT_PANEL.$this->config("GetPHPVersion"); | ||
| 231 | + | ||
| 232 | + //准备POST数据 | ||
| 233 | + $p_data = $this->GetKeyData(); //取签名 | ||
| 234 | + | ||
| 235 | + //请求面板接口 | ||
| 236 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 237 | + | ||
| 238 | + //解析JSON数据 | ||
| 239 | + $data = json_decode($result,true); | ||
| 240 | + | ||
| 241 | + return $data; | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + /** | ||
| 245 | + * 修改指定网站的PHP版本 | ||
| 246 | + * @param [type] $site 网站名 | ||
| 247 | + * @param [type] $php PHP版本 | ||
| 248 | + */ | ||
| 249 | + public function SetPHPVersion($site,$php){ | ||
| 250 | + | ||
| 251 | + $url = $this->BT_PANEL.$this->config("SetPHPVersion"); | ||
| 252 | + | ||
| 253 | + $p_data = $this->GetKeyData(); | ||
| 254 | + $p_data['siteName'] = $site; | ||
| 255 | + $p_data['version'] = $php; | ||
| 256 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 257 | + | ||
| 258 | + $data = json_decode($result,true); | ||
| 259 | + return $data; | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + /** | ||
| 263 | + * 获取指定网站运行的PHP版本 | ||
| 264 | + * @param [type] $site 网站名 | ||
| 265 | + */ | ||
| 266 | + public function GetSitePHPVersion($site){ | ||
| 267 | + $url = $this->BT_PANEL.$this->config("GetSitePHPVersion"); | ||
| 268 | + | ||
| 269 | + $p_data = $this->GetKeyData(); | ||
| 270 | + $p_data['siteName'] = $site; | ||
| 271 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 272 | + | ||
| 273 | + $data = json_decode($result,true); | ||
| 274 | + return $data; | ||
| 275 | + } | ||
| 276 | + | ||
| 277 | + | ||
| 278 | + /** | ||
| 279 | + * 新增网站 | ||
| 280 | + * @param [type] $webname 网站域名 json格式 | ||
| 281 | + * @param [type] $path 网站路径 | ||
| 282 | + * @param [type] $type_id 网站分类ID | ||
| 283 | + * @param string $type 网站类型 | ||
| 284 | + * @param [type] $version PHP版本 | ||
| 285 | + * @param [type] $port 网站端口 | ||
| 286 | + * @param [type] $ps 网站备注 | ||
| 287 | + * @param [type] $ftp 网站是否开通FTP | ||
| 288 | + * @param [type] $ftp_username FTP用户名 | ||
| 289 | + * @param [type] $ftp_password FTP密码 | ||
| 290 | + * @param [type] $sql 网站是否开通数据库 | ||
| 291 | + * @param [type] $codeing 数据库编码类型 utf8|utf8mb4|gbk|big5 | ||
| 292 | + * @param [type] $datauser 数据库账号 | ||
| 293 | + * @param [type] $datapassword 数据库密码 | ||
| 294 | + */ | ||
| 295 | + public function AddSite($infoArr=[]){ | ||
| 296 | + $url = $this->BT_PANEL.$this->config("WebAddSite"); | ||
| 297 | + //准备POST数据 | ||
| 298 | + $p_data = $this->GetKeyData(); //取签名 | ||
| 299 | + $p_data['webname'] = $infoArr['webname']; | ||
| 300 | + $p_data['path'] = $infoArr['path']; | ||
| 301 | + $p_data['type_id'] = $infoArr['type_id']; | ||
| 302 | + $p_data['type'] = $infoArr['type']; | ||
| 303 | + $p_data['version'] = $infoArr['version']; | ||
| 304 | + $p_data['port'] = $infoArr['port']; | ||
| 305 | + $p_data['ps'] = $infoArr['ps']; | ||
| 306 | + $p_data['ftp'] = $infoArr['ftp']; | ||
| 307 | + $p_data['ftp_username'] = $infoArr['ftp_username']; | ||
| 308 | + $p_data['ftp_password'] = $infoArr['ftp_password']; | ||
| 309 | + $p_data['sql'] = $infoArr['sql']; | ||
| 310 | + $p_data['codeing'] = $infoArr['codeing']; | ||
| 311 | + $p_data['datauser'] = $infoArr['datauser']; | ||
| 312 | + $p_data['datapassword'] = $infoArr['datapassword']; | ||
| 313 | + | ||
| 314 | + | ||
| 315 | + | ||
| 316 | + //请求面板接口 | ||
| 317 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 318 | + //var_dump($result); | ||
| 319 | + //解析JSON数据 | ||
| 320 | + $data = json_decode($result,true); | ||
| 321 | + return $data; | ||
| 322 | + } | ||
| 323 | + | ||
| 324 | + /** | ||
| 325 | + * 删除网站 | ||
| 326 | + * @param [type] $id 网站ID | ||
| 327 | + * @param [type] $webname 网站名称 | ||
| 328 | + * @param [type] $ftp 是否删除关联FTP | ||
| 329 | + * @param [type] $database 是否删除关联数据库 | ||
| 330 | + * @param [type] $path 是否删除关联网站根目录 | ||
| 331 | + * | ||
| 332 | + */ | ||
| 333 | + public function WebDeleteSite($id,$webname,$ftp,$database,$path){ | ||
| 334 | + $url = $this->BT_PANEL.$this->config("WebDeleteSite"); | ||
| 335 | + | ||
| 336 | + $p_data = $this->GetKeyData(); | ||
| 337 | + $p_data['id'] = $id; | ||
| 338 | + $p_data['webname'] = $webname; | ||
| 339 | + $p_data['ftp'] = $ftp; | ||
| 340 | + $p_data['database'] = $database; | ||
| 341 | + $p_data['path'] = $path; | ||
| 342 | + | ||
| 343 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 344 | + | ||
| 345 | + $data = json_decode($result,true); | ||
| 346 | + return $data; | ||
| 347 | + } | ||
| 348 | + | ||
| 349 | + /** | ||
| 350 | + * 停用站点 | ||
| 351 | + * @param [type] $id 网站ID | ||
| 352 | + * @param [type] $name 网站域名 | ||
| 353 | + */ | ||
| 354 | + public function WebSiteStop($id,$name){ | ||
| 355 | + $url = $this->BT_PANEL.$this->config("WebSiteStop"); | ||
| 356 | + | ||
| 357 | + $p_data = $this->GetKeyData(); | ||
| 358 | + $p_data['id'] = $id; | ||
| 359 | + $p_data['name'] = $name; | ||
| 360 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 361 | + | ||
| 362 | + $data = json_decode($result,true); | ||
| 363 | + return $data; | ||
| 364 | + } | ||
| 365 | + | ||
| 366 | + /** | ||
| 367 | + * 启用网站 | ||
| 368 | + * @param [type] $id 网站ID | ||
| 369 | + * @param [type] $name 网站域名 | ||
| 370 | + */ | ||
| 371 | + public function WebSiteStart($id,$name){ | ||
| 372 | + $url = $this->BT_PANEL.$this->config("WebSiteStart"); | ||
| 373 | + | ||
| 374 | + $p_data = $this->GetKeyData(); | ||
| 375 | + $p_data['id'] = $id; | ||
| 376 | + $p_data['name'] = $name; | ||
| 377 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 378 | + | ||
| 379 | + $data = json_decode($result,true); | ||
| 380 | + return $data; | ||
| 381 | + } | ||
| 382 | + | ||
| 383 | + /** | ||
| 384 | + * 设置网站到期时间 | ||
| 385 | + * @param [type] $id 网站ID | ||
| 386 | + * @param [type] $edate 网站到期时间 格式:2019-01-01,永久:0000-00-00 | ||
| 387 | + */ | ||
| 388 | + public function WebSetEdate($id,$edate){ | ||
| 389 | + $url = $this->BT_PANEL.$this->config("WebSetEdate"); | ||
| 390 | + | ||
| 391 | + $p_data = $this->GetKeyData(); | ||
| 392 | + $p_data['id'] = $id; | ||
| 393 | + $p_data['edate'] = $edate; | ||
| 394 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 395 | + | ||
| 396 | + $data = json_decode($result,true); | ||
| 397 | + return $data; | ||
| 398 | + } | ||
| 399 | + | ||
| 400 | + /** | ||
| 401 | + * 修改网站备注 | ||
| 402 | + * @param [type] $id 网站ID | ||
| 403 | + * @param [type] $ps 网站备注 | ||
| 404 | + */ | ||
| 405 | + public function WebSetPs($id,$ps){ | ||
| 406 | + $url = $this->BT_PANEL.$this->config("WebSetPs"); | ||
| 407 | + | ||
| 408 | + $p_data = $this->GetKeyData(); | ||
| 409 | + $p_data['id'] = $id; | ||
| 410 | + $p_data['ps'] = $ps; | ||
| 411 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 412 | + | ||
| 413 | + $data = json_decode($result,true); | ||
| 414 | + return $data; | ||
| 415 | + } | ||
| 416 | + | ||
| 417 | + /** | ||
| 418 | + * 获取网站备份列表 | ||
| 419 | + * @param [type] $id 网站ID | ||
| 420 | + * @param string $page 当前分页 | ||
| 421 | + * @param string $limit 每页取出的数据行数 | ||
| 422 | + * @param string $type 备份类型 目前固定为0 | ||
| 423 | + * @param string $tojs 分页js回调若不传则构造 URI 分页连接 get_site_backup | ||
| 424 | + */ | ||
| 425 | + public function WebBackupList($id,$page='1',$limit='5',$type='0',$tojs=''){ | ||
| 426 | + $url = $this->BT_PANEL.$this->config("WebBackupList"); | ||
| 427 | + | ||
| 428 | + $p_data = $this->GetKeyData(); | ||
| 429 | + $p_data['p'] = $page; | ||
| 430 | + $p_data['limit'] = $limit; | ||
| 431 | + $p_data['type'] = $type; | ||
| 432 | + $p_data['tojs'] = $tojs; | ||
| 433 | + $p_data['search'] = $id; | ||
| 434 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 435 | + | ||
| 436 | + $data = json_decode($result,true); | ||
| 437 | + return $data; | ||
| 438 | + } | ||
| 439 | + | ||
| 440 | + /** | ||
| 441 | + * 创建网站备份 | ||
| 442 | + * @param [type] $id 网站ID | ||
| 443 | + */ | ||
| 444 | + public function WebToBackup($id){ | ||
| 445 | + $url = $this->BT_PANEL.$this->config("WebToBackup"); | ||
| 446 | + | ||
| 447 | + $p_data = $this->GetKeyData(); | ||
| 448 | + $p_data['id'] = $id; | ||
| 449 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 450 | + | ||
| 451 | + $data = json_decode($result,true); | ||
| 452 | + return $data; | ||
| 453 | + } | ||
| 454 | + | ||
| 455 | + /** | ||
| 456 | + * 删除网站备份 | ||
| 457 | + * @param [type] $id 网站备份ID | ||
| 458 | + */ | ||
| 459 | + public function WebDelBackup($id){ | ||
| 460 | + $url = $this->BT_PANEL.$this->config("WebDelBackup"); | ||
| 461 | + | ||
| 462 | + $p_data = $this->GetKeyData(); | ||
| 463 | + $p_data['id'] = $id; | ||
| 464 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 465 | + | ||
| 466 | + $data = json_decode($result,true); | ||
| 467 | + return $data; | ||
| 468 | + } | ||
| 469 | + | ||
| 470 | + /** | ||
| 471 | + * 删除数据库备份 | ||
| 472 | + * @param [type] $id 数据库备份ID | ||
| 473 | + */ | ||
| 474 | + public function SQLDelBackup($id){ | ||
| 475 | + $url = $this->BT_PANEL.$this->config("SQLDelBackup"); | ||
| 476 | + | ||
| 477 | + $p_data = $this->GetKeyData(); | ||
| 478 | + $p_data['id'] = $id; | ||
| 479 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 480 | + | ||
| 481 | + $data = json_decode($result,true); | ||
| 482 | + return $data; | ||
| 483 | + } | ||
| 484 | + | ||
| 485 | + /** | ||
| 486 | + * 备份数据库 | ||
| 487 | + * @param [type] $id 数据库列表ID | ||
| 488 | + */ | ||
| 489 | + public function SQLToBackup($id){ | ||
| 490 | + $url = $this->BT_PANEL.$this->config("SQLToBackup"); | ||
| 491 | + | ||
| 492 | + $p_data = $this->GetKeyData(); | ||
| 493 | + $p_data['id'] = $id; | ||
| 494 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 495 | + | ||
| 496 | + $data = json_decode($result,true); | ||
| 497 | + return $data; | ||
| 498 | + } | ||
| 499 | + | ||
| 500 | + /** | ||
| 501 | + * 获取网站域名列表 | ||
| 502 | + * @param [type] $id 网站ID | ||
| 503 | + * @param boolean $list 固定传true | ||
| 504 | + */ | ||
| 505 | + public function WebDoaminList($id,$list=true){ | ||
| 506 | + $url = $this->BT_PANEL.$this->config("WebDoaminList"); | ||
| 507 | + | ||
| 508 | + $p_data = $this->GetKeyData(); | ||
| 509 | + $p_data['search'] = $id; | ||
| 510 | + $p_data['list'] = $list; | ||
| 511 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 512 | + | ||
| 513 | + $data = json_decode($result,true); | ||
| 514 | + return $data; | ||
| 515 | + } | ||
| 516 | + | ||
| 517 | + /** | ||
| 518 | + * 获取网站列表 | ||
| 519 | + * @param string $search | ||
| 520 | + * @param int $p | ||
| 521 | + * @param int $limit | ||
| 522 | + * @param int $type | ||
| 523 | + * @return mixed | ||
| 524 | + */ | ||
| 525 | + public function WebSiteList($search = '', $p = 1, $limit = 20, $type = 0){ | ||
| 526 | + $url = $this->BT_PANEL.$this->config("WebSiteList"); | ||
| 527 | + | ||
| 528 | + $p_data = $this->GetKeyData(); | ||
| 529 | + $p_data['search'] = $search; | ||
| 530 | + $p_data['p'] = $p; | ||
| 531 | + $p_data['limit'] = $limit; | ||
| 532 | + $p_data['type'] = $type; | ||
| 533 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 534 | + | ||
| 535 | + $data = json_decode($result,true); | ||
| 536 | + return $data; | ||
| 537 | + } | ||
| 538 | + | ||
| 539 | + /** | ||
| 540 | + * 添加域名 | ||
| 541 | + * @param [type] $id 网站ID | ||
| 542 | + * @param [type] $webname 网站名称 | ||
| 543 | + * @param [type] $domain 要添加的域名:端口 80 端品不必构造端口,多个域名用换行符隔开 | ||
| 544 | + */ | ||
| 545 | + public function WebAddDomain($id,$webname,$domain){ | ||
| 546 | + $url = $this->BT_PANEL.$this->config("WebAddDomain"); | ||
| 547 | + | ||
| 548 | + $p_data = $this->GetKeyData(); | ||
| 549 | + $p_data['id'] = $id; | ||
| 550 | + $p_data['webname'] = $webname; | ||
| 551 | + $p_data['domain'] = $domain; | ||
| 552 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 553 | + | ||
| 554 | + $data = json_decode($result,true); | ||
| 555 | + return $data; | ||
| 556 | + } | ||
| 557 | + | ||
| 558 | + /** | ||
| 559 | + * 删除网站域名 | ||
| 560 | + * @param [type] $id 网站ID | ||
| 561 | + * @param [type] $webname 网站名 | ||
| 562 | + * @param [type] $domain 网站域名 | ||
| 563 | + * @param [type] $port 网站域名端口 | ||
| 564 | + */ | ||
| 565 | + public function WebDelDomain($id,$webname,$domain,$port){ | ||
| 566 | + $url = $this->BT_PANEL.$this->config("WebDelDomain"); | ||
| 567 | + | ||
| 568 | + $p_data = $this->GetKeyData(); | ||
| 569 | + $p_data['id'] = $id; | ||
| 570 | + $p_data['webname'] = $webname; | ||
| 571 | + $p_data['domain'] = $domain; | ||
| 572 | + $p_data['port'] = $port; | ||
| 573 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 574 | + | ||
| 575 | + $data = json_decode($result,true); | ||
| 576 | + return $data; | ||
| 577 | + } | ||
| 578 | + | ||
| 579 | + /** | ||
| 580 | + * 获取可选的预定义伪静态列表 | ||
| 581 | + * @param [type] $siteName 网站名 | ||
| 582 | + */ | ||
| 583 | + public function GetRewriteList($siteName){ | ||
| 584 | + $url = $this->BT_PANEL.$this->config("GetRewriteList"); | ||
| 585 | + | ||
| 586 | + $p_data = $this->GetKeyData(); | ||
| 587 | + $p_data['siteName'] = $siteName; | ||
| 588 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 589 | + | ||
| 590 | + $data = json_decode($result,true); | ||
| 591 | + return $data; | ||
| 592 | + } | ||
| 593 | + | ||
| 594 | + /** | ||
| 595 | + * 获取预置伪静态规则内容(文件内容) | ||
| 596 | + * @param [type] $path 规则名 | ||
| 597 | + * @param [type] $type 0->获取内置伪静态规则;1->获取当前站点伪静态规则 | ||
| 598 | + */ | ||
| 599 | + public function GetFileBody($path,$type=0){ | ||
| 600 | + $url = $this->BT_PANEL.$this->config("GetFileBody"); | ||
| 601 | + $p_data = $this->GetKeyData(); | ||
| 602 | +// $path_dir = $type?'vhost/rewrite':'rewrite/nginx'; | ||
| 603 | + if ($type == 2) { | ||
| 604 | + $path_dir = 'vhost/nginx'; | ||
| 605 | + } elseif ($type == 1) { | ||
| 606 | + $path_dir = 'vhost/rewrite'; | ||
| 607 | + } else { | ||
| 608 | + $path_dir = 'rewrite/nginx'; | ||
| 609 | + } | ||
| 610 | + | ||
| 611 | + //获取当前站点伪静态规则 | ||
| 612 | + ///www/server/panel/vhost/rewrite/user_hvVBT_1.test.com.conf | ||
| 613 | + //获取内置伪静态规则 | ||
| 614 | + ///www/server/panel/rewrite/nginx/EmpireCMS.conf | ||
| 615 | + //保存伪静态规则到站点 | ||
| 616 | + ///www/server/panel/vhost/rewrite/user_hvVBT_1.test.com.conf | ||
| 617 | + ///www/server/panel/rewrite/nginx/typecho.conf | ||
| 618 | + $p_data['path'] = '/www/server/panel/'.$path_dir.'/'.$path.'.conf'; | ||
| 619 | + //var_dump($p_data['path']); | ||
| 620 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 621 | + | ||
| 622 | + $data = json_decode($result,true); | ||
| 623 | + return $data; | ||
| 624 | + } | ||
| 625 | + | ||
| 626 | + /** | ||
| 627 | + * 保存伪静态规则内容(保存文件内容) | ||
| 628 | + * @param [type] $path 规则名 | ||
| 629 | + * @param [type] $data 规则内容 | ||
| 630 | + * @param string $encoding 规则编码强转utf-8 | ||
| 631 | + * @param number $type 0->系统默认路径;1->自定义全路径 | ||
| 632 | + */ | ||
| 633 | + public function SaveFileBody($path,$data,$encoding='utf-8',$type=0){ | ||
| 634 | + $url = $this->BT_PANEL.$this->config("SaveFileBody"); | ||
| 635 | + if($type){ | ||
| 636 | + $path_dir = $path; | ||
| 637 | + }else{ | ||
| 638 | + $path_dir = '/www/server/panel/vhost/rewrite/'.$path.'.conf'; | ||
| 639 | + } | ||
| 640 | + $p_data = $this->GetKeyData(); | ||
| 641 | + $p_data['path'] = $path_dir; | ||
| 642 | + $p_data['data'] = $data; | ||
| 643 | + $p_data['encoding'] = $encoding; | ||
| 644 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 645 | + | ||
| 646 | + $data = json_decode($result,true); | ||
| 647 | + return $data; | ||
| 648 | + } | ||
| 649 | + | ||
| 650 | + | ||
| 651 | + | ||
| 652 | + /** | ||
| 653 | + * 设置密码访问网站 | ||
| 654 | + * @param [type] $id 网站ID | ||
| 655 | + * @param [type] $username 用户名 | ||
| 656 | + * @param [type] $password 密码 | ||
| 657 | + */ | ||
| 658 | + public function SetHasPwd($id,$username,$password){ | ||
| 659 | + $url = $this->BT_PANEL.$this->config("SetHasPwd"); | ||
| 660 | + | ||
| 661 | + $p_data = $this->GetKeyData(); | ||
| 662 | + $p_data['id'] = $id; | ||
| 663 | + $p_data['username'] = $username; | ||
| 664 | + $p_data['password'] = $password; | ||
| 665 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 666 | + | ||
| 667 | + $data = json_decode($result,true); | ||
| 668 | + return $data; | ||
| 669 | + } | ||
| 670 | + | ||
| 671 | + /** | ||
| 672 | + * 关闭密码访问网站 | ||
| 673 | + * @param [type] $id 网站ID | ||
| 674 | + */ | ||
| 675 | + public function CloseHasPwd($id){ | ||
| 676 | + $url = $this->BT_PANEL.$this->config("CloseHasPwd"); | ||
| 677 | + | ||
| 678 | + $p_data = $this->GetKeyData(); | ||
| 679 | + $p_data['id'] = $id; | ||
| 680 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 681 | + | ||
| 682 | + $data = json_decode($result,true); | ||
| 683 | + return $data; | ||
| 684 | + } | ||
| 685 | + | ||
| 686 | + /** | ||
| 687 | + * 获取网站日志 | ||
| 688 | + * @param [type] $site 网站名 | ||
| 689 | + */ | ||
| 690 | + public function GetSiteLogs($site){ | ||
| 691 | + $url = $this->BT_PANEL.$this->config("GetSiteLogs"); | ||
| 692 | + | ||
| 693 | + $p_data = $this->GetKeyData(); | ||
| 694 | + $p_data['siteName'] = $site; | ||
| 695 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 696 | + | ||
| 697 | + $data = json_decode($result,true); | ||
| 698 | + return $data; | ||
| 699 | + } | ||
| 700 | + | ||
| 701 | + /** | ||
| 702 | + * 获取网站盗链状态及规则信息 | ||
| 703 | + * @param [type] $id 网站ID | ||
| 704 | + * @param [type] $site 网站名 | ||
| 705 | + */ | ||
| 706 | + public function GetSecurity($id,$site){ | ||
| 707 | + $url = $this->BT_PANEL.$this->config("GetSecurity"); | ||
| 708 | + | ||
| 709 | + $p_data = $this->GetKeyData(); | ||
| 710 | + $p_data['id'] = $id; | ||
| 711 | + $p_data['name'] = $site; | ||
| 712 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 713 | + | ||
| 714 | + $data = json_decode($result,true); | ||
| 715 | + return $data; | ||
| 716 | + } | ||
| 717 | + | ||
| 718 | + /** | ||
| 719 | + * 设置网站盗链状态及规则信息 | ||
| 720 | + * @param [type] $id 网站ID | ||
| 721 | + * @param [type] $site 网站名 | ||
| 722 | + * @param [type] $fix URL后缀 | ||
| 723 | + * @param [type] $domains 许可域名 | ||
| 724 | + * @param [type] $status 状态 | ||
| 725 | + */ | ||
| 726 | + public function SetSecurity($id,$site,$fix,$domains,$status){ | ||
| 727 | + $url = $this->BT_PANEL.$this->config("SetSecurity"); | ||
| 728 | + | ||
| 729 | + $p_data = $this->GetKeyData(); | ||
| 730 | + $p_data['id'] = $id; | ||
| 731 | + $p_data['name'] = $site; | ||
| 732 | + $p_data['fix'] = $fix; | ||
| 733 | + $p_data['domains'] = $domains; | ||
| 734 | + $p_data['status'] = $status; | ||
| 735 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 736 | + | ||
| 737 | + $data = json_decode($result,true); | ||
| 738 | + return $data; | ||
| 739 | + } | ||
| 740 | + | ||
| 741 | + /** | ||
| 742 | + * 获取网站三项配置开关(防跨站、日志、密码访问) | ||
| 743 | + * @param [type] $id 网站ID | ||
| 744 | + * @param [type] $path 网站运行目录 | ||
| 745 | + */ | ||
| 746 | + public function GetDirUserINI($id,$path){ | ||
| 747 | + $url = $this->BT_PANEL.$this->config("GetDirUserINI"); | ||
| 748 | + | ||
| 749 | + $p_data = $this->GetKeyData(); | ||
| 750 | + $p_data['id'] = $id; | ||
| 751 | + $p_data['path'] = $path; | ||
| 752 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 753 | + | ||
| 754 | + $data = json_decode($result,true); | ||
| 755 | + return $data; | ||
| 756 | + } | ||
| 757 | + | ||
| 758 | + /** | ||
| 759 | + * 开启强制HTTPS | ||
| 760 | + * @param [type] $site 网站域名(纯域名) | ||
| 761 | + */ | ||
| 762 | + public function HttpToHttps($site){ | ||
| 763 | + $url = $this->BT_PANEL.$this->config("HttpToHttps"); | ||
| 764 | + | ||
| 765 | + $p_data = $this->GetKeyData(); | ||
| 766 | + $p_data['siteName'] = $site; | ||
| 767 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 768 | + | ||
| 769 | + $data = json_decode($result,true); | ||
| 770 | + return $data; | ||
| 771 | + } | ||
| 772 | + | ||
| 773 | + /** | ||
| 774 | + * 关闭强制HTTPS | ||
| 775 | + * @param [type] $site 域名(纯域名) | ||
| 776 | + */ | ||
| 777 | + public function CloseToHttps($site){ | ||
| 778 | + $url = $this->BT_PANEL.$this->config("CloseToHttps"); | ||
| 779 | + | ||
| 780 | + $p_data = $this->GetKeyData(); | ||
| 781 | + $p_data['siteName'] = $site; | ||
| 782 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 783 | + | ||
| 784 | + $data = json_decode($result,true); | ||
| 785 | + return $data; | ||
| 786 | + } | ||
| 787 | + | ||
| 788 | + /** | ||
| 789 | + * 设置SSL域名证书 | ||
| 790 | + * @param [type] $type 类型 | ||
| 791 | + * @param [type] $site 网站名 | ||
| 792 | + * @param [type] $key 证书key | ||
| 793 | + * @param [type] $csr 证书PEM | ||
| 794 | + */ | ||
| 795 | + public function SetSSL($type,$site,$key,$csr){ | ||
| 796 | + $url = $this->BT_PANEL.$this->config("SetSSL"); | ||
| 797 | + | ||
| 798 | + $p_data = $this->GetKeyData(); | ||
| 799 | + $p_data['type'] = $type; | ||
| 800 | + $p_data['siteName'] = $site; | ||
| 801 | + $p_data['key'] = $key; | ||
| 802 | + $p_data['csr'] = $csr; | ||
| 803 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 804 | + | ||
| 805 | + $data = json_decode($result,true); | ||
| 806 | + return $data; | ||
| 807 | + | ||
| 808 | + } | ||
| 809 | + | ||
| 810 | + /** | ||
| 811 | + * 关闭SSL | ||
| 812 | + * @param [type] $updateOf 修改状态码 | ||
| 813 | + * @param [type] $site 域名(纯域名) | ||
| 814 | + */ | ||
| 815 | + public function CloseSSLConf($updateOf,$site){ | ||
| 816 | + $url = $this->BT_PANEL.$this->config("CloseSSLConf"); | ||
| 817 | + | ||
| 818 | + $p_data = $this->GetKeyData(); | ||
| 819 | + $p_data['updateOf'] = $updateOf; | ||
| 820 | + $p_data['siteName'] = $site; | ||
| 821 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 822 | + | ||
| 823 | + $data = json_decode($result,true); | ||
| 824 | + return $data; | ||
| 825 | + } | ||
| 826 | + | ||
| 827 | + /** | ||
| 828 | + * 获取SSL状态及证书信息 | ||
| 829 | + * @param [type] $site 域名(纯域名) | ||
| 830 | + */ | ||
| 831 | + public function GetSSL($site){ | ||
| 832 | + $url = $this->BT_PANEL.$this->config("GetSSL"); | ||
| 833 | + | ||
| 834 | + $p_data = $this->GetKeyData(); | ||
| 835 | + $p_data['siteName'] = $site; | ||
| 836 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 837 | + | ||
| 838 | + $data = json_decode($result,true); | ||
| 839 | + return $data; | ||
| 840 | + } | ||
| 841 | + | ||
| 842 | + /** | ||
| 843 | + * 获取网站默认文件 | ||
| 844 | + * @param [type] $id 网站ID | ||
| 845 | + */ | ||
| 846 | + public function WebGetIndex($id){ | ||
| 847 | + $url = $this->BT_PANEL.$this->config("WebGetIndex"); | ||
| 848 | + | ||
| 849 | + $p_data = $this->GetKeyData(); | ||
| 850 | + $p_data['id'] = $id; | ||
| 851 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 852 | + | ||
| 853 | + $data = json_decode($result,true); | ||
| 854 | + return $data; | ||
| 855 | + } | ||
| 856 | + | ||
| 857 | + /** | ||
| 858 | + * 设置网站默认文件 | ||
| 859 | + * @param [type] $id 网站ID | ||
| 860 | + * @param [type] $index 内容 | ||
| 861 | + */ | ||
| 862 | + public function WebSetIndex($id,$index){ | ||
| 863 | + $url = $this->BT_PANEL.$this->config("WebSetIndex"); | ||
| 864 | + | ||
| 865 | + $p_data = $this->GetKeyData(); | ||
| 866 | + $p_data['id'] = $id; | ||
| 867 | + $p_data['Index'] = $index; | ||
| 868 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 869 | + | ||
| 870 | + $data = json_decode($result,true); | ||
| 871 | + return $data; | ||
| 872 | + } | ||
| 873 | + | ||
| 874 | + /** | ||
| 875 | + * 获取网站流量限制信息 | ||
| 876 | + * @param [type] $id [description] | ||
| 877 | + */ | ||
| 878 | + public function GetLimitNet($id){ | ||
| 879 | + $url = $this->BT_PANEL.$this->config("GetLimitNet"); | ||
| 880 | + | ||
| 881 | + $p_data = $this->GetKeyData(); | ||
| 882 | + $p_data['id'] = $id; | ||
| 883 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 884 | + | ||
| 885 | + $data = json_decode($result,true); | ||
| 886 | + return $data; | ||
| 887 | + } | ||
| 888 | + | ||
| 889 | + /** | ||
| 890 | + * 设置网站流量限制信息 | ||
| 891 | + * @param [type] $id 网站ID | ||
| 892 | + * @param [type] $perserver 并发限制 | ||
| 893 | + * @param [type] $perip 单IP限制 | ||
| 894 | + * @param [type] $limit_rate 流量限制 | ||
| 895 | + */ | ||
| 896 | + public function SetLimitNet($id,$perserver,$perip,$limit_rate){ | ||
| 897 | + $url = $this->BT_PANEL.$this->config("SetLimitNet"); | ||
| 898 | + | ||
| 899 | + $p_data = $this->GetKeyData(); | ||
| 900 | + $p_data['id'] = $id; | ||
| 901 | + $p_data['perserver'] = $perserver; | ||
| 902 | + $p_data['perip'] = $perip; | ||
| 903 | + $p_data['limit_rate'] = $limit_rate; | ||
| 904 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 905 | + | ||
| 906 | + $data = json_decode($result,true); | ||
| 907 | + return $data; | ||
| 908 | + } | ||
| 909 | + | ||
| 910 | + /** | ||
| 911 | + * 关闭网站流量限制 | ||
| 912 | + * @param [type] $id 网站ID | ||
| 913 | + */ | ||
| 914 | + public function CloseLimitNet($id){ | ||
| 915 | + $url = $this->BT_PANEL.$this->config("CloseLimitNet"); | ||
| 916 | + | ||
| 917 | + $p_data = $this->GetKeyData(); | ||
| 918 | + $p_data['id'] = $id; | ||
| 919 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 920 | + | ||
| 921 | + $data = json_decode($result,true); | ||
| 922 | + return $data; | ||
| 923 | + } | ||
| 924 | + | ||
| 925 | + /** | ||
| 926 | + * 获取网站301重定向信息 | ||
| 927 | + * @param [type] $site 网站名 | ||
| 928 | + */ | ||
| 929 | + public function Get301Status($site){ | ||
| 930 | + $url = $this->BT_PANEL.$this->config("Get301Status"); | ||
| 931 | + | ||
| 932 | + $p_data = $this->GetKeyData(); | ||
| 933 | + $p_data['siteName'] = $site; | ||
| 934 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 935 | + | ||
| 936 | + $data = json_decode($result,true); | ||
| 937 | + return $data; | ||
| 938 | + } | ||
| 939 | + | ||
| 940 | + /** | ||
| 941 | + * 设置网站301重定向信息 | ||
| 942 | + * @param [type] $site 网站名 | ||
| 943 | + * @param [type] $toDomain 目标Url | ||
| 944 | + * @param [type] $srcDomain 来自Url | ||
| 945 | + * @param [type] $type 类型 | ||
| 946 | + */ | ||
| 947 | + public function Set301Status($site,$toDomain,$srcDomain,$type){ | ||
| 948 | + $url = $this->BT_PANEL.$this->config("Set301Status"); | ||
| 949 | + | ||
| 950 | + $p_data = $this->GetKeyData(); | ||
| 951 | + $p_data['siteName'] = $site; | ||
| 952 | + $p_data['toDomain'] = $toDomain; | ||
| 953 | + $p_data['srcDomain'] = $srcDomain; | ||
| 954 | + $p_data['type'] = $type; | ||
| 955 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 956 | + | ||
| 957 | + $data = json_decode($result,true); | ||
| 958 | + return $data; | ||
| 959 | + } | ||
| 960 | + | ||
| 961 | + /** | ||
| 962 | + * 获取网站反代信息及状态 | ||
| 963 | + * @param [type] $site [description] | ||
| 964 | + */ | ||
| 965 | + public function GetProxyList($site){ | ||
| 966 | + $url = $this->BT_PANEL.$this->config("GetProxyList"); | ||
| 967 | + | ||
| 968 | + $p_data = $this->GetKeyData(); | ||
| 969 | + $p_data['sitename'] = $site; | ||
| 970 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 971 | + | ||
| 972 | + $data = json_decode($result,true); | ||
| 973 | + return $data; | ||
| 974 | + } | ||
| 975 | + | ||
| 976 | + /** | ||
| 977 | + * 添加网站反代信息 | ||
| 978 | + * @param [type] $cache 是否缓存 | ||
| 979 | + * @param [type] $proxyname 代理名称 | ||
| 980 | + * @param [type] $cachetime 缓存时长 /小时 | ||
| 981 | + * @param [type] $proxydir 代理目录 | ||
| 982 | + * @param [type] $proxysite 反代URL | ||
| 983 | + * @param [type] $todomain 目标域名 | ||
| 984 | + * @param [type] $advanced 高级功能:开启代理目录 | ||
| 985 | + * @param [type] $sitename 网站名 | ||
| 986 | + * @param [type] $subfilter 文本替换json格式[{"sub1":"百度","sub2":"白底"},{"sub1":"","sub2":""}] | ||
| 987 | + * @param [type] $type 开启或关闭 0关;1开 | ||
| 988 | + */ | ||
| 989 | + public function CreateProxy($cache,$proxyname,$cachetime,$proxydir,$proxysite,$todomain,$advanced,$sitename,$subfilter,$type){ | ||
| 990 | + $url = $this->BT_PANEL.$this->config("CreateProxy"); | ||
| 991 | + | ||
| 992 | + $p_data = $this->GetKeyData(); | ||
| 993 | + $p_data['cache'] = $cache; | ||
| 994 | + $p_data['proxyname'] = $proxyname; | ||
| 995 | + $p_data['cachetime'] = $cachetime; | ||
| 996 | + $p_data['proxydir'] = $proxydir; | ||
| 997 | + $p_data['proxysite'] = $proxysite; | ||
| 998 | + $p_data['todomain'] = $todomain; | ||
| 999 | + $p_data['advanced'] = $advanced; | ||
| 1000 | + $p_data['sitename'] = $sitename; | ||
| 1001 | + $p_data['subfilter'] = $subfilter; | ||
| 1002 | + $p_data['type'] = $type; | ||
| 1003 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1004 | + | ||
| 1005 | + $data = json_decode($result,true); | ||
| 1006 | + return $data; | ||
| 1007 | + } | ||
| 1008 | + | ||
| 1009 | + /** | ||
| 1010 | + * 添加网站反代信息 | ||
| 1011 | + * @param [type] $cache 是否缓存 | ||
| 1012 | + * @param [type] $proxyname 代理名称 | ||
| 1013 | + * @param [type] $cachetime 缓存时长 /小时 | ||
| 1014 | + * @param [type] $proxydir 代理目录 | ||
| 1015 | + * @param [type] $proxysite 反代URL | ||
| 1016 | + * @param [type] $todomain 目标域名 | ||
| 1017 | + * @param [type] $advanced 高级功能:开启代理目录 | ||
| 1018 | + * @param [type] $sitename 网站名 | ||
| 1019 | + * @param [type] $subfilter 文本替换json格式[{"sub1":"百度","sub2":"白底"},{"sub1":"","sub2":""}] | ||
| 1020 | + * @param [type] $type 开启或关闭 0关;1开 | ||
| 1021 | + */ | ||
| 1022 | + public function ModifyProxy($cache,$proxyname,$cachetime,$proxydir,$proxysite,$todomain,$advanced,$sitename,$subfilter,$type){ | ||
| 1023 | + $url = $this->BT_PANEL.$this->config("ModifyProxy"); | ||
| 1024 | + | ||
| 1025 | + $p_data = $this->GetKeyData(); | ||
| 1026 | + $p_data['cache'] = $cache; | ||
| 1027 | + $p_data['proxyname'] = $proxyname; | ||
| 1028 | + $p_data['cachetime'] = $cachetime; | ||
| 1029 | + $p_data['proxydir'] = $proxydir; | ||
| 1030 | + $p_data['proxysite'] = $proxysite; | ||
| 1031 | + $p_data['todomain'] = $todomain; | ||
| 1032 | + $p_data['advanced'] = $advanced; | ||
| 1033 | + $p_data['sitename'] = $sitename; | ||
| 1034 | + $p_data['subfilter'] = $subfilter; | ||
| 1035 | + $p_data['type'] = $type; | ||
| 1036 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1037 | + | ||
| 1038 | + $data = json_decode($result,true); | ||
| 1039 | + return $data; | ||
| 1040 | + } | ||
| 1041 | + | ||
| 1042 | + /** | ||
| 1043 | + * 获取网站域名绑定二级目录信息 | ||
| 1044 | + * @param [type] $id 网站ID | ||
| 1045 | + */ | ||
| 1046 | + public function GetDirBinding($id){ | ||
| 1047 | + $url = $this->BT_PANEL.$this->config("GetDirBinding"); | ||
| 1048 | + | ||
| 1049 | + $p_data = $this->GetKeyData(); | ||
| 1050 | + $p_data['id'] = $id; | ||
| 1051 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1052 | + | ||
| 1053 | + $data = json_decode($result,true); | ||
| 1054 | + return $data; | ||
| 1055 | + } | ||
| 1056 | + | ||
| 1057 | + /** | ||
| 1058 | + * 设置网站域名绑定二级目录 | ||
| 1059 | + * @param [type] $id 网站ID | ||
| 1060 | + * @param [type] $domain 域名 | ||
| 1061 | + * @param [type] $dirName 目录 | ||
| 1062 | + */ | ||
| 1063 | + public function AddDirBinding($id,$domain,$dirName){ | ||
| 1064 | + $url = $this->BT_PANEL.$this->config("AddDirBinding"); | ||
| 1065 | + | ||
| 1066 | + $p_data = $this->GetKeyData(); | ||
| 1067 | + $p_data['id'] = $id; | ||
| 1068 | + $p_data['domain'] = $domain; | ||
| 1069 | + $p_data['dirName'] = $dirName; | ||
| 1070 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1071 | + | ||
| 1072 | + $data = json_decode($result,true); | ||
| 1073 | + return $data; | ||
| 1074 | + } | ||
| 1075 | + | ||
| 1076 | + /** | ||
| 1077 | + * 删除网站域名绑定二级目录 | ||
| 1078 | + * @param [type] $dirid 子目录ID | ||
| 1079 | + */ | ||
| 1080 | + public function DelDirBinding($dirid){ | ||
| 1081 | + $url = $this->BT_PANEL.$this->config("DelDirBinding"); | ||
| 1082 | + | ||
| 1083 | + $p_data = $this->GetKeyData(); | ||
| 1084 | + $p_data['id'] = $dirid; | ||
| 1085 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1086 | + | ||
| 1087 | + $data = json_decode($result,true); | ||
| 1088 | + return $data; | ||
| 1089 | + } | ||
| 1090 | + | ||
| 1091 | + /** | ||
| 1092 | + * 获取网站子目录绑定伪静态信息 | ||
| 1093 | + * @param [type] $dirid 子目录绑定ID | ||
| 1094 | + */ | ||
| 1095 | + public function GetDirRewrite($dirid,$type=0){ | ||
| 1096 | + $url = $this->BT_PANEL.$this->config("GetDirRewrite"); | ||
| 1097 | + | ||
| 1098 | + $p_data = $this->GetKeyData(); | ||
| 1099 | + $p_data['id'] = $dirid; | ||
| 1100 | + if($type){ | ||
| 1101 | + $p_data['add'] = 1; | ||
| 1102 | + } | ||
| 1103 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1104 | + | ||
| 1105 | + $data = json_decode($result,true); | ||
| 1106 | + return $data; | ||
| 1107 | + } | ||
| 1108 | + | ||
| 1109 | + /** | ||
| 1110 | + * 修改FTP账号密码 | ||
| 1111 | + * @param [type] $id FTPID | ||
| 1112 | + * @param [type] $ftp_username 用户名 | ||
| 1113 | + * @param [type] $new_password 密码 | ||
| 1114 | + */ | ||
| 1115 | + public function SetUserPassword($id,$ftp_username,$new_password){ | ||
| 1116 | + $url = $this->BT_PANEL.$this->config("SetUserPassword"); | ||
| 1117 | + | ||
| 1118 | + $p_data = $this->GetKeyData(); | ||
| 1119 | + $p_data['id'] = $id; | ||
| 1120 | + $p_data['ftp_username'] = $ftp_username; | ||
| 1121 | + $p_data['new_password'] = $new_password; | ||
| 1122 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1123 | + | ||
| 1124 | + $data = json_decode($result,true); | ||
| 1125 | + return $data; | ||
| 1126 | + } | ||
| 1127 | + | ||
| 1128 | + /** | ||
| 1129 | + * 修改SQL账号密码 | ||
| 1130 | + * @param [type] $id SQLID | ||
| 1131 | + * @param [type] $ftp_username 用户名 | ||
| 1132 | + * @param [type] $new_password 密码 | ||
| 1133 | + */ | ||
| 1134 | + public function ResDatabasePass($id,$name,$password){ | ||
| 1135 | + $url = $this->BT_PANEL.$this->config("ResDatabasePass"); | ||
| 1136 | + | ||
| 1137 | + $p_data = $this->GetKeyData(); | ||
| 1138 | + $p_data['id'] = $id; | ||
| 1139 | + $p_data['name'] = $name; | ||
| 1140 | + $p_data['password'] = $password; | ||
| 1141 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1142 | + | ||
| 1143 | + $data = json_decode($result,true); | ||
| 1144 | + return $data; | ||
| 1145 | + } | ||
| 1146 | + | ||
| 1147 | + /** | ||
| 1148 | + * 启用/禁用FTP | ||
| 1149 | + * @param [type] $id FTPID | ||
| 1150 | + * @param [type] $username 用户名 | ||
| 1151 | + * @param [type] $status 状态 0->关闭;1->开启 | ||
| 1152 | + */ | ||
| 1153 | + public function SetStatus($id,$username,$status){ | ||
| 1154 | + $url = $this->BT_PANEL.$this->config("SetStatus"); | ||
| 1155 | + | ||
| 1156 | + $p_data = $this->GetKeyData(); | ||
| 1157 | + $p_data['id'] = $id; | ||
| 1158 | + $p_data['username'] = $username; | ||
| 1159 | + $p_data['status'] = $status; | ||
| 1160 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1161 | + | ||
| 1162 | + $data = json_decode($result,true); | ||
| 1163 | + return $data; | ||
| 1164 | + } | ||
| 1165 | + | ||
| 1166 | + /** | ||
| 1167 | + * 宝塔一键部署列表 | ||
| 1168 | + * @param string $search 搜索关键词 | ||
| 1169 | + * @return [type] [description] | ||
| 1170 | + */ | ||
| 1171 | + public function deployment($search=''){ | ||
| 1172 | + if($search){ | ||
| 1173 | + $url = $this->BT_PANEL.$this->config("deployment").'&search='.$search; | ||
| 1174 | + }else{ | ||
| 1175 | + $url = $this->BT_PANEL.$this->config("deployment"); | ||
| 1176 | + } | ||
| 1177 | + | ||
| 1178 | + $p_data = $this->GetKeyData(); | ||
| 1179 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1180 | + | ||
| 1181 | + $data = json_decode($result,true); | ||
| 1182 | + return $data; | ||
| 1183 | + } | ||
| 1184 | + | ||
| 1185 | + /** | ||
| 1186 | + * 宝塔一键部署执行 | ||
| 1187 | + * @param [type] $dname 部署程序名 | ||
| 1188 | + * @param [type] $site_name 部署到网站名 | ||
| 1189 | + * @param [type] $php_version PHP版本 | ||
| 1190 | + */ | ||
| 1191 | + public function SetupPackage($dname,$site_name,$php_version){ | ||
| 1192 | + $url = $this->BT_PANEL.$this->config("SetupPackage"); | ||
| 1193 | + | ||
| 1194 | + $p_data = $this->GetKeyData(); | ||
| 1195 | + $p_data['dname'] = $dname; | ||
| 1196 | + $p_data['site_name'] = $site_name; | ||
| 1197 | + $p_data['php_version'] = $php_version; | ||
| 1198 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1199 | + | ||
| 1200 | + $data = json_decode($result,true); | ||
| 1201 | + return $data; | ||
| 1202 | + } | ||
| 1203 | + | ||
| 1204 | + /** | ||
| 1205 | + * 设置文件权限 | ||
| 1206 | + * @param $path | ||
| 1207 | + * @param $user | ||
| 1208 | + * @param $access | ||
| 1209 | + * @param $all | ||
| 1210 | + * @return mixed | ||
| 1211 | + */ | ||
| 1212 | + public function setFileAccess($path, $user, $access, $all) { | ||
| 1213 | + $url = $this->BT_PANEL.$this->config("SetFileAccess"); | ||
| 1214 | + $p_data = $this->GetKeyData(); | ||
| 1215 | + $p_data['user'] = $user; | ||
| 1216 | + $p_data['access'] = $access; | ||
| 1217 | + $p_data['all'] = $all; | ||
| 1218 | + $p_data['filename'] = $path; | ||
| 1219 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1220 | + | ||
| 1221 | + $data = json_decode($result,true); | ||
| 1222 | + return $data; | ||
| 1223 | + } | ||
| 1224 | + | ||
| 1225 | + /** | ||
| 1226 | + * 获取队列 | ||
| 1227 | + * @return mixed | ||
| 1228 | + */ | ||
| 1229 | + public function getProcessList() | ||
| 1230 | + { | ||
| 1231 | + $url = $this->BT_PANEL.$this->config("GetProcessList"); | ||
| 1232 | + $p_data = $this->GetKeyData(); | ||
| 1233 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1234 | + | ||
| 1235 | + $data = json_decode($result,true); | ||
| 1236 | + return $data; | ||
| 1237 | + } | ||
| 1238 | + | ||
| 1239 | + /** | ||
| 1240 | + * 停止队列 | ||
| 1241 | + * @param $program | ||
| 1242 | + * @param int $numprocs | ||
| 1243 | + * @return mixed | ||
| 1244 | + */ | ||
| 1245 | + public function stopProcess($program, $numprocs = 1) | ||
| 1246 | + { | ||
| 1247 | + $url = $this->BT_PANEL.$this->config("StopProcess"); | ||
| 1248 | + $p_data = $this->GetKeyData(); | ||
| 1249 | + $p_data['program'] = $program; | ||
| 1250 | + $p_data['numprocs'] = $numprocs; | ||
| 1251 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1252 | + | ||
| 1253 | + $data = json_decode($result,true); | ||
| 1254 | + return $data; | ||
| 1255 | + } | ||
| 1256 | + | ||
| 1257 | + /** | ||
| 1258 | + * 启动队列 | ||
| 1259 | + * @param $program | ||
| 1260 | + * @param int $numprocs | ||
| 1261 | + * @return mixed | ||
| 1262 | + */ | ||
| 1263 | + public function startProcess($program, $numprocs = 1) | ||
| 1264 | + { | ||
| 1265 | + $url = $this->BT_PANEL.$this->config("StartProcess"); | ||
| 1266 | + $p_data = $this->GetKeyData(); | ||
| 1267 | + $p_data['program'] = $program; | ||
| 1268 | + $p_data['numprocs'] = $numprocs; | ||
| 1269 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1270 | + | ||
| 1271 | + $data = json_decode($result,true); | ||
| 1272 | + return $data; | ||
| 1273 | + } | ||
| 1274 | + | ||
| 1275 | + /** | ||
| 1276 | + * 设置文件权限 | ||
| 1277 | + * @param $path | ||
| 1278 | + * @return mixed | ||
| 1279 | + */ | ||
| 1280 | + public function DeleteFile($path) { | ||
| 1281 | + $url = $this->BT_PANEL.$this->config("DeleteFile"); | ||
| 1282 | + $p_data = $this->GetKeyData(); | ||
| 1283 | + $p_data['path'] = $path; | ||
| 1284 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1285 | + | ||
| 1286 | + $data = json_decode($result,true); | ||
| 1287 | + return $data; | ||
| 1288 | + } | ||
| 1289 | + | ||
| 1290 | + /** | ||
| 1291 | + * 更新网站目录 | ||
| 1292 | + * @param $site_id | ||
| 1293 | + * @param $path | ||
| 1294 | + * @return mixed | ||
| 1295 | + */ | ||
| 1296 | + public function SetPath($site_id, $path) | ||
| 1297 | + { | ||
| 1298 | + $url = $this->BT_PANEL.$this->config("SetPath"); | ||
| 1299 | + $p_data = $this->GetKeyData(); | ||
| 1300 | + $p_data['id'] = $site_id; | ||
| 1301 | + $p_data['path'] = $path; | ||
| 1302 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1303 | + $data = json_decode($result,true); | ||
| 1304 | + return $data; | ||
| 1305 | + } | ||
| 1306 | + | ||
| 1307 | + | ||
| 1308 | + /** | ||
| 1309 | + * 更新运行目录 | ||
| 1310 | + * @param $site_id | ||
| 1311 | + * @param $path | ||
| 1312 | + * @return mixed | ||
| 1313 | + */ | ||
| 1314 | + public function SetSiteRunPath($site_id, $path) | ||
| 1315 | + { | ||
| 1316 | + $url = $this->BT_PANEL.$this->config("SetSiteRunPath"); | ||
| 1317 | + $p_data = $this->GetKeyData(); | ||
| 1318 | + $p_data['id'] = $site_id; | ||
| 1319 | + $p_data['runPath'] = $path; | ||
| 1320 | + $result = $this->HttpPostCookie($url,$p_data); | ||
| 1321 | + $data = json_decode($result,true); | ||
| 1322 | + return $data; | ||
| 1323 | + } | ||
| 1324 | + | ||
| 1325 | + | ||
| 1326 | + /** | ||
| 1327 | + * 构造带有签名的关联数组 | ||
| 1328 | + */ | ||
| 1329 | + public function GetKeyData(){ | ||
| 1330 | + $now_time = time(); | ||
| 1331 | + $p_data = array( | ||
| 1332 | + 'request_token' => md5($now_time.''.md5($this->BT_KEY)), | ||
| 1333 | + 'request_time' => $now_time | ||
| 1334 | + ); | ||
| 1335 | + return $p_data; | ||
| 1336 | + } | ||
| 1337 | + | ||
| 1338 | + /** | ||
| 1339 | + * 发起POST请求 | ||
| 1340 | + * @param String $url 目标网填,带http:// | ||
| 1341 | + * @param Array|String $data 欲提交的数据 | ||
| 1342 | + * @return string | ||
| 1343 | + */ | ||
| 1344 | + private function HttpPostCookie($url, $data,$timeout = 60) | ||
| 1345 | + { | ||
| 1346 | + //定义cookie保存位置 | ||
| 1347 | + $cookie_file='./'.md5($this->BT_PANEL).'.cookie'; | ||
| 1348 | + if(!file_exists($cookie_file)){ | ||
| 1349 | + $fp = fopen($cookie_file,'w+'); | ||
| 1350 | + fclose($fp); | ||
| 1351 | + } | ||
| 1352 | + | ||
| 1353 | + $ch = curl_init(); | ||
| 1354 | + curl_setopt($ch, CURLOPT_URL, $url); | ||
| 1355 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); | ||
| 1356 | + curl_setopt($ch, CURLOPT_POST, 1); | ||
| 1357 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | ||
| 1358 | + curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); | ||
| 1359 | + curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); | ||
| 1360 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
| 1361 | + curl_setopt($ch, CURLOPT_HEADER, 0); | ||
| 1362 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | ||
| 1363 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | ||
| 1364 | + $output = curl_exec($ch); | ||
| 1365 | + curl_close($ch); | ||
| 1366 | + return $output; | ||
| 1367 | + } | ||
| 1368 | + | ||
| 1369 | + /** | ||
| 1370 | + * 加载宝塔数据接口 | ||
| 1371 | + * @param [type] $str [description] | ||
| 1372 | + * @return [type] [description] | ||
| 1373 | + */ | ||
| 1374 | + private function config($str){ | ||
| 1375 | + $config = config("bt"); | ||
| 1376 | + //var_dump($config); | ||
| 1377 | + return $config[$str]; | ||
| 1378 | + } | ||
| 1379 | +} | ||
| 1380 | + | ||
| 1381 | + | ||
| 1382 | + |
app/Repositories/BtRepository.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2023/09/18 | ||
| 6 | + * Time: 20:56 | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +namespace App\Repositories; | ||
| 10 | + | ||
| 11 | +use App\Repositories\Bt\Bt; | ||
| 12 | +use Illuminate\Support\Facades\Log; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * Class BtRepository | ||
| 16 | + * @package App\Repositories | ||
| 17 | + */ | ||
| 18 | +class BtRepository | ||
| 19 | +{ | ||
| 20 | + public $instance = []; | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * @param $domain | ||
| 24 | + * @return array|bool | ||
| 25 | + */ | ||
| 26 | + public function createBtSite($domain, $rewrite = [], $domain_list = []) | ||
| 27 | + { | ||
| 28 | + $domain_array = parse_url($domain); | ||
| 29 | + $host = $domain_array['host'] ?? $domain_array['path']; | ||
| 30 | + | ||
| 31 | + // TODO 验证当前服务器是否已经创建过了 | ||
| 32 | + $bt = $this->getBtObject(); | ||
| 33 | + $site_list = $bt->WebSiteList($host); | ||
| 34 | + if (!empty($site_list['data'])) { | ||
| 35 | + return ['site_id' => $site_list['data'][0]['id']]; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +// if ($domain_list) { | ||
| 39 | +// $web_name = ['domain' => $host, 'domainlist' => $domain_list, 'count' => 0]; | ||
| 40 | +// } else { | ||
| 41 | +// $host_array = explode('.', $host); | ||
| 42 | +// if (FALSE == empty($host_array[0]) && $host_array[0] == 'www') | ||
| 43 | +// unset($host_array[0]); | ||
| 44 | +// $domain_top = implode('.', $host_array); | ||
| 45 | +// if ($domain_top == $host){ | ||
| 46 | +// $web_name = ['domain' => $host, 'domainlist' => ['www.'.$domain_top, '*.' . $host], 'count' => 0]; | ||
| 47 | +// }else{ | ||
| 48 | +// $web_name = ['domain' => $host, 'domainlist' => [$domain_top, '*.' . $domain_top], 'count' => 0]; | ||
| 49 | +// } | ||
| 50 | +// } | ||
| 51 | + $web_name = ['domain' => $host, 'domainlist' => $domain_list, 'count' => 0]; | ||
| 52 | + | ||
| 53 | + $array = [ | ||
| 54 | + 'webname' => json_encode($web_name), | ||
| 55 | + 'path' => '/www/wwwroot/createSite', | ||
| 56 | + 'type_id' => 0, | ||
| 57 | + 'type' => 'PHP', | ||
| 58 | + 'version' => '80', | ||
| 59 | + 'port' => '80', | ||
| 60 | + 'ps' => $host, | ||
| 61 | + 'ftp' => false, | ||
| 62 | + 'ftp_username' => '', | ||
| 63 | + 'ftp_password' => '', | ||
| 64 | + 'sql' => false, | ||
| 65 | + 'codeing' => '', | ||
| 66 | + 'datauser' => '', | ||
| 67 | + 'datapassword' => '', | ||
| 68 | + ]; | ||
| 69 | + | ||
| 70 | + | ||
| 71 | + $result = $bt->AddSite($array); | ||
| 72 | +// result 返回信息 | ||
| 73 | +// $result = ['siteStatus' => true, 'siteId' => 39, 'ftpStatus' => false, 'databaseStatus' => false,]; | ||
| 74 | + if (empty($result) || empty($result['siteId'])) | ||
| 75 | + return false; | ||
| 76 | + // 更新站点目录 更新站点运行目录 | ||
| 77 | + $bt->SetPath($result['siteId'], public_path()); | ||
| 78 | + | ||
| 79 | + // 删除 .user.ini | ||
| 80 | + $bt->DeleteFile('/www/wwwroot/c-globalso/public/.user.ini'); | ||
| 81 | + $bt->DeleteFile('/www/wwwroot/c-globalso/.user.ini'); | ||
| 82 | +// $bt->SetSiteRunPath($result['siteId'], '/'); | ||
| 83 | + #--------------------------------------------------------------------------------------------------------------- | ||
| 84 | + // 伪静态设置 | ||
| 85 | +// $htaccess = $this->rewrite301($rewrite); | ||
| 86 | +// if ($htaccess) | ||
| 87 | +// $bt->SaveFileBody($host, $htaccess); | ||
| 88 | + // 获取配置 | ||
| 89 | + // 设置Nginx配置 | ||
| 90 | +// $nginx_config = $this->getAfterNginxConfStr($host); | ||
| 91 | +// $bt->SaveFileBody('/www/server/panel/vhost/nginx/' . $host . '.conf', $nginx_config, 'utf-8', 1); | ||
| 92 | + #--------------------------------------------------------------------------------------------------------------- | ||
| 93 | + | ||
| 94 | + return ['site_id' => $result['siteId']]; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * 申请免费证书 | ||
| 99 | + * @param string $domain | ||
| 100 | + * @param array $rewrite | ||
| 101 | + * @param array $otherDomain | ||
| 102 | + * @param int $is_https | ||
| 103 | + * @return bool | ||
| 104 | + */ | ||
| 105 | + public function applySsl($domain, $rewrite = [], $otherDomain = [], $is_https = 0) | ||
| 106 | + { | ||
| 107 | + $domain_array = parse_url($domain); | ||
| 108 | + $host = $domain_array['host'] ?? $domain_array['path']; | ||
| 109 | + | ||
| 110 | + $bt = $this->getBtObject(); | ||
| 111 | + $site_list = $bt->WebSiteList($host); | ||
| 112 | + if (empty($site_list['data'])) { | ||
| 113 | + $site = $this->createBtSite($domain,$rewrite,$otherDomain); | ||
| 114 | + $site_id = $site['site_id']; | ||
| 115 | + }else{ | ||
| 116 | + $site_id = $site_list['data'][0]['id']; | ||
| 117 | + $host = $site_list['data'][0]['name']; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + // 获取站点域名 | ||
| 121 | + $site_domain = $bt->WebDoaminList($site_id); | ||
| 122 | + $domain_list = []; | ||
| 123 | + foreach ($site_domain as $val) { | ||
| 124 | + if (FALSE === strpos($val['name'], '*')) { | ||
| 125 | + array_push($domain_list, $val['name']); | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + //添加站点域名 | ||
| 130 | + $this->addDomain($site_id, $host, $otherDomain, $site_domain); | ||
| 131 | + | ||
| 132 | + //还原配置 | ||
| 133 | + $nginx_config = $this->getBeforeNginxConfStr($host); | ||
| 134 | + $bt->SaveFileBody('/www/server/panel/vhost/nginx/' . $host . '.conf', $nginx_config, 'utf-8', 1); | ||
| 135 | + | ||
| 136 | + // 如果已经申请了ssl证书, 并且证书有效期超过3天, 那么就使用已经申请好的证书 | ||
| 137 | + $ssl = $bt->GetSSL($host); | ||
| 138 | + $is_set_status = false;//是否需要设置证书 | ||
| 139 | + if (FALSE == empty($ssl['cert_data']['notAfter']) && strtotime($ssl['cert_data']['notAfter']) - time() > 259200) { | ||
| 140 | + $key = $ssl['key']; | ||
| 141 | + $cer = $ssl['csr']; | ||
| 142 | + $is_set_status = !$ssl['status']; | ||
| 143 | + } else { | ||
| 144 | + // 申请证书时需要将重写规则情况, 不然会跳转到其他地方 | ||
| 145 | + $bt->SaveFileBody($host, ''); | ||
| 146 | + // 如果没有证书, 申请证书并设置证书 | ||
| 147 | + $rs = $bt->ApplyCert(json_encode($domain_list),$site_id); | ||
| 148 | + if(isset($rs['status']) && $rs['status']){ | ||
| 149 | + //申请成功,设置证书 | ||
| 150 | + $key = $rs['private_key']; | ||
| 151 | + $cer = $rs['cert']; | ||
| 152 | + $is_set_status = true; | ||
| 153 | + }else{ | ||
| 154 | + $key = ''; | ||
| 155 | + $cer = ''; | ||
| 156 | + } | ||
| 157 | + } | ||
| 158 | + if($key && $cer && $is_set_status){ | ||
| 159 | + $bt->SetSSL(1, $host, $key, $cer); | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + $bt->DeleteFile('/www/wwwroot/c-globalso/public/.user.ini'); | ||
| 163 | + $bt->DeleteFile('/www/wwwroot/c-globalso/.user.ini'); | ||
| 164 | + $htaccess = $this->rewrite301($rewrite,$is_https); | ||
| 165 | + if ($htaccess) | ||
| 166 | + $bt->SaveFileBody($host, $htaccess); | ||
| 167 | + // 更新配置 | ||
| 168 | + $nginx_config = $this->getAfterNginxConfStr($host); | ||
| 169 | + $bt->SaveFileBody('/www/server/panel/vhost/nginx/' . $host . '.conf', $nginx_config, 'utf-8', 1); | ||
| 170 | + return true; | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + | ||
| 174 | + /** | ||
| 175 | + * 设置ssl证书 | ||
| 176 | + * @param string $domain | ||
| 177 | + * @param array $rewrite | ||
| 178 | + * @param array $otherDomain | ||
| 179 | + * @param string $private_key | ||
| 180 | + * @param string $cert | ||
| 181 | + * @param int $is_https | ||
| 182 | + * @return bool | ||
| 183 | + */ | ||
| 184 | + public function setSsl($domain, $rewrite = [], $otherDomain = [], $private_key = '', $cert = '', $is_https = 0) | ||
| 185 | + { | ||
| 186 | + $domain_array = parse_url($domain); | ||
| 187 | + $host = $domain_array['host'] ?? $domain_array['path']; | ||
| 188 | + $bt = $this->getBtObject(); | ||
| 189 | + $site_list = $bt->WebSiteList($host); | ||
| 190 | + if (empty($site_list['data'])) { | ||
| 191 | + $site = $this->createBtSite($domain,$rewrite,$otherDomain); | ||
| 192 | + $site_id = $site['site_id']; | ||
| 193 | + }else{ | ||
| 194 | + $host = $site_list['data'][0]['name']; | ||
| 195 | + $site_id = $site_list['data'][0]['id']; | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + | ||
| 199 | + //添加站点域名 | ||
| 200 | + $this->addDomain($site_id, $host, $otherDomain); | ||
| 201 | + | ||
| 202 | + // 还原配置 | ||
| 203 | + $nginx_config = $this->getBeforeNginxConfStr($host); | ||
| 204 | + $bt->SaveFileBody('/www/server/panel/vhost/nginx/' . $host . '.conf', $nginx_config, 'utf-8', 1); | ||
| 205 | + $bt->SetSSL(1, $host, $private_key, $cert); | ||
| 206 | + | ||
| 207 | + $bt->DeleteFile('/www/wwwroot/c-globalso/public/.user.ini'); | ||
| 208 | + $bt->DeleteFile('/www/wwwroot/c-globalso/.user.ini'); | ||
| 209 | + | ||
| 210 | + // 设置301跳转 | ||
| 211 | + $htaccess = $this->rewrite301($rewrite,$is_https); | ||
| 212 | + if ($htaccess) | ||
| 213 | + $bt->SaveFileBody($host, $htaccess); | ||
| 214 | + // 更新配置 | ||
| 215 | + $nginx_config = $this->getAfterNginxConfStr($host); | ||
| 216 | + $bt->SaveFileBody('/www/server/panel/vhost/nginx/' . $host . '.conf', $nginx_config, 'utf-8', 1); | ||
| 217 | + | ||
| 218 | + return true; | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + /** | ||
| 222 | + * 获取bt对象 | ||
| 223 | + * @param string $key | ||
| 224 | + * @param string $panel | ||
| 225 | + * @return Bt | ||
| 226 | + */ | ||
| 227 | + public function getBtObject($key = '', $panel = '') | ||
| 228 | + { | ||
| 229 | + $key = $key ?: env('BT_KEY'); | ||
| 230 | + $panel = $panel ?: env('BT_PANEL'); | ||
| 231 | + $object_key = md5($key . $panel); | ||
| 232 | + if (empty($this->instance[$object_key])) { | ||
| 233 | + $bt = new Bt($panel, $key); | ||
| 234 | + $this->instance[$object_key] = $bt; | ||
| 235 | + } | ||
| 236 | + return $this->instance[$object_key]; | ||
| 237 | + } | ||
| 238 | + | ||
| 239 | + /** | ||
| 240 | + * 获取配置前的文件内容 | ||
| 241 | + * @param $domain | ||
| 242 | + * @return string|string[] | ||
| 243 | + */ | ||
| 244 | + public function getBeforeNginxConfStr($domain) | ||
| 245 | + { | ||
| 246 | + $bt = $this->getBtObject(); | ||
| 247 | + $conf = $bt->GetFileBody($domain, 2); | ||
| 248 | + | ||
| 249 | + //如果有变量标识,去掉变量标识 | ||
| 250 | + if (FALSE !== strpos($conf['data'], 'map $domain_prefix')){ | ||
| 251 | + $conf['data'] = str_replace($this->domainPrefixConf(),'',$conf['data']); | ||
| 252 | + //去掉自定义配置 | ||
| 253 | + $conf['data'] = str_replace($this->customConf($domain),'root ' . public_path() . ';', $conf['data']); | ||
| 254 | + } | ||
| 255 | + | ||
| 256 | +// preg_match('/set \$root[\S\s]+root \$root;/iU', $conf['data'], $matches); | ||
| 257 | +// if (FALSE == empty($matches[0])) { | ||
| 258 | +// $conf['data'] = str_replace($matches[0], 'root ' . public_path() . ';', $conf['data']); | ||
| 259 | +// } | ||
| 260 | + return $conf['data']; | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + /** | ||
| 264 | + * 获取配置后的文件内容 | ||
| 265 | + * @param $domain | ||
| 266 | + * @return mixed | ||
| 267 | + */ | ||
| 268 | + public function getAfterNginxConfStr($domain) | ||
| 269 | + { | ||
| 270 | + $bt = $this->getBtObject(); | ||
| 271 | + $conf = $bt->GetFileBody($domain, 2); | ||
| 272 | +// $conf['data'] = file_get_contents(storage_path('logs/nginx.conf')); | ||
| 273 | + // 如果没有变量, 添加变量识别 | ||
| 274 | + if (FALSE === strpos($conf['data'], 'map $domain_prefix')){ | ||
| 275 | + $conf['data'] = $this->domainPrefixConf() . $conf['data']; | ||
| 276 | + // 替换自定义配置 | ||
| 277 | + $conf['data'] = str_replace('root ' . public_path() . ';', $this->customConf($domain), $conf['data']); | ||
| 278 | + } | ||
| 279 | + | ||
| 280 | + return $conf['data']; | ||
| 281 | + } | ||
| 282 | + | ||
| 283 | + | ||
| 284 | + /** | ||
| 285 | + * 需要定制修改的配置 | ||
| 286 | + * @return string | ||
| 287 | + */ | ||
| 288 | + public function customConf($domain): string | ||
| 289 | + { | ||
| 290 | + $string = ' root '.public_path().'; # 设置根目录 | ||
| 291 | + | ||
| 292 | + set $domain_prefix ""; | ||
| 293 | + if ($host ~* "^(?<domain_prefix>[^.]+)\.") { | ||
| 294 | + set $domain_prefix $1; | ||
| 295 | + } | ||
| 296 | + | ||
| 297 | + location / { | ||
| 298 | + root '.public_path().'/'.$domain.'; # 设置根目录 | ||
| 299 | + if ($is_prefix_in_string = 1) { | ||
| 300 | + root '.public_path().'/'.$domain.'/$domain_prefix; | ||
| 301 | + } | ||
| 302 | + try_files $uri $uri/ /404/index.html =404; | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + location ~ ^/(api|search) { | ||
| 306 | + root '.public_path().'; # 设置/api /search /.well-known的根目录 | ||
| 307 | + try_files $uri $uri/ /index.php?$query_string; | ||
| 308 | + } | ||
| 309 | + | ||
| 310 | + location ~ ^/(well-known) { | ||
| 311 | + root '.public_path().'; | ||
| 312 | + try_files $uri $uri/ /404/index.html =404; | ||
| 313 | + } | ||
| 314 | + error_page 403 /404/index.html;'; | ||
| 315 | + return $string; | ||
| 316 | + } | ||
| 317 | + | ||
| 318 | + | ||
| 319 | + /** | ||
| 320 | + * 解析301跳转 | ||
| 321 | + * @param $rewrite | ||
| 322 | + * @param $is_https | ||
| 323 | + * @return string | ||
| 324 | + */ | ||
| 325 | + public function rewrite301($rewrite,$is_https) | ||
| 326 | + { | ||
| 327 | + $string = '# 屏蔽蜘蛛 | ||
| 328 | + if ($http_user_agent ~* "(Knowledge|SiteAuditBot|DotBot|rogerbot|MJ12bot|MegaIndex|Paracrawl|HubSpot|serpstatbot|SemrushBot|DataForSeoBot|BLEXBot|Bytespider|Sogou|Seekport|HubSpot|Barkrowler|PetalBot|Amazonbot|RainBot|test-bot|fidget-spinner-bot)") { | ||
| 329 | + return 444; | ||
| 330 | + } | ||
| 331 | + # 设置跳转 | ||
| 332 | + '; | ||
| 333 | + if (FALSE == is_array($rewrite)) | ||
| 334 | + return $string; | ||
| 335 | + | ||
| 336 | + foreach ($rewrite as $val) { | ||
| 337 | + if (empty($val['origin']) || empty($val['target'])) | ||
| 338 | + continue; | ||
| 339 | + $origin_tmp = parse_url($val['origin']); | ||
| 340 | + $origin = $origin_tmp['host'] ?? $origin_tmp['path']; | ||
| 341 | + $target_tmp = parse_url($val['target']); | ||
| 342 | + $target = $target_tmp['host'] ?? $target_tmp['path']; | ||
| 343 | + $string .= ' | ||
| 344 | + if ($host ~ "^' . $origin . '"){ | ||
| 345 | + return 301 $scheme://' . $target . '$request_uri; | ||
| 346 | + } | ||
| 347 | + '; | ||
| 348 | + } | ||
| 349 | + if($is_https){ | ||
| 350 | + $string .= ' | ||
| 351 | + #HTTP_TO_HTTPS_START | ||
| 352 | + if ($server_port !~ 443){ | ||
| 353 | + rewrite ^(/.*)$ https://$host$1 permanent; | ||
| 354 | + } | ||
| 355 | + '; | ||
| 356 | + } | ||
| 357 | + return $string; | ||
| 358 | + } | ||
| 359 | + | ||
| 360 | + | ||
| 361 | + /** | ||
| 362 | + * 配置变量 | ||
| 363 | + * @return string | ||
| 364 | + */ | ||
| 365 | + public function domainPrefixConf() | ||
| 366 | + { | ||
| 367 | + return 'map $domain_prefix $is_prefix_in_string { | ||
| 368 | + default 0; en 1; zh 1; fr 1; de 1; ko 1; ja 1; es 1; ar 1; pt 1; ru 1; af 1; sq 1; | ||
| 369 | + am 1; hy 1; az 1; eu 1; be 1; bn 1; bs 1; bg 1; ca 1; ceb 1; zh-CN 1; zh-TW 1; co 1; | ||
| 370 | + hr 1; cs 1; da 1; nl 1; eo 1; et 1; fi 1; fy 1; gl 1; ka 1; el 1; gu 1; ht 1; ha 1; haw 1; | ||
| 371 | + iw 1; hi 1; hmn 1; hu 1; is 1; ig 1; id 1; ga 1; it 1; jw 1; kn 1; kk 1; km 1; rw 1; | ||
| 372 | + ku 1; ky 1; lo 1; la 1; lv 1; lt 1; lb 1; mk 1; mg 1; ms 1; ml 1; mt 1; mi 1; mr 1; mn 1; | ||
| 373 | + my 1; ne 1; no 1; ny 1; or 1; ps 1; fa 1; pl 1; pa 1; ro 1; sm 1; gd 1; sr 1; st 1; sn 1; | ||
| 374 | + sd 1; si 1; sk 1; sl 1; so 1; su 1; sw 1; sv 1; tl 1; tg 1; ta 1; tt 1; te 1; th 1; tr 1; | ||
| 375 | + tk 1; uk 1; ur 1; ug 1; uz 1; vi 1; cy 1; xh 1; yi 1; yo 1; zu 1; | ||
| 376 | +}'; | ||
| 377 | + } | ||
| 378 | + | ||
| 379 | + | ||
| 380 | + //添加站点域名 | ||
| 381 | + protected function addDomain($site_id, $domain, $otherDomains, $site_domain = []) | ||
| 382 | + { | ||
| 383 | + $bt = $this->getBtObject(); | ||
| 384 | + if(!$site_domain){ | ||
| 385 | + $site_domain = $bt->WebDoaminList($site_id); | ||
| 386 | + } | ||
| 387 | + | ||
| 388 | + $site_domain = array_column($site_domain, 'name'); | ||
| 389 | + foreach ($otherDomains as $k => $otherDomain) { | ||
| 390 | + // 如果已经包含, 就不添加 | ||
| 391 | + if (in_array($otherDomain, $site_domain)) { | ||
| 392 | + unset($otherDomains[$k]); | ||
| 393 | + } | ||
| 394 | + } | ||
| 395 | + | ||
| 396 | + if ($otherDomains) { | ||
| 397 | + $otherDomains = implode(',', $otherDomains); | ||
| 398 | + | ||
| 399 | + $res = $bt->WebAddDomain($site_id, $domain, $otherDomains); | ||
| 400 | + if (!$res['status']) { | ||
| 401 | + return false; | ||
| 402 | + } | ||
| 403 | + } | ||
| 404 | + return true; | ||
| 405 | + } | ||
| 406 | + | ||
| 407 | + /** | ||
| 408 | + * 创建amp站点 | ||
| 409 | + * @param $domain | ||
| 410 | + * @param $key | ||
| 411 | + * @param $cer | ||
| 412 | + * @return array|bool | ||
| 413 | + * @author Akun | ||
| 414 | + * @date 2024/02/18 17:04 | ||
| 415 | + */ | ||
| 416 | + public function createBtSiteAmp($domain,$key,$cer) | ||
| 417 | + { | ||
| 418 | + $domain_array = parse_url($domain); | ||
| 419 | + $host = $domain_array['host'] ?? $domain_array['path']; | ||
| 420 | + $host_array = explode('.',$host); | ||
| 421 | + if(count($host_array) <= 2){ | ||
| 422 | + array_unshift($host_array,'m'); | ||
| 423 | + }else{ | ||
| 424 | + $host_array[0] = 'm'; | ||
| 425 | + } | ||
| 426 | + $host = implode('.',$host_array); | ||
| 427 | + | ||
| 428 | + // 验证当前服务器是否已经创建过了 | ||
| 429 | + $bt = $this->getBtObject(); | ||
| 430 | + $site_list = $bt->WebSiteList($host); | ||
| 431 | + if (!empty($site_list['data'])) { | ||
| 432 | + $site_id = $site_list['data'][0]['id']; | ||
| 433 | + }else{ | ||
| 434 | + | ||
| 435 | + $web_name = ['domain' => $host, 'domainlist' => [], 'count' => 0]; | ||
| 436 | + | ||
| 437 | + $array = [ | ||
| 438 | + 'webname' => json_encode($web_name), | ||
| 439 | + 'path' => '/www/wwwroot/createSite', | ||
| 440 | + 'type_id' => 0, | ||
| 441 | + 'type' => 'PHP', | ||
| 442 | + 'version' => '80', | ||
| 443 | + 'port' => '80', | ||
| 444 | + 'ps' => $host, | ||
| 445 | + 'ftp' => false, | ||
| 446 | + 'ftp_username' => '', | ||
| 447 | + 'ftp_password' => '', | ||
| 448 | + 'sql' => false, | ||
| 449 | + 'codeing' => '', | ||
| 450 | + 'datauser' => '', | ||
| 451 | + 'datapassword' => '', | ||
| 452 | + ]; | ||
| 453 | + | ||
| 454 | + | ||
| 455 | + $result = $bt->AddSite($array); | ||
| 456 | + | ||
| 457 | + if (empty($result) || empty($result['siteId'])) | ||
| 458 | + return false; | ||
| 459 | + | ||
| 460 | + $site_id = $result['siteId']; | ||
| 461 | + | ||
| 462 | + // 更新站点目录 更新站点运行目录 | ||
| 463 | + $bt->SetPath($site_id, public_path()); | ||
| 464 | + | ||
| 465 | + // 删除 .user.ini | ||
| 466 | + $bt->DeleteFile('/www/wwwroot/c-globalso/public/.user.ini'); | ||
| 467 | + $bt->DeleteFile('/www/wwwroot/c-globalso/.user.ini'); | ||
| 468 | + } | ||
| 469 | + | ||
| 470 | + if(empty($key) || empty($cer)){ | ||
| 471 | + $ssl = $bt->GetSSL($host); | ||
| 472 | + $is_set_status = false;//是否需要设置证书 | ||
| 473 | + if (FALSE == empty($ssl['cert_data']['notAfter']) && strtotime($ssl['cert_data']['notAfter']) - time() > 259200) { | ||
| 474 | + // 如果已经申请了ssl证书, 并且证书有效期超过3天, 那么就使用已经申请好的证书 | ||
| 475 | + $key = $ssl['key']; | ||
| 476 | + $cer = $ssl['csr']; | ||
| 477 | + $is_set_status = !$ssl['status']; | ||
| 478 | + } else { | ||
| 479 | + // 如果没有证书, 申请证书并设置证书 | ||
| 480 | + $bt->SaveFileBody($host, ''); // 申请证书时需要将重写规则清空, 不然会跳转到其他地方 | ||
| 481 | + $rs = $bt->ApplyCert(json_encode([$host]),$site_id); | ||
| 482 | + if(isset($rs['status']) && $rs['status']){ | ||
| 483 | + //申请成功,设置证书 | ||
| 484 | + $key = $rs['private_key']; | ||
| 485 | + $cer = $rs['cert']; | ||
| 486 | + $is_set_status = true; | ||
| 487 | + }else{ | ||
| 488 | + $key = ''; | ||
| 489 | + $cer = ''; | ||
| 490 | + } | ||
| 491 | + } | ||
| 492 | + }else{ | ||
| 493 | + $is_set_status = true; | ||
| 494 | + } | ||
| 495 | + | ||
| 496 | + if($key && $cer && $is_set_status){ | ||
| 497 | + $bt->SetSSL(1, $host, $key, $cer); | ||
| 498 | + } | ||
| 499 | + | ||
| 500 | + // 伪静态设置 | ||
| 501 | + $bt->SaveFileBody($host, 'location / { | ||
| 502 | + try_files $uri $uri/ /index.php?$query_string; | ||
| 503 | +}'); | ||
| 504 | + | ||
| 505 | + return ['site_id' => $site_id]; | ||
| 506 | + } | ||
| 507 | +} |
app/Repositories/StaticHtmlRepository.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2023/8/31 | ||
| 6 | + * Time: 14:54 | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +namespace App\Repositories; | ||
| 10 | + | ||
| 11 | +use App\Helper\Translate; | ||
| 12 | +use App\Models\CustomModule\CustomModule; | ||
| 13 | +use App\Models\CustomModule\CustomModuleCategory; | ||
| 14 | +use App\Models\Module\Module; | ||
| 15 | +use App\Models\Module\ModuleCategory; | ||
| 16 | +use App\Models\RouteMap\RouteMap; | ||
| 17 | +use App\Models\WebSetting\Translate as WebTranslate; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * Class StaticHtmlRepository | ||
| 21 | + * @package App\Repositories | ||
| 22 | + */ | ||
| 23 | +class StaticHtmlRepository | ||
| 24 | +{ | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 通过域名和路由 获取主语种HTML | ||
| 28 | + * @param string $domain | ||
| 29 | + * @param string $route | ||
| 30 | + * @return string | ||
| 31 | + */ | ||
| 32 | + public function getMainHtml($domain, $route) | ||
| 33 | + { | ||
| 34 | + $html = ''; | ||
| 35 | + return $html; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 5.0生成路径 | ||
| 40 | + */ | ||
| 41 | + public function getProjectRoutePath5($project,$route,$page): string | ||
| 42 | + { | ||
| 43 | + $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path","")->first(); | ||
| 44 | + if (empty($routerMap)){ | ||
| 45 | + $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first(); | ||
| 46 | + } | ||
| 47 | + if (!empty($routerMap)){ | ||
| 48 | + if ($routerMap->source == "news"){ | ||
| 49 | + $route = "news/".$route; | ||
| 50 | + }elseif($routerMap->source == "blog" || $routerMap->source == "blogs"){ | ||
| 51 | + $route = "blogs/".$route; | ||
| 52 | + }elseif ($routerMap->source == "news_category"){ | ||
| 53 | + if ($route == "news"){ | ||
| 54 | + $route = $page == null || $page == 1 ? $route : $route . "/page"; | ||
| 55 | + }else{ | ||
| 56 | + $route = $page == null || $page == 1 ? "news_catalog/".$route : "news_catalog/".$route."/page"; | ||
| 57 | + } | ||
| 58 | + }elseif ($routerMap->source == "blog_category"){ | ||
| 59 | + if ($route == "blog"){ | ||
| 60 | + $route = $page == null || $page == 1 ? $route : $route."/page"; | ||
| 61 | + }else{ | ||
| 62 | + $route = $page == null || $page == 1 ? "blog_catalog/".$route : "blog_catalog/".$route."/page"; | ||
| 63 | + } | ||
| 64 | + }elseif ($routerMap->source == "product_category"){ | ||
| 65 | + $route = $page == null || $page == 1 ? $route : $route."/page"; | ||
| 66 | + }elseif ($routerMap->source == "module_category"){ | ||
| 67 | + $moduleCategory = CustomModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id); | ||
| 68 | + if (!empty($moduleCategory->getExtend->route)){ | ||
| 69 | + if ($moduleCategory->getExtend->route == $route){ | ||
| 70 | + $route = $moduleCategory->route; | ||
| 71 | + }else{ | ||
| 72 | + $route = $moduleCategory->getExtend->route."_catalog/".$moduleCategory->route."/page"; | ||
| 73 | + } | ||
| 74 | + }else{ | ||
| 75 | + $route = $moduleCategory->route."/page"; | ||
| 76 | + } | ||
| 77 | + }elseif ($routerMap->source == "module"){ | ||
| 78 | + $modules = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); | ||
| 79 | + $moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$modules); | ||
| 80 | + if (isset($moduleCategoryInfo->getExtend->route) && !empty($moduleCategoryInfo->getExtend->route)){ | ||
| 81 | + $route = $moduleCategoryInfo->route."/".$modules->route; | ||
| 82 | + } | ||
| 83 | + }else{ | ||
| 84 | + $route = $route == "index" ? "/" : $route; | ||
| 85 | + } | ||
| 86 | + }else{ | ||
| 87 | + if ($route == "products"){ | ||
| 88 | + if ($page == null || $page == 1){ | ||
| 89 | + }else{ | ||
| 90 | + $route = $route."/page"; | ||
| 91 | + } | ||
| 92 | + }elseif ($route == "news"){ | ||
| 93 | + }elseif ($route == "blog"){ | ||
| 94 | + $route = $page == null || $page == 1 ? "blog_catalog/".$route : "blog_catalog/".$route."/page"; | ||
| 95 | + }else{ | ||
| 96 | + $route = $route == "index" ? "/" : $route; | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + return $route; | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + /** | ||
| 103 | + * 6.0生成路径 | ||
| 104 | + */ | ||
| 105 | + public function getProjectRoutePath6($project,$route): string | ||
| 106 | + { | ||
| 107 | + $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first(); | ||
| 108 | + if (!empty($routerMap)){ | ||
| 109 | + if ($routerMap->source == "news"){ | ||
| 110 | + $route = "news/".$route; | ||
| 111 | + }elseif($routerMap->source == "blog"){ | ||
| 112 | + $route = "blogs/".$route; | ||
| 113 | + }elseif($routerMap->source == "module"){ | ||
| 114 | + $modules = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); | ||
| 115 | + $moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$modules); | ||
| 116 | + if (isset($moduleCategoryInfo->route) && !empty($moduleCategoryInfo->route)){ | ||
| 117 | + $route = $moduleCategoryInfo->route."/".$route; | ||
| 118 | + } | ||
| 119 | + }else{ | ||
| 120 | + $route = $route == "index" ? "/" : $route; | ||
| 121 | + } | ||
| 122 | + }else{ | ||
| 123 | + $route = $route == "index" ? "/" : $route; | ||
| 124 | + } | ||
| 125 | + return $route; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + public function compactUrl($project,$route,$page): string | ||
| 129 | + { | ||
| 130 | + //是否是5.0升级项目 | ||
| 131 | + if (isset($project->update_info["is_update"]) && $project->update_info["is_update"] == 1){ | ||
| 132 | + //5.0生成路径 | ||
| 133 | + $path = $this->getProjectRoutePath5($project,$route,$page); | ||
| 134 | + }else{ | ||
| 135 | + //6.0生成路径 | ||
| 136 | + $path = $this->getProjectRoutePath6($project,$route); | ||
| 137 | + } | ||
| 138 | + return $path; | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * 通过域名和路由以及目标语种 获取小语种HTML | ||
| 144 | + * @param string $domain | ||
| 145 | + * @param string $route | ||
| 146 | + * @param string $tl | ||
| 147 | + * @return string | ||
| 148 | + */ | ||
| 149 | + public function getOtherLangHtml($domain, $route, $tl) | ||
| 150 | + { | ||
| 151 | + $path = '通过域名和路由获取主语种静态文件路径'; | ||
| 152 | + if (is_file($path)) { | ||
| 153 | + $main_html = file_get_contents($path); | ||
| 154 | + } else { | ||
| 155 | + $main_html = $this->getMainHtml($domain, $route); | ||
| 156 | + } | ||
| 157 | + $html = '通过主语种HTML生成小语种HTML 并处理小语种特有的内容'; | ||
| 158 | + return $html; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + /** | ||
| 162 | + * 获取翻译后的HTML | ||
| 163 | + * TODO HTML转dom, 提取需要渲染的词, 翻译关键词, 根据节点还原关键词, 清除dom, 返回HTML | ||
| 164 | + * @param string $html 原HTML | ||
| 165 | + * @param string $tl 目标语种 | ||
| 166 | + * @param string $sl 原语种 | ||
| 167 | + * @return mixed | ||
| 168 | + */ | ||
| 169 | + public function getTranHtml($project,string $html, string $tl,$route,$page, string $sl = 'auto') | ||
| 170 | + { | ||
| 171 | + $dom = str_get_html($html); | ||
| 172 | +// file_put_contents(public_path("aaa.html"), $html); | ||
| 173 | + if (is_bool($dom)){ | ||
| 174 | + return $html; | ||
| 175 | + } | ||
| 176 | + $texts = $dom->find("text"); | ||
| 177 | + | ||
| 178 | + $description = $dom->find("meta[name=description]",0); | ||
| 179 | + $keywords = $dom->find("meta[name=keywords]",0); | ||
| 180 | + // 组装需要翻译的内容 HTML内文案、meta description、meta keywords | ||
| 181 | + $need_tran = []; | ||
| 182 | + //处理图片alt | ||
| 183 | + $images = $dom->find("img"); | ||
| 184 | + foreach ($images as $img){ | ||
| 185 | + $alt = $img->alt; | ||
| 186 | + if($alt){ | ||
| 187 | + $need_tran[] = $alt; | ||
| 188 | + } | ||
| 189 | + } | ||
| 190 | + //处理a标签title | ||
| 191 | + $aTitles = $dom->find("a"); | ||
| 192 | + foreach ($aTitles as $aTitle){ | ||
| 193 | + $title = $aTitle->title; | ||
| 194 | + if($title){ | ||
| 195 | + $need_tran[] = $title; | ||
| 196 | + } | ||
| 197 | + } | ||
| 198 | + foreach ($texts as $k=>$text) { | ||
| 199 | + $tag= $text->parent()->tag; | ||
| 200 | + if (in_array($tag, ['script', 'style', 'root'])) | ||
| 201 | + continue; | ||
| 202 | + | ||
| 203 | + $string = trim($text->text()); | ||
| 204 | + if (empty($string)) | ||
| 205 | + continue; | ||
| 206 | + | ||
| 207 | + $country_class = ''; | ||
| 208 | + if (method_exists($text->parent()->parent(),"find") && $text->parent()->parent()->find("b")) { | ||
| 209 | + $country_class = $text->parent()->parent()->find("b",0)->class; | ||
| 210 | + } | ||
| 211 | + if(FALSE !== strpos($country_class, 'country-flag')) | ||
| 212 | + continue; | ||
| 213 | + $need_tran[] = htmlspecialchars_decode(html_entity_decode($string)); | ||
| 214 | + } | ||
| 215 | + if (isset($description->attr['content'])){ | ||
| 216 | + $need_tran[] = $description->attr['content']; | ||
| 217 | + } | ||
| 218 | + if (isset($keywords->attr['content'])){ | ||
| 219 | + $need_tran[] = $keywords->attr['content']; | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + // 翻译内容字符串, 最多翻译三次, 超过三次没有结果, 返回原文 | ||
| 223 | + $tran_string = []; | ||
| 224 | + if ($need_tran) { | ||
| 225 | + $i = 0; | ||
| 226 | + $tl_tran = $tl == "zh-ct" ? "zh-TW" : $tl; | ||
| 227 | + TranslateArray: | ||
| 228 | + $tran_result = Translate::translate($need_tran, $tl_tran, $sl); | ||
| 229 | + if (!isset($tran_result[0]) || empty($tran_result[0]['code'] || $tran_result[0]['code'] != 200)) { | ||
| 230 | + if ($i >= 3) | ||
| 231 | + return $html; | ||
| 232 | + $i++; | ||
| 233 | + goto TranslateArray; | ||
| 234 | + } | ||
| 235 | + | ||
| 236 | + $tran_string = $tran_result[0]['texts']; | ||
| 237 | + } | ||
| 238 | + | ||
| 239 | + //组装路由 | ||
| 240 | + $page = $page == null || $page == 1 ? "" : "/".$page; | ||
| 241 | + $route = $this->compactUrl($project,$route,$page); | ||
| 242 | + $url = $route.$page; | ||
| 243 | + //图片翻译校对数据 | ||
| 244 | + $webImageTranslate = WebTranslate::where("alias",$tl)->where("url",$url)->where("type",WebTranslate::$imageType)->first(); | ||
| 245 | + $webImageAllTranslate = WebTranslate::where("alias",$tl)->where("url","All")->where("type",WebTranslate::$imageType)->first(); | ||
| 246 | + $imageAllData = !empty($webImageAllTranslate) ? json_decode($webImageAllTranslate->data,true) : []; | ||
| 247 | + $imageSelfData = !empty($webImageTranslate) ? json_decode($webImageTranslate->data,true) : []; | ||
| 248 | + $imageData = array_merge($imageAllData,$imageSelfData); | ||
| 249 | + //文本翻译校对数据 | ||
| 250 | + $webTextTranslate = WebTranslate::where("alias",$tl)->where("url",$url)->where("type",WebTranslate::$textType)->first(); | ||
| 251 | + $webTextAllTranslate = WebTranslate::where("alias",$tl)->where("url","All")->where("type",WebTranslate::$textType)->first(); | ||
| 252 | + $textAllData = !empty($webTextAllTranslate) ? json_decode($webTextAllTranslate->data,true) : []; | ||
| 253 | + $textSelfData = !empty($webTextTranslate) ? json_decode($webTextTranslate->data,true) : []; | ||
| 254 | + $textData = array_merge($textSelfData, $textAllData); | ||
| 255 | + // 图片按照节点还原 | ||
| 256 | + $tmp = []; | ||
| 257 | + foreach ($images as $img){ | ||
| 258 | + $alt = $img->alt; | ||
| 259 | + if($alt){ | ||
| 260 | + $tmp[] = $alt; | ||
| 261 | + $key = count($tmp) - 1; | ||
| 262 | + if (!empty($imageData) && isset($imageData[$alt])){ | ||
| 263 | + $img->attr['alt'] = $imageData[$alt]; | ||
| 264 | + }else{ | ||
| 265 | + $img->attr['alt'] = $tran_string[$key]; | ||
| 266 | + } | ||
| 267 | + } | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + foreach ($aTitles as $aTitle){ | ||
| 271 | + $title = $aTitle->title; | ||
| 272 | + if($title){ | ||
| 273 | + $tmp[] = $title; | ||
| 274 | + $key = count($tmp) - 1; | ||
| 275 | + if (!empty($textData) && isset($textData[$title])){ | ||
| 276 | + $aTitle->attr['title'] = $textData[$title]; | ||
| 277 | + }else{ | ||
| 278 | + $aTitle->attr['title'] = $tran_string[$key]; | ||
| 279 | + } | ||
| 280 | + } | ||
| 281 | + } | ||
| 282 | + | ||
| 283 | + foreach ($texts as $text) { | ||
| 284 | + $tag= $text->parent()->tag; | ||
| 285 | + if (in_array($tag, ['script', 'style', 'root'])) | ||
| 286 | + continue; | ||
| 287 | + | ||
| 288 | + $string = trim($text->text()); | ||
| 289 | + if (empty($string)) | ||
| 290 | + continue; | ||
| 291 | + | ||
| 292 | + $country_class = ''; | ||
| 293 | + if (method_exists($text->parent()->parent(),"find") && $text->parent()->parent()->find("b")) { | ||
| 294 | + $country_class = $text->parent()->parent()->find("b",0)->class; | ||
| 295 | + } | ||
| 296 | + if(FALSE !== strpos($country_class, 'country-flag')) | ||
| 297 | + continue; | ||
| 298 | + | ||
| 299 | + $tmp[] = htmlspecialchars_decode(html_entity_decode($string)); | ||
| 300 | + // FIXME 查找校对内容中是否有当前值 优先使用校对内容,没有获取翻译内容 | ||
| 301 | + $key = count($tmp) - 1; | ||
| 302 | +// dump($string); | ||
| 303 | + $string = html_entity_decode($string); | ||
| 304 | + if (!empty($textData) && isset($textData[$string])){ | ||
| 305 | +// dump("数据库:".$textData[$string]); | ||
| 306 | + $text->outertext = $textData[$string]; | ||
| 307 | + }else{ | ||
| 308 | +// dump("翻译:".$tran_string[$key]); | ||
| 309 | + $text->outertext = $tran_string[$key]; | ||
| 310 | + } | ||
| 311 | + } | ||
| 312 | + // 按照节点还原 description、keywords | ||
| 313 | + $tmp[] = $description; | ||
| 314 | + $key = count($tmp) - 1; | ||
| 315 | + if (isset($description->attr['content'])){ | ||
| 316 | + $dom->find("meta[name=description]")[0]->attr['content'] = $tran_string[$key]; | ||
| 317 | + } | ||
| 318 | + $tmp[] = $keywords; | ||
| 319 | + $key = count($tmp) - 1; | ||
| 320 | + if (isset($description->attr['keywords'])){ | ||
| 321 | + $dom->find("meta[name=keywords]")[0]->attr['content'] = $tran_string[$key]; | ||
| 322 | + } | ||
| 323 | + | ||
| 324 | + // 保存修改 清除缓存 | ||
| 325 | + $html_string = $dom->save(); | ||
| 326 | + $dom->clear(); | ||
| 327 | + return $html_string; | ||
| 328 | + } | ||
| 329 | +} |
app/Repositories/SyncSubmitRepository.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2024/1/6 | ||
| 6 | + * Time: 14:00 | ||
| 7 | + */ | ||
| 8 | +namespace App\Repositories; | ||
| 9 | + | ||
| 10 | +use App\Models\SyncSubmitTask\SyncSubmitTask; | ||
| 11 | +use App\Models\Visit\Visit; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Class SyncSubmitRepository | ||
| 15 | + * @package App\Repositories | ||
| 16 | + */ | ||
| 17 | +class SyncSubmitRepository | ||
| 18 | +{ | ||
| 19 | + /** | ||
| 20 | + * 上线站点引流 | ||
| 21 | + * @param $ip | ||
| 22 | + * @param $url | ||
| 23 | + * @param $user_agent | ||
| 24 | + * @param string $referrer_url | ||
| 25 | + * @param int $device_port | ||
| 26 | + * @param int $traffic | ||
| 27 | + * @return bool | ||
| 28 | + */ | ||
| 29 | + public function trafficVisit($ip, $url, $user_agent, $referrer_url = '', $device_port = Visit::DEVICE_PC, $traffic = SyncSubmitTask::TRAFFIC_DEFAULT) | ||
| 30 | + { | ||
| 31 | + if (empty($ip) || $ip == '127.0.0.1') | ||
| 32 | + return false; | ||
| 33 | + if ($this->isBot($user_agent)) | ||
| 34 | + return false; | ||
| 35 | + $url_array = parse_url($url); | ||
| 36 | + if (empty($url_array['host'])) | ||
| 37 | + return false; | ||
| 38 | + | ||
| 39 | + // 检查重置来源URL | ||
| 40 | + $referrer_url = $this->initReferrer($referrer_url); | ||
| 41 | + // 头信息中带有这些信息, 代表是手机端, 重置设备类型 | ||
| 42 | + if (preg_match('/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|wap|windowsce|ucweb/', $user_agent)) { | ||
| 43 | + $device_port = 2; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + // 组装字段数据 | ||
| 47 | + $array = [ | ||
| 48 | + 'ip' => $ip, | ||
| 49 | + 'domain' => $url_array['host'], | ||
| 50 | + 'referer' => $referrer_url, | ||
| 51 | + 'user_agent' => $user_agent, | ||
| 52 | + 'data' => [ | ||
| 53 | + 'url' => $url, | ||
| 54 | + 'domain' => $url_array['scheme'] . '://' . $url_array['host'], | ||
| 55 | + 'device_port' => in_array($device_port, array_keys(Visit::deviceMap())) ? $device_port : Visit::DEVICE_PC, | ||
| 56 | + 'referrer_url' => $referrer_url | ||
| 57 | + ] | ||
| 58 | + ]; | ||
| 59 | + SyncSubmitTask::createTask($array, SyncSubmitTask::TYPE_VISIT, $traffic); | ||
| 60 | + return true; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * 通过头信息,判断是否是蜘蛛爬虫 | ||
| 65 | + * @param $agent | ||
| 66 | + * @return bool | ||
| 67 | + */ | ||
| 68 | + public function isBot($agent) | ||
| 69 | + { | ||
| 70 | + $spiderSite= ["TencentTraveler", "Baiduspider+", "BaiduGame", "Googlebot", "msnbot", "Sosospider+", "Sogou web spider", "ia_archiver", "Yahoo! Slurp", "YoudaoBot", | ||
| 71 | + "Yahoo Slurp", "MSNBot", "Java (Often spam bot)", "BaiDuSpider", "Voila", "Yandex bot", "BSpider", "twiceler", "Sogou Spider", "Speedy Spider", "Google AdSense", | ||
| 72 | + "Heritrix", "Python-urllib", "Alexa (IA Archiver)", "Ask", "Exabot", "Custo", "OutfoxBot/YodaoBot", "yacy", "SurveyBot", "legs", "lwp-trivial", "Nutch", "StackRambler", | ||
| 73 | + "The web archive (IA Archiver)", "Perl tool", "MJ12bot", "Netcraft", "MSIECrawler", "WGet tools", "larbin", "Fish search", "yandex.com/bots", "google.com/bot", | ||
| 74 | + "bingbot", "YandexMobileBot", "BingPreview", "AhrefsBot", "bot" | ||
| 75 | + ]; | ||
| 76 | + | ||
| 77 | + foreach($spiderSite as $val) { | ||
| 78 | + $str = strtolower($val); | ||
| 79 | + if (strpos($agent, $str) !== false) { | ||
| 80 | + return true; | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + return false; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * 按照规则重置referrer信息 | ||
| 88 | + * TODO 如果来自特定网站的原样返回, 其他的重置到google | ||
| 89 | + * @param $referrer | ||
| 90 | + * @return string | ||
| 91 | + */ | ||
| 92 | + public function initReferrer($referrer) | ||
| 93 | + { | ||
| 94 | + if (empty($referrer)) | ||
| 95 | + return ''; | ||
| 96 | + if (preg_match('/google|facebook|bing|yahoo|youtobe|linkedin|messefrankfurt|yandex|tiktok|twitter|instagram|reddit|telegram|pinterest|tumblr/', $referrer)) { | ||
| 97 | + return $referrer; | ||
| 98 | + }else{ | ||
| 99 | + return 'https://www.google.com/'; | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | +} |
app/Repositories/ToolRepository.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2023/10/26 | ||
| 6 | + * Time: 13:55 | ||
| 7 | + */ | ||
| 8 | +namespace App\Repositories; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Class ToolRepository | ||
| 12 | + * @package App\Repositories | ||
| 13 | + */ | ||
| 14 | +class ToolRepository | ||
| 15 | +{ | ||
| 16 | + /** | ||
| 17 | + * @param $url | ||
| 18 | + * @param $data | ||
| 19 | + * @param string $method | ||
| 20 | + * @param array $header | ||
| 21 | + * @param int $time_out | ||
| 22 | + * @return array | ||
| 23 | + */ | ||
| 24 | + public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60) | ||
| 25 | + { | ||
| 26 | + $ch = curl_init(); | ||
| 27 | + curl_setopt($ch, CURLOPT_TIMEOUT, $time_out); | ||
| 28 | + curl_setopt($ch, CURLOPT_URL, $url); | ||
| 29 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
| 30 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); | ||
| 31 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); | ||
| 32 | + if ($data) | ||
| 33 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); | ||
| 34 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([ | ||
| 35 | + 'Expect:', | ||
| 36 | + 'Content-type: application/json', | ||
| 37 | + 'Accept: application/json', | ||
| 38 | + ], $header) | ||
| 39 | + ); | ||
| 40 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); | ||
| 41 | + $response = curl_exec($ch); | ||
| 42 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | ||
| 43 | + curl_close($ch); | ||
| 44 | + return [$code, $response]; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 多请求批处理 | ||
| 49 | + * @param $host | ||
| 50 | + * @param $request_urls | ||
| 51 | + * @return array | ||
| 52 | + */ | ||
| 53 | + public function batCurlblobr($request_urls) | ||
| 54 | + { | ||
| 55 | +// //脚本开始的毫秒时刻 | ||
| 56 | +// $start = microtime(true); | ||
| 57 | + | ||
| 58 | + //打开一个curl批处理句柄 | ||
| 59 | + $mh = curl_multi_init(); | ||
| 60 | + $headers = [ | ||
| 61 | + "X-BLOBR-KEY:" . $this->key | ||
| 62 | + ]; | ||
| 63 | + $ch = []; | ||
| 64 | + foreach ($request_urls as $key => $url) { | ||
| 65 | + //初始化cURL会话 | ||
| 66 | + $ch[$key] = curl_init($url); | ||
| 67 | + //设置curl传输选项 | ||
| 68 | + curl_setopt($ch[$key], CURLOPT_RETURNTRANSFER, true); | ||
| 69 | + curl_setopt($ch[$key], CURLOPT_FOLLOWLOCATION, true); | ||
| 70 | + curl_setopt($ch[$key], CURLOPT_ENCODING, ""); | ||
| 71 | + curl_setopt($ch[$key], CURLOPT_MAXREDIRS, 10); | ||
| 72 | +// curl_setopt($ch[$key], CURLOPT_TIMEOUT, $this->time_out); | ||
| 73 | + curl_setopt($ch[$key], CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
| 74 | + curl_setopt($ch[$key], CURLOPT_CUSTOMREQUEST, 'GET'); | ||
| 75 | + curl_setopt($ch[$key], CURLOPT_HTTPHEADER, $headers); | ||
| 76 | +// curl_setopt($ch[$key], CURLOPT_HEADER, 0); | ||
| 77 | + //关闭https请求验证 | ||
| 78 | +// if (strpos($url,'https')){ | ||
| 79 | +// curl_setopt ( $ch[$key], CURLOPT_SSL_VERIFYPEER, false ); | ||
| 80 | +// curl_setopt ( $ch[$key], CURLOPT_SSL_VERIFYHOST, 2 ); | ||
| 81 | +// } | ||
| 82 | + //向批处理句柄中添加单独的curl句柄 | ||
| 83 | + curl_multi_add_handle($mh, $ch[$key]); | ||
| 84 | + } | ||
| 85 | + $running = null; | ||
| 86 | + //执行批处理句柄 | ||
| 87 | + do { | ||
| 88 | + $mrc = curl_multi_exec($mh, $running); | ||
| 89 | + } while ($mrc == CURLM_CALL_MULTI_PERFORM); | ||
| 90 | + | ||
| 91 | + while ($running && $mrc == CURLM_OK) { | ||
| 92 | + if (curl_multi_select($mh) != -1) { | ||
| 93 | + do { | ||
| 94 | + $mrc = curl_multi_exec($mh, $running); | ||
| 95 | + } while ($mrc == CURLM_CALL_MULTI_PERFORM); | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + $res = []; | ||
| 100 | + //获取内容 | ||
| 101 | + foreach ($request_urls as $k => $url) { | ||
| 102 | + //关闭执行完的子句柄 | ||
| 103 | + curl_multi_remove_handle($mh, $ch[$k]); | ||
| 104 | + //返回获取的输出文本流 | ||
| 105 | + $res[$k] = curl_multi_getcontent($ch[$k]); | ||
| 106 | + } | ||
| 107 | + //5.关闭父curl | ||
| 108 | + curl_multi_close($mh); | ||
| 109 | + | ||
| 110 | +// $end = microtime(true) - $start; | ||
| 111 | +// file_put_contents(__DIR__ . '/exec_time.log', $end . PHP_EOL, FILE_APPEND); | ||
| 112 | + return $res; | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + | ||
| 116 | + /** | ||
| 117 | + * 多请求批处理 | ||
| 118 | + * @param $headers | ||
| 119 | + * @param $request_urls | ||
| 120 | + * @return array | ||
| 121 | + */ | ||
| 122 | + public function batCurl($request_urls, $headers = []) | ||
| 123 | + { | ||
| 124 | +// //脚本开始的毫秒时刻 | ||
| 125 | +// $start = microtime(true); | ||
| 126 | + | ||
| 127 | + //打开一个curl批处理句柄 | ||
| 128 | + $mh = curl_multi_init(); | ||
| 129 | + $ch = []; | ||
| 130 | + foreach ($request_urls as $key => $url) { | ||
| 131 | + //初始化cURL会话 | ||
| 132 | + $ch[$key] = curl_init($url); | ||
| 133 | + //设置curl传输选项 | ||
| 134 | + curl_setopt($ch[$key], CURLOPT_RETURNTRANSFER, true); | ||
| 135 | + curl_setopt($ch[$key], CURLOPT_FOLLOWLOCATION, true); | ||
| 136 | + curl_setopt($ch[$key], CURLOPT_ENCODING, ""); | ||
| 137 | + curl_setopt($ch[$key], CURLOPT_MAXREDIRS, 10); | ||
| 138 | + curl_setopt($ch[$key], CURLOPT_TIMEOUT, 30); | ||
| 139 | + curl_setopt($ch[$key], CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
| 140 | + curl_setopt($ch[$key], CURLOPT_CUSTOMREQUEST, 'GET'); | ||
| 141 | + curl_setopt($ch[$key], CURLOPT_HTTPHEADER, $headers); | ||
| 142 | +// curl_setopt($ch[$key], CURLOPT_HEADER, 0); | ||
| 143 | + //关闭https请求验证 | ||
| 144 | +// if (strpos($url,'https')){ | ||
| 145 | +// curl_setopt ( $ch[$key], CURLOPT_SSL_VERIFYPEER, false ); | ||
| 146 | +// curl_setopt ( $ch[$key], CURLOPT_SSL_VERIFYHOST, 2 ); | ||
| 147 | +// } | ||
| 148 | + //向批处理句柄中添加单独的curl句柄 | ||
| 149 | + curl_multi_add_handle($mh, $ch[$key]); | ||
| 150 | + } | ||
| 151 | + $running = null; | ||
| 152 | + //执行批处理句柄 | ||
| 153 | + do { | ||
| 154 | + $mrc = curl_multi_exec($mh, $running); | ||
| 155 | + } while ($mrc == CURLM_CALL_MULTI_PERFORM); | ||
| 156 | + | ||
| 157 | + while ($running && $mrc == CURLM_OK) { | ||
| 158 | + if (curl_multi_select($mh) != -1) { | ||
| 159 | + do { | ||
| 160 | + $mrc = curl_multi_exec($mh, $running); | ||
| 161 | + } while ($mrc == CURLM_CALL_MULTI_PERFORM); | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + $res = []; | ||
| 166 | + //获取内容 | ||
| 167 | + foreach ($request_urls as $k => $url) { | ||
| 168 | + //关闭执行完的子句柄 | ||
| 169 | + curl_multi_remove_handle($mh, $ch[$k]); | ||
| 170 | + //返回获取的输出文本流 | ||
| 171 | + $res[$k] = curl_multi_getcontent($ch[$k]); | ||
| 172 | + } | ||
| 173 | + //5.关闭父curl | ||
| 174 | + curl_multi_close($mh); | ||
| 175 | + | ||
| 176 | +// $end = microtime(true) - $start; | ||
| 177 | +// file_put_contents(__DIR__ . '/exec_time.log', $end . PHP_EOL, FILE_APPEND); | ||
| 178 | + return $res; | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + /** | ||
| 182 | + * 替换特殊词汇 | ||
| 183 | + * @param $data | ||
| 184 | + * @return array | ||
| 185 | + */ | ||
| 186 | + public function filterString($data) | ||
| 187 | + { | ||
| 188 | + if (is_array($data)) { | ||
| 189 | + foreach ($data as $key => $val) { | ||
| 190 | + $data[$key] = $this->filterString($val); | ||
| 191 | + } | ||
| 192 | + } else { | ||
| 193 | + $data = ' ' . $data; | ||
| 194 | + $array = "/\(\w.*\)| company| Company| inc| Inc| Co| co| Ltd| ltd| Llc| llc| Import And Export| Limited| limited|,|\./"; | ||
| 195 | + $result = preg_replace($array, '', $data); | ||
| 196 | + return $result == ' ' ? '' : $result; | ||
| 197 | + } | ||
| 198 | + return $data; | ||
| 199 | + } | ||
| 200 | +} |
| @@ -3,16 +3,17 @@ | @@ -3,16 +3,17 @@ | ||
| 3 | 3 | ||
| 4 | namespace App\Services\Html; | 4 | namespace App\Services\Html; |
| 5 | 5 | ||
| 6 | + | ||
| 6 | use App\Models\Blog\Blog; | 7 | use App\Models\Blog\Blog; |
| 7 | use App\Models\News\News; | 8 | use App\Models\News\News; |
| 8 | use App\Models\Product\Category; | 9 | use App\Models\Product\Category; |
| 9 | use App\Models\Product\CategoryRelated; | 10 | use App\Models\Product\CategoryRelated; |
| 10 | use App\Models\Product\Keyword; | 11 | use App\Models\Product\Keyword; |
| 11 | use App\Models\Product\Product; | 12 | use App\Models\Product\Product; |
| 12 | -use App\Models\RouteMap; | 13 | +use App\Models\RouteMap\RouteMap; |
| 14 | +use App\Models\WebSetting\SettingNum; | ||
| 13 | use App\Models\WebSetting\WebSetting; | 15 | use App\Models\WebSetting\WebSetting; |
| 14 | use App\Models\WebSetting\WebSettingAmp; | 16 | use App\Models\WebSetting\WebSettingAmp; |
| 15 | -use App\Models\WebSetting\WebSettingNum; | ||
| 16 | use App\Models\WebSetting\WebSettingSeo; | 17 | use App\Models\WebSetting\WebSettingSeo; |
| 17 | 18 | ||
| 18 | class AmpService | 19 | class AmpService |
| @@ -432,7 +433,7 @@ class AmpService | @@ -432,7 +433,7 @@ class AmpService | ||
| 432 | public static function getProductSortRule($project_id) | 433 | public static function getProductSortRule($project_id) |
| 433 | { | 434 | { |
| 434 | $order_list = []; | 435 | $order_list = []; |
| 435 | - $orderDataFirst = WebSettingNum::where('project_id', $project_id)->where('type', 10)->first(); | 436 | + $orderDataFirst = SettingNum::where('project_id', $project_id)->where('type', 10)->first(); |
| 436 | if ($orderDataFirst && $orderDataFirst->data) { | 437 | if ($orderDataFirst && $orderDataFirst->data) { |
| 437 | $orderData = json_decode($orderDataFirst->data, true); | 438 | $orderData = json_decode($orderDataFirst->data, true); |
| 438 | foreach ($orderData as $key => $orderDataItem) { | 439 | foreach ($orderData as $key => $orderDataItem) { |
| @@ -3,14 +3,14 @@ | @@ -3,14 +3,14 @@ | ||
| 3 | 3 | ||
| 4 | namespace App\Services\Html; | 4 | namespace App\Services\Html; |
| 5 | 5 | ||
| 6 | -use App\Console\Commands\ProjectService; | ||
| 7 | use App\Helper\Translate; | 6 | use App\Helper\Translate; |
| 7 | +use App\Models\Com\UpdateProgress; | ||
| 8 | use App\Models\Project\DeployBuild; | 8 | use App\Models\Project\DeployBuild; |
| 9 | use App\Models\Project\DeployOptimize; | 9 | use App\Models\Project\DeployOptimize; |
| 10 | use App\Models\Project\DomainInfo; | 10 | use App\Models\Project\DomainInfo; |
| 11 | use App\Models\Project\Project; | 11 | use App\Models\Project\Project; |
| 12 | -use App\Models\Project\UpdateProgressModel; | ||
| 13 | -use App\Models\RouteMap; | 12 | +use App\Models\RouteMap\RouteMap; |
| 13 | +use App\Models\WebSetting\Proofreading; | ||
| 14 | use App\Models\WebSetting\WebLanguage; | 14 | use App\Models\WebSetting\WebLanguage; |
| 15 | use App\Models\WebSetting\WebProofreading; | 15 | use App\Models\WebSetting\WebProofreading; |
| 16 | use App\Models\WebSetting\WebSetting; | 16 | use App\Models\WebSetting\WebSetting; |
| @@ -18,6 +18,7 @@ use App\Models\WebSetting\WebSettingCountry; | @@ -18,6 +18,7 @@ use App\Models\WebSetting\WebSettingCountry; | ||
| 18 | use App\Models\WebSetting\WebSettingHtml; | 18 | use App\Models\WebSetting\WebSettingHtml; |
| 19 | use App\Models\WebSetting\WebSettingText; | 19 | use App\Models\WebSetting\WebSettingText; |
| 20 | use App\Models\WebSetting\WebTemplateCommon; | 20 | use App\Models\WebSetting\WebTemplateCommon; |
| 21 | +use App\Services\ProjectServer; | ||
| 21 | use Illuminate\Support\Facades\Redis; | 22 | use Illuminate\Support\Facades\Redis; |
| 22 | use phpQuery; | 23 | use phpQuery; |
| 23 | 24 | ||
| @@ -63,7 +64,7 @@ class CommonService | @@ -63,7 +64,7 @@ class CommonService | ||
| 63 | */ | 64 | */ |
| 64 | public function translationProofread($project, $content, $lang,$domain) | 65 | public function translationProofread($project, $content, $lang,$domain) |
| 65 | { | 66 | { |
| 66 | - $webProofreading = WebProofreading::where("project_id",$project->id)->where("alias",$lang)->get(); | 67 | + $webProofreading = Proofreading::where("project_id",$project->id)->where("alias",$lang)->get(); |
| 67 | if (!empty($webProofreading)){ | 68 | if (!empty($webProofreading)){ |
| 68 | foreach ($webProofreading as $item){ | 69 | foreach ($webProofreading as $item){ |
| 69 | $content = str_ireplace($item->text,$item->translate,$content); | 70 | $content = str_ireplace($item->text,$item->translate,$content); |
| @@ -85,13 +86,6 @@ class CommonService | @@ -85,13 +86,6 @@ class CommonService | ||
| 85 | Redis::expire("project_".$project->id."_third_party_code", WebSetting::$redisExpireTime); | 86 | Redis::expire("project_".$project->id."_third_party_code", WebSetting::$redisExpireTime); |
| 86 | } | 87 | } |
| 87 | $phpQueryDom = phpQuery::newDocument($content); | 88 | $phpQueryDom = phpQuery::newDocument($content); |
| 88 | - | ||
| 89 | - //处理自定义页面样式问题 | ||
| 90 | -// if ($globalsojsSyles != ""){ | ||
| 91 | -// $phpQueryDom->find("#globalsojs-styles")->remove(); | ||
| 92 | -// $phpQueryDom->find('head')->append($globalsojsSyles); | ||
| 93 | -// } | ||
| 94 | - | ||
| 95 | //网站icon | 89 | //网站icon |
| 96 | $webIcon = WebSetting::where("project_id",$project->id)->first(); | 90 | $webIcon = WebSetting::where("project_id",$project->id)->first(); |
| 97 | if (!empty($webIcon)){ | 91 | if (!empty($webIcon)){ |
| @@ -104,15 +98,12 @@ class CommonService | @@ -104,15 +98,12 @@ class CommonService | ||
| 104 | } | 98 | } |
| 105 | } | 99 | } |
| 106 | } | 100 | } |
| 107 | - | ||
| 108 | //第三方代码(网页顶部,中间,底部),以后启用位置 | 101 | //第三方代码(网页顶部,中间,底部),以后启用位置 |
| 109 | if (!empty($webSettingHtml)) { | 102 | if (!empty($webSettingHtml)) { |
| 110 | $phpQueryDom->find('head')->append($webSettingHtml->head_html?:''); | 103 | $phpQueryDom->find('head')->append($webSettingHtml->head_html?:''); |
| 111 | $phpQueryDom->find('body')->append($webSettingHtml->body_html?:''); | 104 | $phpQueryDom->find('body')->append($webSettingHtml->body_html?:''); |
| 112 | $phpQueryDom->find('html')->append($webSettingHtml->footer_html?:''); | 105 | $phpQueryDom->find('html')->append($webSettingHtml->footer_html?:''); |
| 113 | } | 106 | } |
| 114 | - | ||
| 115 | - | ||
| 116 | //A端添加的网站追踪代码 | 107 | //A端添加的网站追踪代码 |
| 117 | $deployOptimize = DeployOptimize::where("project_id",$project->id)->first(); | 108 | $deployOptimize = DeployOptimize::where("project_id",$project->id)->first(); |
| 118 | if (!empty($deployOptimize)){ | 109 | if (!empty($deployOptimize)){ |
| @@ -120,23 +111,12 @@ class CommonService | @@ -120,23 +111,12 @@ class CommonService | ||
| 120 | $phpQueryDom->find('head')->append($deployOptimize->meta); | 111 | $phpQueryDom->find('head')->append($deployOptimize->meta); |
| 121 | } | 112 | } |
| 122 | } | 113 | } |
| 123 | - | ||
| 124 | - //去掉非index页面header上面的headerindex属性 | ||
| 125 | - //if ($route != "index"){ | ||
| 126 | - //$phpQueryDom->find('header')->removeAttr("headerindex"); | ||
| 127 | - //} | ||
| 128 | //首页头部独立样式 | 114 | //首页头部独立样式 |
| 129 | if ($route == "index"){ | 115 | if ($route == "index"){ |
| 130 | $phpQueryDom->find('header')->attr("headerprivate",""); | 116 | $phpQueryDom->find('header')->attr("headerprivate",""); |
| 131 | } | 117 | } |
| 132 | - | ||
| 133 | //处理header顶部搜索跳转链接 | 118 | //处理header顶部搜索跳转链接 |
| 134 | $phpQueryDom->find('header form')->attr("action", "/search/"); | 119 | $phpQueryDom->find('header form')->attr("action", "/search/"); |
| 135 | - | ||
| 136 | - | ||
| 137 | - //生成锚点,以后启用位置 | ||
| 138 | - //$content = $this->anchorTextHandle($project,$route,$content); | ||
| 139 | - | ||
| 140 | //C端访问埋点 | 120 | //C端访问埋点 |
| 141 | $isBodyEnd = $phpQueryDom->find('body')->eq(0); | 121 | $isBodyEnd = $phpQueryDom->find('body')->eq(0); |
| 142 | if (count($isBodyEnd)>=1){ | 122 | if (count($isBodyEnd)>=1){ |
| @@ -147,21 +127,18 @@ class CommonService | @@ -147,21 +127,18 @@ class CommonService | ||
| 147 | $data = date("Y-m-d H:i:s"); | 127 | $data = date("Y-m-d H:i:s"); |
| 148 | $phpQueryDom->find('html')->append("<!-- Globalso Cache file was created on ".$data." -->"); | 128 | $phpQueryDom->find('html')->append("<!-- Globalso Cache file was created on ".$data." -->"); |
| 149 | //这个功能其他类型页面移到面包屑导航处理 | 129 | //这个功能其他类型页面移到面包屑导航处理 |
| 150 | - if ($route == "index" || (!empty($routeMap) && $routeMap->source == WebTemplateCommon::$pageName)){ | 130 | + if ($route == "index" || (!empty($routeMap) && $routeMap->source == RouteMap::SOURCE_PAGE)){ |
| 151 | $phpQueryDom->find('head')->append('<script>var currentPage = "'.$route.'"</script>'); | 131 | $phpQueryDom->find('head')->append('<script>var currentPage = "'.$route.'"</script>'); |
| 152 | } | 132 | } |
| 153 | - | ||
| 154 | if ($route == "search"){ | 133 | if ($route == "search"){ |
| 155 | //暂时先去掉小语种按钮显示 | 134 | //暂时先去掉小语种按钮显示 |
| 156 | $phpQueryDom->find(".change-language")->remove(); | 135 | $phpQueryDom->find(".change-language")->remove(); |
| 157 | $phpQueryDom->find('head')->append('<meta name="robots" content="noindex, nofollow"/>'); | 136 | $phpQueryDom->find('head')->append('<meta name="robots" content="noindex, nofollow"/>'); |
| 158 | } | 137 | } |
| 159 | $phpQueryDom->find('body')->attr("unevents",""); | 138 | $phpQueryDom->find('body')->attr("unevents",""); |
| 160 | - | ||
| 161 | $content = $phpQueryDom->htmlOuter(); | 139 | $content = $phpQueryDom->htmlOuter(); |
| 162 | unset($phpQueryDom); | 140 | unset($phpQueryDom); |
| 163 | phpQuery::unloadDocuments(); | 141 | phpQuery::unloadDocuments(); |
| 164 | - | ||
| 165 | //处理全部内容,如果有上线正式域名,则把所有的测试域名替换为正式域名 | 142 | //处理全部内容,如果有上线正式域名,则把所有的测试域名替换为正式域名 |
| 166 | $projectDomainInfo = DomainInfo::where("project_id",$project->id)->first(); | 143 | $projectDomainInfo = DomainInfo::where("project_id",$project->id)->first(); |
| 167 | if (!empty($projectDomainInfo)){ | 144 | if (!empty($projectDomainInfo)){ |
| @@ -253,7 +230,7 @@ class CommonService | @@ -253,7 +230,7 @@ class CommonService | ||
| 253 | if (!empty($project)){ | 230 | if (!empty($project)){ |
| 254 | $project->domain = $updateData->domain; | 231 | $project->domain = $updateData->domain; |
| 255 | } | 232 | } |
| 256 | - ProjectService::useProject($project->id,$updateData->domain); | 233 | + ProjectServer::useProject($project->id); |
| 257 | } | 234 | } |
| 258 | return $project; | 235 | return $project; |
| 259 | } | 236 | } |
| @@ -264,7 +241,7 @@ class CommonService | @@ -264,7 +241,7 @@ class CommonService | ||
| 264 | public function getMinorLanguage($updateData) | 241 | public function getMinorLanguage($updateData) |
| 265 | { | 242 | { |
| 266 | $minorLanguage = []; | 243 | $minorLanguage = []; |
| 267 | - $updateProgressQuery = UpdateProgressModel::find($updateData->id); | 244 | + $updateProgressQuery = UpdateProgress::find($updateData->id); |
| 268 | if (!empty($updateProgressQuery)){ | 245 | if (!empty($updateProgressQuery)){ |
| 269 | $extends = $updateProgressQuery->extends; | 246 | $extends = $updateProgressQuery->extends; |
| 270 | if (!empty($extends)){ | 247 | if (!empty($extends)){ |
| @@ -3,34 +3,30 @@ | @@ -3,34 +3,30 @@ | ||
| 3 | 3 | ||
| 4 | namespace App\Services\Html; | 4 | namespace App\Services\Html; |
| 5 | 5 | ||
| 6 | -use App\Helper\Str; | ||
| 7 | use App\Models\Blog\Blog; | 6 | use App\Models\Blog\Blog; |
| 8 | -use App\Models\Module\Module; | ||
| 9 | -use App\Models\Module\ModuleCategory; | 7 | +use App\Models\Collect\CollectTask; |
| 8 | +use App\Models\Com\Notify; | ||
| 9 | +use App\Models\Com\UpdateNotify; | ||
| 10 | +use App\Models\Com\UpdateProgress; | ||
| 11 | +use App\Models\CustomModule\CustomModule; | ||
| 12 | +use App\Models\CustomModule\CustomModuleCategory; | ||
| 10 | use App\Models\News\News; | 13 | use App\Models\News\News; |
| 11 | use App\Models\News\NewsCategory; | 14 | use App\Models\News\NewsCategory; |
| 12 | use App\Models\Product\Category; | 15 | use App\Models\Product\Category; |
| 13 | use App\Models\Product\CategoryRelated; | 16 | use App\Models\Product\CategoryRelated; |
| 14 | use App\Models\Product\Keyword; | 17 | use App\Models\Product\Keyword; |
| 15 | use App\Models\Product\Product; | 18 | use App\Models\Product\Product; |
| 16 | -use App\Models\Project\CollectTask; | ||
| 17 | -use App\Models\Project\Country; | ||
| 18 | use App\Models\Project\CountryCustom; | 19 | use App\Models\Project\CountryCustom; |
| 19 | use App\Models\Project\DeployBuild; | 20 | use App\Models\Project\DeployBuild; |
| 20 | -use App\Models\Project\DomainInfo; | ||
| 21 | -use App\Models\Project\Notify; | ||
| 22 | use App\Models\Project\Project; | 21 | use App\Models\Project\Project; |
| 23 | -use App\Models\Project\UpdateHtmlModel; | ||
| 24 | use App\Models\Project\UpdateMasterWebsiteModel; | 22 | use App\Models\Project\UpdateMasterWebsiteModel; |
| 25 | use App\Models\Project\UpdateMinorLanguagesModel; | 23 | use App\Models\Project\UpdateMinorLanguagesModel; |
| 26 | -use App\Models\Project\UpdateProgressModel; | ||
| 27 | -use App\Models\RouteMap; | ||
| 28 | -use App\Models\Template\BSetting; | ||
| 29 | -use App\Models\WebSetting\WebCustom; | 24 | +use App\Models\RouteMap\RouteMap; |
| 25 | +use App\Models\Template\BCustomTemplate; | ||
| 26 | +use App\Models\Template\BTemplate; | ||
| 27 | +use App\Models\Template\Setting; | ||
| 28 | +use App\Models\WebSetting\SettingNum; | ||
| 30 | use App\Models\WebSetting\WebLanguage; | 29 | use App\Models\WebSetting\WebLanguage; |
| 31 | -use App\Models\WebSetting\WebSettingNum; | ||
| 32 | -use App\Models\WebSetting\WebTemplate; | ||
| 33 | -use App\Models\WebSetting\WebTemplateCommon; | ||
| 34 | use App\Repositories\StaticHtmlRepository; | 30 | use App\Repositories\StaticHtmlRepository; |
| 35 | use Illuminate\Support\Facades\File; | 31 | use Illuminate\Support\Facades\File; |
| 36 | use phpQuery; | 32 | use phpQuery; |
| @@ -55,7 +51,6 @@ class CreatePageService{ | @@ -55,7 +51,6 @@ class CreatePageService{ | ||
| 55 | if($project['update_info']['is_language_update'] == 0){ | 51 | if($project['update_info']['is_language_update'] == 0){ |
| 56 | return ''; | 52 | return ''; |
| 57 | } | 53 | } |
| 58 | - | ||
| 59 | if ($source == 'news' || $source == 'blog' || $source == 'product' || $source == 'page' || $source == 'module'){ | 54 | if ($source == 'news' || $source == 'blog' || $source == 'product' || $source == 'page' || $source == 'module'){ |
| 60 | $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("source",$source)->first(); | 55 | $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("source",$source)->first(); |
| 61 | }elseif($source == ''){ | 56 | }elseif($source == ''){ |
| @@ -63,28 +58,27 @@ class CreatePageService{ | @@ -63,28 +58,27 @@ class CreatePageService{ | ||
| 63 | }else{ | 58 | }else{ |
| 64 | return ''; | 59 | return ''; |
| 65 | } | 60 | } |
| 66 | - | ||
| 67 | if($routerMap) { | 61 | if($routerMap) { |
| 68 | switch ($routerMap->source) { | 62 | switch ($routerMap->source) { |
| 69 | //产品详情 | 63 | //产品详情 |
| 70 | - case WebTemplateCommon::$productName: | 64 | + case RouteMap::SOURCE_PRODUCT: |
| 71 | $detail = Product::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first(); | 65 | $detail = Product::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first(); |
| 72 | break; | 66 | break; |
| 73 | //博客详情 | 67 | //博客详情 |
| 74 | - case WebTemplateCommon::$blogName: | 68 | + case RouteMap::SOURCE_BLOG: |
| 75 | $detail = Blog::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first(); | 69 | $detail = Blog::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first(); |
| 76 | break; | 70 | break; |
| 77 | //新闻详情 | 71 | //新闻详情 |
| 78 | - case WebTemplateCommon::$newsName: | 72 | + case RouteMap::SOURCE_NEWS: |
| 79 | $detail = News::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first(); | 73 | $detail = News::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first(); |
| 80 | break; | 74 | break; |
| 81 | //自定义模块详情 | 75 | //自定义模块详情 |
| 82 | - case WebTemplateCommon::$extendName: | 76 | + case RouteMap::SOURCE_MODULE: |
| 83 | $detail = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); | 77 | $detail = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); |
| 84 | break; | 78 | break; |
| 85 | default: | 79 | default: |
| 86 | //单页详情 | 80 | //单页详情 |
| 87 | - $detail = WebCustom::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first(); | 81 | + $detail = BCustomTemplate::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first(); |
| 88 | } | 82 | } |
| 89 | if($detail && $detail->six_read){ | 83 | if($detail && $detail->six_read){ |
| 90 | return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang); | 84 | return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang); |
| @@ -104,7 +98,6 @@ class CreatePageService{ | @@ -104,7 +98,6 @@ class CreatePageService{ | ||
| 104 | $html = ""; | 98 | $html = ""; |
| 105 | $page = $page == null ? null : (int)$page; | 99 | $page = $page == null ? null : (int)$page; |
| 106 | $router = $route == "" ? "404" : $route; | 100 | $router = $route == "" ? "404" : $route; |
| 107 | - | ||
| 108 | $productKeywordRouter = new Keyword(); | 101 | $productKeywordRouter = new Keyword(); |
| 109 | $productKeywordRouters = $productKeywordRouter->product_keyword_route; | 102 | $productKeywordRouters = $productKeywordRouter->product_keyword_route; |
| 110 | if (in_array($router, $productKeywordRouters)) { | 103 | if (in_array($router, $productKeywordRouters)) { |
| @@ -117,15 +110,15 @@ class CreatePageService{ | @@ -117,15 +110,15 @@ class CreatePageService{ | ||
| 117 | $routerMapRegular = new stdClass(); | 110 | $routerMapRegular = new stdClass(); |
| 118 | if (empty($routerMap)){ | 111 | if (empty($routerMap)){ |
| 119 | if ($router == "products"){ | 112 | if ($router == "products"){ |
| 120 | - $routerMapRegular->source = WebTemplateCommon::$productCategoryName; | 113 | + $routerMapRegular->source = RouteMap::SOURCE_PRODUCT_CATE; |
| 121 | $routerMapRegular->route = "products"; | 114 | $routerMapRegular->route = "products"; |
| 122 | } | 115 | } |
| 123 | if ($router == "news"){ | 116 | if ($router == "news"){ |
| 124 | - $routerMapRegular->source = WebTemplateCommon::$newsCategoryName; | 117 | + $routerMapRegular->source = RouteMap::SOURCE_NEWS_CATE; |
| 125 | $routerMapRegular->route = "news"; | 118 | $routerMapRegular->route = "news"; |
| 126 | } | 119 | } |
| 127 | if ($router == "blog"){ | 120 | if ($router == "blog"){ |
| 128 | - $routerMapRegular->source = WebTemplateCommon::$blogCategoryName; | 121 | + $routerMapRegular->source = RouteMap::SOURCE_BLOG_CATE; |
| 129 | $routerMapRegular->route = "blog"; | 122 | $routerMapRegular->route = "blog"; |
| 130 | } | 123 | } |
| 131 | $routerMapRegular->source_id = 0; | 124 | $routerMapRegular->source_id = 0; |
| @@ -155,43 +148,43 @@ class CreatePageService{ | @@ -155,43 +148,43 @@ class CreatePageService{ | ||
| 155 | $type = $routerMap->source; | 148 | $type = $routerMap->source; |
| 156 | switch ($type) { | 149 | switch ($type) { |
| 157 | //产品详情 | 150 | //产品详情 |
| 158 | - case WebTemplateCommon::$productName: | 151 | + case RouteMap::SOURCE_PRODUCT: |
| 159 | $html = $this->getProductPage($project,$routerMap); | 152 | $html = $this->getProductPage($project,$routerMap); |
| 160 | break; | 153 | break; |
| 161 | //产品列表 | 154 | //产品列表 |
| 162 | - case WebTemplateCommon::$productCategoryName: | 155 | + case RouteMap::SOURCE_PRODUCT_CATE: |
| 163 | $html = $this->getProductListPage($project,$routerMap,$page); | 156 | $html = $this->getProductListPage($project,$routerMap,$page); |
| 164 | break; | 157 | break; |
| 165 | //博客详情 | 158 | //博客详情 |
| 166 | - case WebTemplateCommon::$blogName: | 159 | + case RouteMap::SOURCE_BLOG: |
| 167 | $html = $this->getBlogPage($project,$routerMap); | 160 | $html = $this->getBlogPage($project,$routerMap); |
| 168 | break; | 161 | break; |
| 169 | //博客列表 | 162 | //博客列表 |
| 170 | - case WebTemplateCommon::$blogCategoryName: | 163 | + case RouteMap::SOURCE_BLOG_CATE: |
| 171 | $html = $this->getBlogListPage($project,$routerMap,$page); | 164 | $html = $this->getBlogListPage($project,$routerMap,$page); |
| 172 | break; | 165 | break; |
| 173 | //新闻详情 | 166 | //新闻详情 |
| 174 | - case WebTemplateCommon::$newsName: | 167 | + case RouteMap::SOURCE_NEWS: |
| 175 | $html = $this->getNewsPage($project,$routerMap); | 168 | $html = $this->getNewsPage($project,$routerMap); |
| 176 | break; | 169 | break; |
| 177 | //新闻列表 | 170 | //新闻列表 |
| 178 | - case WebTemplateCommon::$newsCategoryName: | 171 | + case RouteMap::SOURCE_NEWS_CATE: |
| 179 | $html = $this->getNewsListPage($project,$routerMap,$page); | 172 | $html = $this->getNewsListPage($project,$routerMap,$page); |
| 180 | break; | 173 | break; |
| 181 | //自定义模块列表 | 174 | //自定义模块列表 |
| 182 | - case WebTemplateCommon::$extendCategoryName: | 175 | + case RouteMap::SOURCE_MODULE_CATE: |
| 183 | $html = $this->getModuleListPage($project,$routerMap,$page); | 176 | $html = $this->getModuleListPage($project,$routerMap,$page); |
| 184 | break; | 177 | break; |
| 185 | //自定义模块详情 | 178 | //自定义模块详情 |
| 186 | - case WebTemplateCommon::$extendName: | 179 | + case RouteMap::SOURCE_MODULE: |
| 187 | $html = $this->getModulePage($project,$routerMap); | 180 | $html = $this->getModulePage($project,$routerMap); |
| 188 | break; | 181 | break; |
| 189 | //聚合页 | 182 | //聚合页 |
| 190 | - case WebTemplateCommon::$productKeywordName: | 183 | + case RouteMap::SOURCE_PRODUCT_KEYWORD: |
| 191 | $html = $this->getProductKeywordPage($project,$routerMap); | 184 | $html = $this->getProductKeywordPage($project,$routerMap); |
| 192 | break; | 185 | break; |
| 193 | - case WebTemplateCommon::$pageName: | ||
| 194 | - if ($router == WebTemplateCommon::$indexName){ | 186 | + case RouteMap::SOURCE_PAGE: |
| 187 | + if ($router == RouteMap::SOURCE_INDEX){ | ||
| 195 | //首页 | 188 | //首页 |
| 196 | $html = $this->getIndexPage($project,$routerMap); | 189 | $html = $this->getIndexPage($project,$routerMap); |
| 197 | }else{ | 190 | }else{ |
| @@ -216,36 +209,28 @@ class CreatePageService{ | @@ -216,36 +209,28 @@ class CreatePageService{ | ||
| 216 | $commonService = new CommonService(); | 209 | $commonService = new CommonService(); |
| 217 | $tdkService = new TdkService(); | 210 | $tdkService = new TdkService(); |
| 218 | //首页模板 | 211 | //首页模板 |
| 219 | - $info = BSetting::where("project_id",$project->id)->first(); | 212 | + $info = Setting::where("project_id",$project->id)->first(); |
| 220 | if (empty($info)){ | 213 | if (empty($info)){ |
| 221 | return ""; | 214 | return ""; |
| 222 | } | 215 | } |
| 223 | - | ||
| 224 | - $webIndexTemplate = WebTemplate::where("project_id",$project->id)->where("template_id",$info->template_id)->where("source",1)->first(); | 216 | + $webIndexTemplate = BTemplate::where("project_id",$project->id)->where("template_id",$info->template_id)->where("source",1)->first(); |
| 225 | if (!empty($webIndexTemplate)){ | 217 | if (!empty($webIndexTemplate)){ |
| 226 | - $html = $pageService->isAndGetVisualizationHtml($project,WebTemplateCommon::$indexName,$routerMap); | 218 | + $html = $pageService->isAndGetVisualizationHtml($project,RouteMap::SOURCE_INDEX,$routerMap); |
| 227 | if ($html == ""){ | 219 | if ($html == ""){ |
| 228 | //组装首页页面 | 220 | //组装首页页面 |
| 229 | $html = $pageService->assembleIndexPage($project,$webIndexTemplate); | 221 | $html = $pageService->assembleIndexPage($project,$webIndexTemplate); |
| 230 | } | 222 | } |
| 231 | - | ||
| 232 | -// $filePath = public_path("6666.html"); | ||
| 233 | -// file_put_contents($filePath, $html); | ||
| 234 | -// dd(5656); | ||
| 235 | //公共处理 | 223 | //公共处理 |
| 236 | $html = $pageService->publicHtmlHandle($html,$project->id); | 224 | $html = $pageService->publicHtmlHandle($html,$project->id); |
| 237 | - $isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$indexName); | 225 | + $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_INDEX); |
| 238 | if ((int)$isVisual == 1 || $isVisual == null){ | 226 | if ((int)$isVisual == 1 || $isVisual == null){ |
| 239 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) | 227 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) |
| 240 | $html = $pageService->generalTemplateProcessingForDataModules($html,$project->id); | 228 | $html = $pageService->generalTemplateProcessingForDataModules($html,$project->id); |
| 241 | } | 229 | } |
| 242 | //第三方 | 230 | //第三方 |
| 243 | - $html = $commonService->thirdPartyCodeHandle($project,$html,WebTemplateCommon::$indexName); | 231 | + $html = $commonService->thirdPartyCodeHandle($project,$html,RouteMap::SOURCE_INDEX); |
| 244 | //TDK处理 | 232 | //TDK处理 |
| 245 | - $html = $tdkService->pageTdkHandle($project,$html,WebTemplateCommon::$indexName,$routerMap); | ||
| 246 | - //特殊首页模块处理 | ||
| 247 | -// $html = $pageService->specialIndexModuleHandle($project,$html); | ||
| 248 | - //处理URL等,处理html链接a标签href | 233 | + $html = $tdkService->pageTdkHandle($project,$html,RouteMap::SOURCE_INDEX,$routerMap); |
| 249 | if (!empty($html)){ | 234 | if (!empty($html)){ |
| 250 | return $this->pageUrlHandle($project,$routerMap,$html); | 235 | return $this->pageUrlHandle($project,$routerMap,$html); |
| 251 | }else{ | 236 | }else{ |
| @@ -265,16 +250,16 @@ class CreatePageService{ | @@ -265,16 +250,16 @@ class CreatePageService{ | ||
| 265 | $commonService = new CommonService(); | 250 | $commonService = new CommonService(); |
| 266 | $tdkService = new TdkService(); | 251 | $tdkService = new TdkService(); |
| 267 | //公共拼接页面方法 | 252 | //公共拼接页面方法 |
| 268 | - $webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$productCategoryName,$routerMap); | 253 | + $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_PRODUCT_CATE,$routerMap); |
| 269 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 | 254 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 |
| 270 | - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$productCategoryName,$routerMap,$page); | 255 | + $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_PRODUCT_CATE,$routerMap,$page); |
| 271 | //是否开启可视化 | 256 | //是否开启可视化 |
| 272 | - $isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$productCategoryName); | 257 | + $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_PRODUCT_CATE); |
| 273 | if ((int)$isVisual == 1 || $isVisual == null){ | 258 | if ((int)$isVisual == 1 || $isVisual == null){ |
| 274 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) | 259 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) |
| 275 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); | 260 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); |
| 276 | } | 261 | } |
| 277 | - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$productCategoryName,$routerMap); | 262 | + $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_PRODUCT_CATE,$routerMap); |
| 278 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); | 263 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); |
| 279 | unset($pageService); | 264 | unset($pageService); |
| 280 | $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route); | 265 | $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route); |
| @@ -300,10 +285,10 @@ class CreatePageService{ | @@ -300,10 +285,10 @@ class CreatePageService{ | ||
| 300 | $products_detail = $pageService->productDataHandle($project,$products_detail); | 285 | $products_detail = $pageService->productDataHandle($project,$products_detail); |
| 301 | if (!empty($products_detail)){ | 286 | if (!empty($products_detail)){ |
| 302 | //公共拼接页面方法 | 287 | //公共拼接页面方法 |
| 303 | - $webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$productName,$routerMap); | 288 | + $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_PRODUCT,$routerMap); |
| 304 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 | 289 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 |
| 305 | $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,"product",$routerMap,null); | 290 | $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,"product",$routerMap,null); |
| 306 | - $isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$productName); | 291 | + $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_PRODUCT); |
| 307 | if ((int)$isVisual == 1 || $isVisual == null){ | 292 | if ((int)$isVisual == 1 || $isVisual == null){ |
| 308 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) | 293 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) |
| 309 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); | 294 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); |
| @@ -361,7 +346,7 @@ class CreatePageService{ | @@ -361,7 +346,7 @@ class CreatePageService{ | ||
| 361 | $webCustomHtml = $commonService->thirdPartyCodeHandle($project, $html, $routerMap->route); | 346 | $webCustomHtml = $commonService->thirdPartyCodeHandle($project, $html, $routerMap->route); |
| 362 | //TDK | 347 | //TDK |
| 363 | unset($html,$productsKeywordsList,$productsRecommendAndHot,$blogT); | 348 | unset($html,$productsKeywordsList,$productsRecommendAndHot,$blogT); |
| 364 | - $html = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$productKeywordName,$routerMap); | 349 | + $html = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_PRODUCT_KEYWORD,$routerMap); |
| 365 | //处理URL等,处理html链接a标签href | 350 | //处理URL等,处理html链接a标签href |
| 366 | if (!empty($html)){ | 351 | if (!empty($html)){ |
| 367 | return $this->pageUrlHandle($project,$routerMap,$html); | 352 | return $this->pageUrlHandle($project,$routerMap,$html); |
| @@ -383,15 +368,15 @@ class CreatePageService{ | @@ -383,15 +368,15 @@ class CreatePageService{ | ||
| 383 | $tdkService = new TdkService(); | 368 | $tdkService = new TdkService(); |
| 384 | $routePath = $routerMap->route; | 369 | $routePath = $routerMap->route; |
| 385 | //公共拼接页面方法 | 370 | //公共拼接页面方法 |
| 386 | - $webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$newsCategoryName,$routerMap); | 371 | + $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_NEWS_CATE,$routerMap); |
| 387 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 | 372 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 |
| 388 | - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$newsCategoryName,$routerMap,$page); | ||
| 389 | - $isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$newsCategoryName); | 373 | + $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_NEWS_CATE,$routerMap,$page); |
| 374 | + $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_NEWS_CATE); | ||
| 390 | if ((int)$isVisual == 1 || $isVisual == null){ | 375 | if ((int)$isVisual == 1 || $isVisual == null){ |
| 391 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) | 376 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) |
| 392 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); | 377 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); |
| 393 | } | 378 | } |
| 394 | - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$newsCategoryName,$routerMap); | 379 | + $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_NEWS_CATE,$routerMap); |
| 395 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); | 380 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); |
| 396 | unset($pageService); | 381 | unset($pageService); |
| 397 | $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath); | 382 | $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath); |
| @@ -414,16 +399,16 @@ class CreatePageService{ | @@ -414,16 +399,16 @@ class CreatePageService{ | ||
| 414 | $tdkService = new TdkService(); | 399 | $tdkService = new TdkService(); |
| 415 | $routePath = $routerMap->route; | 400 | $routePath = $routerMap->route; |
| 416 | //公共拼接页面方法 | 401 | //公共拼接页面方法 |
| 417 | - $webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$extendCategoryName,$routerMap); | 402 | + $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_MODULE_CATE,$routerMap); |
| 418 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 | 403 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 |
| 419 | - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$extendCategoryName,$routerMap,$page); | ||
| 420 | - $moduleCategoryInfo = ModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id); | 404 | + $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_MODULE_CATE,$routerMap,$page); |
| 405 | + $moduleCategoryInfo = CustomModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id); | ||
| 421 | if (isset($moduleCategoryInfo->getExtend->list_visualization) && $moduleCategoryInfo->getExtend->list_visualization == 1){ | 406 | if (isset($moduleCategoryInfo->getExtend->list_visualization) && $moduleCategoryInfo->getExtend->list_visualization == 1){ |
| 422 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) | 407 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) |
| 423 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); | 408 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); |
| 424 | } | 409 | } |
| 425 | 410 | ||
| 426 | - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$extendCategoryName,$routerMap); | 411 | + $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_MODULE_CATE,$routerMap); |
| 427 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); | 412 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); |
| 428 | unset($pageService); | 413 | unset($pageService); |
| 429 | $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath); | 414 | $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath); |
| @@ -436,7 +421,7 @@ class CreatePageService{ | @@ -436,7 +421,7 @@ class CreatePageService{ | ||
| 436 | } | 421 | } |
| 437 | 422 | ||
| 438 | /** | 423 | /** |
| 439 | - * 获取产品新闻页html | 424 | + * 获取新闻页html |
| 440 | */ | 425 | */ |
| 441 | public function getNewsPage($project,$routerMap,$lang=''): string | 426 | public function getNewsPage($project,$routerMap,$lang=''): string |
| 442 | { | 427 | { |
| @@ -451,16 +436,16 @@ class CreatePageService{ | @@ -451,16 +436,16 @@ class CreatePageService{ | ||
| 451 | return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang); | 436 | return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang); |
| 452 | }else{ | 437 | }else{ |
| 453 | //公共拼接页面方法 | 438 | //公共拼接页面方法 |
| 454 | - $webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$newsName,$routerMap); | 439 | + $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_NEWS,$routerMap); |
| 455 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 | 440 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 |
| 456 | - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$newsName,$routerMap,null); | ||
| 457 | - $isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$newsName); | 441 | + $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_NEWS,$routerMap,null); |
| 442 | + $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_NEWS); | ||
| 458 | if ((int)$isVisual == 1 || $isVisual == null){ | 443 | if ((int)$isVisual == 1 || $isVisual == null){ |
| 459 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) | 444 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) |
| 460 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); | 445 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); |
| 461 | } | 446 | } |
| 462 | //TDK处理 | 447 | //TDK处理 |
| 463 | - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$newsName,$routerMap); | 448 | + $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_NEWS,$routerMap); |
| 464 | //网页公共部分 | 449 | //网页公共部分 |
| 465 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); | 450 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); |
| 466 | unset($pageService); | 451 | unset($pageService); |
| @@ -487,22 +472,22 @@ class CreatePageService{ | @@ -487,22 +472,22 @@ class CreatePageService{ | ||
| 487 | $tdkService = new TdkService(); | 472 | $tdkService = new TdkService(); |
| 488 | //页面路由 | 473 | //页面路由 |
| 489 | $routePath = $routerMap->route; | 474 | $routePath = $routerMap->route; |
| 490 | - $module_detail = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); | 475 | + $module_detail = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); |
| 491 | if (!empty($module_detail)){ | 476 | if (!empty($module_detail)){ |
| 492 | if($project['update_info']['is_update'] && $module_detail->six_read){ | 477 | if($project['update_info']['is_update'] && $module_detail->six_read){ |
| 493 | return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang); | 478 | return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang); |
| 494 | }else{ | 479 | }else{ |
| 495 | //公共拼接页面方法 | 480 | //公共拼接页面方法 |
| 496 | - $webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$extendName,$routerMap); | 481 | + $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_MODULE,$routerMap); |
| 497 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 | 482 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 |
| 498 | - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$extendName,$routerMap,null); | ||
| 499 | - $moduleCategoryInfo = Module::getModuleCategory($project->id,$module_detail); | 483 | + $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_MODULE,$routerMap,null); |
| 484 | + $moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$module_detail); | ||
| 500 | if (isset($moduleCategoryInfo->getExtend->detail_visualization) && $moduleCategoryInfo->getExtend->detail_visualization == 1){ | 485 | if (isset($moduleCategoryInfo->getExtend->detail_visualization) && $moduleCategoryInfo->getExtend->detail_visualization == 1){ |
| 501 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) | 486 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) |
| 502 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); | 487 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); |
| 503 | } | 488 | } |
| 504 | //TDK处理 | 489 | //TDK处理 |
| 505 | - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$extendName,$routerMap); | 490 | + $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_MODULE,$routerMap); |
| 506 | //网页公共部分 | 491 | //网页公共部分 |
| 507 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); | 492 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); |
| 508 | unset($pageService); | 493 | unset($pageService); |
| @@ -528,15 +513,15 @@ class CreatePageService{ | @@ -528,15 +513,15 @@ class CreatePageService{ | ||
| 528 | $commonService = new CommonService(); | 513 | $commonService = new CommonService(); |
| 529 | $tdkService = new TdkService(); | 514 | $tdkService = new TdkService(); |
| 530 | //公共拼接页面方法 | 515 | //公共拼接页面方法 |
| 531 | - $webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$blogCategoryName,$routerMap); | 516 | + $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_BLOG_CATE,$routerMap); |
| 532 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 | 517 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 |
| 533 | - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$blogCategoryName,$routerMap,$page); | ||
| 534 | - $isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$blogCategoryName); | 518 | + $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_BLOG_CATE,$routerMap,$page); |
| 519 | + $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_BLOG_CATE); | ||
| 535 | if ((int)$isVisual == 1 || $isVisual == null){ | 520 | if ((int)$isVisual == 1 || $isVisual == null){ |
| 536 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) | 521 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) |
| 537 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); | 522 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); |
| 538 | } | 523 | } |
| 539 | - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$blogCategoryName,$routerMap); | 524 | + $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_BLOG_CATE,$routerMap); |
| 540 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); | 525 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); |
| 541 | unset($pageService); | 526 | unset($pageService); |
| 542 | $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route); | 527 | $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route); |
| @@ -562,15 +547,15 @@ class CreatePageService{ | @@ -562,15 +547,15 @@ class CreatePageService{ | ||
| 562 | return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang); | 547 | return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang); |
| 563 | }else{ | 548 | }else{ |
| 564 | //公共拼接页面方法 | 549 | //公共拼接页面方法 |
| 565 | - $webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$blogName,$routerMap); | 550 | + $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_BLOG,$routerMap); |
| 566 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 | 551 | //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页 |
| 567 | - $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$blogName,$routerMap,null); | ||
| 568 | - $isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$blogName); | 552 | + $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_BLOG,$routerMap,null); |
| 553 | + $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_BLOG); | ||
| 569 | if ((int)$isVisual == 1 || $isVisual == null){ | 554 | if ((int)$isVisual == 1 || $isVisual == null){ |
| 570 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) | 555 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) |
| 571 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); | 556 | $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id); |
| 572 | } | 557 | } |
| 573 | - $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$blogName,$routerMap); | 558 | + $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_BLOG,$routerMap); |
| 574 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); | 559 | $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id); |
| 575 | unset($pageService); | 560 | unset($pageService); |
| 576 | //生成静态页 | 561 | //生成静态页 |
| @@ -597,22 +582,22 @@ class CreatePageService{ | @@ -597,22 +582,22 @@ class CreatePageService{ | ||
| 597 | $tdkService = new TdkService(); | 582 | $tdkService = new TdkService(); |
| 598 | //页面路由 | 583 | //页面路由 |
| 599 | $routePath = $routerMap->route; | 584 | $routePath = $routerMap->route; |
| 600 | - $webCustom = WebCustom::where("id",$routerMap->source_id)->where("status",1)->first(); | 585 | + $webCustom = BCustomTemplate::where("id",$routerMap->source_id)->where("status",1)->first(); |
| 601 | if (!empty($webCustom)){ | 586 | if (!empty($webCustom)){ |
| 602 | if($project['update_info']['is_update'] && $webCustom->six_read){ | 587 | if($project['update_info']['is_update'] && $webCustom->six_read){ |
| 603 | return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang); | 588 | return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang); |
| 604 | }else{ | 589 | }else{ |
| 605 | //公共拼接页面方法 | 590 | //公共拼接页面方法 |
| 606 | - $content = $pageService->publicMontagePage($project,WebTemplateCommon::$pageName,$routerMap); | 591 | + $content = $pageService->publicMontagePage($project,RouteMap::SOURCE_PAGE,$routerMap); |
| 607 | //公共左侧导航处理 | 592 | //公共左侧导航处理 |
| 608 | $phpQueryDom=phpQuery::newDocument($content); | 593 | $phpQueryDom=phpQuery::newDocument($content); |
| 609 | - $pageService->leftNavSideNavHandle($project,WebTemplateCommon::$pageName,$phpQueryDom,$routerMap); | 594 | + $pageService->leftNavSideNavHandle($project,RouteMap::SOURCE_PAGE,$phpQueryDom,$routerMap); |
| 610 | $content = $phpQueryDom->htmlOuter(); | 595 | $content = $phpQueryDom->htmlOuter(); |
| 611 | unset($phpQueryDom); | 596 | unset($phpQueryDom); |
| 612 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) | 597 | //产品,产品分类,新闻,博客(section模板通用数据模块处理) |
| 613 | $content = $pageService->generalTemplateProcessingForDataModules($content,$project->id); | 598 | $content = $pageService->generalTemplateProcessingForDataModules($content,$project->id); |
| 614 | //生成静态页 | 599 | //生成静态页 |
| 615 | - $content = $tdkService->pageTdkHandle($project,$content,WebTemplateCommon::$pageName,$routerMap); | 600 | + $content = $tdkService->pageTdkHandle($project,$content,RouteMap::SOURCE_PAGE,$routerMap); |
| 616 | $content = $pageService->publicHtmlHandle($content,$project->id); | 601 | $content = $pageService->publicHtmlHandle($content,$project->id); |
| 617 | unset($pageService); | 602 | unset($pageService); |
| 618 | $html = $commonService->thirdPartyCodeHandle($project,$content,$routePath,$routerMap); | 603 | $html = $commonService->thirdPartyCodeHandle($project,$content,$routePath,$routerMap); |
| @@ -679,22 +664,14 @@ class CreatePageService{ | @@ -679,22 +664,14 @@ class CreatePageService{ | ||
| 679 | $domainEnd = $project->domain_end; | 664 | $domainEnd = $project->domain_end; |
| 680 | //主站a链接处理 | 665 | //主站a链接处理 |
| 681 | $this->masterWebATagHandle($phpQueryDom,$project,$domainEnd); | 666 | $this->masterWebATagHandle($phpQueryDom,$project,$domainEnd); |
| 682 | - | ||
| 683 | //html 标签处理 | 667 | //html 标签处理 |
| 684 | $this->htmlTagHandle($phpQueryDom,$project); | 668 | $this->htmlTagHandle($phpQueryDom,$project); |
| 685 | - | ||
| 686 | - //888项目禁用鼠标右键点击,查看元素 | ||
| 687 | -// $this->prohibitRightMouseClick($phpQueryDom,$project); | ||
| 688 | - | ||
| 689 | //国家 | 669 | //国家 |
| 690 | $webCountry = $pageService->getCountryList($project->id); | 670 | $webCountry = $pageService->getCountryList($project->id); |
| 691 | - | ||
| 692 | //语种 alternate | 671 | //语种 alternate |
| 693 | $this->setHrefLang($phpQueryDom,$project,$route,$page,$lang,$webCountry); | 672 | $this->setHrefLang($phpQueryDom,$project,$route,$page,$lang,$webCountry); |
| 694 | - | ||
| 695 | //以-tag的聚合页结尾的路由加上 <meta name="robots" content="noindex"> | 673 | //以-tag的聚合页结尾的路由加上 <meta name="robots" content="noindex"> |
| 696 | $this->setTagRobotsNoindex($phpQueryDom,$routerMap); | 674 | $this->setTagRobotsNoindex($phpQueryDom,$routerMap); |
| 697 | - | ||
| 698 | //<meta name="cookie_consent_banner" content="参数值"> 配置 | 675 | //<meta name="cookie_consent_banner" content="参数值"> 配置 |
| 699 | $this->setCookieConsentBanner($phpQueryDom,$project); | 676 | $this->setCookieConsentBanner($phpQueryDom,$project); |
| 700 | 677 | ||
| @@ -841,18 +818,8 @@ class CreatePageService{ | @@ -841,18 +818,8 @@ class CreatePageService{ | ||
| 841 | } | 818 | } |
| 842 | $countryUrl[$key]["alias"] = $item->short; | 819 | $countryUrl[$key]["alias"] = $item->short; |
| 843 | } | 820 | } |
| 844 | - | ||
| 845 | - //之前 | ||
| 846 | -// $langShort = $item->short == "en" ? "" : $item->short."/"; | ||
| 847 | -// if ((int)$page != null) { | ||
| 848 | -// $countryUrl[$key]["url"] = "https://" . $domain . "/" .$langShort . $route . "/" . (int)$page . "/"; | ||
| 849 | -// } else { | ||
| 850 | -// $countryUrl[$key]["url"] = $route == "index" ? "https://" . $domain . "/" . $langShort : "https://" . $domain . "/" . $langShort. $route . "/"; | ||
| 851 | -// } | ||
| 852 | -// $countryUrl[$key]["alias"] = $item->short; | ||
| 853 | } | 821 | } |
| 854 | } | 822 | } |
| 855 | - | ||
| 856 | //路径 | 823 | //路径 |
| 857 | if ($route == "index") { | 824 | if ($route == "index") { |
| 858 | $webUrl = "https://" . $domain . "/"; | 825 | $webUrl = "https://" . $domain . "/"; |
| @@ -873,7 +840,6 @@ class CreatePageService{ | @@ -873,7 +840,6 @@ class CreatePageService{ | ||
| 873 | } | 840 | } |
| 874 | } | 841 | } |
| 875 | } | 842 | } |
| 876 | - | ||
| 877 | $phpQueryDom->find('head')->append("<meta property='og:url' content='$route'/>"); | 843 | $phpQueryDom->find('head')->append("<meta property='og:url' content='$route'/>"); |
| 878 | $phpQueryDom->find('head')->append("<link rel='canonical' href='$webUrl' />"); | 844 | $phpQueryDom->find('head')->append("<link rel='canonical' href='$webUrl' />"); |
| 879 | if (!empty($countryUrl)){ | 845 | if (!empty($countryUrl)){ |
| @@ -890,7 +856,7 @@ class CreatePageService{ | @@ -890,7 +856,7 @@ class CreatePageService{ | ||
| 890 | */ | 856 | */ |
| 891 | public function setTagRobotsNoindex($phpQueryDom,$routerMap) | 857 | public function setTagRobotsNoindex($phpQueryDom,$routerMap) |
| 892 | { | 858 | { |
| 893 | - if (isset($routerMap->source) && $routerMap->source == WebTemplateCommon::$productKeywordName){ | 859 | + if (isset($routerMap->source) && $routerMap->source == RouteMap::SOURCE_PRODUCT_KEYWORD){ |
| 894 | $routerSuffix = substr($routerMap->route, -4); | 860 | $routerSuffix = substr($routerMap->route, -4); |
| 895 | $routerLength = strlen($routerMap->route); | 861 | $routerLength = strlen($routerMap->route); |
| 896 | if ($routerLength >= 4 && $routerSuffix == "-tag"){ | 862 | if ($routerLength >= 4 && $routerSuffix == "-tag"){ |
| @@ -991,8 +957,8 @@ class CreatePageService{ | @@ -991,8 +957,8 @@ class CreatePageService{ | ||
| 991 | }elseif($routerMap->source == "blog"){ | 957 | }elseif($routerMap->source == "blog"){ |
| 992 | $route = "/blogs/".$route; | 958 | $route = "/blogs/".$route; |
| 993 | }elseif($routerMap->source == "module"){ | 959 | }elseif($routerMap->source == "module"){ |
| 994 | - $modules = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); | ||
| 995 | - $moduleCategoryInfo = Module::getModuleCategory($project->id,$modules); | 960 | + $modules = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); |
| 961 | + $moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$modules); | ||
| 996 | if (isset($moduleCategoryInfo->route) && !empty($moduleCategoryInfo->route)){ | 962 | if (isset($moduleCategoryInfo->route) && !empty($moduleCategoryInfo->route)){ |
| 997 | $route = "/".$moduleCategoryInfo->route."/".$route; | 963 | $route = "/".$moduleCategoryInfo->route."/".$route; |
| 998 | } | 964 | } |
| @@ -1044,7 +1010,7 @@ class CreatePageService{ | @@ -1044,7 +1010,7 @@ class CreatePageService{ | ||
| 1044 | }elseif ($routerMap->source == "product_category"){ | 1010 | }elseif ($routerMap->source == "product_category"){ |
| 1045 | $route = $page == null || $page == 1 ? "/".$route : "/".$route."/page"; | 1011 | $route = $page == null || $page == 1 ? "/".$route : "/".$route."/page"; |
| 1046 | }elseif ($routerMap->source == "module_category"){ | 1012 | }elseif ($routerMap->source == "module_category"){ |
| 1047 | - $moduleCategory = ModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id); | 1013 | + $moduleCategory = CustomModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id); |
| 1048 | if (!empty($moduleCategory->getExtend->route)){ | 1014 | if (!empty($moduleCategory->getExtend->route)){ |
| 1049 | if ($moduleCategory->getExtend->route == $route){ | 1015 | if ($moduleCategory->getExtend->route == $route){ |
| 1050 | $route = "/".$moduleCategory->route; | 1016 | $route = "/".$moduleCategory->route; |
| @@ -1055,8 +1021,8 @@ class CreatePageService{ | @@ -1055,8 +1021,8 @@ class CreatePageService{ | ||
| 1055 | $route = "/".$moduleCategory->route."/page"; | 1021 | $route = "/".$moduleCategory->route."/page"; |
| 1056 | } | 1022 | } |
| 1057 | }elseif ($routerMap->source == "module"){ | 1023 | }elseif ($routerMap->source == "module"){ |
| 1058 | - $modules = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); | ||
| 1059 | - $moduleCategoryInfo = Module::getModuleCategory($project->id,$modules); | 1024 | + $modules = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); |
| 1025 | + $moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$modules); | ||
| 1060 | if (isset($moduleCategoryInfo->getExtend->route) && !empty($moduleCategoryInfo->getExtend->route)){ | 1026 | if (isset($moduleCategoryInfo->getExtend->route) && !empty($moduleCategoryInfo->getExtend->route)){ |
| 1061 | $route = "/".$moduleCategoryInfo->route."/".$modules->route; | 1027 | $route = "/".$moduleCategoryInfo->route."/".$modules->route; |
| 1062 | }else{ | 1028 | }else{ |
| @@ -1143,8 +1109,8 @@ class CreatePageService{ | @@ -1143,8 +1109,8 @@ class CreatePageService{ | ||
| 1143 | }elseif($routerMap->source == "blog"){ | 1109 | }elseif($routerMap->source == "blog"){ |
| 1144 | $route = "/blogs/".$route; | 1110 | $route = "/blogs/".$route; |
| 1145 | }elseif($routerMap->source == "module"){ | 1111 | }elseif($routerMap->source == "module"){ |
| 1146 | - $modules = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); | ||
| 1147 | - $moduleCategoryInfo = Module::getModuleCategory($project->id,$modules); | 1112 | + $modules = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); |
| 1113 | + $moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$modules); | ||
| 1148 | if (isset($moduleCategoryInfo->route) && !empty($moduleCategoryInfo->route)){ | 1114 | if (isset($moduleCategoryInfo->route) && !empty($moduleCategoryInfo->route)){ |
| 1149 | $route = "/".$moduleCategoryInfo->route."/".$route; | 1115 | $route = "/".$moduleCategoryInfo->route."/".$route; |
| 1150 | } | 1116 | } |
| @@ -1187,8 +1153,8 @@ class CreatePageService{ | @@ -1187,8 +1153,8 @@ class CreatePageService{ | ||
| 1187 | }elseif ($routerMap->source == "product_category"){ | 1153 | }elseif ($routerMap->source == "product_category"){ |
| 1188 | $route = "/".$route."/page"; | 1154 | $route = "/".$route."/page"; |
| 1189 | }elseif ($routerMap->source == "module"){ | 1155 | }elseif ($routerMap->source == "module"){ |
| 1190 | - $modules = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); | ||
| 1191 | - $moduleCategoryInfo = Module::getModuleCategory($project->id,$modules); | 1156 | + $modules = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first(); |
| 1157 | + $moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$modules); | ||
| 1192 | if (isset($moduleCategoryInfo->getExtend->route) && !empty($moduleCategoryInfo->getExtend->route)){ | 1158 | if (isset($moduleCategoryInfo->getExtend->route) && !empty($moduleCategoryInfo->getExtend->route)){ |
| 1193 | $route = "/".$moduleCategoryInfo->getExtend->route."_catalog/".$moduleCategoryInfo->route."/page"; | 1159 | $route = "/".$moduleCategoryInfo->getExtend->route."_catalog/".$moduleCategoryInfo->route."/page"; |
| 1194 | }else{ | 1160 | }else{ |
| @@ -1514,7 +1480,7 @@ Disallow: /"; | @@ -1514,7 +1480,7 @@ Disallow: /"; | ||
| 1514 | $routers = null; | 1480 | $routers = null; |
| 1515 | $perPage = 100; | 1481 | $perPage = 100; |
| 1516 | $offset = ($pageNum - 1) * $perPage; | 1482 | $offset = ($pageNum - 1) * $perPage; |
| 1517 | - $updateNotifyQuery = UpdateHtmlModel::where("project_id",$updateNotifyData->project_id); | 1483 | + $updateNotifyQuery = UpdateNotify::where("project_id",$updateNotifyData->project_id); |
| 1518 | if ($updateNotifyData->route == Notify::ROUTE_ALL){ | 1484 | if ($updateNotifyData->route == Notify::ROUTE_ALL){ |
| 1519 | //所有更新 | 1485 | //所有更新 |
| 1520 | if ($updateNotifyData->type == Notify::TYPE_MASTER){ | 1486 | if ($updateNotifyData->type == Notify::TYPE_MASTER){ |
| @@ -1783,7 +1749,7 @@ Disallow: /"; | @@ -1783,7 +1749,7 @@ Disallow: /"; | ||
| 1783 | 1749 | ||
| 1784 | if ($count != 0){ | 1750 | if ($count != 0){ |
| 1785 | if ($router->type == "product_category"){ | 1751 | if ($router->type == "product_category"){ |
| 1786 | - $webSettingNum = WebSettingNum::where("project_id",$updateNotifyData->project_id)->where("type",WebSettingNum::$productListType)->orderBy("id","desc")->first(); | 1752 | + $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$productListType)->orderBy("id","desc")->first(); |
| 1787 | if (!empty($webSettingNum)){ | 1753 | if (!empty($webSettingNum)){ |
| 1788 | $perPage = (int)$webSettingNum->num; | 1754 | $perPage = (int)$webSettingNum->num; |
| 1789 | }else{ | 1755 | }else{ |
| @@ -1791,7 +1757,7 @@ Disallow: /"; | @@ -1791,7 +1757,7 @@ Disallow: /"; | ||
| 1791 | } | 1757 | } |
| 1792 | $total = (int)ceil($count / $perPage); //产品分类总页数 | 1758 | $total = (int)ceil($count / $perPage); //产品分类总页数 |
| 1793 | }elseif($router->type == "news_category"){ | 1759 | }elseif($router->type == "news_category"){ |
| 1794 | - $webSettingNum = WebSettingNum::where("project_id",$updateNotifyData->project_id)->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first(); | 1760 | + $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first(); |
| 1795 | if (!empty($webSettingNum)){ | 1761 | if (!empty($webSettingNum)){ |
| 1796 | $perPage = (int)$webSettingNum->num; | 1762 | $perPage = (int)$webSettingNum->num; |
| 1797 | }else{ | 1763 | }else{ |
| @@ -1799,7 +1765,7 @@ Disallow: /"; | @@ -1799,7 +1765,7 @@ Disallow: /"; | ||
| 1799 | } | 1765 | } |
| 1800 | $total = (int)ceil($count / $perPage); //新闻总页数 | 1766 | $total = (int)ceil($count / $perPage); //新闻总页数 |
| 1801 | }else{ | 1767 | }else{ |
| 1802 | - $webSettingNum = WebSettingNum::where("project_id",$updateNotifyData->project_id)->where("type",WebSettingNum::$blogListType)->orderBy("id","desc")->first(); | 1768 | + $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$blogListType)->orderBy("id","desc")->first(); |
| 1803 | if (!empty($webSettingNum)){ | 1769 | if (!empty($webSettingNum)){ |
| 1804 | $perPage = (int)$webSettingNum->num; | 1770 | $perPage = (int)$webSettingNum->num; |
| 1805 | }else{ | 1771 | }else{ |
| @@ -1851,7 +1817,7 @@ Disallow: /"; | @@ -1851,7 +1817,7 @@ Disallow: /"; | ||
| 1851 | if (empty($routerProductsMap)){ | 1817 | if (empty($routerProductsMap)){ |
| 1852 | $productsCount = Product::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->whereNotNull('route')->orderBy("id","DESC")->count(); | 1818 | $productsCount = Product::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->whereNotNull('route')->orderBy("id","DESC")->count(); |
| 1853 | if ($productsCount != 0){ | 1819 | if ($productsCount != 0){ |
| 1854 | - $webSettingNum = WebSettingNum::where("project_id",$updateNotifyData->project_id)->where("type",WebSettingNum::$productListType)->orderBy("id","desc")->first(); | 1820 | + $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$productListType)->orderBy("id","desc")->first(); |
| 1855 | if (!empty($webSettingNum)){ | 1821 | if (!empty($webSettingNum)){ |
| 1856 | $perPage = (int)$webSettingNum->num; | 1822 | $perPage = (int)$webSettingNum->num; |
| 1857 | }else{ | 1823 | }else{ |
| @@ -1883,7 +1849,7 @@ Disallow: /"; | @@ -1883,7 +1849,7 @@ Disallow: /"; | ||
| 1883 | $routerNewsMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route","news")->first(); | 1849 | $routerNewsMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route","news")->first(); |
| 1884 | if (empty($routerNewsMap)){ | 1850 | if (empty($routerNewsMap)){ |
| 1885 | $newsCount = News::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->orderBy("id","DESC")->count(); | 1851 | $newsCount = News::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->orderBy("id","DESC")->count(); |
| 1886 | - $webSettingNum = WebSettingNum::where("project_id",$updateNotifyData->project_id)->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first(); | 1852 | + $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first(); |
| 1887 | if (!empty($webSettingNum)){ | 1853 | if (!empty($webSettingNum)){ |
| 1888 | $perPage = (int)$webSettingNum->num; | 1854 | $perPage = (int)$webSettingNum->num; |
| 1889 | }else{ | 1855 | }else{ |
| @@ -1914,7 +1880,7 @@ Disallow: /"; | @@ -1914,7 +1880,7 @@ Disallow: /"; | ||
| 1914 | $routerBlogMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route","blog")->first(); | 1880 | $routerBlogMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route","blog")->first(); |
| 1915 | if (empty($routerBlogMap)){ | 1881 | if (empty($routerBlogMap)){ |
| 1916 | $blogCount = Blog::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->orderBy("id","DESC")->count(); | 1882 | $blogCount = Blog::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->orderBy("id","DESC")->count(); |
| 1917 | - $webSettingNum = WebSettingNum::where("project_id",$updateNotifyData->project_id)->where("type",WebSettingNum::$blogListType)->orderBy("id","desc")->first(); | 1883 | + $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$blogListType)->orderBy("id","desc")->first(); |
| 1918 | if (!empty($webSettingNum)){ | 1884 | if (!empty($webSettingNum)){ |
| 1919 | $perPage = (int)$webSettingNum->num; | 1885 | $perPage = (int)$webSettingNum->num; |
| 1920 | }else{ | 1886 | }else{ |
| @@ -1978,7 +1944,7 @@ Disallow: /"; | @@ -1978,7 +1944,7 @@ Disallow: /"; | ||
| 1978 | */ | 1944 | */ |
| 1979 | public function getUpdateProgress($projectId,$type) | 1945 | public function getUpdateProgress($projectId,$type) |
| 1980 | { | 1946 | { |
| 1981 | - $updateProgressQuery = UpdateProgressModel::where("project_id",(int)$projectId)->orderBy("id","desc"); | 1947 | + $updateProgressQuery = UpdateProgress::where("project_id",(int)$projectId)->orderBy("id","desc"); |
| 1982 | if ($type == "master_website"){ | 1948 | if ($type == "master_website"){ |
| 1983 | $updateProgressQuery = $updateProgressQuery->where("type",1)->first(); | 1949 | $updateProgressQuery = $updateProgressQuery->where("type",1)->first(); |
| 1984 | }else{ | 1950 | }else{ |
| @@ -4,6 +4,8 @@ | @@ -4,6 +4,8 @@ | ||
| 4 | namespace App\Services\Html; | 4 | namespace App\Services\Html; |
| 5 | 5 | ||
| 6 | use App\Models\Blog\Blog; | 6 | use App\Models\Blog\Blog; |
| 7 | +use App\Models\CustomModule\CustomModule; | ||
| 8 | +use App\Models\Domain\DomainInfo; | ||
| 7 | use App\Models\Module\Module; | 9 | use App\Models\Module\Module; |
| 8 | use App\Models\News\News; | 10 | use App\Models\News\News; |
| 9 | use App\Models\News\NewsCategory; | 11 | use App\Models\News\NewsCategory; |
| @@ -11,9 +13,10 @@ use App\Models\Product\Category; | @@ -11,9 +13,10 @@ use App\Models\Product\Category; | ||
| 11 | use App\Models\Product\Keyword; | 13 | use App\Models\Product\Keyword; |
| 12 | use App\Models\Product\Product; | 14 | use App\Models\Product\Product; |
| 13 | use App\Models\Project\DeployBuild; | 15 | use App\Models\Project\DeployBuild; |
| 14 | -use App\Models\Project\DomainInfo; | ||
| 15 | use App\Models\Project\Project; | 16 | use App\Models\Project\Project; |
| 16 | -use App\Models\RouteMap; | 17 | +use App\Models\RouteMap\RouteMap; |
| 18 | +use App\Models\Template\BCustomTemplate; | ||
| 19 | +use App\Models\WebSetting\SettingNum; | ||
| 17 | use App\Models\WebSetting\WebCustom; | 20 | use App\Models\WebSetting\WebCustom; |
| 18 | use App\Models\WebSetting\WebLanguage; | 21 | use App\Models\WebSetting\WebLanguage; |
| 19 | use App\Models\WebSetting\WebSettingNum; | 22 | use App\Models\WebSetting\WebSettingNum; |
| @@ -38,7 +41,6 @@ class CreateSitemapService{ | @@ -38,7 +41,6 @@ class CreateSitemapService{ | ||
| 38 | if (empty($domainInfo) || $domain == "demo.globalso.site"){ | 41 | if (empty($domainInfo) || $domain == "demo.globalso.site"){ |
| 39 | return true; | 42 | return true; |
| 40 | } | 43 | } |
| 41 | - | ||
| 42 | $lang = $lang=="en" || $lang=="" ? "" : "/".$lang; | 44 | $lang = $lang=="en" || $lang=="" ? "" : "/".$lang; |
| 43 | $page = $page == null || (int)$page == 1 ? null : "/".(int)$page; | 45 | $page = $page == null || (int)$page == 1 ? null : "/".(int)$page; |
| 44 | if (!empty($routerMap)){ | 46 | if (!empty($routerMap)){ |
| @@ -510,7 +512,7 @@ tr.stripe { background-color:#f7f7f7; } | @@ -510,7 +512,7 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 510 | $count = Product::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$productCategoryItem->source_id.",%")->where("status",1)->count(); | 512 | $count = Product::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$productCategoryItem->source_id.",%")->where("status",1)->count(); |
| 511 | $innerNum++; | 513 | $innerNum++; |
| 512 | if ($count >= 1){ | 514 | if ($count >= 1){ |
| 513 | - $webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$productListType)->orderBy("id","desc")->first(); | 515 | + $webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$productListType)->orderBy("id","desc")->first(); |
| 514 | if (!empty($webSettingNum)){ | 516 | if (!empty($webSettingNum)){ |
| 515 | $categoryNum = (int)$webSettingNum->num; | 517 | $categoryNum = (int)$webSettingNum->num; |
| 516 | }else{ | 518 | }else{ |
| @@ -599,7 +601,7 @@ tr.stripe { background-color:#f7f7f7; } | @@ -599,7 +601,7 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 599 | $count = Product::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$productCategoryItem->source_id.",%")->where("status",1)->count(); | 601 | $count = Product::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$productCategoryItem->source_id.",%")->where("status",1)->count(); |
| 600 | $innerNum++; | 602 | $innerNum++; |
| 601 | if ($count >= 1){ | 603 | if ($count >= 1){ |
| 602 | - $webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$productListType)->orderBy("id","desc")->first(); | 604 | + $webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$productListType)->orderBy("id","desc")->first(); |
| 603 | if (!empty($webSettingNum)){ | 605 | if (!empty($webSettingNum)){ |
| 604 | $categoryNum = (int)$webSettingNum->num; | 606 | $categoryNum = (int)$webSettingNum->num; |
| 605 | }else{ | 607 | }else{ |
| @@ -692,37 +694,6 @@ tr.stripe { background-color:#f7f7f7; } | @@ -692,37 +694,6 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 692 | $innerNum = 0; | 694 | $innerNum = 0; |
| 693 | $xmlInnerDom = ""; | 695 | $xmlInnerDom = ""; |
| 694 | if (!empty($productKeywordInfo['productKeywordListInfo'])){ | 696 | if (!empty($productKeywordInfo['productKeywordListInfo'])){ |
| 695 | - //关键词列表页sitemap | ||
| 696 | -// foreach ($productKeywordInfo['productKeywordListInfo'] as $v){ | ||
| 697 | -// if ($v["total"]>=1){ | ||
| 698 | -// $isExistFile = $this->isExistHtmlFile($item['domain'],"",null,$v["route"],null); | ||
| 699 | -// if ($isExistFile){ | ||
| 700 | -// $innerNum++ ; | ||
| 701 | -// $url = 'https://'.$domain.'/'.$v["route"].'/'; | ||
| 702 | -// $xmlInnerDom .= $this->getUrlStr($url); | ||
| 703 | -// } | ||
| 704 | -// for ($j = 2; $j <= $v["total"]; $j++) { | ||
| 705 | -// $isExistFile = $this->isExistHtmlFile($item['domain'],"",null,$v["route"],$j); | ||
| 706 | -// if ($isExistFile){ | ||
| 707 | -// $innerNum++; | ||
| 708 | -// $url = 'https://'.$domain.'/'.$v["route"].'/'.$j.'/'; | ||
| 709 | -// $xmlInnerDom .= $this->getUrlStr($url); | ||
| 710 | -// } | ||
| 711 | -// if ($innerNum == $this->perPage){ | ||
| 712 | -// $sitemapXmlDom = $sitemapHeader.$xmlInnerDom.$sitemapFooter; | ||
| 713 | -// $botNum = $outerNum+1 == 1 ? "" : "_".($outerNum+1); | ||
| 714 | -// $sitemapPath = public_path($domain."/product_keywords".$botNum."_sitemap.xml"); | ||
| 715 | -// $this->putSitemapFile($sitemapPath,$sitemapXmlDom); | ||
| 716 | -// $xmlInnerDom = ''; | ||
| 717 | -// $urlXml = 'https://'.$domain.'/product_keywords'.$botNum.'_sitemap.xml'; | ||
| 718 | -// $sitemapMain .= $this->getUrlStr($urlXml); | ||
| 719 | -// $innerNum = 0; | ||
| 720 | -// $outerNum++; | ||
| 721 | -// } | ||
| 722 | -// } | ||
| 723 | -// } | ||
| 724 | -// } | ||
| 725 | - | ||
| 726 | //关键词详情页sitemap | 697 | //关键词详情页sitemap |
| 727 | $keywordData = $keywordModel->where("project_id",$item["project_id"])->where("status",1)->get(); | 698 | $keywordData = $keywordModel->where("project_id",$item["project_id"])->where("status",1)->get(); |
| 728 | if (!empty($keywordData)){ | 699 | if (!empty($keywordData)){ |
| @@ -776,61 +747,6 @@ tr.stripe { background-color:#f7f7f7; } | @@ -776,61 +747,6 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 776 | $innerNum = 0; | 747 | $innerNum = 0; |
| 777 | $xmlInnerDom = ""; | 748 | $xmlInnerDom = ""; |
| 778 | if (!empty($productKeywordInfo['productKeywordListInfo'])){ | 749 | if (!empty($productKeywordInfo['productKeywordListInfo'])){ |
| 779 | - //关键词列表页sitemap | ||
| 780 | -// foreach ($productKeywordInfo['productKeywordListInfo'] as $v){ | ||
| 781 | -// if ($v["total"]>=1){ | ||
| 782 | -// $innerNum++ ; | ||
| 783 | -// if ($linkingFormat == 1){ | ||
| 784 | -// $langAlias = $webCountry->short == "en" ? "" : $webCountry->short."/"; | ||
| 785 | -// $isExistFile = $this->isExistHtmlFile($item['domain'],$webCountry->short,null,$v["route"],null); | ||
| 786 | -// if ($isExistFile){ | ||
| 787 | -// $url = 'https://'.$domain.'/'.$langAlias.$v["route"].'/'; | ||
| 788 | -// $xmlInnerDom .= $this->getUrlStr($url); | ||
| 789 | -// } | ||
| 790 | -// }else{ | ||
| 791 | -// $domain_top = $this->getDoMain($domain); | ||
| 792 | -// $isExistFile = $this->isExistHtmlFile($item['domain'],$webCountry->short,null,$v["route"],null); | ||
| 793 | -// if ($isExistFile){ | ||
| 794 | -// $url = 'https://'.$webCountry->short.'.'.$domain_top.'/'.$v["route"].'/'; | ||
| 795 | -// $xmlInnerDom .= $this->getUrlStr($url); | ||
| 796 | -// } | ||
| 797 | -// } | ||
| 798 | -// | ||
| 799 | -// for ($j = 2; $j <= $v["total"]; $j++) { | ||
| 800 | -// if ($linkingFormat == 1){ | ||
| 801 | -// $langAlias = $webCountry->short == "en" ? "" : $webCountry->short."/"; | ||
| 802 | -// $isExistFile = $this->isExistHtmlFile($item['domain'],$webCountry->short,null,$v["route"],$j); | ||
| 803 | -// if ($isExistFile){ | ||
| 804 | -// $innerNum++; | ||
| 805 | -// $url = 'https://'.$domain.'/'.$langAlias.$v["route"].'/'.$j.'/'; | ||
| 806 | -// $xmlInnerDom .= $this->getUrlStr($url); | ||
| 807 | -// } | ||
| 808 | -// }else{ | ||
| 809 | -// $isExistFile = $this->isExistHtmlFile($item['domain'],$webCountry->short,null,$v["route"],$j); | ||
| 810 | -// if ($isExistFile){ | ||
| 811 | -// $innerNum++; | ||
| 812 | -// $domain_top = $this->getDoMain($domain); | ||
| 813 | -// $url = 'https://'.$webCountry->short.'.'.$domain_top.'/'.$v["route"].'/'.$j.'/'; | ||
| 814 | -// $xmlInnerDom .= $this->getUrlStr($url); | ||
| 815 | -// } | ||
| 816 | -// } | ||
| 817 | -// | ||
| 818 | -// if ($innerNum == $this->perPage){ | ||
| 819 | -// $botNum = $outerNum+1 == 1 ? "" : "_".($outerNum+1); | ||
| 820 | -// $sitemapXmlDom = $sitemapHeader.$xmlInnerDom.$sitemapFooter; | ||
| 821 | -// $sitemapPath = public_path($domain."/product_keywords_".$webCountry->short."_trans".$botNum."_sitemap.xml"); | ||
| 822 | -// $this->putSitemapFile($sitemapPath,$sitemapXmlDom); | ||
| 823 | -// $xmlInnerDom = ''; | ||
| 824 | -// $urlXml = 'https://'.$domain.'/product_keywords_'.$webCountry->short.'_trans'.$botNum.'_sitemap.xml'; | ||
| 825 | -// $sitemapMain .= $this->getUrlStr($urlXml); | ||
| 826 | -// $innerNum = 0; | ||
| 827 | -// $outerNum++; | ||
| 828 | -// } | ||
| 829 | -// } | ||
| 830 | -// } | ||
| 831 | -// | ||
| 832 | -// } | ||
| 833 | - | ||
| 834 | //关键词详情页sitemap | 750 | //关键词详情页sitemap |
| 835 | $keywordData = $keywordModel->where("project_id",$item["project_id"])->where("status",1)->get(); | 751 | $keywordData = $keywordModel->where("project_id",$item["project_id"])->where("status",1)->get(); |
| 836 | if (!empty($keywordData)){ | 752 | if (!empty($keywordData)){ |
| @@ -891,10 +807,10 @@ tr.stripe { background-color:#f7f7f7; } | @@ -891,10 +807,10 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 891 | $botNum = $outerNum+1 == 1 ? "" : "_".($outerNum+1); | 807 | $botNum = $outerNum+1 == 1 ? "" : "_".($outerNum+1); |
| 892 | $moduleCategoryUrlItem = ''; | 808 | $moduleCategoryUrlItem = ''; |
| 893 | foreach ($moduleCategory as $moduleCategoryItem){ | 809 | foreach ($moduleCategory as $moduleCategoryItem){ |
| 894 | - $count = Module::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$moduleCategoryItem->source_id.",%")->where("status",0)->count(); | 810 | + $count = CustomModule::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$moduleCategoryItem->source_id.",%")->where("status",0)->count(); |
| 895 | $innerNum++; | 811 | $innerNum++; |
| 896 | if ($count >= 1){ | 812 | if ($count >= 1){ |
| 897 | - $webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first(); | 813 | + $webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first(); |
| 898 | if (!empty($webSettingNum)){ | 814 | if (!empty($webSettingNum)){ |
| 899 | $categoryNum = (int)$webSettingNum->num; | 815 | $categoryNum = (int)$webSettingNum->num; |
| 900 | }else{ | 816 | }else{ |
| @@ -966,7 +882,7 @@ tr.stripe { background-color:#f7f7f7; } | @@ -966,7 +882,7 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 966 | } | 882 | } |
| 967 | $innerNum++; | 883 | $innerNum++; |
| 968 | if ($count >= 1){ | 884 | if ($count >= 1){ |
| 969 | - $webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first(); | 885 | + $webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first(); |
| 970 | if (!empty($webSettingNum)){ | 886 | if (!empty($webSettingNum)){ |
| 971 | $categoryNum = (int)$webSettingNum->num; | 887 | $categoryNum = (int)$webSettingNum->num; |
| 972 | }else{ | 888 | }else{ |
| @@ -1049,7 +965,7 @@ tr.stripe { background-color:#f7f7f7; } | @@ -1049,7 +965,7 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 1049 | $newsCategoryUrlItem .= $this->getUrlStr($url); | 965 | $newsCategoryUrlItem .= $this->getUrlStr($url); |
| 1050 | } | 966 | } |
| 1051 | } | 967 | } |
| 1052 | - $webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first(); | 968 | + $webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first(); |
| 1053 | if (!empty($webSettingNum)){ | 969 | if (!empty($webSettingNum)){ |
| 1054 | $categoryNum = (int)$webSettingNum->num; | 970 | $categoryNum = (int)$webSettingNum->num; |
| 1055 | }else{ | 971 | }else{ |
| @@ -1096,7 +1012,7 @@ tr.stripe { background-color:#f7f7f7; } | @@ -1096,7 +1012,7 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 1096 | $count = News::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$newsCategoryItem->source_id.",%")->where("status",1)->count(); | 1012 | $count = News::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$newsCategoryItem->source_id.",%")->where("status",1)->count(); |
| 1097 | $innerNum++; | 1013 | $innerNum++; |
| 1098 | if ($count >= 1){ | 1014 | if ($count >= 1){ |
| 1099 | - $webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first(); | 1015 | + $webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first(); |
| 1100 | if (!empty($webSettingNum)){ | 1016 | if (!empty($webSettingNum)){ |
| 1101 | $categoryNum = (int)$webSettingNum->num; | 1017 | $categoryNum = (int)$webSettingNum->num; |
| 1102 | }else{ | 1018 | }else{ |
| @@ -1177,8 +1093,8 @@ tr.stripe { background-color:#f7f7f7; } | @@ -1177,8 +1093,8 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 1177 | $data = RouteMap::where("project_id",$item["project_id"])->where("source","module")->offset($offset)->limit($perPage)->get(); | 1093 | $data = RouteMap::where("project_id",$item["project_id"])->where("source","module")->offset($offset)->limit($perPage)->get(); |
| 1178 | if (!empty($data)){ | 1094 | if (!empty($data)){ |
| 1179 | foreach ($data as $j){ | 1095 | foreach ($data as $j){ |
| 1180 | - $module_detail = Module::where("project_id",$item["project_id"])->where("id",$j->source_id)->where("status",0)->first(); | ||
| 1181 | - $moduleAndCategoryInfo = Module::getModuleCategory($item["project_id"],$module_detail); | 1096 | + $module_detail = CustomModule::where("project_id",$item["project_id"])->where("id",$j->source_id)->where("status",0)->first(); |
| 1097 | + $moduleAndCategoryInfo = CustomModule::getModuleCategory($item["project_id"],$module_detail); | ||
| 1182 | if (!empty($module_detail) && !empty($moduleAndCategoryInfo)){ | 1098 | if (!empty($module_detail) && !empty($moduleAndCategoryInfo)){ |
| 1183 | $isExistFile = $this->isExistHtmlFile($item['domain'],"",$j,$j->route,null); | 1099 | $isExistFile = $this->isExistHtmlFile($item['domain'],"",$j,$j->route,null); |
| 1184 | if ($isExistFile){ | 1100 | if ($isExistFile){ |
| @@ -1334,7 +1250,7 @@ tr.stripe { background-color:#f7f7f7; } | @@ -1334,7 +1250,7 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 1334 | $count = Blog::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$blogCategoryItem->source_id.",%")->where("status",1)->count(); | 1250 | $count = Blog::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$blogCategoryItem->source_id.",%")->where("status",1)->count(); |
| 1335 | $innerNum++; | 1251 | $innerNum++; |
| 1336 | if ($count >= 1){ | 1252 | if ($count >= 1){ |
| 1337 | - $webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$blogListType)->orderBy("id","desc")->first(); | 1253 | + $webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$blogListType)->orderBy("id","desc")->first(); |
| 1338 | if (!empty($webSettingNum)){ | 1254 | if (!empty($webSettingNum)){ |
| 1339 | $categoryNum = (int)$webSettingNum->num; | 1255 | $categoryNum = (int)$webSettingNum->num; |
| 1340 | }else{ | 1256 | }else{ |
| @@ -1403,7 +1319,7 @@ tr.stripe { background-color:#f7f7f7; } | @@ -1403,7 +1319,7 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 1403 | $count = Blog::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$blogCategoryItem->source_id.",%")->where("status",1)->count(); | 1319 | $count = Blog::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$blogCategoryItem->source_id.",%")->where("status",1)->count(); |
| 1404 | $innerNum++; | 1320 | $innerNum++; |
| 1405 | if ($count >= 1){ | 1321 | if ($count >= 1){ |
| 1406 | - $webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$blogListType)->orderBy("id","desc")->first(); | 1322 | + $webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$blogListType)->orderBy("id","desc")->first(); |
| 1407 | if (!empty($webSettingNum)){ | 1323 | if (!empty($webSettingNum)){ |
| 1408 | $categoryNum = (int)$webSettingNum->num; | 1324 | $categoryNum = (int)$webSettingNum->num; |
| 1409 | }else{ | 1325 | }else{ |
| @@ -1578,7 +1494,7 @@ tr.stripe { background-color:#f7f7f7; } | @@ -1578,7 +1494,7 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 1578 | $data = RouteMap::where("project_id",$item["project_id"])->where("source","page")->where("route","!=","index")->offset($offset)->limit($perPage)->get(); | 1494 | $data = RouteMap::where("project_id",$item["project_id"])->where("source","page")->where("route","!=","index")->offset($offset)->limit($perPage)->get(); |
| 1579 | if (!empty($data)){ | 1495 | if (!empty($data)){ |
| 1580 | foreach ($data as $j){ | 1496 | foreach ($data as $j){ |
| 1581 | - $customPage = WebCustom::where("project_id",$j->project_id)->where("status",1)->where("url",$j->route)->first(); | 1497 | + $customPage = BCustomTemplate::where("project_id",$j->project_id)->where("status",1)->where("url",$j->route)->first(); |
| 1582 | if (!empty($customPage)){ | 1498 | if (!empty($customPage)){ |
| 1583 | if ($j->route != '404'){ | 1499 | if ($j->route != '404'){ |
| 1584 | $isExistFile = $this->isExistHtmlFile($item['domain'],"",$j,$j->route,null); | 1500 | $isExistFile = $this->isExistHtmlFile($item['domain'],"",$j,$j->route,null); |
| @@ -1825,7 +1741,7 @@ tr.stripe { background-color:#f7f7f7; } | @@ -1825,7 +1741,7 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 1825 | foreach ($sitemapType as $type){ | 1741 | foreach ($sitemapType as $type){ |
| 1826 | if ($type == "product_category"){ | 1742 | if ($type == "product_category"){ |
| 1827 | //产品分类 | 1743 | //产品分类 |
| 1828 | - $webSettingNum = WebSettingNum::where("project_id",$projectId)->where("type",WebSettingNum::$productListType)->orderBy("id","desc")->first(); | 1744 | + $webSettingNum = SettingNum::where("project_id",$projectId)->where("type",SettingNum::$productListType)->orderBy("id","desc")->first(); |
| 1829 | if (!empty($webSettingNum)){ | 1745 | if (!empty($webSettingNum)){ |
| 1830 | $productCategoryNum = (int)$webSettingNum->num; | 1746 | $productCategoryNum = (int)$webSettingNum->num; |
| 1831 | }else{ | 1747 | }else{ |
| @@ -1846,7 +1762,7 @@ tr.stripe { background-color:#f7f7f7; } | @@ -1846,7 +1762,7 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 1846 | $allTypeRouteCountAndPageInfo[$type]["page_total"] = $productTotal; | 1762 | $allTypeRouteCountAndPageInfo[$type]["page_total"] = $productTotal; |
| 1847 | }else if ($type == "news_category"){ | 1763 | }else if ($type == "news_category"){ |
| 1848 | //新闻分类 | 1764 | //新闻分类 |
| 1849 | - $webSettingNum = WebSettingNum::where("project_id",$projectId)->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first(); | 1765 | + $webSettingNum = SettingNum::where("project_id",$projectId)->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first(); |
| 1850 | if (!empty($webSettingNum)){ | 1766 | if (!empty($webSettingNum)){ |
| 1851 | $newsCategoryNum = (int)$webSettingNum->num; | 1767 | $newsCategoryNum = (int)$webSettingNum->num; |
| 1852 | }else{ | 1768 | }else{ |
| @@ -1866,7 +1782,7 @@ tr.stripe { background-color:#f7f7f7; } | @@ -1866,7 +1782,7 @@ tr.stripe { background-color:#f7f7f7; } | ||
| 1866 | $allTypeRouteCountAndPageInfo[$type]["page_total"] = $newsTotal; | 1782 | $allTypeRouteCountAndPageInfo[$type]["page_total"] = $newsTotal; |
| 1867 | }else if ($type == "blog_category"){ | 1783 | }else if ($type == "blog_category"){ |
| 1868 | //博客分类 | 1784 | //博客分类 |
| 1869 | - $webSettingNum = WebSettingNum::where("project_id",$projectId)->where("type",WebSettingNum::$blogListType)->orderBy("id","desc")->first(); | 1785 | + $webSettingNum = SettingNum::where("project_id",$projectId)->where("type",WebSettingNum::$blogListType)->orderBy("id","desc")->first(); |
| 1870 | if (!empty($webSettingNum)){ | 1786 | if (!empty($webSettingNum)){ |
| 1871 | $blogCategoryNum = (int)$webSettingNum->num; | 1787 | $blogCategoryNum = (int)$webSettingNum->num; |
| 1872 | }else{ | 1788 | }else{ |
| @@ -3,10 +3,11 @@ | @@ -3,10 +3,11 @@ | ||
| 3 | 3 | ||
| 4 | namespace App\Services\Html; | 4 | namespace App\Services\Html; |
| 5 | 5 | ||
| 6 | +use App\Models\Domain\DomainInfo; | ||
| 6 | use App\Models\Project\DeleteHtmlModel; | 7 | use App\Models\Project\DeleteHtmlModel; |
| 7 | use App\Models\Project\DeployBuild; | 8 | use App\Models\Project\DeployBuild; |
| 8 | use App\Models\Project\DeployOptimize; | 9 | use App\Models\Project\DeployOptimize; |
| 9 | -use App\Models\Project\DomainInfo; | 10 | +use App\Models\RouteMap\RouteDelete; |
| 10 | use App\Models\WebSetting\WebSetting; | 11 | use App\Models\WebSetting\WebSetting; |
| 11 | use Illuminate\Support\Facades\Redis; | 12 | use Illuminate\Support\Facades\Redis; |
| 12 | 13 | ||
| @@ -121,7 +122,7 @@ class DeletePageService{ | @@ -121,7 +122,7 @@ class DeletePageService{ | ||
| 121 | if (file_exists($path)){ | 122 | if (file_exists($path)){ |
| 122 | $this->deleteDirectory($path); | 123 | $this->deleteDirectory($path); |
| 123 | } | 124 | } |
| 124 | - DeleteHtmlModel::where("project_id",$data->project_id)->where("route",$v->route)->delete(); | 125 | + RouteDelete::where("project_id",$data->project_id)->where("route",$v->route)->delete(); |
| 125 | } | 126 | } |
| 126 | } | 127 | } |
| 127 | 128 |
| @@ -9,7 +9,7 @@ use App\Models\Blog\BlogCategory; | @@ -9,7 +9,7 @@ use App\Models\Blog\BlogCategory; | ||
| 9 | use App\Models\Module\CustomModuleExtendContent; | 9 | use App\Models\Module\CustomModuleExtendContent; |
| 10 | use App\Models\Module\Module; | 10 | use App\Models\Module\Module; |
| 11 | use App\Models\Module\ModuleCategory; | 11 | use App\Models\Module\ModuleCategory; |
| 12 | -use App\Models\News\News; | 12 | +use App\Models\Nav\BNav; |
| 13 | use App\Models\News\NewsCategory; | 13 | use App\Models\News\NewsCategory; |
| 14 | use App\Models\Product\Category; | 14 | use App\Models\Product\Category; |
| 15 | use App\Models\Product\CategoryRelated; | 15 | use App\Models\Product\CategoryRelated; |
| @@ -22,7 +22,7 @@ use App\Models\Project\DeployBuild; | @@ -22,7 +22,7 @@ use App\Models\Project\DeployBuild; | ||
| 22 | use App\Models\Project\Project; | 22 | use App\Models\Project\Project; |
| 23 | use App\Models\Project\ProjectPageSetting; | 23 | use App\Models\Project\ProjectPageSetting; |
| 24 | use App\Models\Project\VisualizationHtml; | 24 | use App\Models\Project\VisualizationHtml; |
| 25 | -use App\Models\RouteMap; | 25 | +use App\Models\RouteMap\RouteMap; |
| 26 | use App\Models\Service\Service; | 26 | use App\Models\Service\Service; |
| 27 | use App\Models\Template\BSetting; | 27 | use App\Models\Template\BSetting; |
| 28 | use App\Models\Template\TemplateTypeMain; | 28 | use App\Models\Template\TemplateTypeMain; |
| @@ -30,8 +30,6 @@ use App\Models\Template\WebTemplateMain; | @@ -30,8 +30,6 @@ use App\Models\Template\WebTemplateMain; | ||
| 30 | use App\Models\WebSetting\AggregationSetting; | 30 | use App\Models\WebSetting\AggregationSetting; |
| 31 | use App\Models\WebSetting\WebCustom; | 31 | use App\Models\WebSetting\WebCustom; |
| 32 | use App\Models\WebSetting\WebLanguage; | 32 | use App\Models\WebSetting\WebLanguage; |
| 33 | -use App\Models\WebSetting\WebNav; | ||
| 34 | -use App\Models\WebSetting\WebNavGroup; | ||
| 35 | use App\Models\WebSetting\WebSetting; | 33 | use App\Models\WebSetting\WebSetting; |
| 36 | use App\Models\WebSetting\WebSettingImage; | 34 | use App\Models\WebSetting\WebSettingImage; |
| 37 | use App\Models\WebSetting\WebSettingNum; | 35 | use App\Models\WebSetting\WebSettingNum; |
| @@ -147,14 +145,7 @@ class PageService{ | @@ -147,14 +145,7 @@ class PageService{ | ||
| 147 | $blockDescDom = $navNumModule->find("[blockdesc]")->eq(0); | 145 | $blockDescDom = $navNumModule->find("[blockdesc]")->eq(0); |
| 148 | $dataNavType = $dataNavType == null || $dataNavType=="" || $dataNavType=="default" ? 1 : (int)$dataNavType; | 146 | $dataNavType = $dataNavType == null || $dataNavType=="" || $dataNavType=="default" ? 1 : (int)$dataNavType; |
| 149 | if (count($blockItemOuterDom) != 0){ | 147 | if (count($blockItemOuterDom) != 0){ |
| 150 | -// $nav = null; | ||
| 151 | -// $flattenedArray = WebNavGroup::getNavGroupSortListByID($projectId,$dataNavType); | ||
| 152 | -// if (!empty($flattenedArray)){ | ||
| 153 | -// $nav = WebNav::where("project_id",$projectId)->whereIn('id', $flattenedArray)->orderByRaw(DB::raw("FIELD(id, " . implode(",", $flattenedArray) . ")"))->where("group_id",$dataNavType)->where("status",1)->get(); | ||
| 154 | -// }else{ | ||
| 155 | -// $nav = WebNav::where("project_id",$projectId)->where("group_id",$dataNavType)->orderBy("sort","desc")->orderBy("id","desc")->where("status",1)->get(); | ||
| 156 | -// } | ||
| 157 | - $nav = WebNav::where("project_id",$projectId)->where("group_id",$dataNavType)->orderBy("sort","asc")->orderBy("id","asc")->where("status",1)->get(); | 148 | + $nav = BNav::where("project_id",$projectId)->where("group_id",$dataNavType)->orderBy("sort","asc")->orderBy("id","asc")->where("status",1)->get(); |
| 158 | if (!empty($nav)){ | 149 | if (!empty($nav)){ |
| 159 | //菜单第一种递归 | 150 | //菜单第一种递归 |
| 160 | // $nav = $this->tree($nav->toArray()); | 151 | // $nav = $this->tree($nav->toArray()); |
| @@ -715,12 +706,6 @@ class PageService{ | @@ -715,12 +706,6 @@ class PageService{ | ||
| 715 | if((int)$dataNavModule != 0){ | 706 | if((int)$dataNavModule != 0){ |
| 716 | $dataNavType = $countryDom->eq($i)->attr("data-nav-type"); | 707 | $dataNavType = $countryDom->eq($i)->attr("data-nav-type"); |
| 717 | $dataNavType = $dataNavType == null || $dataNavType=="" || $dataNavType=="default" ? 2 : (int)$dataNavType; | 708 | $dataNavType = $dataNavType == null || $dataNavType=="" || $dataNavType=="default" ? 2 : (int)$dataNavType; |
| 718 | -// $flattenedArray = WebNavGroup::getNavGroupSortListByID($projectId,$dataNavType); | ||
| 719 | -// if (!empty($flattenedArray)){ | ||
| 720 | -// $navData = WebNav::where("project_id",$projectId)->whereIn('id', $flattenedArray)->orderByRaw(DB::raw("FIELD(id, " . implode(",", $flattenedArray) . ")"))->get(); | ||
| 721 | -// }else{ | ||
| 722 | -// $navData = WebNav::where("project_id",$projectId)->where("group_id",$dataNavType)->orderBy("sort","desc")->orderBy("id","desc")->get(); | ||
| 723 | -// } | ||
| 724 | $navData = WebNav::where("project_id",$projectId)->where("group_id",$dataNavType)->orderBy("sort","asc")->orderBy("id","asc")->get(); | 709 | $navData = WebNav::where("project_id",$projectId)->where("group_id",$dataNavType)->orderBy("sort","asc")->orderBy("id","asc")->get(); |
| 725 | 710 | ||
| 726 | if (!empty($navData)){ | 711 | if (!empty($navData)){ |
-
请 注册 或 登录 后发表评论