最新服务器上的版本,以后用这个
zhangmeng
2023-04-19 e3f5aa12f58d986098a9de0f5cb38060e403036d
commit | author | age
2207d6 1 <?php
W 2 /**
3  * Created by PhpStorm
4  * User: 风哀伤
5  * Date: 2020/10/20
6  * Time: 10:15 上午
7  * @copyright: ©2020 浙江禾匠信息科技
8  * @link: http://www.zjhejiang.com
9  */
10
11 namespace app\forms;
12
13 use Yii;
14 use yii\captcha\CaptchaAction;
15 use yii\helpers\Url;
16 use yii\web\Response;
17
18 class BdCaptchaAction extends CaptchaAction
19 {
20     public function run()
21     {
22         if (Yii::$app->request->getQueryParam(self::REFRESH_GET_VAR) !== null) {
23             // AJAX request for regenerating code
24             $code = $this->getVerifyCode(true);
25             Yii::$app->response->format = Response::FORMAT_JSON;
26             return [
27                 'hash1' => $this->generateValidationHash($code),
28                 'hash2' => $this->generateValidationHash(strtolower($code)),
29                 // we add a random 'v' parameter so that FireFox can refresh the image
30                 // when src attribute of image tag is changed
31                 'url' => Url::to([$this->id, 'v' => uniqid('', true)], true),
32             ];
33         }
34
35         $this->setHttpHeaders();
36         Yii::$app->response->format = Response::FORMAT_RAW;
37
38         return $this->renderImage($this->getVerifyCode());
39     }
40 }