暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VertifyManageBehavior.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace weapp\Systemdoctor\behavior\api;
  3. use think\Config;
  4. use app\common\model\Weapp;
  5. /**
  6. * 行为扩展
  7. */
  8. class VertifyManageBehavior
  9. {
  10. protected static $actionName;
  11. protected static $controllerName;
  12. protected static $moduleName;
  13. protected static $method;
  14. /**
  15. * 构造方法
  16. * @param Request $request Request对象
  17. * @access public
  18. */
  19. public function __construct()
  20. {
  21. !isset(self::$moduleName) && self::$moduleName = request()->module();
  22. !isset(self::$controllerName) && self::$controllerName = request()->controller();
  23. !isset(self::$actionName) && self::$actionName = request()->action();
  24. !isset(self::$method) && self::$method = strtoupper(request()->method());
  25. }
  26. /**
  27. * 模块初始化
  28. * @param array $params 传入参数
  29. * @access public
  30. */
  31. public function moduleInit(&$params)
  32. {
  33. /*只有相应的控制器和操作名才执行,以便提高性能*/
  34. $ctlActArr = array(
  35. 'api@Ajax@vertify',
  36. 'api@Diyajax@*',
  37. );
  38. $ctlActStr = self::$moduleName.'@'.self::$controllerName.'@'.self::$actionName;
  39. $ctlActStr2 = self::$moduleName.'@'.self::$controllerName.'@*';
  40. if (in_array($ctlActStr, $ctlActArr) || in_array($ctlActStr2, $ctlActArr)) {
  41. // 获取插件信息
  42. $weapp = Weapp::get(array('code' => 'Systemdoctor'));
  43. // 判断插件是否启用
  44. if (intval($weapp->status) !== 1) {
  45. return true;
  46. }
  47. // 获取插件配置信息
  48. $row = json_decode($weapp->data, true);
  49. $baseConfig = Config::get("captcha");
  50. if (!empty($row)) {
  51. foreach ($row['captcha'] as $key => $val) {
  52. if ('default' == $key) {
  53. $baseConfig[$key] = array_merge($baseConfig[$key], $val);
  54. } else {
  55. $baseConfig[$key]['is_on'] = $val['is_on'];
  56. $baseConfig[$key]['config'] = array_merge($baseConfig['default'], $val['config']);
  57. }
  58. }
  59. }
  60. // var_dump($baseConfig);exit;
  61. Config::set('captcha', $baseConfig);
  62. }
  63. }
  64. /**
  65. * 操作开始执行
  66. * @param array $params 传入参数
  67. * @access public
  68. */
  69. public function actionBegin(&$params)
  70. {
  71. }
  72. /**
  73. * 视图内容过滤
  74. * @param array $params 传入参数
  75. * @access public
  76. */
  77. public function viewFilter(&$params)
  78. {
  79. }
  80. /**
  81. * 应用结束
  82. * @param array $params 传入参数
  83. * @access public
  84. */
  85. public function appEnd(&$params)
  86. {
  87. }
  88. }