123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705 |
- <?php
- namespace app\modules\admin\controllers;
- use app\common\controllers\BController;
- use app\modules\admin\models\Config;
- use app\models\MobileMsgTpl;
- use app\models\EmailTpl;
- use app\common\components\Sms;
- use app\common\components\Emailer;
- use app\modules\admin\models\Sysconfig;
- use Yii;
- class SettingsController extends BController
- {
- public $layout = 'main';
- public function actionBase()
- {
- $baseConfigModel = Config::find()->where("name='baseconfig'")->limit(1)->one();
- check_record_exists($baseConfigModel);
- $baseconfig = string2array($baseConfigModel->value);
- $wapConfigModel = Config::find()->where("name='wapconfig'")->limit(1)->one();
- check_record_exists($wapConfigModel);
- $wapconfig = string2array($wapConfigModel->value);
- $imageConfigModel = Config::find()->where("name='imageconfig'")->limit(1)->one();
- check_record_exists($imageConfigModel);
- $imageconfig = string2array($imageConfigModel->value);
- $csrConfigModel = Config::find()->where("name='csr'")->limit(1)->one();
- check_record_exists($csrConfigModel);
- $csr = string2array($csrConfigModel->value);
- $ueditorConfigModel = Config::find()->where("name='ueditor'")->limit(1)->one();
- check_record_exists($ueditorConfigModel);
- $ueditorconfig = string2array($ueditorConfigModel->value);
- $baiduConfigModel = Config::find()->where("name='baiduconfig'")->limit(1)->one();
- check_record_exists($baiduConfigModel);
- $baiduconfig = string2array($baiduConfigModel->value);
- $withdrawConfigModel = Config::find()->where("name='withdraw'")->limit(1)->one();
- check_record_exists($withdrawConfigModel);
- $withdrawconfig = string2array($withdrawConfigModel->value);
- $higherConfigModel = Config::find()->where("name='higherconfig'")->limit(1)->one();
- check_record_exists($higherConfigModel);
- $higherconfig = string2array($higherConfigModel->value);
- if(Yii::$app->request->post()){
- $post = Yii::$app->request->post();
- if(!empty($post['baseconfig']))
- {
- $post['baseconfig']['open_cert'] = $post['baseconfig']['open_cert']?$post['baseconfig']['open_cert']:0;
- $post['baseconfig']['open_org'] = $post['baseconfig']['open_org']?$post['baseconfig']['open_org']:0;
- $post['baseconfig']['incomerank'] = $post['baseconfig']['incomerank']?$post['baseconfig']['incomerank']:0;
- $post['baseconfig']['open_virtual'] = $post['baseconfig']['open_virtual']?$post['baseconfig']['open_virtual']:0;
- $baseconfig = $post['baseconfig'];
- $baseConfigModel->value = array2string($post['baseconfig']);
- if($baseConfigModel->save())
- {
- Yii::$app->session->setFlash('success','操作成功');
- }
- $tab = 1;
- }
- if(!empty($post['wapconfig']))
- {
- $wapconfig = $post['wapconfig'];
- $wapConfigModel->value = array2string($post['wapconfig']);
- if($wapConfigModel->save())
- {
- Yii::$app->session->setFlash('success','操作成功');
- }
- $tab = 2;
- }
- if(!empty($post['imageconfig']))
- {
- $imageconfig = $post['imageconfig'];
- $imageConfigModel->value = array2string($post['imageconfig']);
- if($imageConfigModel->save())
- {
- Yii::$app->session->setFlash('success','操作成功');
- }
- $tab = 3;
- }
- if(!empty($post['csr']))
- {
- $post['csr']['wx_mpapi'] = $post['csr']['wx_mpapi']?$post['csr']['wx_mpapi']:0;
- $csr = $post['csr'];
- $csrConfigModel->value = array2string($post['csr']);
- if($csrConfigModel->save())
- {
- Yii::$app->session->setFlash('success','操作成功');
- }
- $tab = 4;
- }
- if(!empty($post['ueditor']))
- {
- $ueditorconfig = $post['ueditor'];
- $ueditorConfigModel->value = array2string($post['ueditor']);
- if($ueditorConfigModel->save())
- {
- $array = $post['ueditor'];
- $array['imageMaxSize'] = $array['imageMaxSize']*1024*1024;
- $array['scrawlMaxSize'] = $array['scrawlMaxSize']*1024*1024;
- $array['catcherMaxSize'] = $array['catcherMaxSize']*1024*1024;
- $array['videoMaxSize'] = $array['videoMaxSize']*1024*1024;
- $array['fileMaxSize'] = $array['fileMaxSize']*1024*1024;
- $this->setConfig($array,'ueditor');
- Yii::$app->session->setFlash('success','操作成功');
- }
- $tab = 5;
- }
- if(!empty($post['baiduconfig']))
- {
- $baiduconfig = $post['baiduconfig'];
- $baiduConfigModel->value = array2string($post['baiduconfig']);
- if($baiduConfigModel->save())
- {
- Yii::$app->session->setFlash('success','操作成功');
- }
- $tab = 6;
- }
- if(!empty($post['withdraw']))
- {
- $withdrawconfig = $post['withdraw'];
- $withdrawConfigModel->value = array2string($post['withdraw']);
- if($withdrawConfigModel->save())
- {
- Yii::$app->session->setFlash('success','操作成功');
- }
- $tab = 7;
- }
- if(!empty($post['higherconfig']))
- {
- $post['higherconfig']['open_sphinx'] = $post['higherconfig']['open_sphinx']?$post['higherconfig']['open_sphinx']:0;
- $post['higherconfig']['multisearch'] = $post['higherconfig']['multisearch']?$post['higherconfig']['multisearch']:0;
- $post['higherconfig']['splitdb'] = $post['higherconfig']['splitdb']?$post['higherconfig']['splitdb']:0;
- $post['higherconfig']['htmlrule'] = $post['higherconfig']['htmlrule']?$post['higherconfig']['htmlrule']:0;
- $post['higherconfig']['opencpc'] = $post['higherconfig']['opencpc']?$post['higherconfig']['opencpc']:0;
- $higherconfig = $post['higherconfig'];
- $higherConfigModel->value = array2string($post['higherconfig']);
- if($higherConfigModel->save())
- {
- $array['htmlrule'] = $higherconfig['htmlrule'];
- $this->setConfig($array,'params');
- Yii::$app->session->setFlash('success','操作成功');
- }
- $tab = 9;
- }
- }
- else
- {
- $tab = 1;
- }
- return $this->render('base',array('tab'=>$tab,'baseconfig'=>$baseconfig,'wapconfig'=>$wapconfig,'imageconfig'=>$imageconfig,'csr'=>$csr,'baiduconfig'=>$baiduconfig,'withdrawconfig'=>$withdrawconfig,'higherconfig'=>$higherconfig,'ueditorconfig'=>$ueditorconfig));
- }
- public function actionUpload()
- {
- $model = Config::find()->where("name='attachment'")->limit(1)->one();
- check_record_exists($model);
- $config = string2array($model->value);
- $ossModel = Config::find()->where("name='oss'")->limit(1)->one();
- check_record_exists($ossModel);
- $ossConfig = string2array($ossModel->value);
- $tab = 1;
- if(Yii::$app->request->post()){
- $post = Yii::$app->request->post();
- if(!empty($post['attachment']))
- {
- $model->value = array2string($post['attachment']);
- if($model->save())
- {
- $config = $post['attachment'];
- $file_types = join(",",explode("|",$config['file_type']));
- $array['extensions'] = $file_types;
- $array['fileNumLimit'] = $config['file_num_limit'];
- $array['fileSingleSizeLimit'] = $config['file_single_size_limit']*1024*1024;
- $array['fileSizeLimit'] = $config['file_size_limit']*1024*1024;
- $this->setConfig($array,'params');
- Yii::$app->session->setFlash('success','操作成功');
- }
- $tab =1;
- }
- if(!empty($post['oss']))
- {
- $post['oss']['OPEN_OSS'] = $post['oss']['OPEN_OSS']?$post['oss']['OPEN_OSS']:0;
- $post['oss']['OPEN_INTERNAL'] = $post['oss']['OPEN_INTERNAL']?$post['oss']['OPEN_INTERNAL']:0;
- $post['oss']['OSS_THUMB'] = $post['oss']['OSS_THUMB']?$post['oss']['OSS_THUMB']:0;
- $ossModel->value = array2string($post['oss']);
- if($ossModel->save())
- {
- $ossConfig = $post['oss'];
- $this->setConfig($ossConfig,'oss');
- Yii::$app->session->setFlash('success','操作成功');
- }
- $tab =2;
- }
- }
- return $this->render('upload',array('config'=>$config,'ossConfig'=>$ossConfig,'tab'=>$tab));
- }
- public function actionPay()
- {
- $model = Config::find()->where("name='pay'")->limit(1)->one();
- check_record_exists($model);
- $config = string2array($model->value);
- if(Yii::$app->request->post()){
- $post = Yii::$app->request->post();
- if(!empty($post['pay']['weixin_config']))
- {
- $post['pay']['weixin_pay'] = $post['pay']['weixin_pay']?$post['pay']['weixin_pay']:0;
- }
- if(!empty($post['pay']['apd_config']))
- {
- $post['pay']['apd_pay'] = $post['pay']['apd_pay']?$post['pay']['apd_pay']:0;
- }
- if(!empty($post['pay']['apw_config']))
- {
- $post['pay']['apw_pay'] = $post['pay']['apw_pay']?$post['pay']['apw_pay']:0;
- }
- if(!empty($post['pay']['hpwx_config']))
- {
- $post['pay']['hpwx_pay'] = $post['pay']['hpwx_pay']?$post['pay']['hpwx_pay']:0;
- }
- if(!empty($post['pay']['hpali_config']))
- {
- $post['pay']['hpali_pay'] = $post['pay']['hpali_pay']?$post['pay']['hpali_pay']:0;
- }
- if(!empty($post['pay']['wxh5_config']))
- {
- $post['pay']['wxh5_pay'] = $post['pay']['wxh5_pay']?$post['pay']['wxh5_pay']:0;
- }
- if(!empty($post['pay']['coupon_config']))
- {
- $post['pay']['open_coupon'] = $post['pay']['open_coupon']?$post['pay']['open_coupon']:0;
- }
- if($_FILES['weixin_apiclient_cert']['name'])
- {
- $tempFile = $_FILES['weixin_apiclient_cert']['tmp_name'];
- $targetPath = Yii::$app->params['wxPayCertPath'];
- dir_create($targetPath);
- $targetFile = $targetPath.'apiclient_cert.pem';
- move_uploaded_file($tempFile,$targetFile);
- $post['pay']['weixin_apiclient_cert'] = str_replace(Yii::$app->params['wxPayCertPath'],"",$targetFile);
- $certList['weixin_apiclient_cert'] = $targetFile;
- }
- else
- {
- $certList['weixin_apiclient_cert'] = Yii::$app->params['wxPayCertPath'].'apiclient_cert.pem';
- }
- if($_FILES['weixin_apiclient_key']['name'])
- {
- $tempFile = $_FILES['weixin_apiclient_key']['tmp_name'];
- $targetPath = Yii::$app->params['wxPayCertPath'];
- dir_create($targetPath);
- $targetFile = $targetPath.'apiclient_key.pem';
- move_uploaded_file($tempFile,$targetFile);
- $post['pay']['weixin_apiclient_key'] = str_replace(Yii::$app->params['wxPayCertPath'],"",$targetFile);
- $certList['weixin_apiclient_key'] = $targetFile;
- }
- else
- {
- $certList['weixin_apiclient_key'] = Yii::$app->params['wxPayCertPath'].'apiclient_key.pem';
- }
- if($_FILES['weixin_cert']['name'])
- {
- $tempFile = $_FILES['weixin_cert']['tmp_name'];
- $targetPath = Yii::$app->params['wxPayCertPath'];
- dir_create($targetPath);
- $targetFile = $targetPath.'weixin_cert.pem';
- move_uploaded_file($tempFile,$targetFile);
- $post['pay']['weixin_cert'] = str_replace(Yii::$app->params['wxPayCertPath'],"",$targetFile);
- $certList['weixin_cert'] = $targetFile;
- }
- else
- {
- $certList['weixin_cert'] = Yii::$app->params['wxPayCertPath'].'weixin_cert.pem';
- }
- $newConfig = array_merge($config,$post['pay']);
- $model->value = array2string($newConfig);
- if($model->save())
- {
- $config = $newConfig;
- $this->setConfig($post['pay'],'pay');
- if(!empty($certList))$this->setConfig($certList,'pay');
- Yii::$app->session->setFlash('success','操作成功');
- //$this->refresh();
- }
- }
- return $this->render('pay',array('config'=>$config));
- }
- //短信配置
- public function actionSms(){
- $configModel = Config::find()->where("name='sms'")->limit(1)->one();
- check_record_exists($configModel);
- $config = string2array($configModel->value);
- if(Yii::$app->request->post()){
- $post = Yii::$app->request->post();
- $post['sms']['open_sms'] = $post['sms']['open_sms']?$post['sms']['open_sms']:0;
- $post['sms']['open_imgvalid'] = $post['sms']['open_imgvalid']?$post['sms']['open_imgvalid']:0;
- $configModel->value = array2string($post['sms']);
- if($configModel->save())
- {
- $config = $post['sms'];
- Yii::$app->session->setFlash('success','操作成功');
- }
- }
- if (Yii::$app->request->isAjax) {
- $query = MobileMsgTpl::find();
- $data = [];
- $params = Yii::$app->request->get('MobileMsgTpl');
- $query = mergeParams($query,$params);
- //排序
- if(isset($_GET['sort'])&&isset($_GET['sortOrder']))
- {
- $resultList = $query->orderBy([$_GET['sort']=>($_GET['sortOrder']=='asc'?SORT_ASC:SORT_DESC)])->all();
- }
- else
- {
- $resultList = $query->orderBy(['id'=>SORT_ASC])->all();
- }
- foreach($resultList as $result)
- {
- $data[] = array('id'=>$result->id,'key'=>$result->key,'name'=>$result->name,'code'=>$result->code,'tpl'=>$result->tpl,'type'=>MobileMsgTpl::typeOptions($result->type));
- }
- echo_json($data);
- }
- $this->tableTitle = array(
- array('field'=>'id','title'=>Yii::t('attr','mobile_msg_tpl.id'),'align'=>'center','sortable'=>true,'class'=>'col-md-2'),
- array('field'=>'key','title'=>Yii::t('attr','mobile_msg_tpl.key'),'align'=>'center'),
- array('field'=>'name','title'=>Yii::t('attr','mobile_msg_tpl.name'),'align'=>'center'),
- array('field'=>'code','title'=>Yii::t('attr','mobile_msg_tpl.code'),'align'=>'center'),
- array('field'=>'tpl','title'=>Yii::t('attr','mobile_msg_tpl.tpl'),'align'=>'center'),
- array('field'=>'type','title'=>Yii::t('attr','mobile_msg_tpl.type'),'align'=>'center'),
- array('field'=>'operate','title'=>'操作','align'=>'center','events'=>'window.operateEvents','formatter'=>'operateFormatter'),
- );
- $this->tableConfig = array('table'=>MobileMsgTpl::shortTableName(),'url'=>$this->createRealUrl(['admin/settings/sms']),'idField'=>MobileMsgTpl::modelPrimaryKey(),'checkbox'=>0,'dropmenu'=>1,'pagination'=>false,'refresh'=>true);
- return $this->render('sms',array('config'=>$config,'model'=>new MobileMsgTpl()));
- }
- //添加短信模板
- public function actionAddsms()
- {
- $model = new MobileMsgTpl();
- if(Yii::$app->request->isAjax&&$model->load(Yii::$app->request->post())){
- $exist = MobileMsgTpl::find()->alias("a")->where("a.key='".$model->key."'")->exists();
- if($exist)
- {
- $msgdata = ['error' => 1,'msg' => '已存在相同Key,添加失败'];
- echo_json($msgdata);
- }
- if(!$model->validate())
- {
- $msgdata = ['error' => 1,'msg' => $model->returnFirstError()];
- }
- else
- {
- if($model->save())
- {
- $msgdata = ['error' => 0,'msg' => '操作成功'];
- }
- else
- {
- $msgdata = ['error' => 1,'msg' => '操作失败'];
- }
- }
- echo_json($msgdata);
- }
- return $this->renderAjax('addsms',array('model'=>$model));
- }
- //编辑短信模板
- public function actionEditsms()
- {
- $id = $this->getKeyId();
- $model = MobileMsgTpl::findOne($id);
- check_record_exists($model);
- if($model->load(Yii::$app->request->post())){
- if(!$model->validate())
- {
- $msgdata = ['error' => 1,'msg' => $model->returnFirstError()];
- }
- else
- {
- if($model->save())
- {
- $msgdata = ['error' => 0,'msg' => '操作成功'];
- }
- else
- {
- $msgdata = ['error' => 1,'msg' => '操作失败'];
- }
- }
- echo_json($msgdata);
- }
- return $this->renderAjax('addsms',array('model'=>$model));
- }
- //删除短信模板
- public function actionDelsms()
- {
- $id = $this->getKeyId();
- $model = MobileMsgTpl::findOne($id);
- check_record_exists($model);
- if($model->delete())
- {
- $msgdata = ['error' => 0,'msg' => '删除成功'];
- }
- else
- {
- $msgdata = ['error' => 1,'msg' => '删除失败'];
- }
- echo_json($msgdata);
- }
- //测试短信发送
- public function actionSendsms()
- {
- $id = $this->getKeyId();
- $model = MobileMsgTpl::findOne($id);
- check_record_exists($model);
- $post = Yii::$app->request->post();
- if(!empty($post['mobile'])){
- preg_match_all('/{(.*?)}/i',$model->tpl,$return);
- $args = explode("|",$post['args']);
- if(is_array($args))foreach($args as $k=>$arg)
- {
- $newArgs[$return[1][$k]] = $arg;
- }
- $sms = new Sms();
- $sms->init();
- $result = $sms->send($model->key,$post['mobile'],$newArgs,2);
- if($result)
- {
- $msgdata = ['error' => 0,'msg' => '发送成功'];
- }
- else
- {
- $msgdata = ['error' => 1,'msg' => '发送失败'];
- }
- echo_json($msgdata);
- }
- return $this->renderAjax('sendsms');
- }
- //邮箱配置
- public function actionMail(){
- $configModel = Config::find()->where("name='mailer'")->limit(1)->one();
- check_record_exists($configModel);
- $config = string2array($configModel->value);
- if(Yii::$app->request->post()){
- $post = Yii::$app->request->post();
- $post['mailer']['open'] = $post['mailer']['open']?$post['mailer']['open']:0;
- $configModel->value = array2string($post['mailer']);
- if($configModel->save())
- {
- $config = $post['mailer'];
- $this->setConfig($config,'mailer');
- Yii::$app->session->setFlash('success','操作成功');
- }
- }
- if (Yii::$app->request->isAjax) {
- $query = EmailTpl::find();
- $data = [];
- $params = Yii::$app->request->get('EmailTpl');
- $query = mergeParams($query,$params);
- //排序
- if(isset($_GET['sort'])&&isset($_GET['sortOrder']))
- {
- $resultList = $query->orderBy([$_GET['sort']=>($_GET['sortOrder']=='asc'?SORT_ASC:SORT_DESC)])->all();
- }
- else
- {
- $resultList = $query->orderBy(['id'=>SORT_ASC])->all();
- }
- foreach($resultList as $result)
- {
- $data[] = array('id'=>$result->id,'key'=>$result->key,'title'=>$result->title,'tpl'=>$result->tpl,'type'=>EmailTpl::typeOptions($result->type));
- }
- echo_json($data);
- }
- $this->tableTitle = array(
- array('field'=>'id','title'=>Yii::t('attr','email_tpl.id'),'align'=>'center','sortable'=>true,'class'=>'col-md-2'),
- array('field'=>'key','title'=>Yii::t('attr','email_tpl.key'),'align'=>'center'),
- array('field'=>'title','title'=>Yii::t('attr','email_tpl.title'),'align'=>'center'),
- array('field'=>'type','title'=>Yii::t('attr','email_tpl.type'),'align'=>'center'),
- array('field'=>'operate','title'=>'操作','align'=>'center','events'=>'window.operateEvents','formatter'=>'operateFormatter'),
- );
- $this->tableConfig = array('table'=>EmailTpl::shortTableName(),'url'=>$this->createRealUrl(['admin/settings/mail']),'idField'=>EmailTpl::modelPrimaryKey(),'checkbox'=>1,'dropmenu'=>1,'pagination'=>false,'refresh'=>true);
- return $this->render('mail',array('config'=>$config,'model'=>new EmailTpl()));
- }
- //添加邮件模板
- public function actionAddmailtpl()
- {
- $model = new EmailTpl();
- if(Yii::$app->request->isAjax&&$model->load(Yii::$app->request->post())){
- $exist = EmailTpl::find()->alias("a")->where("a.key='".$model->key."'")->exists();
- if($exist)
- {
- $msgdata = ['error' => 1,'msg' => '已存在相同Key,添加失败'];
- echo_json($msgdata);
- }
- if(!$model->validate())
- {
- $msgdata = ['error' => 1,'msg' => $model->returnFirstError()];
- }
- else
- {
- if($model->save())
- {
- $msgdata = ['error' => 0,'msg' => '操作成功'];
- }
- else
- {
- $msgdata = ['error' => 1,'msg' => '操作失败'];
- }
- }
- echo_json($msgdata);
- }
- return $this->renderAjax('addmailtpl',array('model'=>$model));
- }
- //编辑邮箱模板
- public function actionEditmailtpl()
- {
- $id = $this->getKeyId();
- $model = EmailTpl::findOne($id);
- check_record_exists($model);
- if($model->load(Yii::$app->request->post())){
- if(!$model->validate())
- {
- $msgdata = ['error' => 1,'msg' => $model->returnFirstError()];
- }
- else
- {
- if($model->save())
- {
- $msgdata = ['error' => 0,'msg' => '操作成功'];
- }
- else
- {
- $msgdata = ['error' => 1,'msg' => '操作失败'];
- }
- }
- echo_json($msgdata);
- }
- return $this->renderAjax('addmailtpl',array('model'=>$model));
- }
- //删除邮件模板
- public function actionDelmailtpl()
- {
- $id = $this->getKeyId();
- $model = EmailTpl::findOne($id);
- check_record_exists($model);
- if($model->delete())
- {
- $msgdata = ['error' => 0,'msg' => '删除成功'];
- }
- else
- {
- $msgdata = ['error' => 1,'msg' => '删除失败'];
- }
- echo_json($msgdata);
- }
- //测试邮件发送
- public function actionSendmail()
- {
- $id = $this->getKeyId();
- $model = EmailTpl::findOne($id);
- check_record_exists($model);
- $post = Yii::$app->request->post();
- if(!empty($post['mailaddress'])){
- preg_match_all('/{(.*?)}/i',$model->tpl,$return);
- $newArgs = [];
- $args = explode("|",$post['args']);
- if(is_array($args))foreach($args as $k=>$arg)
- {
- $newArgs[$return[1][$k]] = $arg;
- }
- $mailer = new Emailer();
- $result = $mailer->send($model->key,$post['mailaddress'],$newArgs);
- if($result)
- {
- $msgdata = ['error' => 0,'msg' => '发送成功'];
- }
- else
- {
- $msgdata = ['error' => 1,'msg' => '发送失败'];
- }
- echo_json($msgdata);
- }
- return $this->renderAjax('sendmail');
- }
- //金币设置
- public function actionCoin(){
- $settings = getSysconfigValue('coin');
- $configModel = Config::find()->where("name='coin'")->limit(1)->one();
- check_record_exists($configModel);
- $config = string2array($configModel->value);
- if(Yii::$app->request->post()){
- $post = Yii::$app->request->post();
- $configModel->value = array2string($post['coin']);
- if($configModel->save())
- {
- $config = $post['coin'];
- $this->writeConfigFile($config,'coin');
- Yii::$app->session->setFlash('success','操作成功');
- }
- }
- return $this->render('coin',array('config'=>$config,'settings'=>$settings));
- }
- //积分设置
- public function actionPoint(){
- $settings = getSysconfigValue('point');
- $configModel = Config::find()->where("name='point'")->limit(1)->one();
- check_record_exists($configModel);
- $config = string2array($configModel->value);
- if(Yii::$app->request->post()){
- $post = Yii::$app->request->post();
- $configModel->value = array2string($post['point']);
- if($configModel->save())
- {
- $config = $post['point'];
- $this->writeConfigFile($config,'point');
- Yii::$app->session->setFlash('success','操作成功');
- }
- }
- return $this->render('point',array('config'=>$config,'settings'=>$settings));
- }
- //第三方登录设置
- public function actionOpenauth(){
- $model = Config::find()->where("name='openauth'")->limit(1)->one();
- check_record_exists($model);
- $config = string2array($model->value);
- if(Yii::$app->request->post()){
- $post = Yii::$app->request->post();
- if(!empty($post['openauth']['systemConfig']))
- {
- $post['openauth']['commonAccount'] = $post['openauth']['commonAccount']?$post['openauth']['commonAccount']:0;
- $post['openauth']['fastAccount'] = $post['openauth']['fastAccount']?$post['openauth']['fastAccount']:0;
- $post['openauth']['fastAccountType'] = $post['openauth']['fastAccountType']?$post['openauth']['fastAccountType']:0;
- $tab = 1;
- }
- if(!empty($post['openauth']['mpConfig']))
- {
- $post['openauth']['openMpLogin'] = $post['openauth']['openMpLogin']?$post['openauth']['openMpLogin']:0;
- $post['openauth']['mpAutoLoginWap'] = $post['openauth']['mpAutoLoginWap']?$post['openauth']['mpAutoLoginWap']:0;
- $post['openauth']['openMpSubLogin'] = $post['openauth']['openMpSubLogin']?$post['openauth']['openMpSubLogin']:0;
- $tab = 2;
- }
- if(!empty($post['openauth']['qqConfig']))
- {
- $post['openauth']['openQqLogin'] = $post['openauth']['openQqLogin']?$post['openauth']['openQqLogin']:0;
- $post['openauth']['m_openQqLogin'] = $post['openauth']['m_openQqLogin']?$post['openauth']['m_openQqLogin']:0;
- $tab = 3;
- }
- if(!empty($post['openauth']['dingConfig']))
- {
- $post['openauth']['dingtalkLogin'] = $post['openauth']['dingtalkLogin']?$post['openauth']['dingtalkLogin']:0;
- $post['openauth']['m_dingtalkLogin'] = $post['openauth']['m_dingtalkLogin']?$post['openauth']['m_dingtalkLogin']:0;
- $tab = 4;
- }
- if(!empty($post['openauth']['systemUnion']))
- {
- $post['openauth']['openUnionId'] = $post['openauth']['openUnionId']?$post['openauth']['openUnionId']:0;
- $tab = 5;
- }
- $newConfig = array_merge($config,$post['openauth']);
- $model->value = array2string($newConfig);
- if($model->save())
- {
- $config = $newConfig;
- $this->writeConfigFile($newConfig,'openauth');
- Yii::$app->session->setFlash('success','操作成功');
- //$this->refresh();
- }
- }
- return $this->render('openauth',array('config'=>$config,'tab'=>$tab));
- }
- }
|