Ei kuvausta
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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace weapp\Systemdoctor\behavior\admin;
  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. 'Admin@login',
  36. 'Admin@vertify',
  37. );
  38. $ctlActStr = self::$controllerName.'@'.self::$actionName;
  39. if (in_array($ctlActStr, $ctlActArr)) {
  40. // 获取插件信息
  41. $weapp = Weapp::get(array('code' => 'Systemdoctor'));
  42. // 判断插件是否启用
  43. if (intval($weapp->status) !== 1) {
  44. return true;
  45. }
  46. // 获取插件配置信息
  47. $row = json_decode($weapp->data, true);
  48. $baseConfig = Config::get("captcha");
  49. if (!empty($row)) {
  50. foreach ($row['captcha'] as $key => $val) {
  51. if ('default' == $key) {
  52. $baseConfig[$key] = array_merge($baseConfig[$key], $val);
  53. } else {
  54. $baseConfig[$key]['is_on'] = $val['is_on'];
  55. $baseConfig[$key]['config'] = array_merge($baseConfig['default'], $val['config']);
  56. }
  57. }
  58. }
  59. // var_dump($baseConfig);exit;
  60. Config::set('captcha', $baseConfig);
  61. }
  62. }
  63. /**
  64. * 操作开始执行
  65. * @param array $params 传入参数
  66. * @access public
  67. */
  68. public function actionBegin(&$params)
  69. {
  70. }
  71. /**
  72. * 视图内容过滤
  73. * @param array $params 传入参数
  74. * @access public
  75. */
  76. public function viewFilter(&$params)
  77. {
  78. }
  79. /**
  80. * 应用结束
  81. * @param array $params 传入参数
  82. * @access public
  83. */
  84. public function appEnd(&$params)
  85. {
  86. }
  87. }