正在显示
3 个修改的文件
包含
30 行增加
和
30 行删除
| @@ -926,6 +926,28 @@ function base62_encode($num) { | @@ -926,6 +926,28 @@ function base62_encode($num) { | ||
| 926 | return $result; | 926 | return $result; |
| 927 | } | 927 | } |
| 928 | 928 | ||
| 929 | +/** | ||
| 930 | + * @remark :腾讯云安全的base64 | ||
| 931 | + * @name :urlSafeBase64Encode | ||
| 932 | + * @author :lyh | ||
| 933 | + * @method :post | ||
| 934 | + * @time :2024/8/19 14:21 | ||
| 935 | + */ | ||
| 936 | +function urlSafeBase64Encode($data = '') { | ||
| 937 | + if(empty($data)){ | ||
| 938 | + return $data; | ||
| 939 | + } | ||
| 940 | + // 1. 使用标准的 BASE64 编码 | ||
| 941 | + $base64 = base64_encode($data); | ||
| 942 | + // 2. 将加号(+)替换成连接号(-) | ||
| 943 | + $base64 = str_replace('+', '-', $base64); | ||
| 944 | + // 3. 将正斜线(/)替换成下划线(_) | ||
| 945 | + $base64 = str_replace('/', '_', $base64); | ||
| 946 | + // 4. 去掉末尾的等号(=) | ||
| 947 | + $base64 = rtrim($base64, '='); | ||
| 948 | + return $base64; | ||
| 949 | +} | ||
| 950 | + | ||
| 929 | 951 | ||
| 930 | 952 | ||
| 931 | 953 |
| @@ -652,7 +652,7 @@ class ImageController extends Controller | @@ -652,7 +652,7 @@ class ImageController extends Controller | ||
| 652 | $domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名 | 652 | $domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名 |
| 653 | if($is_image){ | 653 | if($is_image){ |
| 654 | $param = [ | 654 | $param = [ |
| 655 | - 'image/'.$this->urlSafeBase64Encode($domain.$data['image'] ?? ''),//图片 | 655 | + 'image/'.urlSafeBase64Encode($domain.$data['image'] ?? ''),//图片 |
| 656 | 'gravity/'.($data['gravity'] ?? 'SouthEast'), | 656 | 'gravity/'.($data['gravity'] ?? 'SouthEast'), |
| 657 | 'dx/'.($data['dx'] ?? 0), | 657 | 'dx/'.($data['dx'] ?? 0), |
| 658 | 'dy/'. ($data['dy'] ?? 0), | 658 | 'dy/'. ($data['dy'] ?? 0), |
| @@ -667,13 +667,13 @@ class ImageController extends Controller | @@ -667,13 +667,13 @@ class ImageController extends Controller | ||
| 667 | } | 667 | } |
| 668 | }else{ | 668 | }else{ |
| 669 | $param = [ | 669 | $param = [ |
| 670 | - 'text/'.$this->urlSafeBase64Encode($data['text'] ?? ''),//文字水印名称 | 670 | + 'text/'.urlSafeBase64Encode($data['text'] ?? ''),//文字水印名称 |
| 671 | 'gravity/'.($data['gravity'] ?? 'SouthEast'), | 671 | 'gravity/'.($data['gravity'] ?? 'SouthEast'), |
| 672 | 'dx/'.($data['dx'] ?? 10), | 672 | 'dx/'.($data['dx'] ?? 10), |
| 673 | 'dy/'. ($data['dy'] ?? 10), | 673 | 'dy/'. ($data['dy'] ?? 10), |
| 674 | - 'font/'.$this->urlSafeBase64Encode($data['font'] ?? 'tahoma.ttf'),//默认宋体 | 674 | + 'font/'.urlSafeBase64Encode($data['font'] ?? 'tahoma.ttf'),//默认宋体 |
| 675 | 'fontsize/'.($data['fontsize'] ?? 24),//水印文字字体大小,单位为磅,缺省值13 | 675 | 'fontsize/'.($data['fontsize'] ?? 24),//水印文字字体大小,单位为磅,缺省值13 |
| 676 | - 'fill/'.$this->urlSafeBase64Encode($data['fill'] ?? '#3D3D3D'),//颜色 | 676 | + 'fill/'.urlSafeBase64Encode($data['fill'] ?? '#3D3D3D'),//颜色 |
| 677 | 'dissolve/'.($data['dissolve'] ?? 50),//透明度 | 677 | 'dissolve/'.($data['dissolve'] ?? 50),//透明度 |
| 678 | 'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0 | 678 | 'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0 |
| 679 | 'batch/'.($data['batch'] ?? 0),//平铺水印功能 | 679 | 'batch/'.($data['batch'] ?? 0),//平铺水印功能 |
| @@ -188,7 +188,7 @@ class CosService | @@ -188,7 +188,7 @@ class CosService | ||
| 188 | $url = $domain . $cdnUrl; | 188 | $url = $domain . $cdnUrl; |
| 189 | if($is_image){ | 189 | if($is_image){ |
| 190 | $param = [ | 190 | $param = [ |
| 191 | - 'image/'.$this->urlSafeBase64Encode($domain.$data['image'] ?? ''),//图片 | 191 | + 'image/'.urlSafeBase64Encode($domain.$data['image'] ?? ''),//图片 |
| 192 | 'gravity/'.($data['gravity'] ?? 'SouthEast'), | 192 | 'gravity/'.($data['gravity'] ?? 'SouthEast'), |
| 193 | 'dx/'.($data['dx'] ?? 0), | 193 | 'dx/'.($data['dx'] ?? 0), |
| 194 | 'dy/'. ($data['dy'] ?? 0), | 194 | 'dy/'. ($data['dy'] ?? 0), |
| @@ -199,13 +199,13 @@ class CosService | @@ -199,13 +199,13 @@ class CosService | ||
| 199 | $url = $url.'?watermark/1/'.implode('/',$param); | 199 | $url = $url.'?watermark/1/'.implode('/',$param); |
| 200 | }else{ | 200 | }else{ |
| 201 | $param = [ | 201 | $param = [ |
| 202 | - 'text/'.$this->urlSafeBase64Encode($data['text'] ?? ''),//文字水印名称 | 202 | + 'text/'.urlSafeBase64Encode($data['text'] ?? ''),//文字水印名称 |
| 203 | 'gravity/'.($data['gravity'] ?? 'SouthEast'), | 203 | 'gravity/'.($data['gravity'] ?? 'SouthEast'), |
| 204 | 'dx/'.($data['dx'] ?? 10), | 204 | 'dx/'.($data['dx'] ?? 10), |
| 205 | 'dy/'. ($data['dy'] ?? 10), | 205 | 'dy/'. ($data['dy'] ?? 10), |
| 206 | - 'font/'.$this->urlSafeBase64Encode($data['font'] ?? 'tahoma.ttf'),//默认宋体 | 206 | + 'font/'.urlSafeBase64Encode($data['font'] ?? 'tahoma.ttf'),//默认宋体 |
| 207 | 'fontsize/'.($data['fontsize'] ?? 24),//水印文字字体大小,单位为磅,缺省值13 | 207 | 'fontsize/'.($data['fontsize'] ?? 24),//水印文字字体大小,单位为磅,缺省值13 |
| 208 | - 'fill/'.$this->urlSafeBase64Encode($data['fill'] ?? '#3D3D3D'),//颜色 | 208 | + 'fill/'.urlSafeBase64Encode($data['fill'] ?? '#3D3D3D'),//颜色 |
| 209 | 'dissolve/'.($data['dissolve'] ?? 50),//透明度 | 209 | 'dissolve/'.($data['dissolve'] ?? 50),//透明度 |
| 210 | 'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0 | 210 | 'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0 |
| 211 | 'batch/'.($data['batch'] ?? 0),//平铺水印功能 | 211 | 'batch/'.($data['batch'] ?? 0),//平铺水印功能 |
| @@ -247,28 +247,6 @@ class CosService | @@ -247,28 +247,6 @@ class CosService | ||
| 247 | } | 247 | } |
| 248 | 248 | ||
| 249 | /** | 249 | /** |
| 250 | - * @remark :腾讯云安全的base64 | ||
| 251 | - * @name :urlSafeBase64Encode | ||
| 252 | - * @author :lyh | ||
| 253 | - * @method :post | ||
| 254 | - * @time :2024/8/19 14:21 | ||
| 255 | - */ | ||
| 256 | - public function urlSafeBase64Encode($data = '') { | ||
| 257 | - if(empty($data)){ | ||
| 258 | - return $data; | ||
| 259 | - } | ||
| 260 | - // 1. 使用标准的 BASE64 编码 | ||
| 261 | - $base64 = base64_encode($data); | ||
| 262 | - // 2. 将加号(+)替换成连接号(-) | ||
| 263 | - $base64 = str_replace('+', '-', $base64); | ||
| 264 | - // 3. 将正斜线(/)替换成下划线(_) | ||
| 265 | - $base64 = str_replace('/', '_', $base64); | ||
| 266 | - // 4. 去掉末尾的等号(=) | ||
| 267 | - $base64 = rtrim($base64, '='); | ||
| 268 | - return $base64; | ||
| 269 | - } | ||
| 270 | - | ||
| 271 | - /** | ||
| 272 | * @remark :处理9宫格数据 | 250 | * @remark :处理9宫格数据 |
| 273 | * @name :getPosition | 251 | * @name :getPosition |
| 274 | * @author :lyh | 252 | * @author :lyh |
-
请 注册 或 登录 后发表评论