York 3 лет назад
Родитель
Сommit
e6d982c21b
1 измененных файлов с 54 добавлено и 52 удалено
  1. 54 52
      common/components/Controller.php

+ 54 - 52
common/components/Controller.php

@@ -1,53 +1,55 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: Leo
- * Date: 2017/9/3
- * Time: 下午3:05
- */
-
-namespace common\components;
-
-
-use common\helpers\Tool;
-use yii\base\ActionEvent;
-use yii\helpers\Json;
-use yii\helpers\Url;
-
-class Controller extends \yii\web\Controller {
-
-    /**
-     * @return array
-     */
-    public function actions() {
-        return [
-            'captcha' =>  [
-                'class' => 'common\helpers\CaptchaAction',
-                'width' => 120,
-                'height' => 40,
-                'padding' => 0,
-                'minLength' => 4,
-                'maxLength' => 4,
-                'offset'=>8,        //设置字符偏移量 有效果
-                'testLimit'=>1,
-            ],
-        ];
-    }
-
-    /**
-     * 不允许直接访问ajax页面
-     * @param $action
-     * @return bool
-     * @throws \yii\web\BadRequestHttpException
-     */
-    protected function checkAjax(&$action){
-        $currentAction = $action->id;
-        if(strpos($currentAction ,'ajax-')===0){
-            if(!\Yii::$app->request->getIsAjax()){
-                throw new \yii\web\BadRequestHttpException('无法完成您的请求');
-            }
-        }
-        return true;
-    }
-
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Leo
+ * Date: 2017/9/3
+ * Time: 下午3:05
+ */
+
+namespace common\components;
+
+
+use common\helpers\Tool;
+use yii\base\ActionEvent;
+use yii\helpers\Json;
+use yii\helpers\Url;
+
+class Controller extends \yii\web\Controller {
+
+    /**
+     * @return array
+     */
+    public function actions() {
+        return [
+            'captcha' =>  [
+                'class' => 'common\helpers\CaptchaAction',
+                'backColor' => 0x000000,//背景颜色
+                'foreColor' => 0xffffff,     //字体颜色
+                'width' => 120,
+                'height' => 40,
+                'padding' => 0,
+                'minLength' => 4,
+                'maxLength' => 4,
+                'offset'=>8,        //设置字符偏移量 有效果
+                'testLimit'=>1,
+            ],
+        ];
+    }
+
+    /**
+     * 不允许直接访问ajax页面
+     * @param $action
+     * @return bool
+     * @throws \yii\web\BadRequestHttpException
+     */
+    protected function checkAjax(&$action){
+        $currentAction = $action->id;
+        if(strpos($currentAction ,'ajax-')===0){
+            if(!\Yii::$app->request->getIsAjax()){
+                throw new \yii\web\BadRequestHttpException('无法完成您的请求');
+            }
+        }
+        return true;
+    }
+
 }