This action will force synchronization from LEADSHOP开源商城系统/Leadshop_免费且开源, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
<?php/*** 应用管理* @link http://www.heshop.com/* @copyright Copyright (c) 2020 HeShop Software LLC* @license http://www.heshop.com/license/*/namespace leadmall\api;use basics\api\BasicsController as BasicsModules;use framework\wechat\WechatAccesstoken;use leadmall\Map;use Yii;class AppconfigController extends BasicsModules implements Map{/*** 重写父类* @return [type] [description]*/public function actions(){$actions = parent::actions();unset($actions['create']);unset($actions['update']);return $actions;}public function actionIndex(){$url = Yii::$app->basePath . '/stores/' . Yii::$app->params['AppID'] . '.json';if (file_exists($url)) {$json = file_get_contents($url);$arr = to_array($json);$arr['apply']['wechat']['url'] = Yii::$app->request->hostInfo;$arr['apply']['wechat']['token'] = $arr['apply']['wechat']['token'] ? $arr['apply']['wechat']['token'] : get_random(6);$arr['apply']['wechat']['encodingAesKey'] = $arr['apply']['wechat']['encodingAesKey'] ? $arr['apply']['wechat']['token'] : get_random(43);return $arr;} else {Error('文件不存在');}}public function actionCreate(){//获取操作$behavior = Yii::$app->request->get('behavior', '');switch ($behavior) {case 'upload':return $this->upload();break;case 'save':return $this->save();break;default:return 111222;break;}}public function save(){$post = Yii::$app->request->post();$key = Yii::$app->request->get('key', '');if (empty($post)) {Error('数据为空');}$url = Yii::$app->basePath . '/stores/' . Yii::$app->params['AppID'] . '.json';if (file_exists($url)) {$json = file_get_contents($url);$data = to_array($json);$key = explode('_', $key);if (isset($data[$key[0]][$key[1]])) {$data[$key[0]][$key[1]] = $post;} else {Error('配置不存在');}$data = to_json($data);if ($key[0] == 'apply') {$this->check($key[1]);}return to_mkdir($url, $data, true, true);} else {Error('文件不存在');}}private function check($type){$platform = '微信小程序';if ($type == 'wechat') {$platform = '微信公众号';}$appId = Yii::$app->request->post('AppID', false);$appSecret = Yii::$app->request->post('AppSecret', false);if (!$appId) {throw new \Exception($platform . 'AppId有误');}if (!$appSecret) {throw new \Exception($platform . 'AppSecret有误');}try {$weapp = new WechatAccesstoken();$weapp->resetAuth($appId);$weapp->getAccessToken($appId, $appSecret);} catch (\Exception $exception) {if (isset($weapp->errCode) && isset($weapp->errMsg)) {if ($weapp->errCode == '40013') {Error($platform . 'AppId有误(' . $weapp->errMsg . ')');}if ($weapp->errCode == '40125') {Error($platform . 'appSecret有误(' . $weapp->errMsg . ')');}}Error($platform . $exception->getMessage());}return true;}public function upload(){$file = $_FILES['file'];preg_match('|\.(\w+)$|', $file['name'], $ext);$ext = strtolower($ext[1]);if (!in_array($ext, ['txt','ico'])) {Error('不被允许的文件类型');}if (move_uploaded_file($file['tmp_name'], Yii::$app->basePath . '/web/' . $file['name'])) {$url = Yii::$app->request->hostInfo;return $url . '/' . $file['name'];} else {Error('上传失败');}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。