作者 刘锟

update

@@ -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