切换导航条
此项目
正在载入...
登录
何书鹏
/
recruit
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
何书鹏
4 years ago
提交
498d34b5338350739449f6e837d2d2b657ee36a0
1 个父辈
541bbb38
1 个管道 的构建
通过
耗费 0 秒
bug修改
变更
2
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
16 行增加
和
25 行删除
application/api/common.php
application/api/controller/User.php
application/api/common.php
查看文件 @
498d34b
...
...
@@ -47,29 +47,20 @@ function createRoundImg($imgpath) {
}
/**
*
高效判断远程图片
是否存在
*
判断远程文件
是否存在
*/
function
remoteImageExist
(
$url
)
{
// $exif_imagetype = [
// 1 => 'GIF',
// 2 => 'JPG',
// 3 => 'PNG',
// 4 => 'SWF',
// 5 => 'PSD',
// 6 => 'BMP',
// 7 => 'TIFF(intel byte order)',
// 8 => 'TIFF(motorola byte order)',
// 9 => 'JPC',
// 10 => 'JP2',
// 11 => 'JPX',
// 12 => 'JB2',
// 13 => 'SWC',
// 14 => 'IFF',
// 15 => 'WBMP',
// 16 => 'XBM'
// ];
$isExsit
=
@
exif_imagetype
(
$url
);
if
(
$isExsit
===
false
)
return
false
;
return
in_array
(
$isExsit
,
[
1
,
2
,
3
])
?
true
:
false
;
function
url_exists
(
$url
)
{
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
//不下载
curl_setopt
(
$ch
,
CURLOPT_NOBODY
,
1
);
//设置超时
curl_setopt
(
$ch
,
CURLOPT_CONNECTTIMEOUT
,
3
);
curl_setopt
(
$ch
,
CURLOPT_TIMEOUT
,
3
);
curl_exec
(
$ch
);
$http_code
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
if
(
$http_code
==
200
)
{
return
true
;
}
return
false
;
}
\ No newline at end of file
...
...
application/api/controller/User.php
查看文件 @
498d34b
...
...
@@ -681,7 +681,7 @@ class User extends Api
{
$user
=
\app\api\model\User
::
get
(
$this
->
auth
->
id
);
empty
(
$user
[
'avatar'
])
&&
$this
->
error
(
'请先上传头像'
);
!
remoteImageExist
(
$user
[
'avatar'
])
&&
$this
->
error
(
'头像失效,请更新头像'
);
!
url_exists
(
$user
[
'avatar'
])
&&
$this
->
error
(
'头像失效,请更新头像'
);
// 本地路径
$dir
=
'uploads/user'
;
if
(
!
file_exists
(
$dir
)){
...
...
请
注册
或
登录
后发表评论