Jelajahi Sumber

优化图片协议、优化vod_actor长度问题

magicblack 3 tahun lalu
induk
melakukan
ca68800ba5

+ 15 - 4
application/api/controller/Provide.php

@@ -342,7 +342,7 @@ class Provide extends Base
                 $v['art_time'] = date('Y-m-d H:i:s', $v['art_time']);
 
                 if (substr($v["art_pic"], 0, 4) == "mac:") {
-                    $v["art_pic"] = str_replace('mac:', 'http:', $v["art_pic"]);
+                    $v["art_pic"] = str_replace('mac:', $this->getImgUrlProtocol('art'), $v["art_pic"]);
                 } elseif (!empty($v["art_pic"]) && substr($v["art_pic"], 0, 4) != "http" && substr($v["art_pic"], 0, 2) != "//") {
                     $v["art_pic"] = $GLOBALS['config']['api']['art']['imgurl'] . $v["art_pic"];
                 }
@@ -453,7 +453,7 @@ class Provide extends Base
                 $v['actor_time'] = date('Y-m-d H:i:s', $v['actor_time']);
 
                 if (substr($v["actor_pic"], 0, 4) == "mac:") {
-                    $v["actor_pic"] = str_replace('mac:', 'http:', $v["actor_pic"]);
+                    $v["actor_pic"] = str_replace('mac:', $this->getImgUrlProtocol('actor'), $v["actor_pic"]);
                 } elseif (!empty($v["actor_pic"]) && substr($v["actor_pic"], 0, 4) != "http" && substr($v["actor_pic"], 0, 2) != "//") {
                     $v["actor_pic"] = $GLOBALS['config']['api']['actor']['imgurl'] . $v["actor_pic"];
                 }
@@ -565,7 +565,7 @@ class Provide extends Base
                 $v['vod_director'] = $v['data']['vod_director'];
                 unset($v['data']);
                 if (substr($v["role_pic"], 0, 4) == "mac:") {
-                    $v["role_pic"] = str_replace('mac:', 'http:', $v["role_pic"]);
+                    $v["role_pic"] = str_replace('mac:', $this->getImgUrlProtocol('role'), $v["role_pic"]);
                 } elseif (!empty($v["role_pic"]) && substr($v["role_pic"], 0, 4) != "http" && substr($v["role_pic"], 0, 2) != "//") {
                     $v["role_pic"] = $GLOBALS['config']['api']['role']['imgurl'] . $v["role_pic"];
                 }
@@ -665,7 +665,7 @@ class Provide extends Base
                 $v['website_time'] = date('Y-m-d H:i:s', $v['website_time']);
 
                 if (substr($v["website_pic"], 0, 4) == "mac:") {
-                    $v["website_pic"] = str_replace('mac:', 'http:', $v["website_pic"]);
+                    $v["website_pic"] = str_replace('mac:', $this->getImgUrlProtocol('website'), $v["website_pic"]);
                 } elseif (!empty($v["website_pic"]) && substr($v["website_pic"], 0, 4) != "http" && substr($v["website_pic"], 0, 2) != "//") {
                     $v["website_pic"] = $GLOBALS['config']['api']['website']['imgurl'] . $v["website_pic"];
                 }
@@ -731,4 +731,15 @@ class Provide extends Base
             exit;
         }
     }
+
+    private function getImgUrlProtocol($key)
+    {
+        if (!isset($GLOBALS['config']['api'][$key]['imgurl'])) {
+            return 'http:';
+        }
+        if (substr($GLOBALS['config']['api'][$key]['imgurl'], 0, 5) == 'https') {
+            return 'https:';
+        }
+        return 'http:';
+    }
 }

+ 1 - 1
application/common/model/Vod.php

@@ -679,7 +679,7 @@ class Vod extends Base {
                 continue;
             }
             $data[$filter_field] = mac_filter_xss($data[$filter_field]);
-            $data[$filter_field] = mb_substr($data[$filter_field], 0, $field_length);
+            $data[$filter_field] = mb_substr($data[$filter_field], 0, $field_length - 1);
         }
 
         if(!empty($data['vod_id'])){

+ 1 - 1
application/lang/zh-cn.php

@@ -955,7 +955,7 @@ https://www.baidu.com/123.jpg
     'admin/system/configapi/pagesize'=>'列表每页显示数量',
     'admin/system/configapi/pagesize_tip'=>'数据每页显示量,不建议超过50',
     'admin/system/configapi/imgurl'=>'图片域名',
-    'admin/system/configapi/imgurl_tip'=>'显示图片的完整访问路径所需要,以http:开头,/结尾,不包含upload目录',
+    'admin/system/configapi/imgurl_tip'=>'显示图片的完整访问路径所需要,以http(s):开头,/结尾,不包含upload目录',
     'admin/system/configapi/typefilter'=>'分类过滤参数',
     'admin/system/configapi/typefilter_tip'=>'列出需要显示的分类ids例如 11,12,13',
     'admin/system/configapi/datafilter'=>'数据过滤参数',

+ 1 - 1
application/lang/zh-tw.php

@@ -955,7 +955,7 @@ https://www.baidu.com/123.jpg
     'admin/system/configapi/pagesize'=>'列表每頁顯示數量',
     'admin/system/configapi/pagesize_tip'=>'數據每頁顯示量,不建議超過50',
     'admin/system/configapi/imgurl'=>'圖片域名',
-    'admin/system/configapi/imgurl_tip'=>'顯示圖片的完整訪問路徑所需要,以http:開頭,/結尾,不包含upload目錄',
+    'admin/system/configapi/imgurl_tip'=>'顯示圖片的完整訪問路徑所需要,以http(s):開頭,/結尾,不包含upload目錄',
     'admin/system/configapi/typefilter'=>'分類過濾參數',
     'admin/system/configapi/typefilter_tip'=>'列出需要顯示的分類ids例如 11,12,13',
     'admin/system/configapi/datafilter'=>'數據過濾參數',