[更新]代码巡检优化修复

This commit is contained in:
Anyon 2017-06-24 15:44:22 +08:00
parent c11064ef7b
commit d9cc3f3dce
3 changed files with 10 additions and 9 deletions

View File

@ -151,9 +151,9 @@ class FileService {
/**
* 获取文件相对名称
* @param 文件标识 $source
* @param 文件后缀 $ext
* @param 文件前缀 $pre
* @param string $source 文件标识
* @param string $ext 文件后缀
* @param string $pre 文件前缀
* @return string
*/
public static function getFileName($source, $ext = '', $pre = '') {
@ -295,7 +295,7 @@ class FileService {
return self::local($filename, file_get_contents($url));
} catch (\Exception $e) {
Log::error("FileService 文件下载失败 [ {$url} ] . {$e->getMessage()}");
return false;
return null;
}
}

View File

@ -35,7 +35,8 @@ class NodeService {
session('user', Db::name('SystemUser')->where('id', $userid)->find());
}
if (($authorize = session('user.authorize'))) {
$authorizeids = Db::name('SystemAuth')->where('id', 'in', explode(',', $authorize))->where('status', '1')->column('id');
$where = ['id' => ['in', explode(',', $authorize)], 'status' => '1'];
$authorizeids = Db::name('SystemAuth')->where($where)->column('id');
if (empty($authorizeids)) {
return session('user.nodes', []);
}
@ -72,7 +73,7 @@ class NodeService {
if (!in_array($auth_node, self::getAuthNode())) {
return true;
}
return in_array($auth_node, (array) session('user.nodes'));
return in_array($auth_node, (array)session('user.nodes'));
}
/**

View File

@ -62,8 +62,8 @@ class WechatService {
# 下载临时文件到本地
$filename = 'wechat/image/' . join('/', str_split(md5($local_url), 16)) . '.' . strtolower(pathinfo($local_url, 4));
$result = FileService::local($filename, file_get_contents($local_url));
if ($result && isset($result['file'])) {
# 上传图片到微信服务器
if ($result && isset($result['file'])) {
$wechat = &load_wechat('media');
$mediainfo = $wechat->uploadImg(['media' => "@{$result['file']}"]);
if (!empty($mediainfo)) {
@ -71,8 +71,8 @@ class WechatService {
Db::name('WechatNewsImage')->insert($data);
return $mediainfo['url'];
}
}
Log::error("图片上传失败,请稍后再试!{$wechat->errMsg}[{$wechat->errCode}]");
}
return null;
}