|
|
|
@ -13,6 +13,8 @@ use common\models\SendLogT; |
|
|
|
|
use common\models\UserLogT; |
|
|
|
|
use common\models\UserT; |
|
|
|
|
use Yii; |
|
|
|
|
use yii\captcha\Captcha; |
|
|
|
|
use yii\captcha\CaptchaAction; |
|
|
|
|
use yii\db\Exception; |
|
|
|
|
use yii\web\Response; |
|
|
|
|
use yii\web\UploadedFile; |
|
|
|
@ -845,6 +847,18 @@ class ApiController extends \yii\web\Controller |
|
|
|
|
header("Access-Control-Allow-Headers: Content-Type, X-Requested-With, Cache-Control,Authorization,Beeba-Sign,Beeba-Timestamp"); |
|
|
|
|
Yii::$app->response->format = Response::FORMAT_JSON; |
|
|
|
|
$params = Yii::$app->request->post(); |
|
|
|
|
$cache = Yii::$app->cache; |
|
|
|
|
$now = time(); |
|
|
|
|
$last_visited_name = 'hy_last_visit_ip_' . Yii::$app->request->getUserIP(); |
|
|
|
|
$last_visited_time = $cache->get($last_visited_name); |
|
|
|
|
if ($last_visited_time && $now - $last_visited_time < 90) { |
|
|
|
|
$result['success'] = false; |
|
|
|
|
$result['msg'] = '接口调用过于频繁'; |
|
|
|
|
$result['data'] = $now - $last_visited_time; |
|
|
|
|
return $result; |
|
|
|
|
} else { |
|
|
|
|
$cache->set($last_visited_name, $now); |
|
|
|
|
} |
|
|
|
|
if (!isset($params['mobile']) || $params['mobile'] == '') { |
|
|
|
|
$result['success'] = false; |
|
|
|
|
$result['msg'] = '手机号无效'; |
|
|
|
@ -888,7 +902,7 @@ class ApiController extends \yii\web\Controller |
|
|
|
|
$user = UserT::findOne(['name' => $name, 'phone' => $mobile]); |
|
|
|
|
if($name == '' || !preg_match('/^1[345789]\d{9}$/', $mobile)){ |
|
|
|
|
$result['code'] = -1; |
|
|
|
|
$result['msg'] = '参数错误:'.'手机'.$mobile.'-'.(!preg_match('/^1[345789]\d{9}$/', $mobile)).'name'.$name.'--'.($name == ''); |
|
|
|
|
$result['msg'] = '参数错误'; |
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
|
if($code == '' || Yii::$app->session->get('hy_vcode_'.$mobile) != $code){ |
|
|
|
|