123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
-
- namespace app\api\behavior;
-
- use think\Config;
-
-
- class ModuleInitBehavior {
- protected static $actionName;
- protected static $controllerName;
- protected static $moduleName;
- protected static $method;
-
-
-
- public function __construct()
- {
-
- }
-
-
- public function run(&$params){
- self::$actionName = request()->action();
- self::$controllerName = request()->controller();
- self::$moduleName = request()->module();
- self::$method = request()->method();
- $this->_initialize();
- }
-
- private function _initialize() {
- $this->vertifyCode();
- }
-
-
-
- private function vertifyCode()
- {
-
- $ctlActArr = array(
- 'api@Ajax@vertify',
- 'api@Diyajax@*',
- );
- $ctlActStr = self::$moduleName.'@'.self::$controllerName.'@'.self::$actionName;
- $ctlActStr2 = self::$moduleName.'@'.self::$controllerName.'@*';
- if (in_array($ctlActStr, $ctlActArr) || in_array($ctlActStr2, $ctlActArr)) {
- $row = tpSetting('system.system_vertify');
-
- $row = json_decode($row, true);
- $baseConfig = Config::get("captcha");
- if (!empty($row)) {
- foreach ($row['captcha'] as $key => $val) {
- if ('default' == $key) {
- $baseConfig[$key] = array_merge($baseConfig[$key], $val);
- } else {
- $baseConfig[$key]['is_on'] = $val['is_on'];
- $baseConfig[$key]['config'] = array_merge($baseConfig['default'], $val['config']);
- }
- }
- }
-
- Config::set('captcha', $baseConfig);
- }
- }
- }
|