作者 刘锟

update

... ... @@ -101,7 +101,7 @@ class HtmlLanguageCollect extends Command
$source_list = $this->html_preg($new_html, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']);
if ($source_list) {
$html = $this->upload_source($html, $source_list, $project_id);
$html = $this->upload_source($html, $source_list, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']);
}
} catch (\Exception $e) {
$collect_info->status = CollectTask::STATUS_FAIL;
... ... @@ -283,9 +283,6 @@ class HtmlLanguageCollect extends Command
{
if ($url) {
$url = str_replace('"', '', $url);
if(strpos($url,'mailto:') !== false){
return false;
}
$arr = parse_url($url);
$scheme = $arr['scheme'] ?? '';
$host = $arr['host'] ?? '';
... ... @@ -323,7 +320,7 @@ class HtmlLanguageCollect extends Command
}
//下载并替换资源
protected function upload_source($html, $source, $project_id)
protected function upload_source($html, $source, $project_id, $domain, $web_url_domain, $home_url)
{
foreach ($source as $vs) {
... ... @@ -389,6 +386,36 @@ class HtmlLanguageCollect extends Command
]);
}
}
} elseif (substr($new_source, -2, 2) == 'js') {
$js_html = curl_c(getImageUrl($new_source), false);
preg_match_all("/[large|thumb]+URL:['\"]+(\s*[^>]+?)['\"]+,/i", $js_html, $result_js_source);
$js_source = $result_js_source[1] ?? [];
if ($js_source) {
foreach ($js_source as $vjs) {
$vjs_result = $this->url_check($vjs, $project_id, $domain, $web_url_domain, $home_url);
if (!$vjs_result) {
continue;
}
if ($vjs_result['download']) {
$new_vjs = CosService::uploadRemote($project_id, 'source', $vjs_result['url_complete']);
if ($new_vjs) {
CollectSource::insert([
'project_id' => $project_id,
'origin' => $vjs_result['url'],
'target' => $new_vjs,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
$js_html = str_replace($vjs, getImageUrl($new_vjs), $js_html);
}
} else {
$js_html = str_replace($vjs, getImageUrl($vjs_result['url_complete']), $js_html);
}
}
CosService::uploadRemote($project_id, 'source', $new_source, $new_source, $js_html);
}
}
}
} else {
... ...