作者 lyh
@@ -418,39 +418,39 @@ class HtmlCollect extends Command @@ -418,39 +418,39 @@ class HtmlCollect extends Command
418 } 418 }
419 } 419 }
420 } 420 }
421 - } elseif(substr($vs['url_complete'], -2, 2) == 'js') {  
422 -  
423 - $js_html = curl_c(getImageUrl($vs['url_complete']), false);  
424 - preg_match_all("/[large|thumb]+URL:['\"]+(\s*[^>]+?)['\"]+,/i", $js_html, $result_js_source);  
425 - $js_source = $result_js_source[1] ?? [];  
426 - if($js_source){  
427 - foreach ($js_source as $vjs) {  
428 - $vjs_result = $this->url_check($vjs, $project_id, $domain, $web_url_domain, $home_url);  
429 - if (!$vjs_result) {  
430 - continue;  
431 - } 421 + } else {
  422 + $html = str_replace($vs['url'], getImageUrl($vs['url_complete']), $html);
  423 + if(substr($vs['url_complete'], -2, 2) == 'js'){
  424 + $js_html = curl_c(getImageUrl($vs['url_complete']), false);
  425 + preg_match_all("/[large|thumb]+URL:['\"]+(\s*[^>]+?)['\"]+,/i", $js_html, $result_js_source);
  426 + $js_source = $result_js_source[1] ?? [];
  427 + if($js_source){
  428 + foreach ($js_source as $vjs) {
  429 + $vjs_result = $this->url_check($vjs, $project_id, $domain, $web_url_domain, $home_url);
  430 + if (!$vjs_result) {
  431 + continue;
  432 + }
432 433
433 - if ($vjs_result['download']) {  
434 - $new_vjs = CosService::uploadRemote($project_id, 'source', $vjs_result['url_complete']);  
435 - if ($new_vjs) {  
436 - CollectSource::insert([  
437 - 'project_id' => $project_id,  
438 - 'origin' => $vjs_result['url'],  
439 - 'target' => $new_vjs,  
440 - 'created_at' => date('Y-m-d H:i:s'),  
441 - 'updated_at' => date('Y-m-d H:i:s'),  
442 - ]);  
443 - $js_html = str_replace($vjs, getImageUrl($new_vjs), $js_html); 434 + if ($vjs_result['download']) {
  435 + $new_vjs = CosService::uploadRemote($project_id, 'source', $vjs_result['url_complete']);
  436 + if ($new_vjs) {
  437 + CollectSource::insert([
  438 + 'project_id' => $project_id,
  439 + 'origin' => $vjs_result['url'],
  440 + 'target' => $new_vjs,
  441 + 'created_at' => date('Y-m-d H:i:s'),
  442 + 'updated_at' => date('Y-m-d H:i:s'),
  443 + ]);
  444 + $js_html = str_replace($vjs, getImageUrl($new_vjs), $js_html);
  445 + }
  446 + } else {
  447 + $js_html = str_replace($vjs, getImageUrl($vjs_result['url_complete']), $js_html);
444 } 448 }
445 - } else {  
446 - $js_html = str_replace($vjs, getImageUrl($vjs_result['url_complete']), $js_html);  
447 } 449 }
448 - }  
449 450
450 - CosService::uploadRemote($project_id, 'source', $vs['url_complete'], $vs['url_complete'], $js_html); 451 + CosService::uploadRemote($project_id, 'source', $vs['url_complete'], $vs['url_complete'], $js_html);
  452 + }
451 } 453 }
452 - }else{  
453 - $html = str_replace($vs['url'], getImageUrl($vs['url_complete']), $html);  
454 } 454 }
455 } 455 }
456 456
@@ -101,7 +101,7 @@ class HtmlLanguageCollect extends Command @@ -101,7 +101,7 @@ class HtmlLanguageCollect extends Command
101 $source_list = $this->html_preg($new_html, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']); 101 $source_list = $this->html_preg($new_html, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']);
102 102
103 if ($source_list) { 103 if ($source_list) {
104 - $html = $this->upload_source($html, $source_list, $project_id); 104 + $html = $this->upload_source($html, $source_list, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']);
105 } 105 }
106 } catch (\Exception $e) { 106 } catch (\Exception $e) {
107 $collect_info->status = CollectTask::STATUS_FAIL; 107 $collect_info->status = CollectTask::STATUS_FAIL;
@@ -283,9 +283,6 @@ class HtmlLanguageCollect extends Command @@ -283,9 +283,6 @@ class HtmlLanguageCollect extends Command
283 { 283 {
284 if ($url) { 284 if ($url) {
285 $url = str_replace('"', '', $url); 285 $url = str_replace('"', '', $url);
286 - if(strpos($url,'mailto:') !== false){  
287 - return false;  
288 - }  
289 $arr = parse_url($url); 286 $arr = parse_url($url);
290 $scheme = $arr['scheme'] ?? ''; 287 $scheme = $arr['scheme'] ?? '';
291 $host = $arr['host'] ?? ''; 288 $host = $arr['host'] ?? '';
@@ -323,7 +320,7 @@ class HtmlLanguageCollect extends Command @@ -323,7 +320,7 @@ class HtmlLanguageCollect extends Command
323 } 320 }
324 321
325 //下载并替换资源 322 //下载并替换资源
326 - protected function upload_source($html, $source, $project_id) 323 + protected function upload_source($html, $source, $project_id, $domain, $web_url_domain, $home_url)
327 { 324 {
328 foreach ($source as $vs) { 325 foreach ($source as $vs) {
329 326
@@ -389,6 +386,36 @@ class HtmlLanguageCollect extends Command @@ -389,6 +386,36 @@ class HtmlLanguageCollect extends Command
389 ]); 386 ]);
390 } 387 }
391 } 388 }
  389 + } elseif (substr($new_source, -2, 2) == 'js') {
  390 + $js_html = curl_c(getImageUrl($new_source), false);
  391 + preg_match_all("/[large|thumb]+URL:['\"]+(\s*[^>]+?)['\"]+,/i", $js_html, $result_js_source);
  392 + $js_source = $result_js_source[1] ?? [];
  393 + if ($js_source) {
  394 + foreach ($js_source as $vjs) {
  395 + $vjs_result = $this->url_check($vjs, $project_id, $domain, $web_url_domain, $home_url);
  396 + if (!$vjs_result) {
  397 + continue;
  398 + }
  399 +
  400 + if ($vjs_result['download']) {
  401 + $new_vjs = CosService::uploadRemote($project_id, 'source', $vjs_result['url_complete']);
  402 + if ($new_vjs) {
  403 + CollectSource::insert([
  404 + 'project_id' => $project_id,
  405 + 'origin' => $vjs_result['url'],
  406 + 'target' => $new_vjs,
  407 + 'created_at' => date('Y-m-d H:i:s'),
  408 + 'updated_at' => date('Y-m-d H:i:s'),
  409 + ]);
  410 + $js_html = str_replace($vjs, getImageUrl($new_vjs), $js_html);
  411 + }
  412 + } else {
  413 + $js_html = str_replace($vjs, getImageUrl($vjs_result['url_complete']), $js_html);
  414 + }
  415 + }
  416 +
  417 + CosService::uploadRemote($project_id, 'source', $new_source, $new_source, $js_html);
  418 + }
392 } 419 }
393 } 420 }
394 } else { 421 } else {