作者 lyh
... ... @@ -95,6 +95,12 @@ class HtmlCollect extends Command
//采集html页面,下载资源到本地并替换
try {
$html = curl_c('https://' . $collect_info->domain . $collect_info->route, false);
if($html == '0'){
$collect_info->status = CollectTask::STATUS_FAIL;
$collect_info->save();
return true;
}
$source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url);
if ($source_list) {
... ...
... ... @@ -102,6 +102,12 @@ class HtmlLanguageCollect extends Command
//采集html页面,下载资源到本地并替换
try {
$html = curl_c('https://' . $collect_info->domain . $collect_info->route, false);
if($html == '0'){
$collect_info->status = CollectTask::STATUS_FAIL;
$collect_info->save();
return true;
}
$source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url);
if ($source_list) {
... ...
... ... @@ -272,6 +272,7 @@ class ProjectUpdate extends Command
'description' => $item['description'] ?? ''
]),
'status' => Product::STATUS_ON,
'is_upgrade' => 1,
'route' => $route
]);
$this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id);
... ... @@ -334,6 +335,7 @@ class ProjectUpdate extends Command
'text' => $item['content'] ?? '',
'image' => $image,
'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE,
'is_upgrade' => 1,
'url' => $route
]);
$this->set_map($route, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id);
... ... @@ -382,6 +384,7 @@ class ProjectUpdate extends Command
'description' => $item['description'] ?? '',
'html' => $item['content'] ?? '',
'status' => 1,
'is_upgrade' => 1,
'url' => $route
]);
$this->set_map($route, RouteMap::SOURCE_PAGE, $id, $project_id);
... ...
... ... @@ -268,10 +268,10 @@ class BlogLogic extends BaseLogic
$text = '';
if($data[4]){
//处理内容中的图片
$pattern = '<img src="(.*?)">';
$pattern = '/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i';
preg_match_all($pattern, $data[4], $result);
if($result[1]){
foreach ($result[1] as $img){
if($result[2]){
foreach ($result[2] as $img){
$data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]);
}
}
... ... @@ -292,8 +292,7 @@ class BlogLogic extends BaseLogic
'operator_id' => $user_id,
'create_id' => $user_id,
'status' => Blog::STATUS_ONE,
'url' => '',
'is_upgrade'=>1
'url' => ''
]
);
//更新路由
... ...
... ... @@ -304,10 +304,10 @@ class NewsLogic extends BaseLogic
$text = '';
if($data[4]){
//处理内容中的图片
$pattern = '<img src="(.*?)">';
$pattern = '/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i';
preg_match_all($pattern, $data[4], $result);
if($result[1]){
foreach ($result[1] as $img){
if($result[2]){
foreach ($result[2] as $img){
$data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]);
}
}
... ... @@ -328,8 +328,7 @@ class NewsLogic extends BaseLogic
'operator_id' => $user_id,
'create_id' => $user_id,
'status' => News::STATUS_ONE,
'url' => '',
'is_upgrade'=>1
'url' => ''
]
);
//更新路由
... ...
... ... @@ -637,8 +637,7 @@ class ProductLogic extends BaseLogic
'content' => $content,
'seo_mate' => Arr::a2s($seo_mate),
'created_uid' => $user_id,
'status' => Product::STATUS_ON,
'is_upgrade'=>1
'status' => Product::STATUS_ON
]
);
//更新路由
... ...
... ... @@ -34,7 +34,7 @@ class UpdateLog extends Model
$log->api_type = $type;
$log->api_url = $url;
$log->sort = $type == 'category' ? 0 : 1;
$log->collect_status = ($type == 'category' || $type == 'website_info') ? 1 : 0;
$log->collect_status = ($type == 'category' || $type == 'website_info' || $type == 'tag') ? 1 : 0;
return $log->save();
}
return true;
... ... @@ -58,7 +58,7 @@ class UpdateLog extends Model
}
$log->save();
}
return true;
}
}
... ...