本文整理汇总了PHP中Safe::checkTry方法的典型用法代码示例。如果您正苦于以下问题:PHP Safe::checkTry方法的具体用法?PHP Safe::checkTry怎么用?PHP Safe::checkTry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Safe
的用法示例。
在下文中一共展示了Safe::checkTry方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: POST_emailAction
/**
* 通过邮箱找回密码
* @method POST_emailAction
* @author NewFuture
*/
public function POST_emailAction()
{
$response['status'] = 0;
if (!Input::post('email', $email, 'email')) {
$response['info'] = '邮箱格式有误或者不支持!';
} elseif (!Input::post('number', $number, 'card')) {
$response['info'] = '学号格式有误!';
} elseif (!Safe::checkTry('pwd_email_' . $number)) {
$response['info'] = '尝试次数过多,临时封禁!';
} elseif (!($user = UserModel::where('number', $number)->field('id,name,email')->find())) {
$response['info'] = '尚未注册,或者学号错误';
} elseif (empty($user['email'])) {
$response['info'] = '未绑定邮箱,或者学号错误';
} elseif (Encrypt::decryptEmail($user['email']) != $email) {
$response['info'] = '绑定邮箱不一致,或者邮箱错误';
} elseif (!Mail::findPwd($email, $code = Random::code(6), $user['name'])) {
$response['info'] = '邮件发送出错,请联系我们!';
} else {
/*发送成功*/
$findPwd = ['id' => $user['id'], 'number' => $number, 'code' => strtoupper($code)];
Session::set('find_info', $findPwd);
Safe::del('pwd_email_' . $number);
$response['status'] = 1;
$response['info'] = '找回验证码已发送到' . $email;
}
$this->response = $response;
}
示例2: POST_emailAction
/**
* 通过邮箱找回密码
* @method POST_emailAction
* @author NewFuture
*/
public function POST_emailAction()
{
$response['status'] = 0;
if (!Input::post('email', $email, 'email')) {
$response['info'] = '邮箱格式有误或者不支持!';
} elseif (!Input::post('account', $account, Config::get('regex.account'))) {
$response['info'] = '学号格式有误!';
} elseif (!Safe::checkTry('pwd_email_' . $account)) {
$response['info'] = '尝试次数过多,临时封禁!';
} elseif (!($Printer = PrinterModel::where('account', $account)->field('id,email')->find())) {
$response['info'] = '尚未注册,或者账号错误';
} elseif (empty($Printer['email'])) {
$response['info'] = '未绑定邮箱,或邮箱不存在';
} elseif ($Printer['email'] != $email) {
$response['info'] = '绑定邮箱不一致,或者邮箱错误';
} elseif (!Mail::findPwd($email, $code = Random::code(6))) {
$response['info'] = '邮件发送出错,请联系我们!';
} else {
/*发送成功*/
$find = ['id' => $user['id'], 'account' => $account, 'code' => strtoupper($code)];
Session::set('find_info_p', $find);
Safe::del('pwd_email_' . $account);
$response['status'] = 1;
$response['info'] = '验证邮件已发送!';
}
$this->response = $response;
}
示例3: indexAction
/**
* 登录注册验证
* @method indexAction
* @return [type] [description]
* @author NewFuture
*/
public function indexAction()
{
if (Input::post('number', $number, 'card') && Input::post('password', $password, 'trim')) {
Input::post('sch_id', $sch_id, 'int');
$safekey = $sch_id . 'auth_' . $number;
if (!Safe::checkTry($safekey, 5)) {
$this->response(0, '尝试次过度,账号临时封禁');
} elseif (Input::post('code', $code, 'ctype_alnum')) {
/*输入验证码直接验证*/
if ($this->verify($number, $password, $sch_id, $code)) {
/*验证通过*/
Safe::del($safekey);
} else {
$this->response(-1, '学校账号验证失败,请检查密码是否正确,您也可尝试登录该系统!');
}
} elseif ($result = $this->login($number, md5($password), $sch_id)) {
/*登录成功*/
Safe::del($safekey);
} elseif ($sch_id && false === $result) {
/*指定学校后登录失败*/
$this->response(-1, '登录失败!请检查学号和密码是否正确,或者找回密码!');
} elseif ($this->verify($number, $password, $sch_id)) {
/*验证成功*/
Safe::del($safekey);
} else {
/*注册验证失败*/
$this->response(-1, '验证出错,请检查学号或者密码是否正确!');
}
} else {
$this->response(-1, '学号或者密码无效!');
}
}
示例4: POST_indexAction
/**
* 打印店登录
* @method loginAction
* @return [type] [description]
* @author NewFuture
*/
public function POST_indexAction()
{
$response['status'] = 0;
if (!Input::post('account', $account, Config::get('regex.account'))) {
$response['info'] = '账号格式错误';
} elseif (!Input::post('password', $password, 'isMd5')) {
$response['info'] = '密码未加密处理';
} elseif (!Safe::checkTry('printer_auth_' . $account)) {
$response['info'] = '尝试次数过多账号临时封禁,稍后重试或者联系我们';
} elseif (!($Printer = PrinterModel::where('account', $account)->field('id,sch_id,password,status,name')->find())) {
$response['info'] = '账号错误';
} elseif (Encrypt::encryptPwd($password, $account) != $Printer['password']) {
$response['info'] = '密码错误';
} else {
Safe::del('printer_auth_' . $account);
unset($Printer['password']);
$sid = Session::start();
Session::set('printer', ['id' => $Printer['id'], 'sch_id' => $Printer['sch_id']]);
$response['status'] = 1;
$response['info'] = ['sid' => $sid, 'printer' => $Printer];
}
$this->response = $response;
}
示例5: PUT_emailAction
/**
* 修改用户邮箱
* PUT /user/1/phone {code:"C09Eaf"}
* @method GET_infoAction
* @param integer $id [description]
* @author NewFuture
*/
public function PUT_emailAction($id = 0)
{
$id = $this->auth($id);
$response['status'] = 0;
$Code = new Model('code');
if (!Input::put('code', $code, 'ctype_alnum')) {
$response['info'] = '验证码格式不对';
} elseif (!$Code->where('use_id', $id)->where('type', 1)->field('id,time,code,content')->find()) {
$response['info'] = '验证信息不存在';
} elseif (!Safe::checkTry('email_code_' . $id)) {
$Code->delete();
Safe::del('email_code_' . $id);
$response['info'] = '尝试次数过多,请重新验证';
} elseif (strtoupper($code) != strtoupper(substr($Code['code'], -6))) {
$response['info'] = '验证码不匹配';
} elseif (!UserModel::saveEmail($Code['content'], $Code['use_id'])) {
$response['info'] = '邮箱绑定失败';
} else {
$Code->delete();
Safe::del('email_code_' . $id);
$response['info'] = $Code['content'];
$response['status'] = 1;
}
$this->response = $response;
}