作者 lyh
@@ -95,6 +95,12 @@ class HtmlCollect extends Command @@ -95,6 +95,12 @@ class HtmlCollect extends Command
95 //采集html页面,下载资源到本地并替换 95 //采集html页面,下载资源到本地并替换
96 try { 96 try {
97 $html = curl_c('https://' . $collect_info->domain . $collect_info->route, false); 97 $html = curl_c('https://' . $collect_info->domain . $collect_info->route, false);
  98 + if($html == '0'){
  99 + $collect_info->status = CollectTask::STATUS_FAIL;
  100 + $collect_info->save();
  101 + return true;
  102 + }
  103 +
98 $source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url); 104 $source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url);
99 105
100 if ($source_list) { 106 if ($source_list) {
@@ -102,6 +102,12 @@ class HtmlLanguageCollect extends Command @@ -102,6 +102,12 @@ class HtmlLanguageCollect extends Command
102 //采集html页面,下载资源到本地并替换 102 //采集html页面,下载资源到本地并替换
103 try { 103 try {
104 $html = curl_c('https://' . $collect_info->domain . $collect_info->route, false); 104 $html = curl_c('https://' . $collect_info->domain . $collect_info->route, false);
  105 + if($html == '0'){
  106 + $collect_info->status = CollectTask::STATUS_FAIL;
  107 + $collect_info->save();
  108 + return true;
  109 + }
  110 +
105 $source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url); 111 $source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url);
106 112
107 if ($source_list) { 113 if ($source_list) {
@@ -272,6 +272,7 @@ class ProjectUpdate extends Command @@ -272,6 +272,7 @@ class ProjectUpdate extends Command
272 'description' => $item['description'] ?? '' 272 'description' => $item['description'] ?? ''
273 ]), 273 ]),
274 'status' => Product::STATUS_ON, 274 'status' => Product::STATUS_ON,
  275 + 'is_upgrade' => 1,
275 'route' => $route 276 'route' => $route
276 ]); 277 ]);
277 $this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id); 278 $this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id);
@@ -334,6 +335,7 @@ class ProjectUpdate extends Command @@ -334,6 +335,7 @@ class ProjectUpdate extends Command
334 'text' => $item['content'] ?? '', 335 'text' => $item['content'] ?? '',
335 'image' => $image, 336 'image' => $image,
336 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE, 337 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE,
  338 + 'is_upgrade' => 1,
337 'url' => $route 339 'url' => $route
338 ]); 340 ]);
339 $this->set_map($route, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id); 341 $this->set_map($route, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id);
@@ -382,6 +384,7 @@ class ProjectUpdate extends Command @@ -382,6 +384,7 @@ class ProjectUpdate extends Command
382 'description' => $item['description'] ?? '', 384 'description' => $item['description'] ?? '',
383 'html' => $item['content'] ?? '', 385 'html' => $item['content'] ?? '',
384 'status' => 1, 386 'status' => 1,
  387 + 'is_upgrade' => 1,
385 'url' => $route 388 'url' => $route
386 ]); 389 ]);
387 $this->set_map($route, RouteMap::SOURCE_PAGE, $id, $project_id); 390 $this->set_map($route, RouteMap::SOURCE_PAGE, $id, $project_id);
@@ -268,10 +268,10 @@ class BlogLogic extends BaseLogic @@ -268,10 +268,10 @@ class BlogLogic extends BaseLogic
268 $text = ''; 268 $text = '';
269 if($data[4]){ 269 if($data[4]){
270 //处理内容中的图片 270 //处理内容中的图片
271 - $pattern = '<img src="(.*?)">'; 271 + $pattern = '/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i';
272 preg_match_all($pattern, $data[4], $result); 272 preg_match_all($pattern, $data[4], $result);
273 - if($result[1]){  
274 - foreach ($result[1] as $img){ 273 + if($result[2]){
  274 + foreach ($result[2] as $img){
275 $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]); 275 $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]);
276 } 276 }
277 } 277 }
@@ -292,8 +292,7 @@ class BlogLogic extends BaseLogic @@ -292,8 +292,7 @@ class BlogLogic extends BaseLogic
292 'operator_id' => $user_id, 292 'operator_id' => $user_id,
293 'create_id' => $user_id, 293 'create_id' => $user_id,
294 'status' => Blog::STATUS_ONE, 294 'status' => Blog::STATUS_ONE,
295 - 'url' => '',  
296 - 'is_upgrade'=>1 295 + 'url' => ''
297 ] 296 ]
298 ); 297 );
299 //更新路由 298 //更新路由
@@ -304,10 +304,10 @@ class NewsLogic extends BaseLogic @@ -304,10 +304,10 @@ class NewsLogic extends BaseLogic
304 $text = ''; 304 $text = '';
305 if($data[4]){ 305 if($data[4]){
306 //处理内容中的图片 306 //处理内容中的图片
307 - $pattern = '<img src="(.*?)">'; 307 + $pattern = '/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i';
308 preg_match_all($pattern, $data[4], $result); 308 preg_match_all($pattern, $data[4], $result);
309 - if($result[1]){  
310 - foreach ($result[1] as $img){ 309 + if($result[2]){
  310 + foreach ($result[2] as $img){
311 $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]); 311 $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]);
312 } 312 }
313 } 313 }
@@ -328,8 +328,7 @@ class NewsLogic extends BaseLogic @@ -328,8 +328,7 @@ class NewsLogic extends BaseLogic
328 'operator_id' => $user_id, 328 'operator_id' => $user_id,
329 'create_id' => $user_id, 329 'create_id' => $user_id,
330 'status' => News::STATUS_ONE, 330 'status' => News::STATUS_ONE,
331 - 'url' => '',  
332 - 'is_upgrade'=>1 331 + 'url' => ''
333 ] 332 ]
334 ); 333 );
335 //更新路由 334 //更新路由
@@ -637,8 +637,7 @@ class ProductLogic extends BaseLogic @@ -637,8 +637,7 @@ class ProductLogic extends BaseLogic
637 'content' => $content, 637 'content' => $content,
638 'seo_mate' => Arr::a2s($seo_mate), 638 'seo_mate' => Arr::a2s($seo_mate),
639 'created_uid' => $user_id, 639 'created_uid' => $user_id,
640 - 'status' => Product::STATUS_ON,  
641 - 'is_upgrade'=>1 640 + 'status' => Product::STATUS_ON
642 ] 641 ]
643 ); 642 );
644 //更新路由 643 //更新路由
@@ -34,7 +34,7 @@ class UpdateLog extends Model @@ -34,7 +34,7 @@ class UpdateLog extends Model
34 $log->api_type = $type; 34 $log->api_type = $type;
35 $log->api_url = $url; 35 $log->api_url = $url;
36 $log->sort = $type == 'category' ? 0 : 1; 36 $log->sort = $type == 'category' ? 0 : 1;
37 - $log->collect_status = ($type == 'category' || $type == 'website_info') ? 1 : 0; 37 + $log->collect_status = ($type == 'category' || $type == 'website_info' || $type == 'tag') ? 1 : 0;
38 return $log->save(); 38 return $log->save();
39 } 39 }
40 return true; 40 return true;
@@ -58,7 +58,7 @@ class UpdateLog extends Model @@ -58,7 +58,7 @@ class UpdateLog extends Model
58 } 58 }
59 $log->save(); 59 $log->save();
60 } 60 }
61 - 61 +
62 return true; 62 return true;
63 } 63 }
64 } 64 }