作者 刘锟

update

@@ -64,7 +64,7 @@ class ThumbProjectImage extends Command @@ -64,7 +64,7 @@ class ThumbProjectImage extends Command
64 } else { 64 } else {
65 //所有项目 65 //所有项目
66 $projectModel = new Project(); 66 $projectModel = new Project();
67 - $list = $projectModel->list(['id' => ['>', 893], 'delete_status' => 0, 'is_upgrade' => 0, 'type' => ['in', [1, 2, 3, 4, 6]]], 'id', ['id'], 'asc'); 67 + $list = $projectModel->list(['id' => ['>=', 2108], 'delete_status' => 0, 'is_upgrade' => 0, 'type' => ['in', [1, 2, 3, 4, 6]]], 'id', ['id'], 'asc');
68 foreach ($list as $k => $v) { 68 foreach ($list as $k => $v) {
69 $project_id = $v['id']; 69 $project_id = $v['id'];
70 70
@@ -1491,7 +1491,14 @@ function thumbImageByUrl($url, $width = 360) @@ -1491,7 +1491,14 @@ function thumbImageByUrl($url, $width = 360)
1491 } 1491 }
1492 1492
1493 //获取图片完整访问地址 1493 //获取图片完整访问地址
  1494 + $url_complete = getImageUrl($url, 0, 0, 0);//先用v6-file地址
  1495 + if (strpos($url_complete, 'v6-file') !== false) {
  1496 + $is_exists = checkRemoteFileExists($url_complete);
  1497 + if (!$is_exists) {
  1498 + //不存在,再用cdn地址
1494 $url_complete = getImageUrl($url); 1499 $url_complete = getImageUrl($url);
  1500 + }
  1501 + }
1495 1502
1496 //获取与原图存储路径相同的压缩路径 1503 //获取与原图存储路径相同的压缩路径
1497 $path = parse_url($url_complete, PHP_URL_PATH); 1504 $path = parse_url($url_complete, PHP_URL_PATH);
@@ -1525,6 +1532,23 @@ function thumbImageByUrl($url, $width = 360) @@ -1525,6 +1532,23 @@ function thumbImageByUrl($url, $width = 360)
1525 return $url; 1532 return $url;
1526 } 1533 }
1527 1534
  1535 +function checkRemoteFileExists($url)
  1536 +{
  1537 + $curl = curl_init($url);
  1538 + curl_setopt($curl, CURLOPT_NOBODY, true);
  1539 + $result = curl_exec($curl);
  1540 + $found = false;
  1541 + if ($result !== false) {
  1542 + $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  1543 + if ($statusCode == 200) {
  1544 + $found = true;
  1545 + }
  1546 + }
  1547 + curl_close($curl);
  1548 +
  1549 + return $found;
  1550 +}
  1551 +
1528 if (!function_exists('httpGetSsl')) { 1552 if (!function_exists('httpGetSsl')) {
1529 /** 1553 /**
1530 * 获取通配符证书 1554 * 获取通配符证书