作者 lyh

gx

... ... @@ -196,7 +196,56 @@ if (!function_exists('checkDomain')) {
}
}
if (!function_exists('page_init')) {
/**
* amp分页初始化
* @param $page
* @param $total
* @author Akun
* @date 2024/01/29 15:43
*/
function page_init($page, $total)
{
//中间页处理
$center_page = [];
if ($total <= 5) {
for ($i = 1; $i <= $total; $i++) {
$center_page[] = $i;
}
} else {
if ($page < 5) {
for ($i = 1; $i <= 5; $i++) {
$center_page[] = $i;
}
} else {
if ($page == $total) {
for ($i = $total - 5; $i <= $total; $i++) {
$center_page[] = $i;
}
} else if ($page <= $total) {
if ($total - $page <= 5) {
if ($total - $page == 1) {
for ($i = $total - 4; $i <= $total; $i++) {
$center_page[] = $i;
}
} else {
for ($i = $page - 2; $i <= $page + 2; $i++) {
$center_page[] = $i;
}
}
} else {
for ($i = $page - 2; $i <= $page + 2; $i++) {
$center_page[] = $i;
}
}
}
}
}
return $center_page;
}
}
/**
* 把返回的数据集转换成Tree
* @param $list array 数据列表
... ... @@ -240,6 +289,37 @@ function list_to_tree($list, $pk = 'id', $pid = 'pid', $child = '_child', $root
return $tree;
}
if (!function_exists('special2str')) {
/**
* 特殊字符串替换
* @param $str
* @return string|string[]
* @author Akun
* @date 2024/01/30 17:46
*/
function special2str($str)
{
if (strpos($str, ';') === false) {
return $str;
}
$list = [
'&lt;' => '<',
'&gt;' => '>',
'&amp;' => '&',
'&acute;' => '´',
'&quot;' => '“',
'&nbsp;' => ' '
];
foreach ($list as $k => $v) {
$str = str_replace($k, $v, $str);
}
return $str;
}
}
/**
* tree数据转list
* @param $tree
... ...
... ... @@ -7,4 +7,32 @@ use App\Models\Base;
class Notify extends Base
{
protected $table = 'gl_notify';
/**
* 状态 0:待处理, 1:路由生成完成, 2:页面生成完成
*/
const STATUS_INIT = 0;
const STATUS_FINISH_ROUTE = 1;
const STATUS_FINISH_PAGE = 2;
/**
* 类型 1:主站, 2:小语种
*/
const TYPE_MASTER = 1;
const TYPE_MINOR = 2;
/**
* 路由
* 1:所有路由,整站生成,
* 2:修改过内容的路由,按需生成,
* 3:指定路由,按url生成
* 4:生成聚合页生成
* 5:生成漏翻页面
* 6:生成视频聚合页
*/
const ROUTE_ALL = 1;
const ROUTE_NEED = 2;
const ROUTE_URL = 3;
const ROUTE_PRODUCT_KEYWORD = 4;
const ROUTE_NOT_TRANSLATE = 5;
const ROUTE_PRODUCT_VIDEO_KEYWORD = 6;
}
... ...
... ... @@ -10,10 +10,27 @@
namespace App\Models\CustomModule;
use App\Models\Base;
use App\Models\Module\ModuleCategory;
class CustomModule extends Base
{
protected $table = 'gl_custom_module';
//连接数据库
protected $connection = 'custom_mysql';
/**
* 根据模块查找自定义模块分类数据
*/
public static function getModuleCategory($projectId,$modules)
{
$moduleCategoryInfo = null;
if (isset($modules->category_id) && !empty($modules->category_id) && $modules->category_id != ",,"){
$cateArr = explode(",",$modules->category_id);
$cateArr = array_filter($cateArr);
if (!empty($cateArr)){
$cateId = (int)array_shift($cateArr);
$moduleCategoryInfo = CustomModuleCategory::getModuleCategoryAndExtendById($projectId,$cateId);
}
}
return $moduleCategoryInfo;
}
}
... ...
... ... @@ -16,4 +16,20 @@ class CustomModuleCategory extends Base
protected $table = 'gl_custom_module_category';
//连接数据库
protected $connection = 'custom_mysql';
/**
* 根据路由获取模块分类及模块信息
*/
public static function getModuleCategoryAndExtendByRoute($projectId,$route)
{
return self::with("getExtend")->where("project_id",$projectId)->where("route",$route)->where("status",0)->first();
}
/**
* 根据路由获取模块分类及模块信息
*/
public static function getModuleCategoryAndExtendById($projectId,$id)
{
return self::with("getExtend")->where("project_id",$projectId)->where("id",$id)->where("status",0)->first();
}
}
... ...
... ... @@ -17,4 +17,7 @@ class NewsCategory extends Base
const STATUS_SHOW = 0;
const STATUS_HIDE = 1;
//新闻分类,博客分类列表分页条数
public static $newsCategoryPagePercent = 10;
}
... ...
... ... @@ -21,6 +21,9 @@ class Category extends Base
protected $connection = 'custom_mysql';
const STATUS_ACTIVE = 1;
//新闻产品分类列表分页条数
public static $productCategoryPagePercent = 15;
public static $productSearchPagePercent = 12;
/**
* 获取指定分类的所有子分类IDS(包括自己)
... ... @@ -72,4 +75,33 @@ class Category extends Base
$count = count($productArr);
return $count;
}
/**
* 根据分类ID查询下面所有子级ID,递归
*/
public static function getAllSonCategoryById($projectId,$id): array
{
$ids = [];
$ids[] = $id;
self::getProductCategoryList($projectId,$id,$ids);
return $ids;
}
/**
* 获取分类
*/
public static function getProductCategoryList($projectId,$id,&$ids)
{
$categoryListPid = self::where("project_id",$projectId)->where("pid",$id)->get();
if (!empty($categoryListPid)){
foreach ($categoryListPid as $item){
$ids[] = $item->id;
self::getProductCategoryList($projectId,$item->id,$ids);
}
}else{
$ids[] = $categoryListPid->id;
}
return $ids;
}
}
... ...
... ... @@ -55,4 +55,13 @@ class Keyword extends Base
}
return $value ?: [];
}
/**
* 随机获取关键词列表
*/
public function getProductsKeywordsList($project)
{
return Keyword::where("project_id",$project->id)->where("status",1)->inRandomOrder()->take(10)->get();
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Models\Project;
use App\Models\Base;
use App\Models\WebSetting\WebSetting;
use Illuminate\Database\Eloquent\SoftDeletes;
class CountryCustom extends Base
... ... @@ -10,4 +11,14 @@ class CountryCustom extends Base
use SoftDeletes;
protected $table = 'gl_project_country_custom';
public static function getCountryCustomByProjectId($projectId){
if (Redis::get("project_" . $projectId . "_country_custom") == null) {
$countryCustomInfo = self::with("countryCustomLanguage")->where("project_id",$projectId)->where("status",1)->where("is_create",1)->get();
Redis::set("project_" . $projectId . "_country_custom", json_encode($countryCustomInfo));
Redis::expire("project_" . $projectId . "_country_custom", WebSetting::$redisExpireTime);
}
return json_decode(Redis::get("project_".$projectId."_country_custom"));
}
}
... ...
... ... @@ -14,7 +14,25 @@ class Project extends Base
{
//设置关联表名
protected $table = 'gl_project';
public static $domainEndSlash = 1; //斜杠结尾
public static $projectLocationZero = 0; //普通项目
public static $projectLocationDangerous = 1; //危险项目
public static $storageTypeZero = 0; //默认腾讯压缩存储桶
public static $storageTypeOne = 1; //非压缩存储桶
public static $storageTypeZeroFileFix = "ecdn6.globalso.com"; //非压缩存储桶
public static $storageTypeOneFileFix = "ecdn6-nc.globalso.com"; //压缩存储桶
public static $projectLocationDangerousFileFix = "globalso-v6.s3.us-west-2.amazonaws.com"; //危险项目存储桶
//项目标识集合
public static $blockItems = "blockitems"; //html循环项父级标识
public static $blockAttrItems = "[blockitems]"; //html循环项父级属性标识
public static $blockItem = "blockitem"; //html循环项标识
public static $blockAttrItem = "[blockitem]"; //html循环项属性标识
public static $productListBlock = "productlistblock"; //html产品列表标识
public static $newListBlock = "newlistblock"; //html新闻列表标识
public static $blogListBlock = "bloglistblock"; //html博客列表标识
public static $productCategoryListBlock = "productcategorylistblock"; //html产品分类列表标识
const DATABASE_NAME_FIX = 'gl_data_';
const CUSTOMIZED_ONE = 1;//定制项目
... ...
<?php
namespace App\Models\Project;
use Illuminate\Database\Eloquent\Model;
/**
* @method static where(string $string, int $param)
* @method static find($id)
* @method static get()
* @method static insertGetId()
* @method static create(array $array)
* @method static offset(float|int $param)
* @method static select(string $string)
* @method static orderBy(string $string, string $string1)
*/
class UpdateMasterWebsiteModel extends Model
{
protected $connection = "custom_mysql";
protected $table = 'gl_update_master_website';
}
... ...
<?php
namespace App\Models\Project;
use Illuminate\Database\Eloquent\Model;
/**
* @method static where(string $string, int $param)
* @method static find($id)
* @method static get()
* @method static insertGetId()
* @method static create(array $array)
* @method static select(string $string)
* @method static orderBy(string $string, string $string1)
*/
class UpdateMinorLanguagesModel extends Model
{
protected $connection = "custom_mysql";
protected $table = 'gl_update_minor_languages';
}
... ...
... ... @@ -25,4 +25,9 @@ class SettingNum extends Base
protected $table = 'gl_setting_num';
//连接数据库
protected $connection = 'custom_mysql';
//列表页种类
public static $productListType = 1;
public static $blogListType = 2;
public static $newsListType = 3;
}
... ...
... ... @@ -16,4 +16,8 @@ class Translate extends Base
protected $table = 'gl_translate';
//连接数据库
protected $connection = 'custom_mysql';
public static $textType = 1;
public static $imageType = 2;
}
... ...
... ... @@ -48,4 +48,31 @@ class WebLanguage extends Base
}
return $id;
}
/**
* 获取项目主语种
*/
public static function getProjectMainLang($mainLangId = 1)
{
$mainLang = self::find($mainLangId);
if (empty($mainLang)){
return null;
}
return $mainLang;
}
/**
* 关键词17种语种IDS
*/
public static function getKeywordsCountryIds($project = null): array
{
$languageIds = [1,4,5,6,7,8,9,10,11,14,15,18,22,26,40,68,78,95,99];
//加入项目主语种
if (!empty($project)){
$mainLangId = $project->main_lang_id;
array_unshift($languageIds,(int)$mainLangId);
}
return array_unique($languageIds);
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Models\WebSetting;
use App\Models\Base;
use Illuminate\Support\Facades\Redis;
class WebSetting extends Base
{
... ... @@ -12,5 +13,26 @@ class WebSetting extends Base
//连接数据库
protected $connection = 'custom_mysql';
//网站缓存过期时间
public static $redisExpireTime = 600;
public static $redisUpdateHtmlExpireTime = 60;
public static $okStatus = 200;
public static $errStatus = 500;
/**
* 网站设置
*/
public static function getWebSetting($project)
{
if (Redis::get("project_".$project->id."_web_setting") == null) {
$webSetting = self::where("project_id", $project->id)->first();
if (!empty($webSetting)) {
Redis::set("project_".$project->id."_web_setting", json_encode($webSetting->toArray()));
} else {
Redis::set("project_".$project->id."_web_setting", null);
}
Redis::expire("project_".$project->id."_web_setting", WebSetting::$redisExpireTime);
}
return json_decode(Redis::get("project_".$project->id."_web_setting"));
}
}
... ...
<?php
namespace App\Models\WebSetting;
use Illuminate\Database\Eloquent\Model;
/**
* @method static whereIn(string $string, false|string[] $explode)
* @method static where(string $string, mixed|string $lang)
*/
class WebSettingCountry extends Model
{
protected $table = 'gl_web_setting_country';
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Models\WebSetting;
use App\Models\Base;
use Illuminate\Support\Facades\Redis;
class WebSettingText extends Base
{
... ... @@ -27,4 +28,21 @@ class WebSettingText extends Base
self::TYPE_NEWS=>'新闻页',
self::TYPE_BLOG=>'博客页',
];
/**
* 网站锚文本
*/
public static function getWebSettingText($project)
{
if (Redis::get("project_".$project->id."_web_setting_text") == null) {
$webSettingText = WebSettingText::where("project_id",$project->id)->get();
if (!empty($webSettingText)) {
Redis::set("project_".$project->id."_web_setting_text", json_encode($webSettingText->toArray()));
} else {
Redis::set("project_".$project->id."_web_setting_text", null);
}
Redis::expire("project_".$project->id."_web_setting_text", WebSetting::$redisExpireTime);
}
return json_decode(Redis::get("project_".$project->id."_web_setting_text"));
}
}
... ...
<?php
namespace App\Repositories\Bt;
/**
* 宝塔面板站点操作类库
* @author 阿良 or Youngxj(二次开发)
* @link https://www.bt.cn/api-doc.pdf
* @link https://gitee.com/youngxj0/Bty1.0
* @version 1.0
* @example
* $bt = new Bt('http://127.0.0.1/8888','xxxxxxxxxxxxxxxx');
* echo $bt->GetSystemTotal();//获取系统基础统计
* @return Array
*/
class Bt
{
private $BT_KEY = ""; //接口密钥
private $BT_PANEL = "http://127.0.0.1/8888"; //面板地址
/**
* 初始化
* @param [type] $bt_panel 宝塔接口地址
* @param [type] $bt_key 宝塔Api密钥
*/
public function __construct($bt_panel = null,$bt_key = null){
if($bt_panel) $this->BT_PANEL = $bt_panel;
if($bt_key) $this->BT_KEY = $bt_key;
}
/**
* 获取系统基础统计
*/
public function GetSystemTotal(){
$url = $this->BT_PANEL.$this->config("GetSystemTotal");
$p_data = $this->GetKeyData();
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取磁盘分区信息
*/
public function GetDiskInfo(){
$url = $this->BT_PANEL.$this->config("GetDiskInfo");
$p_data = $this->GetKeyData();
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取实时状态信息
* (CPU、内存、网络、负载)
*/
public function GetNetWork(){
$url = $this->BT_PANEL.$this->config("GetNetWork");
$p_data = $this->GetKeyData();
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 检查是否有安装任务
*/
public function GetTaskCount(){
$url = $this->BT_PANEL.$this->config("GetTaskCount");
$p_data = $this->GetKeyData();
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 检查面板更新
*/
public function UpdatePanel($check=false,$force=false){
$url = $this->BT_PANEL.$this->config("UpdatePanel");
$p_data = $this->GetKeyData();
$p_data['check'] = $check;
$p_data['force'] = $force;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 申请ssl
*/
public function ApplyCert($domains,$id){
$url = $this->BT_PANEL.$this->config("ApplyCert");
$p_data = $this->GetKeyData();
$p_data['domains'] = $domains;
$p_data['auth_type'] = "http";
$p_data['auth_to'] = $id;
$p_data['auto_wildcard'] = 0;
$p_data['id'] = $id;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 续签ssl
*/
public function RenewCert($index){
$url = $this->BT_PANEL.$this->config("RenewCert");
$p_data = $this->GetKeyData();
$p_data['index'] = $index;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站列表
* @param string $page 当前分页
* @param string $limit 取出的数据行数
* @param string $type 分类标识 -1: 分部分类 0: 默认分类
* @param string $order 排序规则 使用 id 降序:id desc 使用名称升序:name desc
* @param string $tojs 分页 JS 回调,若不传则构造 URI 分页连接
* @param string $search 搜索内容
*/
public function Websites($search='',$page='1',$limit='15',$type='-1',$order='id desc',$tojs=''){
$url = $this->BT_PANEL.$this->config("Websites");
$p_data = $this->GetKeyData();
$p_data['p'] = $page;
$p_data['limit'] = $limit;
$p_data['type'] = $type;
$p_data['order'] = $order;
$p_data['tojs'] = $tojs;
$p_data['search'] = $search;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站FTP列表
* @param string $page 当前分页
* @param string $limit 取出的数据行数
* @param string $type 分类标识 -1: 分部分类 0: 默认分类
* @param string $order 排序规则 使用 id 降序:id desc 使用名称升序:name desc
* @param string $tojs 分页 JS 回调,若不传则构造 URI 分页连接
* @param string $search 搜索内容
*/
public function WebFtpList($search='',$page='1',$limit='15',$type='-1',$order='id desc',$tojs=''){
$url = $this->BT_PANEL.$this->config("WebFtpList");
$p_data = $this->GetKeyData();
$p_data['p'] = $page;
$p_data['limit'] = $limit;
$p_data['type'] = $type;
$p_data['order'] = $order;
$p_data['tojs'] = $tojs;
$p_data['search'] = $search;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站SQL列表
* @param string $page 当前分页
* @param string $limit 取出的数据行数
* @param string $type 分类标识 -1: 分部分类 0: 默认分类
* @param string $order 排序规则 使用 id 降序:id desc 使用名称升序:name desc
* @param string $tojs 分页 JS 回调,若不传则构造 URI 分页连接
* @param string $search 搜索内容
*/
public function WebSqlList($search='',$page='1',$limit='15',$type='-1',$order='id desc',$tojs=''){
$url = $this->BT_PANEL.$this->config("WebSqlList");
$p_data = $this->GetKeyData();
$p_data['p'] = $page;
$p_data['limit'] = $limit;
$p_data['type'] = $type;
$p_data['order'] = $order;
$p_data['tojs'] = $tojs;
$p_data['search'] = $search;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取所有网站分类
*/
public function Webtypes(){
$url = $this->BT_PANEL.$this->config("Webtypes");
$p_data = $this->GetKeyData();
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取已安装的 PHP 版本列表
*/
public function GetPHPVersion(){
//拼接URL地址
$url = $this->BT_PANEL.$this->config("GetPHPVersion");
//准备POST数据
$p_data = $this->GetKeyData(); //取签名
//请求面板接口
$result = $this->HttpPostCookie($url,$p_data);
//解析JSON数据
$data = json_decode($result,true);
return $data;
}
/**
* 修改指定网站的PHP版本
* @param [type] $site 网站名
* @param [type] $php PHP版本
*/
public function SetPHPVersion($site,$php){
$url = $this->BT_PANEL.$this->config("SetPHPVersion");
$p_data = $this->GetKeyData();
$p_data['siteName'] = $site;
$p_data['version'] = $php;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取指定网站运行的PHP版本
* @param [type] $site 网站名
*/
public function GetSitePHPVersion($site){
$url = $this->BT_PANEL.$this->config("GetSitePHPVersion");
$p_data = $this->GetKeyData();
$p_data['siteName'] = $site;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 新增网站
* @param [type] $webname 网站域名 json格式
* @param [type] $path 网站路径
* @param [type] $type_id 网站分类ID
* @param string $type 网站类型
* @param [type] $version PHP版本
* @param [type] $port 网站端口
* @param [type] $ps 网站备注
* @param [type] $ftp 网站是否开通FTP
* @param [type] $ftp_username FTP用户名
* @param [type] $ftp_password FTP密码
* @param [type] $sql 网站是否开通数据库
* @param [type] $codeing 数据库编码类型 utf8|utf8mb4|gbk|big5
* @param [type] $datauser 数据库账号
* @param [type] $datapassword 数据库密码
*/
public function AddSite($infoArr=[]){
$url = $this->BT_PANEL.$this->config("WebAddSite");
//准备POST数据
$p_data = $this->GetKeyData(); //取签名
$p_data['webname'] = $infoArr['webname'];
$p_data['path'] = $infoArr['path'];
$p_data['type_id'] = $infoArr['type_id'];
$p_data['type'] = $infoArr['type'];
$p_data['version'] = $infoArr['version'];
$p_data['port'] = $infoArr['port'];
$p_data['ps'] = $infoArr['ps'];
$p_data['ftp'] = $infoArr['ftp'];
$p_data['ftp_username'] = $infoArr['ftp_username'];
$p_data['ftp_password'] = $infoArr['ftp_password'];
$p_data['sql'] = $infoArr['sql'];
$p_data['codeing'] = $infoArr['codeing'];
$p_data['datauser'] = $infoArr['datauser'];
$p_data['datapassword'] = $infoArr['datapassword'];
//请求面板接口
$result = $this->HttpPostCookie($url,$p_data);
//var_dump($result);
//解析JSON数据
$data = json_decode($result,true);
return $data;
}
/**
* 删除网站
* @param [type] $id 网站ID
* @param [type] $webname 网站名称
* @param [type] $ftp 是否删除关联FTP
* @param [type] $database 是否删除关联数据库
* @param [type] $path 是否删除关联网站根目录
*
*/
public function WebDeleteSite($id,$webname,$ftp,$database,$path){
$url = $this->BT_PANEL.$this->config("WebDeleteSite");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['webname'] = $webname;
$p_data['ftp'] = $ftp;
$p_data['database'] = $database;
$p_data['path'] = $path;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 停用站点
* @param [type] $id 网站ID
* @param [type] $name 网站域名
*/
public function WebSiteStop($id,$name){
$url = $this->BT_PANEL.$this->config("WebSiteStop");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['name'] = $name;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 启用网站
* @param [type] $id 网站ID
* @param [type] $name 网站域名
*/
public function WebSiteStart($id,$name){
$url = $this->BT_PANEL.$this->config("WebSiteStart");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['name'] = $name;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 设置网站到期时间
* @param [type] $id 网站ID
* @param [type] $edate 网站到期时间 格式:2019-01-01,永久:0000-00-00
*/
public function WebSetEdate($id,$edate){
$url = $this->BT_PANEL.$this->config("WebSetEdate");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['edate'] = $edate;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 修改网站备注
* @param [type] $id 网站ID
* @param [type] $ps 网站备注
*/
public function WebSetPs($id,$ps){
$url = $this->BT_PANEL.$this->config("WebSetPs");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['ps'] = $ps;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站备份列表
* @param [type] $id 网站ID
* @param string $page 当前分页
* @param string $limit 每页取出的数据行数
* @param string $type 备份类型 目前固定为0
* @param string $tojs 分页js回调若不传则构造 URI 分页连接 get_site_backup
*/
public function WebBackupList($id,$page='1',$limit='5',$type='0',$tojs=''){
$url = $this->BT_PANEL.$this->config("WebBackupList");
$p_data = $this->GetKeyData();
$p_data['p'] = $page;
$p_data['limit'] = $limit;
$p_data['type'] = $type;
$p_data['tojs'] = $tojs;
$p_data['search'] = $id;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 创建网站备份
* @param [type] $id 网站ID
*/
public function WebToBackup($id){
$url = $this->BT_PANEL.$this->config("WebToBackup");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 删除网站备份
* @param [type] $id 网站备份ID
*/
public function WebDelBackup($id){
$url = $this->BT_PANEL.$this->config("WebDelBackup");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 删除数据库备份
* @param [type] $id 数据库备份ID
*/
public function SQLDelBackup($id){
$url = $this->BT_PANEL.$this->config("SQLDelBackup");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 备份数据库
* @param [type] $id 数据库列表ID
*/
public function SQLToBackup($id){
$url = $this->BT_PANEL.$this->config("SQLToBackup");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站域名列表
* @param [type] $id 网站ID
* @param boolean $list 固定传true
*/
public function WebDoaminList($id,$list=true){
$url = $this->BT_PANEL.$this->config("WebDoaminList");
$p_data = $this->GetKeyData();
$p_data['search'] = $id;
$p_data['list'] = $list;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站列表
* @param string $search
* @param int $p
* @param int $limit
* @param int $type
* @return mixed
*/
public function WebSiteList($search = '', $p = 1, $limit = 20, $type = 0){
$url = $this->BT_PANEL.$this->config("WebSiteList");
$p_data = $this->GetKeyData();
$p_data['search'] = $search;
$p_data['p'] = $p;
$p_data['limit'] = $limit;
$p_data['type'] = $type;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 添加域名
* @param [type] $id 网站ID
* @param [type] $webname 网站名称
* @param [type] $domain 要添加的域名:端口 80 端品不必构造端口,多个域名用换行符隔开
*/
public function WebAddDomain($id,$webname,$domain){
$url = $this->BT_PANEL.$this->config("WebAddDomain");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['webname'] = $webname;
$p_data['domain'] = $domain;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 删除网站域名
* @param [type] $id 网站ID
* @param [type] $webname 网站名
* @param [type] $domain 网站域名
* @param [type] $port 网站域名端口
*/
public function WebDelDomain($id,$webname,$domain,$port){
$url = $this->BT_PANEL.$this->config("WebDelDomain");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['webname'] = $webname;
$p_data['domain'] = $domain;
$p_data['port'] = $port;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取可选的预定义伪静态列表
* @param [type] $siteName 网站名
*/
public function GetRewriteList($siteName){
$url = $this->BT_PANEL.$this->config("GetRewriteList");
$p_data = $this->GetKeyData();
$p_data['siteName'] = $siteName;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取预置伪静态规则内容(文件内容)
* @param [type] $path 规则名
* @param [type] $type 0->获取内置伪静态规则;1->获取当前站点伪静态规则
*/
public function GetFileBody($path,$type=0){
$url = $this->BT_PANEL.$this->config("GetFileBody");
$p_data = $this->GetKeyData();
// $path_dir = $type?'vhost/rewrite':'rewrite/nginx';
if ($type == 2) {
$path_dir = 'vhost/nginx';
} elseif ($type == 1) {
$path_dir = 'vhost/rewrite';
} else {
$path_dir = 'rewrite/nginx';
}
//获取当前站点伪静态规则
///www/server/panel/vhost/rewrite/user_hvVBT_1.test.com.conf
//获取内置伪静态规则
///www/server/panel/rewrite/nginx/EmpireCMS.conf
//保存伪静态规则到站点
///www/server/panel/vhost/rewrite/user_hvVBT_1.test.com.conf
///www/server/panel/rewrite/nginx/typecho.conf
$p_data['path'] = '/www/server/panel/'.$path_dir.'/'.$path.'.conf';
//var_dump($p_data['path']);
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 保存伪静态规则内容(保存文件内容)
* @param [type] $path 规则名
* @param [type] $data 规则内容
* @param string $encoding 规则编码强转utf-8
* @param number $type 0->系统默认路径;1->自定义全路径
*/
public function SaveFileBody($path,$data,$encoding='utf-8',$type=0){
$url = $this->BT_PANEL.$this->config("SaveFileBody");
if($type){
$path_dir = $path;
}else{
$path_dir = '/www/server/panel/vhost/rewrite/'.$path.'.conf';
}
$p_data = $this->GetKeyData();
$p_data['path'] = $path_dir;
$p_data['data'] = $data;
$p_data['encoding'] = $encoding;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 设置密码访问网站
* @param [type] $id 网站ID
* @param [type] $username 用户名
* @param [type] $password 密码
*/
public function SetHasPwd($id,$username,$password){
$url = $this->BT_PANEL.$this->config("SetHasPwd");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['username'] = $username;
$p_data['password'] = $password;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 关闭密码访问网站
* @param [type] $id 网站ID
*/
public function CloseHasPwd($id){
$url = $this->BT_PANEL.$this->config("CloseHasPwd");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站日志
* @param [type] $site 网站名
*/
public function GetSiteLogs($site){
$url = $this->BT_PANEL.$this->config("GetSiteLogs");
$p_data = $this->GetKeyData();
$p_data['siteName'] = $site;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站盗链状态及规则信息
* @param [type] $id 网站ID
* @param [type] $site 网站名
*/
public function GetSecurity($id,$site){
$url = $this->BT_PANEL.$this->config("GetSecurity");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['name'] = $site;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 设置网站盗链状态及规则信息
* @param [type] $id 网站ID
* @param [type] $site 网站名
* @param [type] $fix URL后缀
* @param [type] $domains 许可域名
* @param [type] $status 状态
*/
public function SetSecurity($id,$site,$fix,$domains,$status){
$url = $this->BT_PANEL.$this->config("SetSecurity");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['name'] = $site;
$p_data['fix'] = $fix;
$p_data['domains'] = $domains;
$p_data['status'] = $status;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站三项配置开关(防跨站、日志、密码访问)
* @param [type] $id 网站ID
* @param [type] $path 网站运行目录
*/
public function GetDirUserINI($id,$path){
$url = $this->BT_PANEL.$this->config("GetDirUserINI");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['path'] = $path;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 开启强制HTTPS
* @param [type] $site 网站域名(纯域名)
*/
public function HttpToHttps($site){
$url = $this->BT_PANEL.$this->config("HttpToHttps");
$p_data = $this->GetKeyData();
$p_data['siteName'] = $site;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 关闭强制HTTPS
* @param [type] $site 域名(纯域名)
*/
public function CloseToHttps($site){
$url = $this->BT_PANEL.$this->config("CloseToHttps");
$p_data = $this->GetKeyData();
$p_data['siteName'] = $site;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 设置SSL域名证书
* @param [type] $type 类型
* @param [type] $site 网站名
* @param [type] $key 证书key
* @param [type] $csr 证书PEM
*/
public function SetSSL($type,$site,$key,$csr){
$url = $this->BT_PANEL.$this->config("SetSSL");
$p_data = $this->GetKeyData();
$p_data['type'] = $type;
$p_data['siteName'] = $site;
$p_data['key'] = $key;
$p_data['csr'] = $csr;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 关闭SSL
* @param [type] $updateOf 修改状态码
* @param [type] $site 域名(纯域名)
*/
public function CloseSSLConf($updateOf,$site){
$url = $this->BT_PANEL.$this->config("CloseSSLConf");
$p_data = $this->GetKeyData();
$p_data['updateOf'] = $updateOf;
$p_data['siteName'] = $site;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取SSL状态及证书信息
* @param [type] $site 域名(纯域名)
*/
public function GetSSL($site){
$url = $this->BT_PANEL.$this->config("GetSSL");
$p_data = $this->GetKeyData();
$p_data['siteName'] = $site;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站默认文件
* @param [type] $id 网站ID
*/
public function WebGetIndex($id){
$url = $this->BT_PANEL.$this->config("WebGetIndex");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 设置网站默认文件
* @param [type] $id 网站ID
* @param [type] $index 内容
*/
public function WebSetIndex($id,$index){
$url = $this->BT_PANEL.$this->config("WebSetIndex");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['Index'] = $index;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站流量限制信息
* @param [type] $id [description]
*/
public function GetLimitNet($id){
$url = $this->BT_PANEL.$this->config("GetLimitNet");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 设置网站流量限制信息
* @param [type] $id 网站ID
* @param [type] $perserver 并发限制
* @param [type] $perip 单IP限制
* @param [type] $limit_rate 流量限制
*/
public function SetLimitNet($id,$perserver,$perip,$limit_rate){
$url = $this->BT_PANEL.$this->config("SetLimitNet");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['perserver'] = $perserver;
$p_data['perip'] = $perip;
$p_data['limit_rate'] = $limit_rate;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 关闭网站流量限制
* @param [type] $id 网站ID
*/
public function CloseLimitNet($id){
$url = $this->BT_PANEL.$this->config("CloseLimitNet");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站301重定向信息
* @param [type] $site 网站名
*/
public function Get301Status($site){
$url = $this->BT_PANEL.$this->config("Get301Status");
$p_data = $this->GetKeyData();
$p_data['siteName'] = $site;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 设置网站301重定向信息
* @param [type] $site 网站名
* @param [type] $toDomain 目标Url
* @param [type] $srcDomain 来自Url
* @param [type] $type 类型
*/
public function Set301Status($site,$toDomain,$srcDomain,$type){
$url = $this->BT_PANEL.$this->config("Set301Status");
$p_data = $this->GetKeyData();
$p_data['siteName'] = $site;
$p_data['toDomain'] = $toDomain;
$p_data['srcDomain'] = $srcDomain;
$p_data['type'] = $type;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站反代信息及状态
* @param [type] $site [description]
*/
public function GetProxyList($site){
$url = $this->BT_PANEL.$this->config("GetProxyList");
$p_data = $this->GetKeyData();
$p_data['sitename'] = $site;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 添加网站反代信息
* @param [type] $cache 是否缓存
* @param [type] $proxyname 代理名称
* @param [type] $cachetime 缓存时长 /小时
* @param [type] $proxydir 代理目录
* @param [type] $proxysite 反代URL
* @param [type] $todomain 目标域名
* @param [type] $advanced 高级功能:开启代理目录
* @param [type] $sitename 网站名
* @param [type] $subfilter 文本替换json格式[{"sub1":"百度","sub2":"白底"},{"sub1":"","sub2":""}]
* @param [type] $type 开启或关闭 0关;1开
*/
public function CreateProxy($cache,$proxyname,$cachetime,$proxydir,$proxysite,$todomain,$advanced,$sitename,$subfilter,$type){
$url = $this->BT_PANEL.$this->config("CreateProxy");
$p_data = $this->GetKeyData();
$p_data['cache'] = $cache;
$p_data['proxyname'] = $proxyname;
$p_data['cachetime'] = $cachetime;
$p_data['proxydir'] = $proxydir;
$p_data['proxysite'] = $proxysite;
$p_data['todomain'] = $todomain;
$p_data['advanced'] = $advanced;
$p_data['sitename'] = $sitename;
$p_data['subfilter'] = $subfilter;
$p_data['type'] = $type;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 添加网站反代信息
* @param [type] $cache 是否缓存
* @param [type] $proxyname 代理名称
* @param [type] $cachetime 缓存时长 /小时
* @param [type] $proxydir 代理目录
* @param [type] $proxysite 反代URL
* @param [type] $todomain 目标域名
* @param [type] $advanced 高级功能:开启代理目录
* @param [type] $sitename 网站名
* @param [type] $subfilter 文本替换json格式[{"sub1":"百度","sub2":"白底"},{"sub1":"","sub2":""}]
* @param [type] $type 开启或关闭 0关;1开
*/
public function ModifyProxy($cache,$proxyname,$cachetime,$proxydir,$proxysite,$todomain,$advanced,$sitename,$subfilter,$type){
$url = $this->BT_PANEL.$this->config("ModifyProxy");
$p_data = $this->GetKeyData();
$p_data['cache'] = $cache;
$p_data['proxyname'] = $proxyname;
$p_data['cachetime'] = $cachetime;
$p_data['proxydir'] = $proxydir;
$p_data['proxysite'] = $proxysite;
$p_data['todomain'] = $todomain;
$p_data['advanced'] = $advanced;
$p_data['sitename'] = $sitename;
$p_data['subfilter'] = $subfilter;
$p_data['type'] = $type;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站域名绑定二级目录信息
* @param [type] $id 网站ID
*/
public function GetDirBinding($id){
$url = $this->BT_PANEL.$this->config("GetDirBinding");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 设置网站域名绑定二级目录
* @param [type] $id 网站ID
* @param [type] $domain 域名
* @param [type] $dirName 目录
*/
public function AddDirBinding($id,$domain,$dirName){
$url = $this->BT_PANEL.$this->config("AddDirBinding");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['domain'] = $domain;
$p_data['dirName'] = $dirName;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 删除网站域名绑定二级目录
* @param [type] $dirid 子目录ID
*/
public function DelDirBinding($dirid){
$url = $this->BT_PANEL.$this->config("DelDirBinding");
$p_data = $this->GetKeyData();
$p_data['id'] = $dirid;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取网站子目录绑定伪静态信息
* @param [type] $dirid 子目录绑定ID
*/
public function GetDirRewrite($dirid,$type=0){
$url = $this->BT_PANEL.$this->config("GetDirRewrite");
$p_data = $this->GetKeyData();
$p_data['id'] = $dirid;
if($type){
$p_data['add'] = 1;
}
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 修改FTP账号密码
* @param [type] $id FTPID
* @param [type] $ftp_username 用户名
* @param [type] $new_password 密码
*/
public function SetUserPassword($id,$ftp_username,$new_password){
$url = $this->BT_PANEL.$this->config("SetUserPassword");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['ftp_username'] = $ftp_username;
$p_data['new_password'] = $new_password;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 修改SQL账号密码
* @param [type] $id SQLID
* @param [type] $ftp_username 用户名
* @param [type] $new_password 密码
*/
public function ResDatabasePass($id,$name,$password){
$url = $this->BT_PANEL.$this->config("ResDatabasePass");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['name'] = $name;
$p_data['password'] = $password;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 启用/禁用FTP
* @param [type] $id FTPID
* @param [type] $username 用户名
* @param [type] $status 状态 0->关闭;1->开启
*/
public function SetStatus($id,$username,$status){
$url = $this->BT_PANEL.$this->config("SetStatus");
$p_data = $this->GetKeyData();
$p_data['id'] = $id;
$p_data['username'] = $username;
$p_data['status'] = $status;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 宝塔一键部署列表
* @param string $search 搜索关键词
* @return [type] [description]
*/
public function deployment($search=''){
if($search){
$url = $this->BT_PANEL.$this->config("deployment").'&search='.$search;
}else{
$url = $this->BT_PANEL.$this->config("deployment");
}
$p_data = $this->GetKeyData();
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 宝塔一键部署执行
* @param [type] $dname 部署程序名
* @param [type] $site_name 部署到网站名
* @param [type] $php_version PHP版本
*/
public function SetupPackage($dname,$site_name,$php_version){
$url = $this->BT_PANEL.$this->config("SetupPackage");
$p_data = $this->GetKeyData();
$p_data['dname'] = $dname;
$p_data['site_name'] = $site_name;
$p_data['php_version'] = $php_version;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 设置文件权限
* @param $path
* @param $user
* @param $access
* @param $all
* @return mixed
*/
public function setFileAccess($path, $user, $access, $all) {
$url = $this->BT_PANEL.$this->config("SetFileAccess");
$p_data = $this->GetKeyData();
$p_data['user'] = $user;
$p_data['access'] = $access;
$p_data['all'] = $all;
$p_data['filename'] = $path;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 获取队列
* @return mixed
*/
public function getProcessList()
{
$url = $this->BT_PANEL.$this->config("GetProcessList");
$p_data = $this->GetKeyData();
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 停止队列
* @param $program
* @param int $numprocs
* @return mixed
*/
public function stopProcess($program, $numprocs = 1)
{
$url = $this->BT_PANEL.$this->config("StopProcess");
$p_data = $this->GetKeyData();
$p_data['program'] = $program;
$p_data['numprocs'] = $numprocs;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 启动队列
* @param $program
* @param int $numprocs
* @return mixed
*/
public function startProcess($program, $numprocs = 1)
{
$url = $this->BT_PANEL.$this->config("StartProcess");
$p_data = $this->GetKeyData();
$p_data['program'] = $program;
$p_data['numprocs'] = $numprocs;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 设置文件权限
* @param $path
* @return mixed
*/
public function DeleteFile($path) {
$url = $this->BT_PANEL.$this->config("DeleteFile");
$p_data = $this->GetKeyData();
$p_data['path'] = $path;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 更新网站目录
* @param $site_id
* @param $path
* @return mixed
*/
public function SetPath($site_id, $path)
{
$url = $this->BT_PANEL.$this->config("SetPath");
$p_data = $this->GetKeyData();
$p_data['id'] = $site_id;
$p_data['path'] = $path;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 更新运行目录
* @param $site_id
* @param $path
* @return mixed
*/
public function SetSiteRunPath($site_id, $path)
{
$url = $this->BT_PANEL.$this->config("SetSiteRunPath");
$p_data = $this->GetKeyData();
$p_data['id'] = $site_id;
$p_data['runPath'] = $path;
$result = $this->HttpPostCookie($url,$p_data);
$data = json_decode($result,true);
return $data;
}
/**
* 构造带有签名的关联数组
*/
public function GetKeyData(){
$now_time = time();
$p_data = array(
'request_token' => md5($now_time.''.md5($this->BT_KEY)),
'request_time' => $now_time
);
return $p_data;
}
/**
* 发起POST请求
* @param String $url 目标网填,带http://
* @param Array|String $data 欲提交的数据
* @return string
*/
private function HttpPostCookie($url, $data,$timeout = 60)
{
//定义cookie保存位置
$cookie_file='./'.md5($this->BT_PANEL).'.cookie';
if(!file_exists($cookie_file)){
$fp = fopen($cookie_file,'w+');
fclose($fp);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
/**
* 加载宝塔数据接口
* @param [type] $str [description]
* @return [type] [description]
*/
private function config($str){
$config = config("bt");
//var_dump($config);
return $config[$str];
}
}
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2023/09/18
* Time: 20:56
*/
namespace App\Repositories;
use App\Repositories\Bt\Bt;
use Illuminate\Support\Facades\Log;
/**
* Class BtRepository
* @package App\Repositories
*/
class BtRepository
{
public $instance = [];
/**
* @param $domain
* @return array|bool
*/
public function createBtSite($domain, $rewrite = [], $domain_list = [])
{
$domain_array = parse_url($domain);
$host = $domain_array['host'] ?? $domain_array['path'];
// TODO 验证当前服务器是否已经创建过了
$bt = $this->getBtObject();
$site_list = $bt->WebSiteList($host);
if (!empty($site_list['data'])) {
return ['site_id' => $site_list['data'][0]['id']];
}
// if ($domain_list) {
// $web_name = ['domain' => $host, 'domainlist' => $domain_list, 'count' => 0];
// } else {
// $host_array = explode('.', $host);
// if (FALSE == empty($host_array[0]) && $host_array[0] == 'www')
// unset($host_array[0]);
// $domain_top = implode('.', $host_array);
// if ($domain_top == $host){
// $web_name = ['domain' => $host, 'domainlist' => ['www.'.$domain_top, '*.' . $host], 'count' => 0];
// }else{
// $web_name = ['domain' => $host, 'domainlist' => [$domain_top, '*.' . $domain_top], 'count' => 0];
// }
// }
$web_name = ['domain' => $host, 'domainlist' => $domain_list, 'count' => 0];
$array = [
'webname' => json_encode($web_name),
'path' => '/www/wwwroot/createSite',
'type_id' => 0,
'type' => 'PHP',
'version' => '80',
'port' => '80',
'ps' => $host,
'ftp' => false,
'ftp_username' => '',
'ftp_password' => '',
'sql' => false,
'codeing' => '',
'datauser' => '',
'datapassword' => '',
];
$result = $bt->AddSite($array);
// result 返回信息
// $result = ['siteStatus' => true, 'siteId' => 39, 'ftpStatus' => false, 'databaseStatus' => false,];
if (empty($result) || empty($result['siteId']))
return false;
// 更新站点目录 更新站点运行目录
$bt->SetPath($result['siteId'], public_path());
// 删除 .user.ini
$bt->DeleteFile('/www/wwwroot/c-globalso/public/.user.ini');
$bt->DeleteFile('/www/wwwroot/c-globalso/.user.ini');
// $bt->SetSiteRunPath($result['siteId'], '/');
#---------------------------------------------------------------------------------------------------------------
// 伪静态设置
// $htaccess = $this->rewrite301($rewrite);
// if ($htaccess)
// $bt->SaveFileBody($host, $htaccess);
// 获取配置
// 设置Nginx配置
// $nginx_config = $this->getAfterNginxConfStr($host);
// $bt->SaveFileBody('/www/server/panel/vhost/nginx/' . $host . '.conf', $nginx_config, 'utf-8', 1);
#---------------------------------------------------------------------------------------------------------------
return ['site_id' => $result['siteId']];
}
/**
* 申请免费证书
* @param string $domain
* @param array $rewrite
* @param array $otherDomain
* @param int $is_https
* @return bool
*/
public function applySsl($domain, $rewrite = [], $otherDomain = [], $is_https = 0)
{
$domain_array = parse_url($domain);
$host = $domain_array['host'] ?? $domain_array['path'];
$bt = $this->getBtObject();
$site_list = $bt->WebSiteList($host);
if (empty($site_list['data'])) {
$site = $this->createBtSite($domain,$rewrite,$otherDomain);
$site_id = $site['site_id'];
}else{
$site_id = $site_list['data'][0]['id'];
$host = $site_list['data'][0]['name'];
}
// 获取站点域名
$site_domain = $bt->WebDoaminList($site_id);
$domain_list = [];
foreach ($site_domain as $val) {
if (FALSE === strpos($val['name'], '*')) {
array_push($domain_list, $val['name']);
}
}
//添加站点域名
$this->addDomain($site_id, $host, $otherDomain, $site_domain);
//还原配置
$nginx_config = $this->getBeforeNginxConfStr($host);
$bt->SaveFileBody('/www/server/panel/vhost/nginx/' . $host . '.conf', $nginx_config, 'utf-8', 1);
// 如果已经申请了ssl证书, 并且证书有效期超过3天, 那么就使用已经申请好的证书
$ssl = $bt->GetSSL($host);
$is_set_status = false;//是否需要设置证书
if (FALSE == empty($ssl['cert_data']['notAfter']) && strtotime($ssl['cert_data']['notAfter']) - time() > 259200) {
$key = $ssl['key'];
$cer = $ssl['csr'];
$is_set_status = !$ssl['status'];
} else {
// 申请证书时需要将重写规则情况, 不然会跳转到其他地方
$bt->SaveFileBody($host, '');
// 如果没有证书, 申请证书并设置证书
$rs = $bt->ApplyCert(json_encode($domain_list),$site_id);
if(isset($rs['status']) && $rs['status']){
//申请成功,设置证书
$key = $rs['private_key'];
$cer = $rs['cert'];
$is_set_status = true;
}else{
$key = '';
$cer = '';
}
}
if($key && $cer && $is_set_status){
$bt->SetSSL(1, $host, $key, $cer);
}
$bt->DeleteFile('/www/wwwroot/c-globalso/public/.user.ini');
$bt->DeleteFile('/www/wwwroot/c-globalso/.user.ini');
$htaccess = $this->rewrite301($rewrite,$is_https);
if ($htaccess)
$bt->SaveFileBody($host, $htaccess);
// 更新配置
$nginx_config = $this->getAfterNginxConfStr($host);
$bt->SaveFileBody('/www/server/panel/vhost/nginx/' . $host . '.conf', $nginx_config, 'utf-8', 1);
return true;
}
/**
* 设置ssl证书
* @param string $domain
* @param array $rewrite
* @param array $otherDomain
* @param string $private_key
* @param string $cert
* @param int $is_https
* @return bool
*/
public function setSsl($domain, $rewrite = [], $otherDomain = [], $private_key = '', $cert = '', $is_https = 0)
{
$domain_array = parse_url($domain);
$host = $domain_array['host'] ?? $domain_array['path'];
$bt = $this->getBtObject();
$site_list = $bt->WebSiteList($host);
if (empty($site_list['data'])) {
$site = $this->createBtSite($domain,$rewrite,$otherDomain);
$site_id = $site['site_id'];
}else{
$host = $site_list['data'][0]['name'];
$site_id = $site_list['data'][0]['id'];
}
//添加站点域名
$this->addDomain($site_id, $host, $otherDomain);
// 还原配置
$nginx_config = $this->getBeforeNginxConfStr($host);
$bt->SaveFileBody('/www/server/panel/vhost/nginx/' . $host . '.conf', $nginx_config, 'utf-8', 1);
$bt->SetSSL(1, $host, $private_key, $cert);
$bt->DeleteFile('/www/wwwroot/c-globalso/public/.user.ini');
$bt->DeleteFile('/www/wwwroot/c-globalso/.user.ini');
// 设置301跳转
$htaccess = $this->rewrite301($rewrite,$is_https);
if ($htaccess)
$bt->SaveFileBody($host, $htaccess);
// 更新配置
$nginx_config = $this->getAfterNginxConfStr($host);
$bt->SaveFileBody('/www/server/panel/vhost/nginx/' . $host . '.conf', $nginx_config, 'utf-8', 1);
return true;
}
/**
* 获取bt对象
* @param string $key
* @param string $panel
* @return Bt
*/
public function getBtObject($key = '', $panel = '')
{
$key = $key ?: env('BT_KEY');
$panel = $panel ?: env('BT_PANEL');
$object_key = md5($key . $panel);
if (empty($this->instance[$object_key])) {
$bt = new Bt($panel, $key);
$this->instance[$object_key] = $bt;
}
return $this->instance[$object_key];
}
/**
* 获取配置前的文件内容
* @param $domain
* @return string|string[]
*/
public function getBeforeNginxConfStr($domain)
{
$bt = $this->getBtObject();
$conf = $bt->GetFileBody($domain, 2);
//如果有变量标识,去掉变量标识
if (FALSE !== strpos($conf['data'], 'map $domain_prefix')){
$conf['data'] = str_replace($this->domainPrefixConf(),'',$conf['data']);
//去掉自定义配置
$conf['data'] = str_replace($this->customConf($domain),'root ' . public_path() . ';', $conf['data']);
}
// preg_match('/set \$root[\S\s]+root \$root;/iU', $conf['data'], $matches);
// if (FALSE == empty($matches[0])) {
// $conf['data'] = str_replace($matches[0], 'root ' . public_path() . ';', $conf['data']);
// }
return $conf['data'];
}
/**
* 获取配置后的文件内容
* @param $domain
* @return mixed
*/
public function getAfterNginxConfStr($domain)
{
$bt = $this->getBtObject();
$conf = $bt->GetFileBody($domain, 2);
// $conf['data'] = file_get_contents(storage_path('logs/nginx.conf'));
// 如果没有变量, 添加变量识别
if (FALSE === strpos($conf['data'], 'map $domain_prefix')){
$conf['data'] = $this->domainPrefixConf() . $conf['data'];
// 替换自定义配置
$conf['data'] = str_replace('root ' . public_path() . ';', $this->customConf($domain), $conf['data']);
}
return $conf['data'];
}
/**
* 需要定制修改的配置
* @return string
*/
public function customConf($domain): string
{
$string = ' root '.public_path().'; # 设置根目录
set $domain_prefix "";
if ($host ~* "^(?<domain_prefix>[^.]+)\.") {
set $domain_prefix $1;
}
location / {
root '.public_path().'/'.$domain.'; # 设置根目录
if ($is_prefix_in_string = 1) {
root '.public_path().'/'.$domain.'/$domain_prefix;
}
try_files $uri $uri/ /404/index.html =404;
}
location ~ ^/(api|search) {
root '.public_path().'; # 设置/api /search /.well-known的根目录
try_files $uri $uri/ /index.php?$query_string;
}
location ~ ^/(well-known) {
root '.public_path().';
try_files $uri $uri/ /404/index.html =404;
}
error_page 403 /404/index.html;';
return $string;
}
/**
* 解析301跳转
* @param $rewrite
* @param $is_https
* @return string
*/
public function rewrite301($rewrite,$is_https)
{
$string = '# 屏蔽蜘蛛
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)") {
return 444;
}
# 设置跳转
';
if (FALSE == is_array($rewrite))
return $string;
foreach ($rewrite as $val) {
if (empty($val['origin']) || empty($val['target']))
continue;
$origin_tmp = parse_url($val['origin']);
$origin = $origin_tmp['host'] ?? $origin_tmp['path'];
$target_tmp = parse_url($val['target']);
$target = $target_tmp['host'] ?? $target_tmp['path'];
$string .= '
if ($host ~ "^' . $origin . '"){
return 301 $scheme://' . $target . '$request_uri;
}
';
}
if($is_https){
$string .= '
#HTTP_TO_HTTPS_START
if ($server_port !~ 443){
rewrite ^(/.*)$ https://$host$1 permanent;
}
';
}
return $string;
}
/**
* 配置变量
* @return string
*/
public function domainPrefixConf()
{
return 'map $domain_prefix $is_prefix_in_string {
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;
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;
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;
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;
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;
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;
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;
tk 1; uk 1; ur 1; ug 1; uz 1; vi 1; cy 1; xh 1; yi 1; yo 1; zu 1;
}';
}
//添加站点域名
protected function addDomain($site_id, $domain, $otherDomains, $site_domain = [])
{
$bt = $this->getBtObject();
if(!$site_domain){
$site_domain = $bt->WebDoaminList($site_id);
}
$site_domain = array_column($site_domain, 'name');
foreach ($otherDomains as $k => $otherDomain) {
// 如果已经包含, 就不添加
if (in_array($otherDomain, $site_domain)) {
unset($otherDomains[$k]);
}
}
if ($otherDomains) {
$otherDomains = implode(',', $otherDomains);
$res = $bt->WebAddDomain($site_id, $domain, $otherDomains);
if (!$res['status']) {
return false;
}
}
return true;
}
/**
* 创建amp站点
* @param $domain
* @param $key
* @param $cer
* @return array|bool
* @author Akun
* @date 2024/02/18 17:04
*/
public function createBtSiteAmp($domain,$key,$cer)
{
$domain_array = parse_url($domain);
$host = $domain_array['host'] ?? $domain_array['path'];
$host_array = explode('.',$host);
if(count($host_array) <= 2){
array_unshift($host_array,'m');
}else{
$host_array[0] = 'm';
}
$host = implode('.',$host_array);
// 验证当前服务器是否已经创建过了
$bt = $this->getBtObject();
$site_list = $bt->WebSiteList($host);
if (!empty($site_list['data'])) {
$site_id = $site_list['data'][0]['id'];
}else{
$web_name = ['domain' => $host, 'domainlist' => [], 'count' => 0];
$array = [
'webname' => json_encode($web_name),
'path' => '/www/wwwroot/createSite',
'type_id' => 0,
'type' => 'PHP',
'version' => '80',
'port' => '80',
'ps' => $host,
'ftp' => false,
'ftp_username' => '',
'ftp_password' => '',
'sql' => false,
'codeing' => '',
'datauser' => '',
'datapassword' => '',
];
$result = $bt->AddSite($array);
if (empty($result) || empty($result['siteId']))
return false;
$site_id = $result['siteId'];
// 更新站点目录 更新站点运行目录
$bt->SetPath($site_id, public_path());
// 删除 .user.ini
$bt->DeleteFile('/www/wwwroot/c-globalso/public/.user.ini');
$bt->DeleteFile('/www/wwwroot/c-globalso/.user.ini');
}
if(empty($key) || empty($cer)){
$ssl = $bt->GetSSL($host);
$is_set_status = false;//是否需要设置证书
if (FALSE == empty($ssl['cert_data']['notAfter']) && strtotime($ssl['cert_data']['notAfter']) - time() > 259200) {
// 如果已经申请了ssl证书, 并且证书有效期超过3天, 那么就使用已经申请好的证书
$key = $ssl['key'];
$cer = $ssl['csr'];
$is_set_status = !$ssl['status'];
} else {
// 如果没有证书, 申请证书并设置证书
$bt->SaveFileBody($host, ''); // 申请证书时需要将重写规则清空, 不然会跳转到其他地方
$rs = $bt->ApplyCert(json_encode([$host]),$site_id);
if(isset($rs['status']) && $rs['status']){
//申请成功,设置证书
$key = $rs['private_key'];
$cer = $rs['cert'];
$is_set_status = true;
}else{
$key = '';
$cer = '';
}
}
}else{
$is_set_status = true;
}
if($key && $cer && $is_set_status){
$bt->SetSSL(1, $host, $key, $cer);
}
// 伪静态设置
$bt->SaveFileBody($host, 'location / {
try_files $uri $uri/ /index.php?$query_string;
}');
return ['site_id' => $site_id];
}
}
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2023/8/31
* Time: 14:54
*/
namespace App\Repositories;
use App\Helper\Translate;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\Module\Module;
use App\Models\Module\ModuleCategory;
use App\Models\RouteMap\RouteMap;
use App\Models\WebSetting\Translate as WebTranslate;
/**
* Class StaticHtmlRepository
* @package App\Repositories
*/
class StaticHtmlRepository
{
/**
* 通过域名和路由 获取主语种HTML
* @param string $domain
* @param string $route
* @return string
*/
public function getMainHtml($domain, $route)
{
$html = '';
return $html;
}
/**
* 5.0生成路径
*/
public function getProjectRoutePath5($project,$route,$page): string
{
$routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path","")->first();
if (empty($routerMap)){
$routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first();
}
if (!empty($routerMap)){
if ($routerMap->source == "news"){
$route = "news/".$route;
}elseif($routerMap->source == "blog" || $routerMap->source == "blogs"){
$route = "blogs/".$route;
}elseif ($routerMap->source == "news_category"){
if ($route == "news"){
$route = $page == null || $page == 1 ? $route : $route . "/page";
}else{
$route = $page == null || $page == 1 ? "news_catalog/".$route : "news_catalog/".$route."/page";
}
}elseif ($routerMap->source == "blog_category"){
if ($route == "blog"){
$route = $page == null || $page == 1 ? $route : $route."/page";
}else{
$route = $page == null || $page == 1 ? "blog_catalog/".$route : "blog_catalog/".$route."/page";
}
}elseif ($routerMap->source == "product_category"){
$route = $page == null || $page == 1 ? $route : $route."/page";
}elseif ($routerMap->source == "module_category"){
$moduleCategory = CustomModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id);
if (!empty($moduleCategory->getExtend->route)){
if ($moduleCategory->getExtend->route == $route){
$route = $moduleCategory->route;
}else{
$route = $moduleCategory->getExtend->route."_catalog/".$moduleCategory->route."/page";
}
}else{
$route = $moduleCategory->route."/page";
}
}elseif ($routerMap->source == "module"){
$modules = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
$moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$modules);
if (isset($moduleCategoryInfo->getExtend->route) && !empty($moduleCategoryInfo->getExtend->route)){
$route = $moduleCategoryInfo->route."/".$modules->route;
}
}else{
$route = $route == "index" ? "/" : $route;
}
}else{
if ($route == "products"){
if ($page == null || $page == 1){
}else{
$route = $route."/page";
}
}elseif ($route == "news"){
}elseif ($route == "blog"){
$route = $page == null || $page == 1 ? "blog_catalog/".$route : "blog_catalog/".$route."/page";
}else{
$route = $route == "index" ? "/" : $route;
}
}
return $route;
}
/**
* 6.0生成路径
*/
public function getProjectRoutePath6($project,$route): string
{
$routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first();
if (!empty($routerMap)){
if ($routerMap->source == "news"){
$route = "news/".$route;
}elseif($routerMap->source == "blog"){
$route = "blogs/".$route;
}elseif($routerMap->source == "module"){
$modules = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
$moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$modules);
if (isset($moduleCategoryInfo->route) && !empty($moduleCategoryInfo->route)){
$route = $moduleCategoryInfo->route."/".$route;
}
}else{
$route = $route == "index" ? "/" : $route;
}
}else{
$route = $route == "index" ? "/" : $route;
}
return $route;
}
public function compactUrl($project,$route,$page): string
{
//是否是5.0升级项目
if (isset($project->update_info["is_update"]) && $project->update_info["is_update"] == 1){
//5.0生成路径
$path = $this->getProjectRoutePath5($project,$route,$page);
}else{
//6.0生成路径
$path = $this->getProjectRoutePath6($project,$route);
}
return $path;
}
/**
* 通过域名和路由以及目标语种 获取小语种HTML
* @param string $domain
* @param string $route
* @param string $tl
* @return string
*/
public function getOtherLangHtml($domain, $route, $tl)
{
$path = '通过域名和路由获取主语种静态文件路径';
if (is_file($path)) {
$main_html = file_get_contents($path);
} else {
$main_html = $this->getMainHtml($domain, $route);
}
$html = '通过主语种HTML生成小语种HTML 并处理小语种特有的内容';
return $html;
}
/**
* 获取翻译后的HTML
* TODO HTML转dom, 提取需要渲染的词, 翻译关键词, 根据节点还原关键词, 清除dom, 返回HTML
* @param string $html 原HTML
* @param string $tl 目标语种
* @param string $sl 原语种
* @return mixed
*/
public function getTranHtml($project,string $html, string $tl,$route,$page, string $sl = 'auto')
{
$dom = str_get_html($html);
// file_put_contents(public_path("aaa.html"), $html);
if (is_bool($dom)){
return $html;
}
$texts = $dom->find("text");
$description = $dom->find("meta[name=description]",0);
$keywords = $dom->find("meta[name=keywords]",0);
// 组装需要翻译的内容 HTML内文案、meta description、meta keywords
$need_tran = [];
//处理图片alt
$images = $dom->find("img");
foreach ($images as $img){
$alt = $img->alt;
if($alt){
$need_tran[] = $alt;
}
}
//处理a标签title
$aTitles = $dom->find("a");
foreach ($aTitles as $aTitle){
$title = $aTitle->title;
if($title){
$need_tran[] = $title;
}
}
foreach ($texts as $k=>$text) {
$tag= $text->parent()->tag;
if (in_array($tag, ['script', 'style', 'root']))
continue;
$string = trim($text->text());
if (empty($string))
continue;
$country_class = '';
if (method_exists($text->parent()->parent(),"find") && $text->parent()->parent()->find("b")) {
$country_class = $text->parent()->parent()->find("b",0)->class;
}
if(FALSE !== strpos($country_class, 'country-flag'))
continue;
$need_tran[] = htmlspecialchars_decode(html_entity_decode($string));
}
if (isset($description->attr['content'])){
$need_tran[] = $description->attr['content'];
}
if (isset($keywords->attr['content'])){
$need_tran[] = $keywords->attr['content'];
}
// 翻译内容字符串, 最多翻译三次, 超过三次没有结果, 返回原文
$tran_string = [];
if ($need_tran) {
$i = 0;
$tl_tran = $tl == "zh-ct" ? "zh-TW" : $tl;
TranslateArray:
$tran_result = Translate::translate($need_tran, $tl_tran, $sl);
if (!isset($tran_result[0]) || empty($tran_result[0]['code'] || $tran_result[0]['code'] != 200)) {
if ($i >= 3)
return $html;
$i++;
goto TranslateArray;
}
$tran_string = $tran_result[0]['texts'];
}
//组装路由
$page = $page == null || $page == 1 ? "" : "/".$page;
$route = $this->compactUrl($project,$route,$page);
$url = $route.$page;
//图片翻译校对数据
$webImageTranslate = WebTranslate::where("alias",$tl)->where("url",$url)->where("type",WebTranslate::$imageType)->first();
$webImageAllTranslate = WebTranslate::where("alias",$tl)->where("url","All")->where("type",WebTranslate::$imageType)->first();
$imageAllData = !empty($webImageAllTranslate) ? json_decode($webImageAllTranslate->data,true) : [];
$imageSelfData = !empty($webImageTranslate) ? json_decode($webImageTranslate->data,true) : [];
$imageData = array_merge($imageAllData,$imageSelfData);
//文本翻译校对数据
$webTextTranslate = WebTranslate::where("alias",$tl)->where("url",$url)->where("type",WebTranslate::$textType)->first();
$webTextAllTranslate = WebTranslate::where("alias",$tl)->where("url","All")->where("type",WebTranslate::$textType)->first();
$textAllData = !empty($webTextAllTranslate) ? json_decode($webTextAllTranslate->data,true) : [];
$textSelfData = !empty($webTextTranslate) ? json_decode($webTextTranslate->data,true) : [];
$textData = array_merge($textSelfData, $textAllData);
// 图片按照节点还原
$tmp = [];
foreach ($images as $img){
$alt = $img->alt;
if($alt){
$tmp[] = $alt;
$key = count($tmp) - 1;
if (!empty($imageData) && isset($imageData[$alt])){
$img->attr['alt'] = $imageData[$alt];
}else{
$img->attr['alt'] = $tran_string[$key];
}
}
}
foreach ($aTitles as $aTitle){
$title = $aTitle->title;
if($title){
$tmp[] = $title;
$key = count($tmp) - 1;
if (!empty($textData) && isset($textData[$title])){
$aTitle->attr['title'] = $textData[$title];
}else{
$aTitle->attr['title'] = $tran_string[$key];
}
}
}
foreach ($texts as $text) {
$tag= $text->parent()->tag;
if (in_array($tag, ['script', 'style', 'root']))
continue;
$string = trim($text->text());
if (empty($string))
continue;
$country_class = '';
if (method_exists($text->parent()->parent(),"find") && $text->parent()->parent()->find("b")) {
$country_class = $text->parent()->parent()->find("b",0)->class;
}
if(FALSE !== strpos($country_class, 'country-flag'))
continue;
$tmp[] = htmlspecialchars_decode(html_entity_decode($string));
// FIXME 查找校对内容中是否有当前值 优先使用校对内容,没有获取翻译内容
$key = count($tmp) - 1;
// dump($string);
$string = html_entity_decode($string);
if (!empty($textData) && isset($textData[$string])){
// dump("数据库:".$textData[$string]);
$text->outertext = $textData[$string];
}else{
// dump("翻译:".$tran_string[$key]);
$text->outertext = $tran_string[$key];
}
}
// 按照节点还原 description、keywords
$tmp[] = $description;
$key = count($tmp) - 1;
if (isset($description->attr['content'])){
$dom->find("meta[name=description]")[0]->attr['content'] = $tran_string[$key];
}
$tmp[] = $keywords;
$key = count($tmp) - 1;
if (isset($description->attr['keywords'])){
$dom->find("meta[name=keywords]")[0]->attr['content'] = $tran_string[$key];
}
// 保存修改 清除缓存
$html_string = $dom->save();
$dom->clear();
return $html_string;
}
}
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2024/1/6
* Time: 14:00
*/
namespace App\Repositories;
use App\Models\SyncSubmitTask\SyncSubmitTask;
use App\Models\Visit\Visit;
/**
* Class SyncSubmitRepository
* @package App\Repositories
*/
class SyncSubmitRepository
{
/**
* 上线站点引流
* @param $ip
* @param $url
* @param $user_agent
* @param string $referrer_url
* @param int $device_port
* @param int $traffic
* @return bool
*/
public function trafficVisit($ip, $url, $user_agent, $referrer_url = '', $device_port = Visit::DEVICE_PC, $traffic = SyncSubmitTask::TRAFFIC_DEFAULT)
{
if (empty($ip) || $ip == '127.0.0.1')
return false;
if ($this->isBot($user_agent))
return false;
$url_array = parse_url($url);
if (empty($url_array['host']))
return false;
// 检查重置来源URL
$referrer_url = $this->initReferrer($referrer_url);
// 头信息中带有这些信息, 代表是手机端, 重置设备类型
if (preg_match('/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|wap|windowsce|ucweb/', $user_agent)) {
$device_port = 2;
}
// 组装字段数据
$array = [
'ip' => $ip,
'domain' => $url_array['host'],
'referer' => $referrer_url,
'user_agent' => $user_agent,
'data' => [
'url' => $url,
'domain' => $url_array['scheme'] . '://' . $url_array['host'],
'device_port' => in_array($device_port, array_keys(Visit::deviceMap())) ? $device_port : Visit::DEVICE_PC,
'referrer_url' => $referrer_url
]
];
SyncSubmitTask::createTask($array, SyncSubmitTask::TYPE_VISIT, $traffic);
return true;
}
/**
* 通过头信息,判断是否是蜘蛛爬虫
* @param $agent
* @return bool
*/
public function isBot($agent)
{
$spiderSite= ["TencentTraveler", "Baiduspider+", "BaiduGame", "Googlebot", "msnbot", "Sosospider+", "Sogou web spider", "ia_archiver", "Yahoo! Slurp", "YoudaoBot",
"Yahoo Slurp", "MSNBot", "Java (Often spam bot)", "BaiDuSpider", "Voila", "Yandex bot", "BSpider", "twiceler", "Sogou Spider", "Speedy Spider", "Google AdSense",
"Heritrix", "Python-urllib", "Alexa (IA Archiver)", "Ask", "Exabot", "Custo", "OutfoxBot/YodaoBot", "yacy", "SurveyBot", "legs", "lwp-trivial", "Nutch", "StackRambler",
"The web archive (IA Archiver)", "Perl tool", "MJ12bot", "Netcraft", "MSIECrawler", "WGet tools", "larbin", "Fish search", "yandex.com/bots", "google.com/bot",
"bingbot", "YandexMobileBot", "BingPreview", "AhrefsBot", "bot"
];
foreach($spiderSite as $val) {
$str = strtolower($val);
if (strpos($agent, $str) !== false) {
return true;
}
}
return false;
}
/**
* 按照规则重置referrer信息
* TODO 如果来自特定网站的原样返回, 其他的重置到google
* @param $referrer
* @return string
*/
public function initReferrer($referrer)
{
if (empty($referrer))
return '';
if (preg_match('/google|facebook|bing|yahoo|youtobe|linkedin|messefrankfurt|yandex|tiktok|twitter|instagram|reddit|telegram|pinterest|tumblr/', $referrer)) {
return $referrer;
}else{
return 'https://www.google.com/';
}
}
}
\ No newline at end of file
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2023/10/26
* Time: 13:55
*/
namespace App\Repositories;
/**
* Class ToolRepository
* @package App\Repositories
*/
class ToolRepository
{
/**
* @param $url
* @param $data
* @param string $method
* @param array $header
* @param int $time_out
* @return array
*/
public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
if ($data)
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([
'Expect:',
'Content-type: application/json',
'Accept: application/json',
], $header)
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return [$code, $response];
}
/**
* 多请求批处理
* @param $host
* @param $request_urls
* @return array
*/
public function batCurlblobr($request_urls)
{
// //脚本开始的毫秒时刻
// $start = microtime(true);
//打开一个curl批处理句柄
$mh = curl_multi_init();
$headers = [
"X-BLOBR-KEY:" . $this->key
];
$ch = [];
foreach ($request_urls as $key => $url) {
//初始化cURL会话
$ch[$key] = curl_init($url);
//设置curl传输选项
curl_setopt($ch[$key], CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch[$key], CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch[$key], CURLOPT_ENCODING, "");
curl_setopt($ch[$key], CURLOPT_MAXREDIRS, 10);
// curl_setopt($ch[$key], CURLOPT_TIMEOUT, $this->time_out);
curl_setopt($ch[$key], CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch[$key], CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch[$key], CURLOPT_HTTPHEADER, $headers);
// curl_setopt($ch[$key], CURLOPT_HEADER, 0);
//关闭https请求验证
// if (strpos($url,'https')){
// curl_setopt ( $ch[$key], CURLOPT_SSL_VERIFYPEER, false );
// curl_setopt ( $ch[$key], CURLOPT_SSL_VERIFYHOST, 2 );
// }
//向批处理句柄中添加单独的curl句柄
curl_multi_add_handle($mh, $ch[$key]);
}
$running = null;
//执行批处理句柄
do {
$mrc = curl_multi_exec($mh, $running);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($running && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) {
do {
$mrc = curl_multi_exec($mh, $running);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
$res = [];
//获取内容
foreach ($request_urls as $k => $url) {
//关闭执行完的子句柄
curl_multi_remove_handle($mh, $ch[$k]);
//返回获取的输出文本流
$res[$k] = curl_multi_getcontent($ch[$k]);
}
//5.关闭父curl
curl_multi_close($mh);
// $end = microtime(true) - $start;
// file_put_contents(__DIR__ . '/exec_time.log', $end . PHP_EOL, FILE_APPEND);
return $res;
}
/**
* 多请求批处理
* @param $headers
* @param $request_urls
* @return array
*/
public function batCurl($request_urls, $headers = [])
{
// //脚本开始的毫秒时刻
// $start = microtime(true);
//打开一个curl批处理句柄
$mh = curl_multi_init();
$ch = [];
foreach ($request_urls as $key => $url) {
//初始化cURL会话
$ch[$key] = curl_init($url);
//设置curl传输选项
curl_setopt($ch[$key], CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch[$key], CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch[$key], CURLOPT_ENCODING, "");
curl_setopt($ch[$key], CURLOPT_MAXREDIRS, 10);
curl_setopt($ch[$key], CURLOPT_TIMEOUT, 30);
curl_setopt($ch[$key], CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch[$key], CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch[$key], CURLOPT_HTTPHEADER, $headers);
// curl_setopt($ch[$key], CURLOPT_HEADER, 0);
//关闭https请求验证
// if (strpos($url,'https')){
// curl_setopt ( $ch[$key], CURLOPT_SSL_VERIFYPEER, false );
// curl_setopt ( $ch[$key], CURLOPT_SSL_VERIFYHOST, 2 );
// }
//向批处理句柄中添加单独的curl句柄
curl_multi_add_handle($mh, $ch[$key]);
}
$running = null;
//执行批处理句柄
do {
$mrc = curl_multi_exec($mh, $running);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($running && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) {
do {
$mrc = curl_multi_exec($mh, $running);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
$res = [];
//获取内容
foreach ($request_urls as $k => $url) {
//关闭执行完的子句柄
curl_multi_remove_handle($mh, $ch[$k]);
//返回获取的输出文本流
$res[$k] = curl_multi_getcontent($ch[$k]);
}
//5.关闭父curl
curl_multi_close($mh);
// $end = microtime(true) - $start;
// file_put_contents(__DIR__ . '/exec_time.log', $end . PHP_EOL, FILE_APPEND);
return $res;
}
/**
* 替换特殊词汇
* @param $data
* @return array
*/
public function filterString($data)
{
if (is_array($data)) {
foreach ($data as $key => $val) {
$data[$key] = $this->filterString($val);
}
} else {
$data = ' ' . $data;
$array = "/\(\w.*\)| company| Company| inc| Inc| Co| co| Ltd| ltd| Llc| llc| Import And Export| Limited| limited|,|\./";
$result = preg_replace($array, '', $data);
return $result == ' ' ? '' : $result;
}
return $data;
}
}
... ...
... ... @@ -3,16 +3,17 @@
namespace App\Services\Html;
use App\Models\Blog\Blog;
use App\Models\News\News;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\RouteMap;
use App\Models\RouteMap\RouteMap;
use App\Models\WebSetting\SettingNum;
use App\Models\WebSetting\WebSetting;
use App\Models\WebSetting\WebSettingAmp;
use App\Models\WebSetting\WebSettingNum;
use App\Models\WebSetting\WebSettingSeo;
class AmpService
... ... @@ -432,7 +433,7 @@ class AmpService
public static function getProductSortRule($project_id)
{
$order_list = [];
$orderDataFirst = WebSettingNum::where('project_id', $project_id)->where('type', 10)->first();
$orderDataFirst = SettingNum::where('project_id', $project_id)->where('type', 10)->first();
if ($orderDataFirst && $orderDataFirst->data) {
$orderData = json_decode($orderDataFirst->data, true);
foreach ($orderData as $key => $orderDataItem) {
... ...
... ... @@ -3,14 +3,14 @@
namespace App\Services\Html;
use App\Console\Commands\ProjectService;
use App\Helper\Translate;
use App\Models\Com\UpdateProgress;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\DomainInfo;
use App\Models\Project\Project;
use App\Models\Project\UpdateProgressModel;
use App\Models\RouteMap;
use App\Models\RouteMap\RouteMap;
use App\Models\WebSetting\Proofreading;
use App\Models\WebSetting\WebLanguage;
use App\Models\WebSetting\WebProofreading;
use App\Models\WebSetting\WebSetting;
... ... @@ -18,6 +18,7 @@ use App\Models\WebSetting\WebSettingCountry;
use App\Models\WebSetting\WebSettingHtml;
use App\Models\WebSetting\WebSettingText;
use App\Models\WebSetting\WebTemplateCommon;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\Redis;
use phpQuery;
... ... @@ -63,7 +64,7 @@ class CommonService
*/
public function translationProofread($project, $content, $lang,$domain)
{
$webProofreading = WebProofreading::where("project_id",$project->id)->where("alias",$lang)->get();
$webProofreading = Proofreading::where("project_id",$project->id)->where("alias",$lang)->get();
if (!empty($webProofreading)){
foreach ($webProofreading as $item){
$content = str_ireplace($item->text,$item->translate,$content);
... ... @@ -85,13 +86,6 @@ class CommonService
Redis::expire("project_".$project->id."_third_party_code", WebSetting::$redisExpireTime);
}
$phpQueryDom = phpQuery::newDocument($content);
//处理自定义页面样式问题
// if ($globalsojsSyles != ""){
// $phpQueryDom->find("#globalsojs-styles")->remove();
// $phpQueryDom->find('head')->append($globalsojsSyles);
// }
//网站icon
$webIcon = WebSetting::where("project_id",$project->id)->first();
if (!empty($webIcon)){
... ... @@ -104,15 +98,12 @@ class CommonService
}
}
}
//第三方代码(网页顶部,中间,底部),以后启用位置
if (!empty($webSettingHtml)) {
$phpQueryDom->find('head')->append($webSettingHtml->head_html?:'');
$phpQueryDom->find('body')->append($webSettingHtml->body_html?:'');
$phpQueryDom->find('html')->append($webSettingHtml->footer_html?:'');
}
//A端添加的网站追踪代码
$deployOptimize = DeployOptimize::where("project_id",$project->id)->first();
if (!empty($deployOptimize)){
... ... @@ -120,23 +111,12 @@ class CommonService
$phpQueryDom->find('head')->append($deployOptimize->meta);
}
}
//去掉非index页面header上面的headerindex属性
//if ($route != "index"){
//$phpQueryDom->find('header')->removeAttr("headerindex");
//}
//首页头部独立样式
if ($route == "index"){
$phpQueryDom->find('header')->attr("headerprivate","");
}
//处理header顶部搜索跳转链接
$phpQueryDom->find('header form')->attr("action", "/search/");
//生成锚点,以后启用位置
//$content = $this->anchorTextHandle($project,$route,$content);
//C端访问埋点
$isBodyEnd = $phpQueryDom->find('body')->eq(0);
if (count($isBodyEnd)>=1){
... ... @@ -147,21 +127,18 @@ class CommonService
$data = date("Y-m-d H:i:s");
$phpQueryDom->find('html')->append("<!-- Globalso Cache file was created on ".$data." -->");
//这个功能其他类型页面移到面包屑导航处理
if ($route == "index" || (!empty($routeMap) && $routeMap->source == WebTemplateCommon::$pageName)){
if ($route == "index" || (!empty($routeMap) && $routeMap->source == RouteMap::SOURCE_PAGE)){
$phpQueryDom->find('head')->append('<script>var currentPage = "'.$route.'"</script>');
}
if ($route == "search"){
//暂时先去掉小语种按钮显示
$phpQueryDom->find(".change-language")->remove();
$phpQueryDom->find('head')->append('<meta name="robots" content="noindex, nofollow"/>');
}
$phpQueryDom->find('body')->attr("unevents","");
$content = $phpQueryDom->htmlOuter();
unset($phpQueryDom);
phpQuery::unloadDocuments();
//处理全部内容,如果有上线正式域名,则把所有的测试域名替换为正式域名
$projectDomainInfo = DomainInfo::where("project_id",$project->id)->first();
if (!empty($projectDomainInfo)){
... ... @@ -253,7 +230,7 @@ class CommonService
if (!empty($project)){
$project->domain = $updateData->domain;
}
ProjectService::useProject($project->id,$updateData->domain);
ProjectServer::useProject($project->id);
}
return $project;
}
... ... @@ -264,7 +241,7 @@ class CommonService
public function getMinorLanguage($updateData)
{
$minorLanguage = [];
$updateProgressQuery = UpdateProgressModel::find($updateData->id);
$updateProgressQuery = UpdateProgress::find($updateData->id);
if (!empty($updateProgressQuery)){
$extends = $updateProgressQuery->extends;
if (!empty($extends)){
... ...
... ... @@ -3,34 +3,30 @@
namespace App\Services\Html;
use App\Helper\Str;
use App\Models\Blog\Blog;
use App\Models\Module\Module;
use App\Models\Module\ModuleCategory;
use App\Models\Collect\CollectTask;
use App\Models\Com\Notify;
use App\Models\Com\UpdateNotify;
use App\Models\Com\UpdateProgress;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\CollectTask;
use App\Models\Project\Country;
use App\Models\Project\CountryCustom;
use App\Models\Project\DeployBuild;
use App\Models\Project\DomainInfo;
use App\Models\Project\Notify;
use App\Models\Project\Project;
use App\Models\Project\UpdateHtmlModel;
use App\Models\Project\UpdateMasterWebsiteModel;
use App\Models\Project\UpdateMinorLanguagesModel;
use App\Models\Project\UpdateProgressModel;
use App\Models\RouteMap;
use App\Models\Template\BSetting;
use App\Models\WebSetting\WebCustom;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
use App\Models\Template\BTemplate;
use App\Models\Template\Setting;
use App\Models\WebSetting\SettingNum;
use App\Models\WebSetting\WebLanguage;
use App\Models\WebSetting\WebSettingNum;
use App\Models\WebSetting\WebTemplate;
use App\Models\WebSetting\WebTemplateCommon;
use App\Repositories\StaticHtmlRepository;
use Illuminate\Support\Facades\File;
use phpQuery;
... ... @@ -55,7 +51,6 @@ class CreatePageService{
if($project['update_info']['is_language_update'] == 0){
return '';
}
if ($source == 'news' || $source == 'blog' || $source == 'product' || $source == 'page' || $source == 'module'){
$routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("source",$source)->first();
}elseif($source == ''){
... ... @@ -63,28 +58,27 @@ class CreatePageService{
}else{
return '';
}
if($routerMap) {
switch ($routerMap->source) {
//产品详情
case WebTemplateCommon::$productName:
case RouteMap::SOURCE_PRODUCT:
$detail = Product::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();
break;
//博客详情
case WebTemplateCommon::$blogName:
case RouteMap::SOURCE_BLOG:
$detail = Blog::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();
break;
//新闻详情
case WebTemplateCommon::$newsName:
case RouteMap::SOURCE_NEWS:
$detail = News::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();
break;
//自定义模块详情
case WebTemplateCommon::$extendName:
case RouteMap::SOURCE_MODULE:
$detail = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
break;
default:
//单页详情
$detail = WebCustom::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();
$detail = BCustomTemplate::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();
}
if($detail && $detail->six_read){
return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);
... ... @@ -104,7 +98,6 @@ class CreatePageService{
$html = "";
$page = $page == null ? null : (int)$page;
$router = $route == "" ? "404" : $route;
$productKeywordRouter = new Keyword();
$productKeywordRouters = $productKeywordRouter->product_keyword_route;
if (in_array($router, $productKeywordRouters)) {
... ... @@ -117,15 +110,15 @@ class CreatePageService{
$routerMapRegular = new stdClass();
if (empty($routerMap)){
if ($router == "products"){
$routerMapRegular->source = WebTemplateCommon::$productCategoryName;
$routerMapRegular->source = RouteMap::SOURCE_PRODUCT_CATE;
$routerMapRegular->route = "products";
}
if ($router == "news"){
$routerMapRegular->source = WebTemplateCommon::$newsCategoryName;
$routerMapRegular->source = RouteMap::SOURCE_NEWS_CATE;
$routerMapRegular->route = "news";
}
if ($router == "blog"){
$routerMapRegular->source = WebTemplateCommon::$blogCategoryName;
$routerMapRegular->source = RouteMap::SOURCE_BLOG_CATE;
$routerMapRegular->route = "blog";
}
$routerMapRegular->source_id = 0;
... ... @@ -155,43 +148,43 @@ class CreatePageService{
$type = $routerMap->source;
switch ($type) {
//产品详情
case WebTemplateCommon::$productName:
case RouteMap::SOURCE_PRODUCT:
$html = $this->getProductPage($project,$routerMap);
break;
//产品列表
case WebTemplateCommon::$productCategoryName:
case RouteMap::SOURCE_PRODUCT_CATE:
$html = $this->getProductListPage($project,$routerMap,$page);
break;
//博客详情
case WebTemplateCommon::$blogName:
case RouteMap::SOURCE_BLOG:
$html = $this->getBlogPage($project,$routerMap);
break;
//博客列表
case WebTemplateCommon::$blogCategoryName:
case RouteMap::SOURCE_BLOG_CATE:
$html = $this->getBlogListPage($project,$routerMap,$page);
break;
//新闻详情
case WebTemplateCommon::$newsName:
case RouteMap::SOURCE_NEWS:
$html = $this->getNewsPage($project,$routerMap);
break;
//新闻列表
case WebTemplateCommon::$newsCategoryName:
case RouteMap::SOURCE_NEWS_CATE:
$html = $this->getNewsListPage($project,$routerMap,$page);
break;
//自定义模块列表
case WebTemplateCommon::$extendCategoryName:
case RouteMap::SOURCE_MODULE_CATE:
$html = $this->getModuleListPage($project,$routerMap,$page);
break;
//自定义模块详情
case WebTemplateCommon::$extendName:
case RouteMap::SOURCE_MODULE:
$html = $this->getModulePage($project,$routerMap);
break;
//聚合页
case WebTemplateCommon::$productKeywordName:
case RouteMap::SOURCE_PRODUCT_KEYWORD:
$html = $this->getProductKeywordPage($project,$routerMap);
break;
case WebTemplateCommon::$pageName:
if ($router == WebTemplateCommon::$indexName){
case RouteMap::SOURCE_PAGE:
if ($router == RouteMap::SOURCE_INDEX){
//首页
$html = $this->getIndexPage($project,$routerMap);
}else{
... ... @@ -216,36 +209,28 @@ class CreatePageService{
$commonService = new CommonService();
$tdkService = new TdkService();
//首页模板
$info = BSetting::where("project_id",$project->id)->first();
$info = Setting::where("project_id",$project->id)->first();
if (empty($info)){
return "";
}
$webIndexTemplate = WebTemplate::where("project_id",$project->id)->where("template_id",$info->template_id)->where("source",1)->first();
$webIndexTemplate = BTemplate::where("project_id",$project->id)->where("template_id",$info->template_id)->where("source",1)->first();
if (!empty($webIndexTemplate)){
$html = $pageService->isAndGetVisualizationHtml($project,WebTemplateCommon::$indexName,$routerMap);
$html = $pageService->isAndGetVisualizationHtml($project,RouteMap::SOURCE_INDEX,$routerMap);
if ($html == ""){
//组装首页页面
$html = $pageService->assembleIndexPage($project,$webIndexTemplate);
}
// $filePath = public_path("6666.html");
// file_put_contents($filePath, $html);
// dd(5656);
//公共处理
$html = $pageService->publicHtmlHandle($html,$project->id);
$isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$indexName);
$isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_INDEX);
if ((int)$isVisual == 1 || $isVisual == null){
//产品,产品分类,新闻,博客(section模板通用数据模块处理)
$html = $pageService->generalTemplateProcessingForDataModules($html,$project->id);
}
//第三方
$html = $commonService->thirdPartyCodeHandle($project,$html,WebTemplateCommon::$indexName);
$html = $commonService->thirdPartyCodeHandle($project,$html,RouteMap::SOURCE_INDEX);
//TDK处理
$html = $tdkService->pageTdkHandle($project,$html,WebTemplateCommon::$indexName,$routerMap);
//特殊首页模块处理
// $html = $pageService->specialIndexModuleHandle($project,$html);
//处理URL等,处理html链接a标签href
$html = $tdkService->pageTdkHandle($project,$html,RouteMap::SOURCE_INDEX,$routerMap);
if (!empty($html)){
return $this->pageUrlHandle($project,$routerMap,$html);
}else{
... ... @@ -265,16 +250,16 @@ class CreatePageService{
$commonService = new CommonService();
$tdkService = new TdkService();
//公共拼接页面方法
$webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$productCategoryName,$routerMap);
$webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_PRODUCT_CATE,$routerMap);
//公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$productCategoryName,$routerMap,$page);
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_PRODUCT_CATE,$routerMap,$page);
//是否开启可视化
$isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$productCategoryName);
$isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_PRODUCT_CATE);
if ((int)$isVisual == 1 || $isVisual == null){
//产品,产品分类,新闻,博客(section模板通用数据模块处理)
$webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
}
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$productCategoryName,$routerMap);
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_PRODUCT_CATE,$routerMap);
$webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
unset($pageService);
$html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route);
... ... @@ -300,10 +285,10 @@ class CreatePageService{
$products_detail = $pageService->productDataHandle($project,$products_detail);
if (!empty($products_detail)){
//公共拼接页面方法
$webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$productName,$routerMap);
$webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_PRODUCT,$routerMap);
//公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,"product",$routerMap,null);
$isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$productName);
$isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_PRODUCT);
if ((int)$isVisual == 1 || $isVisual == null){
//产品,产品分类,新闻,博客(section模板通用数据模块处理)
$webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
... ... @@ -361,7 +346,7 @@ class CreatePageService{
$webCustomHtml = $commonService->thirdPartyCodeHandle($project, $html, $routerMap->route);
//TDK
unset($html,$productsKeywordsList,$productsRecommendAndHot,$blogT);
$html = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$productKeywordName,$routerMap);
$html = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_PRODUCT_KEYWORD,$routerMap);
//处理URL等,处理html链接a标签href
if (!empty($html)){
return $this->pageUrlHandle($project,$routerMap,$html);
... ... @@ -383,15 +368,15 @@ class CreatePageService{
$tdkService = new TdkService();
$routePath = $routerMap->route;
//公共拼接页面方法
$webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$newsCategoryName,$routerMap);
$webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_NEWS_CATE,$routerMap);
//公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$newsCategoryName,$routerMap,$page);
$isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$newsCategoryName);
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_NEWS_CATE,$routerMap,$page);
$isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_NEWS_CATE);
if ((int)$isVisual == 1 || $isVisual == null){
//产品,产品分类,新闻,博客(section模板通用数据模块处理)
$webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
}
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$newsCategoryName,$routerMap);
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_NEWS_CATE,$routerMap);
$webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
unset($pageService);
$html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath);
... ... @@ -414,16 +399,16 @@ class CreatePageService{
$tdkService = new TdkService();
$routePath = $routerMap->route;
//公共拼接页面方法
$webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$extendCategoryName,$routerMap);
$webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_MODULE_CATE,$routerMap);
//公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$extendCategoryName,$routerMap,$page);
$moduleCategoryInfo = ModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id);
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_MODULE_CATE,$routerMap,$page);
$moduleCategoryInfo = CustomModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id);
if (isset($moduleCategoryInfo->getExtend->list_visualization) && $moduleCategoryInfo->getExtend->list_visualization == 1){
//产品,产品分类,新闻,博客(section模板通用数据模块处理)
$webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
}
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$extendCategoryName,$routerMap);
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_MODULE_CATE,$routerMap);
$webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
unset($pageService);
$html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath);
... ... @@ -436,7 +421,7 @@ class CreatePageService{
}
/**
* 获取产品新闻页html
* 获取新闻页html
*/
public function getNewsPage($project,$routerMap,$lang=''): string
{
... ... @@ -451,16 +436,16 @@ class CreatePageService{
return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);
}else{
//公共拼接页面方法
$webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$newsName,$routerMap);
$webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_NEWS,$routerMap);
//公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$newsName,$routerMap,null);
$isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$newsName);
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_NEWS,$routerMap,null);
$isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_NEWS);
if ((int)$isVisual == 1 || $isVisual == null){
//产品,产品分类,新闻,博客(section模板通用数据模块处理)
$webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
}
//TDK处理
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$newsName,$routerMap);
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_NEWS,$routerMap);
//网页公共部分
$webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
unset($pageService);
... ... @@ -487,22 +472,22 @@ class CreatePageService{
$tdkService = new TdkService();
//页面路由
$routePath = $routerMap->route;
$module_detail = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
$module_detail = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
if (!empty($module_detail)){
if($project['update_info']['is_update'] && $module_detail->six_read){
return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);
}else{
//公共拼接页面方法
$webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$extendName,$routerMap);
$webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_MODULE,$routerMap);
//公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$extendName,$routerMap,null);
$moduleCategoryInfo = Module::getModuleCategory($project->id,$module_detail);
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_MODULE,$routerMap,null);
$moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$module_detail);
if (isset($moduleCategoryInfo->getExtend->detail_visualization) && $moduleCategoryInfo->getExtend->detail_visualization == 1){
//产品,产品分类,新闻,博客(section模板通用数据模块处理)
$webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
}
//TDK处理
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$extendName,$routerMap);
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_MODULE,$routerMap);
//网页公共部分
$webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
unset($pageService);
... ... @@ -528,15 +513,15 @@ class CreatePageService{
$commonService = new CommonService();
$tdkService = new TdkService();
//公共拼接页面方法
$webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$blogCategoryName,$routerMap);
$webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_BLOG_CATE,$routerMap);
//公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$blogCategoryName,$routerMap,$page);
$isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$blogCategoryName);
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_BLOG_CATE,$routerMap,$page);
$isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_BLOG_CATE);
if ((int)$isVisual == 1 || $isVisual == null){
//产品,产品分类,新闻,博客(section模板通用数据模块处理)
$webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
}
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$blogCategoryName,$routerMap);
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_BLOG_CATE,$routerMap);
$webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
unset($pageService);
$html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route);
... ... @@ -562,15 +547,15 @@ class CreatePageService{
return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);
}else{
//公共拼接页面方法
$webCustomHtml = $pageService->publicMontagePage($project,WebTemplateCommon::$blogName,$routerMap);
$webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_BLOG,$routerMap);
//公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,WebTemplateCommon::$blogName,$routerMap,null);
$isVisual = $pageService->isOpenVisualization($project,WebTemplateCommon::$blogName);
$webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_BLOG,$routerMap,null);
$isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_BLOG);
if ((int)$isVisual == 1 || $isVisual == null){
//产品,产品分类,新闻,博客(section模板通用数据模块处理)
$webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
}
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,WebTemplateCommon::$blogName,$routerMap);
$webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_BLOG,$routerMap);
$webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
unset($pageService);
//生成静态页
... ... @@ -597,22 +582,22 @@ class CreatePageService{
$tdkService = new TdkService();
//页面路由
$routePath = $routerMap->route;
$webCustom = WebCustom::where("id",$routerMap->source_id)->where("status",1)->first();
$webCustom = BCustomTemplate::where("id",$routerMap->source_id)->where("status",1)->first();
if (!empty($webCustom)){
if($project['update_info']['is_update'] && $webCustom->six_read){
return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);
}else{
//公共拼接页面方法
$content = $pageService->publicMontagePage($project,WebTemplateCommon::$pageName,$routerMap);
$content = $pageService->publicMontagePage($project,RouteMap::SOURCE_PAGE,$routerMap);
//公共左侧导航处理
$phpQueryDom=phpQuery::newDocument($content);
$pageService->leftNavSideNavHandle($project,WebTemplateCommon::$pageName,$phpQueryDom,$routerMap);
$pageService->leftNavSideNavHandle($project,RouteMap::SOURCE_PAGE,$phpQueryDom,$routerMap);
$content = $phpQueryDom->htmlOuter();
unset($phpQueryDom);
//产品,产品分类,新闻,博客(section模板通用数据模块处理)
$content = $pageService->generalTemplateProcessingForDataModules($content,$project->id);
//生成静态页
$content = $tdkService->pageTdkHandle($project,$content,WebTemplateCommon::$pageName,$routerMap);
$content = $tdkService->pageTdkHandle($project,$content,RouteMap::SOURCE_PAGE,$routerMap);
$content = $pageService->publicHtmlHandle($content,$project->id);
unset($pageService);
$html = $commonService->thirdPartyCodeHandle($project,$content,$routePath,$routerMap);
... ... @@ -679,22 +664,14 @@ class CreatePageService{
$domainEnd = $project->domain_end;
//主站a链接处理
$this->masterWebATagHandle($phpQueryDom,$project,$domainEnd);
//html 标签处理
$this->htmlTagHandle($phpQueryDom,$project);
//888项目禁用鼠标右键点击,查看元素
// $this->prohibitRightMouseClick($phpQueryDom,$project);
//国家
$webCountry = $pageService->getCountryList($project->id);
//语种 alternate
$this->setHrefLang($phpQueryDom,$project,$route,$page,$lang,$webCountry);
//以-tag的聚合页结尾的路由加上 <meta name="robots" content="noindex">
$this->setTagRobotsNoindex($phpQueryDom,$routerMap);
//<meta name="cookie_consent_banner" content="参数值"> 配置
$this->setCookieConsentBanner($phpQueryDom,$project);
... ... @@ -841,18 +818,8 @@ class CreatePageService{
}
$countryUrl[$key]["alias"] = $item->short;
}
//之前
// $langShort = $item->short == "en" ? "" : $item->short."/";
// if ((int)$page != null) {
// $countryUrl[$key]["url"] = "https://" . $domain . "/" .$langShort . $route . "/" . (int)$page . "/";
// } else {
// $countryUrl[$key]["url"] = $route == "index" ? "https://" . $domain . "/" . $langShort : "https://" . $domain . "/" . $langShort. $route . "/";
// }
// $countryUrl[$key]["alias"] = $item->short;
}
}
//路径
if ($route == "index") {
$webUrl = "https://" . $domain . "/";
... ... @@ -873,7 +840,6 @@ class CreatePageService{
}
}
}
$phpQueryDom->find('head')->append("<meta property='og:url' content='$route'/>");
$phpQueryDom->find('head')->append("<link rel='canonical' href='$webUrl' />");
if (!empty($countryUrl)){
... ... @@ -890,7 +856,7 @@ class CreatePageService{
*/
public function setTagRobotsNoindex($phpQueryDom,$routerMap)
{
if (isset($routerMap->source) && $routerMap->source == WebTemplateCommon::$productKeywordName){
if (isset($routerMap->source) && $routerMap->source == RouteMap::SOURCE_PRODUCT_KEYWORD){
$routerSuffix = substr($routerMap->route, -4);
$routerLength = strlen($routerMap->route);
if ($routerLength >= 4 && $routerSuffix == "-tag"){
... ... @@ -991,8 +957,8 @@ class CreatePageService{
}elseif($routerMap->source == "blog"){
$route = "/blogs/".$route;
}elseif($routerMap->source == "module"){
$modules = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
$moduleCategoryInfo = Module::getModuleCategory($project->id,$modules);
$modules = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
$moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$modules);
if (isset($moduleCategoryInfo->route) && !empty($moduleCategoryInfo->route)){
$route = "/".$moduleCategoryInfo->route."/".$route;
}
... ... @@ -1044,7 +1010,7 @@ class CreatePageService{
}elseif ($routerMap->source == "product_category"){
$route = $page == null || $page == 1 ? "/".$route : "/".$route."/page";
}elseif ($routerMap->source == "module_category"){
$moduleCategory = ModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id);
$moduleCategory = CustomModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id);
if (!empty($moduleCategory->getExtend->route)){
if ($moduleCategory->getExtend->route == $route){
$route = "/".$moduleCategory->route;
... ... @@ -1055,8 +1021,8 @@ class CreatePageService{
$route = "/".$moduleCategory->route."/page";
}
}elseif ($routerMap->source == "module"){
$modules = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
$moduleCategoryInfo = Module::getModuleCategory($project->id,$modules);
$modules = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
$moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$modules);
if (isset($moduleCategoryInfo->getExtend->route) && !empty($moduleCategoryInfo->getExtend->route)){
$route = "/".$moduleCategoryInfo->route."/".$modules->route;
}else{
... ... @@ -1143,8 +1109,8 @@ class CreatePageService{
}elseif($routerMap->source == "blog"){
$route = "/blogs/".$route;
}elseif($routerMap->source == "module"){
$modules = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
$moduleCategoryInfo = Module::getModuleCategory($project->id,$modules);
$modules = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
$moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$modules);
if (isset($moduleCategoryInfo->route) && !empty($moduleCategoryInfo->route)){
$route = "/".$moduleCategoryInfo->route."/".$route;
}
... ... @@ -1187,8 +1153,8 @@ class CreatePageService{
}elseif ($routerMap->source == "product_category"){
$route = "/".$route."/page";
}elseif ($routerMap->source == "module"){
$modules = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
$moduleCategoryInfo = Module::getModuleCategory($project->id,$modules);
$modules = CustomModule::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
$moduleCategoryInfo = CustomModule::getModuleCategory($project->id,$modules);
if (isset($moduleCategoryInfo->getExtend->route) && !empty($moduleCategoryInfo->getExtend->route)){
$route = "/".$moduleCategoryInfo->getExtend->route."_catalog/".$moduleCategoryInfo->route."/page";
}else{
... ... @@ -1514,7 +1480,7 @@ Disallow: /";
$routers = null;
$perPage = 100;
$offset = ($pageNum - 1) * $perPage;
$updateNotifyQuery = UpdateHtmlModel::where("project_id",$updateNotifyData->project_id);
$updateNotifyQuery = UpdateNotify::where("project_id",$updateNotifyData->project_id);
if ($updateNotifyData->route == Notify::ROUTE_ALL){
//所有更新
if ($updateNotifyData->type == Notify::TYPE_MASTER){
... ... @@ -1783,7 +1749,7 @@ Disallow: /";
if ($count != 0){
if ($router->type == "product_category"){
$webSettingNum = WebSettingNum::where("project_id",$updateNotifyData->project_id)->where("type",WebSettingNum::$productListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$productListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$perPage = (int)$webSettingNum->num;
}else{
... ... @@ -1791,7 +1757,7 @@ Disallow: /";
}
$total = (int)ceil($count / $perPage); //产品分类总页数
}elseif($router->type == "news_category"){
$webSettingNum = WebSettingNum::where("project_id",$updateNotifyData->project_id)->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$perPage = (int)$webSettingNum->num;
}else{
... ... @@ -1799,7 +1765,7 @@ Disallow: /";
}
$total = (int)ceil($count / $perPage); //新闻总页数
}else{
$webSettingNum = WebSettingNum::where("project_id",$updateNotifyData->project_id)->where("type",WebSettingNum::$blogListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$blogListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$perPage = (int)$webSettingNum->num;
}else{
... ... @@ -1851,7 +1817,7 @@ Disallow: /";
if (empty($routerProductsMap)){
$productsCount = Product::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->whereNotNull('route')->orderBy("id","DESC")->count();
if ($productsCount != 0){
$webSettingNum = WebSettingNum::where("project_id",$updateNotifyData->project_id)->where("type",WebSettingNum::$productListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$productListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$perPage = (int)$webSettingNum->num;
}else{
... ... @@ -1883,7 +1849,7 @@ Disallow: /";
$routerNewsMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route","news")->first();
if (empty($routerNewsMap)){
$newsCount = News::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->orderBy("id","DESC")->count();
$webSettingNum = WebSettingNum::where("project_id",$updateNotifyData->project_id)->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$perPage = (int)$webSettingNum->num;
}else{
... ... @@ -1914,7 +1880,7 @@ Disallow: /";
$routerBlogMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route","blog")->first();
if (empty($routerBlogMap)){
$blogCount = Blog::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->orderBy("id","DESC")->count();
$webSettingNum = WebSettingNum::where("project_id",$updateNotifyData->project_id)->where("type",WebSettingNum::$blogListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$blogListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$perPage = (int)$webSettingNum->num;
}else{
... ... @@ -1978,7 +1944,7 @@ Disallow: /";
*/
public function getUpdateProgress($projectId,$type)
{
$updateProgressQuery = UpdateProgressModel::where("project_id",(int)$projectId)->orderBy("id","desc");
$updateProgressQuery = UpdateProgress::where("project_id",(int)$projectId)->orderBy("id","desc");
if ($type == "master_website"){
$updateProgressQuery = $updateProgressQuery->where("type",1)->first();
}else{
... ...
... ... @@ -4,6 +4,8 @@
namespace App\Services\Html;
use App\Models\Blog\Blog;
use App\Models\CustomModule\CustomModule;
use App\Models\Domain\DomainInfo;
use App\Models\Module\Module;
use App\Models\News\News;
use App\Models\News\NewsCategory;
... ... @@ -11,9 +13,10 @@ use App\Models\Product\Category;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\Project\DeployBuild;
use App\Models\Project\DomainInfo;
use App\Models\Project\Project;
use App\Models\RouteMap;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
use App\Models\WebSetting\SettingNum;
use App\Models\WebSetting\WebCustom;
use App\Models\WebSetting\WebLanguage;
use App\Models\WebSetting\WebSettingNum;
... ... @@ -38,7 +41,6 @@ class CreateSitemapService{
if (empty($domainInfo) || $domain == "demo.globalso.site"){
return true;
}
$lang = $lang=="en" || $lang=="" ? "" : "/".$lang;
$page = $page == null || (int)$page == 1 ? null : "/".(int)$page;
if (!empty($routerMap)){
... ... @@ -510,7 +512,7 @@ tr.stripe { background-color:#f7f7f7; }
$count = Product::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$productCategoryItem->source_id.",%")->where("status",1)->count();
$innerNum++;
if ($count >= 1){
$webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$productListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$productListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$categoryNum = (int)$webSettingNum->num;
}else{
... ... @@ -599,7 +601,7 @@ tr.stripe { background-color:#f7f7f7; }
$count = Product::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$productCategoryItem->source_id.",%")->where("status",1)->count();
$innerNum++;
if ($count >= 1){
$webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$productListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$productListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$categoryNum = (int)$webSettingNum->num;
}else{
... ... @@ -692,37 +694,6 @@ tr.stripe { background-color:#f7f7f7; }
$innerNum = 0;
$xmlInnerDom = "";
if (!empty($productKeywordInfo['productKeywordListInfo'])){
//关键词列表页sitemap
// foreach ($productKeywordInfo['productKeywordListInfo'] as $v){
// if ($v["total"]>=1){
// $isExistFile = $this->isExistHtmlFile($item['domain'],"",null,$v["route"],null);
// if ($isExistFile){
// $innerNum++ ;
// $url = 'https://'.$domain.'/'.$v["route"].'/';
// $xmlInnerDom .= $this->getUrlStr($url);
// }
// for ($j = 2; $j <= $v["total"]; $j++) {
// $isExistFile = $this->isExistHtmlFile($item['domain'],"",null,$v["route"],$j);
// if ($isExistFile){
// $innerNum++;
// $url = 'https://'.$domain.'/'.$v["route"].'/'.$j.'/';
// $xmlInnerDom .= $this->getUrlStr($url);
// }
// if ($innerNum == $this->perPage){
// $sitemapXmlDom = $sitemapHeader.$xmlInnerDom.$sitemapFooter;
// $botNum = $outerNum+1 == 1 ? "" : "_".($outerNum+1);
// $sitemapPath = public_path($domain."/product_keywords".$botNum."_sitemap.xml");
// $this->putSitemapFile($sitemapPath,$sitemapXmlDom);
// $xmlInnerDom = '';
// $urlXml = 'https://'.$domain.'/product_keywords'.$botNum.'_sitemap.xml';
// $sitemapMain .= $this->getUrlStr($urlXml);
// $innerNum = 0;
// $outerNum++;
// }
// }
// }
// }
//关键词详情页sitemap
$keywordData = $keywordModel->where("project_id",$item["project_id"])->where("status",1)->get();
if (!empty($keywordData)){
... ... @@ -776,61 +747,6 @@ tr.stripe { background-color:#f7f7f7; }
$innerNum = 0;
$xmlInnerDom = "";
if (!empty($productKeywordInfo['productKeywordListInfo'])){
//关键词列表页sitemap
// foreach ($productKeywordInfo['productKeywordListInfo'] as $v){
// if ($v["total"]>=1){
// $innerNum++ ;
// if ($linkingFormat == 1){
// $langAlias = $webCountry->short == "en" ? "" : $webCountry->short."/";
// $isExistFile = $this->isExistHtmlFile($item['domain'],$webCountry->short,null,$v["route"],null);
// if ($isExistFile){
// $url = 'https://'.$domain.'/'.$langAlias.$v["route"].'/';
// $xmlInnerDom .= $this->getUrlStr($url);
// }
// }else{
// $domain_top = $this->getDoMain($domain);
// $isExistFile = $this->isExistHtmlFile($item['domain'],$webCountry->short,null,$v["route"],null);
// if ($isExistFile){
// $url = 'https://'.$webCountry->short.'.'.$domain_top.'/'.$v["route"].'/';
// $xmlInnerDom .= $this->getUrlStr($url);
// }
// }
//
// for ($j = 2; $j <= $v["total"]; $j++) {
// if ($linkingFormat == 1){
// $langAlias = $webCountry->short == "en" ? "" : $webCountry->short."/";
// $isExistFile = $this->isExistHtmlFile($item['domain'],$webCountry->short,null,$v["route"],$j);
// if ($isExistFile){
// $innerNum++;
// $url = 'https://'.$domain.'/'.$langAlias.$v["route"].'/'.$j.'/';
// $xmlInnerDom .= $this->getUrlStr($url);
// }
// }else{
// $isExistFile = $this->isExistHtmlFile($item['domain'],$webCountry->short,null,$v["route"],$j);
// if ($isExistFile){
// $innerNum++;
// $domain_top = $this->getDoMain($domain);
// $url = 'https://'.$webCountry->short.'.'.$domain_top.'/'.$v["route"].'/'.$j.'/';
// $xmlInnerDom .= $this->getUrlStr($url);
// }
// }
//
// if ($innerNum == $this->perPage){
// $botNum = $outerNum+1 == 1 ? "" : "_".($outerNum+1);
// $sitemapXmlDom = $sitemapHeader.$xmlInnerDom.$sitemapFooter;
// $sitemapPath = public_path($domain."/product_keywords_".$webCountry->short."_trans".$botNum."_sitemap.xml");
// $this->putSitemapFile($sitemapPath,$sitemapXmlDom);
// $xmlInnerDom = '';
// $urlXml = 'https://'.$domain.'/product_keywords_'.$webCountry->short.'_trans'.$botNum.'_sitemap.xml';
// $sitemapMain .= $this->getUrlStr($urlXml);
// $innerNum = 0;
// $outerNum++;
// }
// }
// }
//
// }
//关键词详情页sitemap
$keywordData = $keywordModel->where("project_id",$item["project_id"])->where("status",1)->get();
if (!empty($keywordData)){
... ... @@ -891,10 +807,10 @@ tr.stripe { background-color:#f7f7f7; }
$botNum = $outerNum+1 == 1 ? "" : "_".($outerNum+1);
$moduleCategoryUrlItem = '';
foreach ($moduleCategory as $moduleCategoryItem){
$count = Module::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$moduleCategoryItem->source_id.",%")->where("status",0)->count();
$count = CustomModule::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$moduleCategoryItem->source_id.",%")->where("status",0)->count();
$innerNum++;
if ($count >= 1){
$webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$categoryNum = (int)$webSettingNum->num;
}else{
... ... @@ -966,7 +882,7 @@ tr.stripe { background-color:#f7f7f7; }
}
$innerNum++;
if ($count >= 1){
$webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$categoryNum = (int)$webSettingNum->num;
}else{
... ... @@ -1049,7 +965,7 @@ tr.stripe { background-color:#f7f7f7; }
$newsCategoryUrlItem .= $this->getUrlStr($url);
}
}
$webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$categoryNum = (int)$webSettingNum->num;
}else{
... ... @@ -1096,7 +1012,7 @@ tr.stripe { background-color:#f7f7f7; }
$count = News::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$newsCategoryItem->source_id.",%")->where("status",1)->count();
$innerNum++;
if ($count >= 1){
$webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$categoryNum = (int)$webSettingNum->num;
}else{
... ... @@ -1177,8 +1093,8 @@ tr.stripe { background-color:#f7f7f7; }
$data = RouteMap::where("project_id",$item["project_id"])->where("source","module")->offset($offset)->limit($perPage)->get();
if (!empty($data)){
foreach ($data as $j){
$module_detail = Module::where("project_id",$item["project_id"])->where("id",$j->source_id)->where("status",0)->first();
$moduleAndCategoryInfo = Module::getModuleCategory($item["project_id"],$module_detail);
$module_detail = CustomModule::where("project_id",$item["project_id"])->where("id",$j->source_id)->where("status",0)->first();
$moduleAndCategoryInfo = CustomModule::getModuleCategory($item["project_id"],$module_detail);
if (!empty($module_detail) && !empty($moduleAndCategoryInfo)){
$isExistFile = $this->isExistHtmlFile($item['domain'],"",$j,$j->route,null);
if ($isExistFile){
... ... @@ -1334,7 +1250,7 @@ tr.stripe { background-color:#f7f7f7; }
$count = Blog::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$blogCategoryItem->source_id.",%")->where("status",1)->count();
$innerNum++;
if ($count >= 1){
$webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$blogListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$blogListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$categoryNum = (int)$webSettingNum->num;
}else{
... ... @@ -1403,7 +1319,7 @@ tr.stripe { background-color:#f7f7f7; }
$count = Blog::where("project_id",$item["project_id"])->where("category_id","like","%,".(string)$blogCategoryItem->source_id.",%")->where("status",1)->count();
$innerNum++;
if ($count >= 1){
$webSettingNum = WebSettingNum::where("project_id",$item["project_id"])->where("type",WebSettingNum::$blogListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$item["project_id"])->where("type",SettingNum::$blogListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$categoryNum = (int)$webSettingNum->num;
}else{
... ... @@ -1578,7 +1494,7 @@ tr.stripe { background-color:#f7f7f7; }
$data = RouteMap::where("project_id",$item["project_id"])->where("source","page")->where("route","!=","index")->offset($offset)->limit($perPage)->get();
if (!empty($data)){
foreach ($data as $j){
$customPage = WebCustom::where("project_id",$j->project_id)->where("status",1)->where("url",$j->route)->first();
$customPage = BCustomTemplate::where("project_id",$j->project_id)->where("status",1)->where("url",$j->route)->first();
if (!empty($customPage)){
if ($j->route != '404'){
$isExistFile = $this->isExistHtmlFile($item['domain'],"",$j,$j->route,null);
... ... @@ -1825,7 +1741,7 @@ tr.stripe { background-color:#f7f7f7; }
foreach ($sitemapType as $type){
if ($type == "product_category"){
//产品分类
$webSettingNum = WebSettingNum::where("project_id",$projectId)->where("type",WebSettingNum::$productListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$projectId)->where("type",SettingNum::$productListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$productCategoryNum = (int)$webSettingNum->num;
}else{
... ... @@ -1846,7 +1762,7 @@ tr.stripe { background-color:#f7f7f7; }
$allTypeRouteCountAndPageInfo[$type]["page_total"] = $productTotal;
}else if ($type == "news_category"){
//新闻分类
$webSettingNum = WebSettingNum::where("project_id",$projectId)->where("type",WebSettingNum::$newsListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$projectId)->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$newsCategoryNum = (int)$webSettingNum->num;
}else{
... ... @@ -1866,7 +1782,7 @@ tr.stripe { background-color:#f7f7f7; }
$allTypeRouteCountAndPageInfo[$type]["page_total"] = $newsTotal;
}else if ($type == "blog_category"){
//博客分类
$webSettingNum = WebSettingNum::where("project_id",$projectId)->where("type",WebSettingNum::$blogListType)->orderBy("id","desc")->first();
$webSettingNum = SettingNum::where("project_id",$projectId)->where("type",WebSettingNum::$blogListType)->orderBy("id","desc")->first();
if (!empty($webSettingNum)){
$blogCategoryNum = (int)$webSettingNum->num;
}else{
... ...
... ... @@ -3,10 +3,11 @@
namespace App\Services\Html;
use App\Models\Domain\DomainInfo;
use App\Models\Project\DeleteHtmlModel;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\DomainInfo;
use App\Models\RouteMap\RouteDelete;
use App\Models\WebSetting\WebSetting;
use Illuminate\Support\Facades\Redis;
... ... @@ -121,7 +122,7 @@ class DeletePageService{
if (file_exists($path)){
$this->deleteDirectory($path);
}
DeleteHtmlModel::where("project_id",$data->project_id)->where("route",$v->route)->delete();
RouteDelete::where("project_id",$data->project_id)->where("route",$v->route)->delete();
}
}
... ...
... ... @@ -9,7 +9,7 @@ use App\Models\Blog\BlogCategory;
use App\Models\Module\CustomModuleExtendContent;
use App\Models\Module\Module;
use App\Models\Module\ModuleCategory;
use App\Models\News\News;
use App\Models\Nav\BNav;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
... ... @@ -22,7 +22,7 @@ use App\Models\Project\DeployBuild;
use App\Models\Project\Project;
use App\Models\Project\ProjectPageSetting;
use App\Models\Project\VisualizationHtml;
use App\Models\RouteMap;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service;
use App\Models\Template\BSetting;
use App\Models\Template\TemplateTypeMain;
... ... @@ -30,8 +30,6 @@ use App\Models\Template\WebTemplateMain;
use App\Models\WebSetting\AggregationSetting;
use App\Models\WebSetting\WebCustom;
use App\Models\WebSetting\WebLanguage;
use App\Models\WebSetting\WebNav;
use App\Models\WebSetting\WebNavGroup;
use App\Models\WebSetting\WebSetting;
use App\Models\WebSetting\WebSettingImage;
use App\Models\WebSetting\WebSettingNum;
... ... @@ -147,14 +145,7 @@ class PageService{
$blockDescDom = $navNumModule->find("[blockdesc]")->eq(0);
$dataNavType = $dataNavType == null || $dataNavType=="" || $dataNavType=="default" ? 1 : (int)$dataNavType;
if (count($blockItemOuterDom) != 0){
// $nav = null;
// $flattenedArray = WebNavGroup::getNavGroupSortListByID($projectId,$dataNavType);
// if (!empty($flattenedArray)){
// $nav = WebNav::where("project_id",$projectId)->whereIn('id', $flattenedArray)->orderByRaw(DB::raw("FIELD(id, " . implode(",", $flattenedArray) . ")"))->where("group_id",$dataNavType)->where("status",1)->get();
// }else{
// $nav = WebNav::where("project_id",$projectId)->where("group_id",$dataNavType)->orderBy("sort","desc")->orderBy("id","desc")->where("status",1)->get();
// }
$nav = WebNav::where("project_id",$projectId)->where("group_id",$dataNavType)->orderBy("sort","asc")->orderBy("id","asc")->where("status",1)->get();
$nav = BNav::where("project_id",$projectId)->where("group_id",$dataNavType)->orderBy("sort","asc")->orderBy("id","asc")->where("status",1)->get();
if (!empty($nav)){
//菜单第一种递归
// $nav = $this->tree($nav->toArray());
... ... @@ -715,12 +706,6 @@ class PageService{
if((int)$dataNavModule != 0){
$dataNavType = $countryDom->eq($i)->attr("data-nav-type");
$dataNavType = $dataNavType == null || $dataNavType=="" || $dataNavType=="default" ? 2 : (int)$dataNavType;
// $flattenedArray = WebNavGroup::getNavGroupSortListByID($projectId,$dataNavType);
// if (!empty($flattenedArray)){
// $navData = WebNav::where("project_id",$projectId)->whereIn('id', $flattenedArray)->orderByRaw(DB::raw("FIELD(id, " . implode(",", $flattenedArray) . ")"))->get();
// }else{
// $navData = WebNav::where("project_id",$projectId)->where("group_id",$dataNavType)->orderBy("sort","desc")->orderBy("id","desc")->get();
// }
$navData = WebNav::where("project_id",$projectId)->where("group_id",$dataNavType)->orderBy("sort","asc")->orderBy("id","asc")->get();
if (!empty($navData)){
... ...