本文整理匯總了PHP中Random::code方法的典型用法代碼示例。如果您正苦於以下問題:PHP Random::code方法的具體用法?PHP Random::code怎麽用?PHP Random::code使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Random
的用法示例。
在下文中一共展示了Random::code方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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('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;
}
示例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('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;
}