作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !167
@@ -390,30 +390,32 @@ class HtmlCollect extends Command @@ -390,30 +390,32 @@ class HtmlCollect extends Command
390 $js_html = curl_c(getImageUrl($new_source), false); 390 $js_html = curl_c(getImageUrl($new_source), false);
391 preg_match_all("/[large|thumb]+URL:['\"]+(\s*[^>]+?)['\"]+,/i", $js_html, $result_js_source); 391 preg_match_all("/[large|thumb]+URL:['\"]+(\s*[^>]+?)['\"]+,/i", $js_html, $result_js_source);
392 $js_source = $result_js_source[1] ?? []; 392 $js_source = $result_js_source[1] ?? [];
393 - foreach ($js_source as $vjs) {  
394 - $vjs_result = $this->url_check($vjs, $project_id, $domain, $web_url_domain, $home_url);  
395 - if (!$vjs_result) {  
396 - continue;  
397 - } 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 + }
398 399
399 - if ($vjs_result['download']) {  
400 - $new_vjs = CosService::uploadRemote($project_id, 'source', $vjs_result['url_complete']);  
401 - if ($new_vjs) {  
402 - CollectSource::insert([  
403 - 'project_id' => $project_id,  
404 - 'origin' => $vjs_result['url'],  
405 - 'target' => $new_vjs,  
406 - 'created_at' => date('Y-m-d H:i:s'),  
407 - 'updated_at' => date('Y-m-d H:i:s'),  
408 - ]);  
409 - $js_html = str_replace($vjs, getImageUrl($new_vjs), $js_html); 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);
410 } 414 }
411 - } else {  
412 - $js_html = str_replace($vjs, getImageUrl($vjs_result['url_complete']), $js_html);  
413 } 415 }
414 - }  
415 416
416 - CosService::uploadRemote($project_id, 'source', $new_source, $new_source, $js_html); 417 + CosService::uploadRemote($project_id, 'source', $new_source, $new_source, $js_html);
  418 + }
417 } 419 }
418 } 420 }
419 } elseif(substr($vs['url_complete'], -2, 2) == 'js') { 421 } elseif(substr($vs['url_complete'], -2, 2) == 'js') {
@@ -421,30 +423,32 @@ class HtmlCollect extends Command @@ -421,30 +423,32 @@ class HtmlCollect extends Command
421 $js_html = curl_c(getImageUrl($vs['url_complete']), false); 423 $js_html = curl_c(getImageUrl($vs['url_complete']), false);
422 preg_match_all("/[large|thumb]+URL:['\"]+(\s*[^>]+?)['\"]+,/i", $js_html, $result_js_source); 424 preg_match_all("/[large|thumb]+URL:['\"]+(\s*[^>]+?)['\"]+,/i", $js_html, $result_js_source);
423 $js_source = $result_js_source[1] ?? []; 425 $js_source = $result_js_source[1] ?? [];
424 - foreach ($js_source as $vjs) {  
425 - $vjs_result = $this->url_check($vjs, $project_id, $domain, $web_url_domain, $home_url);  
426 - if (!$vjs_result) {  
427 - continue;  
428 - } 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 + }
429 432
430 - if ($vjs_result['download']) {  
431 - $new_vjs = CosService::uploadRemote($project_id, 'source', $vjs_result['url_complete']);  
432 - if ($new_vjs) {  
433 - CollectSource::insert([  
434 - 'project_id' => $project_id,  
435 - 'origin' => $vjs_result['url'],  
436 - 'target' => $new_vjs,  
437 - 'created_at' => date('Y-m-d H:i:s'),  
438 - 'updated_at' => date('Y-m-d H:i:s'),  
439 - ]);  
440 - $js_html = str_replace($vjs, getImageUrl($new_vjs), $js_html); 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);
  444 + }
  445 + } else {
  446 + $js_html = str_replace($vjs, getImageUrl($vjs_result['url_complete']), $js_html);
441 } 447 }
442 - } else {  
443 - $js_html = str_replace($vjs, getImageUrl($vjs_result['url_complete']), $js_html);  
444 } 448 }
445 - }  
446 449
447 - CosService::uploadRemote($project_id, 'source', $vs['url_complete'], $vs['url_complete'], $js_html); 450 + CosService::uploadRemote($project_id, 'source', $vs['url_complete'], $vs['url_complete'], $js_html);
  451 + }
448 }else{ 452 }else{
449 $html = str_replace($vs['url'], getImageUrl($vs['url_complete']), $html); 453 $html = str_replace($vs['url'], getImageUrl($vs['url_complete']), $html);
450 } 454 }