mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-05 19:41:44 +08:00
[更新]基于标准优化代码
This commit is contained in:
parent
1ccbf8322d
commit
cbc573f3b9
@ -75,11 +75,7 @@ class Index extends BasicAdmin
|
||||
{
|
||||
if (session('user.username') === 'admin' && session('user.password') === '21232f297a57a5a743894a0e4a801fc3') {
|
||||
$url = url('admin/index/pass') . '?id=' . session('user.id');
|
||||
$alert = [
|
||||
'type' => 'danger',
|
||||
'title' => '安全提示',
|
||||
'content' => "超级管理员默认密码未修改,建议马上<a href='javascript:void(0)' data-modal='{$url}'>修改</a>!"
|
||||
];
|
||||
$alert = ['type' => 'danger', 'title' => '安全提示', 'content' => "超级管理员默认密码未修改,建议马上<a href='javascript:void(0)' data-modal='{$url}'>修改</a>!",];
|
||||
$this->assign('alert', $alert);
|
||||
$this->assign('title', '后台首页');
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class Plugs extends BasicAdmin
|
||||
$time = time() + 3600;
|
||||
$policyText = [
|
||||
'expiration' => date('Y-m-d', $time) . 'T' . date('H:i:s', $time) . '.000Z',
|
||||
'conditions' => [['content-length-range', 0, 1048576000]]
|
||||
'conditions' => [['content-length-range', 0, 1048576000]],
|
||||
];
|
||||
$config['policy'] = base64_encode(json_encode($policyText));
|
||||
$config['server'] = FileService::getUploadOssUrl();
|
||||
@ -123,8 +123,8 @@ class Plugs extends BasicAdmin
|
||||
$host = sysconf('storage_qiniu_domain');
|
||||
$protocol = sysconf('storage_qiniu_is_https') ? 'https' : 'http';
|
||||
$params = [
|
||||
"scope" => "{$bucket}:{$key}",
|
||||
"deadline" => 3600 + time(),
|
||||
"scope" => "{$bucket}:{$key}",
|
||||
"deadline" => 3600 + time(),
|
||||
"returnBody" => "{\"data\":{\"site_url\":\"{$protocol}://{$host}/$(key)\",\"file_url\":\"$(key)\"}, \"code\": \"SUCCESS\"}",
|
||||
];
|
||||
$data = str_replace(['+', '/'], ['-', '_'], base64_encode(json_encode($params)));
|
||||
|
@ -158,13 +158,13 @@ class Api extends Controller
|
||||
protected function _news($news_id = 0)
|
||||
{
|
||||
if (is_array($newsinfo = WechatService::getNewsById($news_id)) && !empty($newsinfo['articles'])) {
|
||||
$newsdata = array();
|
||||
$newsdata = [];
|
||||
foreach ($newsinfo['articles'] as $vo) {
|
||||
$newsdata[] = [
|
||||
'Title' => $vo['title'],
|
||||
'Title' => $vo['title'],
|
||||
'Description' => $vo['digest'],
|
||||
'PicUrl' => $vo['local_url'],
|
||||
'Url' => url("@wechat/review", '', true, true) . "?content={$vo['id']}&type=article",
|
||||
'PicUrl' => $vo['local_url'],
|
||||
'Url' => url("@wechat/review", '', true, true) . "?content={$vo['id']}&type=article",
|
||||
];
|
||||
}
|
||||
return $this->wechat->news($newsdata)->reply(false, true);
|
||||
|
@ -45,16 +45,16 @@ class Menu extends BasicAdmin
|
||||
* 微信菜单的类型
|
||||
* @var array
|
||||
*/
|
||||
protected $menu_type = array(
|
||||
'view' => '跳转URL',
|
||||
'click' => '点击推事件',
|
||||
'scancode_push' => '扫码推事件',
|
||||
'scancode_waitmsg' => '扫码推事件且弹出“消息接收中”提示框',
|
||||
'pic_sysphoto' => '弹出系统拍照发图',
|
||||
protected $menu_type = [
|
||||
'view' => '跳转URL',
|
||||
'click' => '点击推事件',
|
||||
'scancode_push' => '扫码推事件',
|
||||
'scancode_waitmsg' => '扫码推事件且弹出“消息接收中”提示框',
|
||||
'pic_sysphoto' => '弹出系统拍照发图',
|
||||
'pic_photo_or_album' => '弹出拍照或者相册发图',
|
||||
'pic_weixin' => '弹出微信相册发图器',
|
||||
'location_select' => '弹出地理位置选择器',
|
||||
);
|
||||
'pic_weixin' => '弹出微信相册发图器',
|
||||
'location_select' => '弹出地理位置选择器',
|
||||
];
|
||||
|
||||
/**
|
||||
* 显示列表操作
|
||||
@ -164,9 +164,9 @@ class Menu extends BasicAdmin
|
||||
}
|
||||
$wechat = &load_wechat('Menu');
|
||||
if (false !== $wechat->createMenu(['button' => $menus])) {
|
||||
return array('status' => true, 'errmsg' => '');
|
||||
return ['status' => true, 'errmsg' => ''];
|
||||
}
|
||||
return array('status' => false, 'errmsg' => $wechat->errMsg);
|
||||
return ['status' => false, 'errmsg' => $wechat->errMsg];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ class News extends BasicAdmin
|
||||
$id = intval($vo['id']);
|
||||
$result = Db::name('WechatNewsArticle')->where('id', $id)->update($vo);
|
||||
}
|
||||
if ($result !== FALSE) {
|
||||
if ($result !== false) {
|
||||
$ids[] = $id;
|
||||
}
|
||||
}
|
||||
@ -193,8 +193,8 @@ class News extends BasicAdmin
|
||||
if ($this->request->isGet()) {
|
||||
$fans_tags = Db::name('WechatFansTags')->select();
|
||||
array_unshift($fans_tags, [
|
||||
'id' => 0,
|
||||
'name' => '全部',
|
||||
'id' => 0,
|
||||
'name' => '全部',
|
||||
'count' => Db::name('WechatFans')->where('subscribe', '1')->count(),
|
||||
]);
|
||||
return view('push', ['vo' => $newsinfo, 'fans_tags' => $fans_tags]);
|
||||
@ -216,7 +216,7 @@ class News extends BasicAdmin
|
||||
$data['mpnews'] = ['media_id' => $newsinfo['media_id']];
|
||||
}
|
||||
$wechat = &load_wechat('Receive');
|
||||
if (FALSE !== $wechat->sendGroupMassMessage($data)) {
|
||||
if (false !== $wechat->sendGroupMassMessage($data)) {
|
||||
LogService::write('微信管理', "图文[{$news_id}]推送成功");
|
||||
$this->success('微信图文推送成功!', '');
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class Notify extends Controller
|
||||
$notifyInfo = $pay->getNotify();
|
||||
|
||||
// 支付通知数据获取失败
|
||||
if ($notifyInfo === FALSE) {
|
||||
if ($notifyInfo === false) {
|
||||
// 接口失败的处理
|
||||
Log::error("微信支付通知消息验证失败,{$pay->errCode}[{$pay->errCode}]");
|
||||
return $pay->errMsg;
|
||||
|
@ -111,7 +111,7 @@ class BasicAdmin extends Controller
|
||||
$fields = $db->getTableFields($db->getTable());
|
||||
in_array('sort', $fields) && $db->order('sort asc');
|
||||
}
|
||||
$result = array();
|
||||
$result = [];
|
||||
if ($isPage) {
|
||||
$rowPage = intval($this->request->get('rows', cookie('rows')));
|
||||
cookie('rows', $rowPage >= 10 ? $rowPage : 20);
|
||||
|
@ -96,7 +96,7 @@ class BasicWechat extends Controller
|
||||
if (!$this->request->get('code', false)) {
|
||||
$this->redirect($wechat->getOauthRedirect($wxoauth_url, 'webOauth', 'snsapi_base'));
|
||||
}
|
||||
if (FALSE === ($result = $wechat->getOauthAccessToken()) || empty($result['openid'])) {
|
||||
if (false === ($result = $wechat->getOauthAccessToken()) || empty($result['openid'])) {
|
||||
Log::error("微信网页授权失败, {$wechat->errMsg}[{$wechat->errCode}]");
|
||||
$this->error("微信网页授权失败, {$wechat->errMsg}[{$wechat->errCode}]");
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ class FilterView
|
||||
$this->request = Request::instance();
|
||||
$appRoot = $this->request->root(true);
|
||||
$replace = [
|
||||
'__APP__' => $appRoot,
|
||||
'__SELF__' => $this->request->url(true),
|
||||
'__APP__' => $appRoot,
|
||||
'__SELF__' => $this->request->url(true),
|
||||
'__PUBLIC__' => strpos($appRoot, EXT) ? ltrim(dirname($appRoot), DS) : $appRoot,
|
||||
];
|
||||
$params = str_replace(array_keys($replace), array_values($replace), $params);
|
||||
|
@ -36,14 +36,14 @@ class ExpressService
|
||||
*/
|
||||
public static function line($ShipperCode, $LogisticCode)
|
||||
{
|
||||
$sendData = json_encode(array('ShipperCode' => $ShipperCode, 'LogisticCode' => $LogisticCode), JSON_UNESCAPED_UNICODE);
|
||||
$data = array(
|
||||
$sendData = json_encode(['ShipperCode' => $ShipperCode, 'LogisticCode' => $LogisticCode], JSON_UNESCAPED_UNICODE);
|
||||
$data = [
|
||||
'RequestData' => $sendData,
|
||||
'EBusinessID' => self::APPID,
|
||||
'RequestType' => '1002',
|
||||
'DataType' => 2,
|
||||
'DataSign' => base64_encode(md5($sendData . self::APPKEY)),
|
||||
);
|
||||
'DataType' => 2,
|
||||
'DataSign' => base64_encode(md5($sendData . self::APPKEY)),
|
||||
];
|
||||
$result = HttpService::post(self::APIURI, $data);
|
||||
!($resultJson = json_decode($result, true)) && die(var_export($result));
|
||||
return self::response($resultJson);
|
||||
@ -57,11 +57,11 @@ class ExpressService
|
||||
public static function response($result)
|
||||
{
|
||||
$status = "fail";
|
||||
$data = array();
|
||||
$data = [];
|
||||
$message = "此单号无跟踪记录";
|
||||
if (isset($result['Message'])) {
|
||||
$message = $result['Message'];
|
||||
} else if (isset($result['Reason'])) {
|
||||
} elseif (isset($result['Reason'])) {
|
||||
$message = $result['Reason'];
|
||||
}
|
||||
if (isset($result['Traces']) && $result['Traces']) {
|
||||
@ -72,7 +72,7 @@ class ExpressService
|
||||
$status = "success";
|
||||
$message = '此订单号有' . count($data) . '条跟踪记录';
|
||||
}
|
||||
return array('result' => $status, 'data' => $data, 'message' => $message);
|
||||
return ['result' => $status, 'data' => $data, 'message' => $message];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class HttpService
|
||||
* @param array $header 请求Header信息
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function get($url, $data = array(), $second = 30, $header = [])
|
||||
public static function get($url, $data = [], $second = 30, $header = [])
|
||||
{
|
||||
if (!empty($data)) {
|
||||
$url .= (stripos($url, '?') === false ? '?' : '&');
|
||||
|
@ -90,9 +90,9 @@ class PayService
|
||||
* @param string|null $refund_no 退款订单号
|
||||
* @return bool
|
||||
*/
|
||||
public static function putWechatRefund(WechatPay $pay, $order_no, $fee = 0, $refund_no = NULL, $refund_account = '')
|
||||
public static function putWechatRefund(WechatPay $pay, $order_no, $fee = 0, $refund_no = null, $refund_account = '')
|
||||
{
|
||||
$map = array('order_no' => $order_no, 'is_pay' => '1', 'appid' => $pay->appid);
|
||||
$map = ['order_no' => $order_no, 'is_pay' => '1', 'appid' => $pay->appid];
|
||||
$notify = Db::name('WechatPayPrepayid')->where($map)->find();
|
||||
if (empty($notify)) {
|
||||
Log::error("内部订单号{$order_no}验证退款失败");
|
||||
|
@ -49,11 +49,11 @@ class ToolsService
|
||||
public static function corsRequestHander()
|
||||
{
|
||||
return [
|
||||
'Access-Control-Allow-Origin' => '*',
|
||||
'Access-Control-Allow-Origin' => '*',
|
||||
'Access-Control-Allow-Credentials' => true,
|
||||
'Access-Control-Allow-Methods' => 'GET,POST,OPTIONS',
|
||||
'X-Support' => 'service@cuci.cc',
|
||||
'X-Servers' => 'Guangzhou Cuci Technology Co. Ltd',
|
||||
'Access-Control-Allow-Methods' => 'GET,POST,OPTIONS',
|
||||
'X-Support' => 'service@cuci.cc',
|
||||
'X-Servers' => 'Guangzhou Cuci Technology Co. Ltd',
|
||||
];
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ class ToolsService
|
||||
*/
|
||||
public static function arr2tree($list, $id = 'id', $pid = 'pid', $son = 'sub')
|
||||
{
|
||||
$tree = $map = array();
|
||||
$tree = $map = [];
|
||||
foreach ($list as $item) {
|
||||
$map[$item[$id]] = $item;
|
||||
}
|
||||
@ -117,12 +117,12 @@ class ToolsService
|
||||
public static function arr2table($list, $id = 'id', $pid = 'pid', $path = 'path', $ppath = '')
|
||||
{
|
||||
$_array_tree = self::arr2tree($list, $id, $pid);
|
||||
$tree = array();
|
||||
$tree = [];
|
||||
foreach ($_array_tree as $_tree) {
|
||||
$_tree[$path] = $ppath . '-' . $_tree[$id];
|
||||
$_tree['spl'] = str_repeat(" ├ ", substr_count($ppath, '-'));
|
||||
if (!isset($_tree['sub'])) {
|
||||
$_tree['sub'] = array();
|
||||
$_tree['sub'] = [];
|
||||
}
|
||||
$sub = $_tree['sub'];
|
||||
unset($_tree['sub']);
|
||||
@ -145,7 +145,7 @@ class ToolsService
|
||||
*/
|
||||
public static function getArrSubIds($list, $id = 0, $key = 'id', $pkey = 'pid')
|
||||
{
|
||||
$ids = array(intval($id));
|
||||
$ids = [intval($id)];
|
||||
foreach ($list as $vo) {
|
||||
if (intval($vo[$pkey]) > 0 && intval($vo[$pkey]) == intval($id)) {
|
||||
$ids = array_merge($ids, self::getArrSubIds($list, intval($vo[$key]), $key, $pkey));
|
||||
|
@ -38,7 +38,7 @@ class WechatService
|
||||
$data = Db::name('WechatNews')->where('id', $id)->where($where)->find();
|
||||
$article_ids = explode(',', $data['article_id']);
|
||||
$articles = Db::name('WechatNewsArticle')->where('id', 'in', $article_ids)->select();
|
||||
$data['articles'] = array();
|
||||
$data['articles'] = [];
|
||||
foreach ($article_ids as $article_id) {
|
||||
foreach ($articles as $article) {
|
||||
if (intval($article['id']) === intval($article_id)) {
|
||||
@ -87,7 +87,7 @@ class WechatService
|
||||
* @param array $video_info 视频信息
|
||||
* @return string|null
|
||||
*/
|
||||
public static function uploadForeverMedia($local_url = '', $type = 'image', $is_video = false, $video_info = array())
|
||||
public static function uploadForeverMedia($local_url = '', $type = 'image', $is_video = false, $video_info = [])
|
||||
{
|
||||
# 检测文件上否已经上传过了
|
||||
$wechat = &load_wechat('media');
|
||||
@ -101,7 +101,7 @@ class WechatService
|
||||
$upload = FileService::local($filename, file_get_contents($local_url));
|
||||
if (!empty($upload) && isset($upload['file']) && file_exists($upload['file'])) {
|
||||
# 上传图片到微信服务器
|
||||
if (false !== ($result = $wechat->uploadForeverMedia(array('media' => "@{$upload['file']}"), $type, $is_video, $video_info))) {
|
||||
if (false !== ($result = $wechat->uploadForeverMedia(['media' => "@{$upload['file']}"], $type, $is_video, $video_info))) {
|
||||
$data = ['md5' => $md5, 'type' => $type, 'appid' => $wechat->appid, 'media_id' => $result['media_id'], 'local_url' => $local_url];
|
||||
isset($result['url']) && $data['media_url'] = $result['url'];
|
||||
Db::name('WechatNewsMedia')->insert($data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user