|
@@ -5,8 +5,11 @@ namespace api\modules\v1\controllers;
|
|
|
|
|
|
|
|
|
|
use api\common\controllers\Controller;
|
|
use api\common\controllers\Controller;
|
|
|
|
+use common\helpers\CodeImgGenerate;
|
|
|
|
+use common\helpers\Util;
|
|
use common\modules\config\models\Config;
|
|
use common\modules\config\models\Config;
|
|
use common\models\Survey;
|
|
use common\models\Survey;
|
|
|
|
+use Yii;
|
|
use yii\helpers\ArrayHelper;
|
|
use yii\helpers\ArrayHelper;
|
|
use api\common\behaviors\QueryParamAuth;
|
|
use api\common\behaviors\QueryParamAuth;
|
|
use yii\captcha\CaptchaAction;
|
|
use yii\captcha\CaptchaAction;
|
|
@@ -29,18 +32,22 @@ class SurveyController extends Controller {
|
|
|
|
|
|
public function actionCaptcha()
|
|
public function actionCaptcha()
|
|
{
|
|
{
|
|
-
|
|
|
|
- $obj = new CaptchaAction(\Yii::$app->controller->id,\Yii::$app->controller);
|
|
|
|
-
|
|
|
|
- $obj->width = 100;
|
|
|
|
- $obj->minLength = 3;
|
|
|
|
- $obj->maxLength = 3;
|
|
|
|
- $obj->offset = 3;
|
|
|
|
- $code = $obj->getVerifyCode(true);
|
|
|
|
- //echo $code;die;
|
|
|
|
- // 生成图片
|
|
|
|
- echo $obj->run();
|
|
|
|
- die;
|
|
|
|
|
|
+// $obj = new CaptchaAction(\Yii::$app->controller->id,\Yii::$app->controller);
|
|
|
|
+//
|
|
|
|
+// $obj->width = 100;
|
|
|
|
+// $obj->minLength = 3;
|
|
|
|
+// $obj->maxLength = 3;
|
|
|
|
+// $obj->offset = 3;
|
|
|
|
+// $code = $obj->getVerifyCode(true);
|
|
|
|
+// //echo $code;die;
|
|
|
|
+// // 生成图片
|
|
|
|
+// echo $obj->run();
|
|
|
|
+// die;
|
|
|
|
+
|
|
|
|
+ $CodeImgGenerate = new CodeImgGenerate(\Yii::$app->controller->id,\Yii::$app->controller);
|
|
|
|
+ $codeInfo = $CodeImgGenerate->inline(); // 验证码二进制流
|
|
|
|
+ header("Content-type: image/png"); // 输出图片
|
|
|
|
+ exit($codeInfo);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -203,14 +210,14 @@ class SurveyController extends Controller {
|
|
if(empty($type)) $type = 'industry';
|
|
if(empty($type)) $type = 'industry';
|
|
|
|
|
|
$survey = Survey::find()->where(['type' => $type])->all();
|
|
$survey = Survey::find()->where(['type' => $type])->all();
|
|
-
|
|
|
|
- $captcha = new CaptchaAction(\Yii::$app->controller->id,\Yii::$app->controller);
|
|
|
|
-
|
|
|
|
- $result = $captcha->validate($data['code'], false);
|
|
|
|
|
|
+
|
|
|
|
+ $captcha = new CodeImgGenerate(\Yii::$app->controller->id,\Yii::$app->controller);
|
|
|
|
+
|
|
|
|
+ $result = $captcha->validate($data['code']);
|
|
|
|
|
|
- // if(!$result){
|
|
|
|
- // return ['errcode' => CodeEnum::CODE_ERROR, 'errmsg' => '验证码错误'];
|
|
|
|
- // }
|
|
|
|
|
|
+ if(!$result){
|
|
|
|
+ return ['errcode' => CodeEnum::CODE_ERROR, 'errmsg' => '验证码错误'];
|
|
|
|
+ }
|
|
|
|
|
|
$list = [];
|
|
$list = [];
|
|
foreach ($survey as $key=>$value) {
|
|
foreach ($survey as $key=>$value) {
|