1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace mini\sdk\controller;
- use huolib\status\CommonStatus;
- use huomp\controller\game\GameMini;
- use huomp\controller\sec\secCheckApi;
- use mini\common\controller\V2ApiBaseController;
- use think\Log;
- class MpSecCheckController extends V2ApiBaseController {
- function _initialize() {
- parent::_initialize();
- $this->checkLogin();
- }
-
- public function msgSecCheck() {
- $_game_rq = $this->setGameData();
- $_app_id = $_game_rq->getHAppId();
- $_content = get_val($this->rq_data, 'content', '');
- if (empty($_content)) {
- $_code = CommonStatus::INVALID_PARAMS;
- $this->error('检测内容为空', [], $_code);
- }
- $_config = (new GameMini())->getMpConfig($_app_id);
- if (empty($_config) || empty($_config['app_id']) || empty($_config['app_secret'])) {
- $_err_msg = 'func='.__FUNCTION__.'&class='.__CLASS__.'¶m='.json_encode($this->request->param())
- .'&config='.json_encode($_config);
- Log::write($_err_msg, Log::ERROR, true);
- $_code = CommonStatus::INVALID_PARAMS;
- $this->error(CommonStatus::getMsg($_code), [], $_code);
- }
- $_rs = (new secCheckApi())->msgSecCheck($_config['app_id'], $_config['app_secret'], $_content);
- $this->returnData($_rs);
- }
-
- public function imgSecCheck() {
- $_game_rq = $this->setGameData();
- $_app_id = $_game_rq->getHAppId();
- $file = request()->file('image');
- $_path = ROOT_PATH.'public'.DS.'upload/secCheck/';
- if ($file) {
- $info = $file->move($_path);
- if ($info) {
- $_img_path = $_path.$info->getSaveName();
- $_ext = $info->getExtension();
- $_img_name = $info->getBasename('.'.$_ext);
- $_image = \think\Image::open($_img_path);
- $_thumb = $_img_name.'_thumb.'.$_ext;
- $_thumb_path = $_path.$_thumb;
- $_image->thumb(750, 750)->save($_thumb_path);
-
- $_config = (new GameMini())->getMpConfig($_app_id);
- if (empty($_config) || empty($_config['app_id']) || empty($_config['app_secret'])) {
- $_err_msg = 'func='.__FUNCTION__.'&class='.__CLASS__.'¶m='.json_encode($this->request->param())
- .'&config='.json_encode($_config);
- Log::write($_err_msg, Log::ERROR, true);
- $_code = CommonStatus::INVALID_PARAMS;
- $this->error(CommonStatus::getMsg($_code), [], $_code);
- }
- $_rs = (new secCheckApi())->imgSecCheck($_config['app_id'], $_config['app_secret'], $_thumb_path);
-
- unlink($_thumb_path);
- unlink($_img_path);
- $this->returnData($_rs);
- } else {
-
- echo $file->getError();
- }
- }
- }
- }
|