Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
11 个修改的文件
包含
94 行增加
和
14 行删除
| @@ -94,11 +94,20 @@ class HtmlCollect extends Command | @@ -94,11 +94,20 @@ class HtmlCollect extends Command | ||
| 94 | 94 | ||
| 95 | //采集html页面,下载资源到本地并替换 | 95 | //采集html页面,下载资源到本地并替换 |
| 96 | try { | 96 | try { |
| 97 | - $html = file_get_contents('https://' . $collect_info->domain . $collect_info->route); | 97 | + $opts = [ |
| 98 | + 'http' => [ | ||
| 99 | + 'header' => 'User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0' | ||
| 100 | + ], | ||
| 101 | + 'ssl' => [ | ||
| 102 | + 'verify_peer' => false, | ||
| 103 | + 'verify_peer_name' => false, | ||
| 104 | + ] | ||
| 105 | + ]; | ||
| 106 | + $html = file_get_contents('https://' . $collect_info->domain . $collect_info->route, false, stream_context_create($opts)); | ||
| 98 | $source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url); | 107 | $source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url); |
| 99 | 108 | ||
| 100 | if ($source_list) { | 109 | if ($source_list) { |
| 101 | - $html = $this->upload_source($html, $source_list, $project_id); | 110 | + $html = $this->upload_source($html, $source_list, $project_id, $opts); |
| 102 | } | 111 | } |
| 103 | } catch (\Exception $e) { | 112 | } catch (\Exception $e) { |
| 104 | $collect_info->status = CollectTask::STATUS_FAIL; | 113 | $collect_info->status = CollectTask::STATUS_FAIL; |
| @@ -271,7 +280,7 @@ class HtmlCollect extends Command | @@ -271,7 +280,7 @@ class HtmlCollect extends Command | ||
| 271 | } | 280 | } |
| 272 | 281 | ||
| 273 | //下载并替换资源 | 282 | //下载并替换资源 |
| 274 | - protected function upload_source($html, $source, $project_id) | 283 | + protected function upload_source($html, $source, $project_id, $opts) |
| 275 | { | 284 | { |
| 276 | foreach ($source as $vs) { | 285 | foreach ($source as $vs) { |
| 277 | 286 | ||
| @@ -289,7 +298,7 @@ class HtmlCollect extends Command | @@ -289,7 +298,7 @@ class HtmlCollect extends Command | ||
| 289 | 298 | ||
| 290 | if (substr($new_source, -3, 3) == 'css') { | 299 | if (substr($new_source, -3, 3) == 'css') { |
| 291 | // 下载css文件中的资源 | 300 | // 下载css文件中的资源 |
| 292 | - $css_html = file_get_contents($vs['url_complete']); | 301 | + $css_html = file_get_contents($vs['url_complete'], false, stream_context_create($opts)); |
| 293 | preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source); | 302 | preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source); |
| 294 | $css_source = $result_css_source[1] ?? []; | 303 | $css_source = $result_css_source[1] ?? []; |
| 295 | 304 |
| @@ -93,11 +93,20 @@ class HtmlLanguageCollect extends Command | @@ -93,11 +93,20 @@ class HtmlLanguageCollect extends Command | ||
| 93 | 93 | ||
| 94 | //采集html页面,下载资源到本地并替换 | 94 | //采集html页面,下载资源到本地并替换 |
| 95 | try { | 95 | try { |
| 96 | - $html = file_get_contents('https://' . $collect_info->domain . $collect_info->route); | 96 | + $opts = [ |
| 97 | + 'http' => [ | ||
| 98 | + 'header' => 'User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0' | ||
| 99 | + ], | ||
| 100 | + 'ssl' => [ | ||
| 101 | + 'verify_peer' => false, | ||
| 102 | + 'verify_peer_name' => false, | ||
| 103 | + ] | ||
| 104 | + ]; | ||
| 105 | + $html = file_get_contents('https://' . $collect_info->domain . $collect_info->route, false, stream_context_create($opts)); | ||
| 97 | $source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url); | 106 | $source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url); |
| 98 | 107 | ||
| 99 | if ($source_list) { | 108 | if ($source_list) { |
| 100 | - $html = $this->upload_source($html, $source_list, $project_id); | 109 | + $html = $this->upload_source($html, $source_list, $project_id, $opts); |
| 101 | } | 110 | } |
| 102 | } catch (\Exception $e) { | 111 | } catch (\Exception $e) { |
| 103 | $collect_info->status = CollectTask::STATUS_FAIL; | 112 | $collect_info->status = CollectTask::STATUS_FAIL; |
| @@ -270,7 +279,7 @@ class HtmlLanguageCollect extends Command | @@ -270,7 +279,7 @@ class HtmlLanguageCollect extends Command | ||
| 270 | } | 279 | } |
| 271 | 280 | ||
| 272 | //下载并替换资源 | 281 | //下载并替换资源 |
| 273 | - protected function upload_source($html, $source, $project_id) | 282 | + protected function upload_source($html, $source, $project_id, $opts) |
| 274 | { | 283 | { |
| 275 | foreach ($source as $vs) { | 284 | foreach ($source as $vs) { |
| 276 | 285 | ||
| @@ -288,7 +297,7 @@ class HtmlLanguageCollect extends Command | @@ -288,7 +297,7 @@ class HtmlLanguageCollect extends Command | ||
| 288 | 297 | ||
| 289 | if (substr($new_source, -3, 3) == 'css') { | 298 | if (substr($new_source, -3, 3) == 'css') { |
| 290 | // 下载css文件中的资源 | 299 | // 下载css文件中的资源 |
| 291 | - $css_html = file_get_contents($vs['url_complete']); | 300 | + $css_html = file_get_contents($vs['url_complete'], false, stream_context_create($opts)); |
| 292 | preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source); | 301 | preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source); |
| 293 | $css_source = $result_css_source[1] ?? []; | 302 | $css_source = $result_css_source[1] ?? []; |
| 294 | 303 |
| @@ -177,7 +177,7 @@ class UpdateSeoTdk extends Command | @@ -177,7 +177,7 @@ class UpdateSeoTdk extends Command | ||
| 177 | if(!Redis::setnx($cache_key, 1)){ | 177 | if(!Redis::setnx($cache_key, 1)){ |
| 178 | continue; | 178 | continue; |
| 179 | } | 179 | } |
| 180 | - Redis::expire($cache_key, 300); | 180 | + Redis::expire($cache_key, 120); |
| 181 | 181 | ||
| 182 | echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL; | 182 | echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL; |
| 183 | $v = DB::connection('custom_mysql')->table($table)->where('id', $v['id'])->first(); | 183 | $v = DB::connection('custom_mysql')->table($table)->where('id', $v['id'])->first(); |
| @@ -24,7 +24,7 @@ class BlogController extends BaseController | @@ -24,7 +24,7 @@ class BlogController extends BaseController | ||
| 24 | * @time :2023/9/14 10:45 | 24 | * @time :2023/9/14 10:45 |
| 25 | */ | 25 | */ |
| 26 | public function lists(BlogModel $blogModel){ | 26 | public function lists(BlogModel $blogModel){ |
| 27 | - $filed = ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']; | 27 | + $filed = ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url','release_at']; |
| 28 | $this->order = 'sort'; | 28 | $this->order = 'sort'; |
| 29 | $query = $blogModel->orderBy($this->order ,'desc')->orderBy('id','desc'); | 29 | $query = $blogModel->orderBy($this->order ,'desc')->orderBy('id','desc'); |
| 30 | $query = $this->searchParam($query); | 30 | $query = $this->searchParam($query); |
| @@ -24,7 +24,7 @@ class NewsController extends BaseController | @@ -24,7 +24,7 @@ class NewsController extends BaseController | ||
| 24 | * @method | 24 | * @method |
| 25 | */ | 25 | */ |
| 26 | public function lists(NewsModel $news){ | 26 | public function lists(NewsModel $news){ |
| 27 | - $filed = ['id','category_id','operator_id','status','created_at','image','updated_at','name','sort','url']; | 27 | + $filed = ['id','category_id','operator_id','status','created_at','image','updated_at','name','sort','url', 'release_at']; |
| 28 | $this->order = 'sort'; | 28 | $this->order = 'sort'; |
| 29 | $query = $news->orderBy($this->order ,'desc')->orderBy('id','desc'); | 29 | $query = $news->orderBy($this->order ,'desc')->orderBy('id','desc'); |
| 30 | $query = $this->searchParam($query); | 30 | $query = $this->searchParam($query); |
| @@ -54,15 +54,16 @@ class KeywordLogic extends BaseLogic | @@ -54,15 +54,16 @@ class KeywordLogic extends BaseLogic | ||
| 54 | $this->param = $this->handleSaveParam($this->param); | 54 | $this->param = $this->handleSaveParam($this->param); |
| 55 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 55 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 56 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 56 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 57 | + $id = $this->param['id']; | ||
| 57 | }else{ | 58 | }else{ |
| 58 | $this->param['project_id'] = $this->user['project_id']; | 59 | $this->param['project_id'] = $this->user['project_id']; |
| 59 | $this->param['created_at'] = date('Y-m-d H:i:s'); | 60 | $this->param['created_at'] = date('Y-m-d H:i:s'); |
| 60 | $this->param['updated_at'] = $this->param['created_at']; | 61 | $this->param['updated_at'] = $this->param['created_at']; |
| 61 | $id = $this->model->insertGetId($this->param); | 62 | $id = $this->model->insertGetId($this->param); |
| 62 | - //路由映射 | ||
| 63 | - $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | ||
| 64 | - $this->model->edit(['route'=>$route],['id'=>$id]); | ||
| 65 | } | 63 | } |
| 64 | + //路由映射 | ||
| 65 | + $route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | ||
| 66 | + $this->model->edit(['route'=>$route],['id'=>$id]); | ||
| 66 | //清除缓存 | 67 | //清除缓存 |
| 67 | Common::del_user_cache('product_keyword',$this->user['project_id']); | 68 | Common::del_user_cache('product_keyword',$this->user['project_id']); |
| 68 | DB::commit(); | 69 | DB::commit(); |
| @@ -92,6 +93,12 @@ class KeywordLogic extends BaseLogic | @@ -92,6 +93,12 @@ class KeywordLogic extends BaseLogic | ||
| 92 | if(isset($param['keyword_video']) && !empty($param['keyword_video'])){ | 93 | if(isset($param['keyword_video']) && !empty($param['keyword_video'])){ |
| 93 | $param['keyword_video'] = Arr::a2s($param['keyword_video']); | 94 | $param['keyword_video'] = Arr::a2s($param['keyword_video']); |
| 94 | } | 95 | } |
| 96 | + if(!empty($param['related_news_ids'])){ | ||
| 97 | + $param['related_news_ids'] = Arr::arrToSet($param['related_news_ids']); | ||
| 98 | + } | ||
| 99 | + if(!empty($param['related_blog_ids'])){ | ||
| 100 | + $param['related_blog_ids'] = Arr::arrToSet($param['related_blog_ids']); | ||
| 101 | + } | ||
| 95 | return $param; | 102 | return $param; |
| 96 | } | 103 | } |
| 97 | 104 |
| @@ -34,6 +34,8 @@ class KeywordRequest extends FormRequest | @@ -34,6 +34,8 @@ class KeywordRequest extends FormRequest | ||
| 34 | 'seo_title'=>'max:200', | 34 | 'seo_title'=>'max:200', |
| 35 | 'seo_keywords'=>'max:200', | 35 | 'seo_keywords'=>'max:200', |
| 36 | 'seo_description'=>'max:200', | 36 | 'seo_description'=>'max:200', |
| 37 | + 'related_news_ids'=>'array|max:2', | ||
| 38 | + 'related_blog_ids'=>'array|max:2', | ||
| 37 | ]; | 39 | ]; |
| 38 | } | 40 | } |
| 39 | 41 | ||
| @@ -45,6 +47,8 @@ class KeywordRequest extends FormRequest | @@ -45,6 +47,8 @@ class KeywordRequest extends FormRequest | ||
| 45 | 'seo_title.max' => 'SEO标题不能超过200个字符', | 47 | 'seo_title.max' => 'SEO标题不能超过200个字符', |
| 46 | 'seo_keywords.max' => 'SEO关键词不能超过200个字符', | 48 | 'seo_keywords.max' => 'SEO关键词不能超过200个字符', |
| 47 | 'seo_description.max' => 'SEO描述不能超过200个字符', | 49 | 'seo_description.max' => 'SEO描述不能超过200个字符', |
| 50 | + 'related_news_ids.max' => '关联新闻不能超过两条', | ||
| 51 | + 'related_blog_ids.max' => '关联博客不能超过两条', | ||
| 48 | ]; | 52 | ]; |
| 49 | } | 53 | } |
| 50 | 54 |
| @@ -14,6 +14,14 @@ class Blog extends Base | @@ -14,6 +14,14 @@ class Blog extends Base | ||
| 14 | public function user(){ | 14 | public function user(){ |
| 15 | return $this->hasMany(User::class,'operator_id','id'); | 15 | return $this->hasMany(User::class,'operator_id','id'); |
| 16 | } | 16 | } |
| 17 | + | ||
| 18 | + public function getReleaseAtAttribute($value){ | ||
| 19 | + if(!$value){ | ||
| 20 | + return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at'))); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + return $value; | ||
| 24 | + } | ||
| 17 | } | 25 | } |
| 18 | 26 | ||
| 19 | 27 |
| @@ -15,4 +15,12 @@ class News extends Base | @@ -15,4 +15,12 @@ class News extends Base | ||
| 15 | public static function getNumByProjectId($project_id){ | 15 | public static function getNumByProjectId($project_id){ |
| 16 | return self::where('project_id', $project_id)->where('status', 1)->count(); | 16 | return self::where('project_id', $project_id)->where('status', 1)->count(); |
| 17 | } | 17 | } |
| 18 | + | ||
| 19 | + public function getReleaseAtAttribute($value){ | ||
| 20 | + if(!$value){ | ||
| 21 | + return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at'))); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + return $value; | ||
| 25 | + } | ||
| 18 | } | 26 | } |
| @@ -56,4 +56,30 @@ class Keyword extends Base | @@ -56,4 +56,30 @@ class Keyword extends Base | ||
| 56 | } | 56 | } |
| 57 | return $value; | 57 | return $value; |
| 58 | } | 58 | } |
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * @param $value | ||
| 62 | + * @return array|mixed | ||
| 63 | + * @author zbj | ||
| 64 | + * @date 2023/11/21 | ||
| 65 | + */ | ||
| 66 | + public function getRelatedNewsIdsAttribute($value){ | ||
| 67 | + if(!empty($value)){ | ||
| 68 | + $value = Arr::setToArr($value); | ||
| 69 | + } | ||
| 70 | + return $value; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * @param $value | ||
| 75 | + * @return array|false|mixed|string[] | ||
| 76 | + * @author zbj | ||
| 77 | + * @date 2023/11/21 | ||
| 78 | + */ | ||
| 79 | + public function getRelatedBlogIdsAttribute($value){ | ||
| 80 | + if(!empty($value)){ | ||
| 81 | + $value = Arr::setToArr($value); | ||
| 82 | + } | ||
| 83 | + return $value; | ||
| 84 | + } | ||
| 59 | } | 85 | } |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Models\RouteMap; | 3 | namespace App\Models\RouteMap; |
| 4 | 4 | ||
| 5 | use App\Helper\Translate; | 5 | use App\Helper\Translate; |
| 6 | +use App\Http\Logic\Aside\Project\ProjectLogic; | ||
| 6 | use App\Models\Base; | 7 | use App\Models\Base; |
| 7 | 8 | ||
| 8 | /** | 9 | /** |
| @@ -106,6 +107,14 @@ class RouteMap extends Base | @@ -106,6 +107,14 @@ class RouteMap extends Base | ||
| 106 | } | 107 | } |
| 107 | try { | 108 | try { |
| 108 | $route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first(); | 109 | $route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first(); |
| 110 | + //上线项目 不能修改链接了 | ||
| 111 | + if($route_map){ | ||
| 112 | + $project = ProjectLogic::instance()->getInfo($project_id); | ||
| 113 | + if($project['type'] !== Project::STATUS_ONE){ | ||
| 114 | + return $route_map->route; | ||
| 115 | +// throw new \Exception('站点已上线,禁止修改链接'); | ||
| 116 | + } | ||
| 117 | + } | ||
| 109 | if(!$route_map){ | 118 | if(!$route_map){ |
| 110 | $route_map = new self(); | 119 | $route_map = new self(); |
| 111 | $route_map->source = $source; | 120 | $route_map->source = $source; |
-
请 注册 或 登录 后发表评论