本文整理匯總了PHP中Regex::match方法的典型用法代碼示例。如果您正苦於以下問題:PHP Regex::match方法的具體用法?PHP Regex::match怎麽用?PHP Regex::match使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Regex
的用法示例。
在下文中一共展示了Regex::match方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ajaxSendEmailAction
public function ajaxSendEmailAction()
{
$email = Request::getPOST('email');
$verify = Request::getPOST('verify');
if (empty($verify)) {
$this->renderAjax(1, '請輸入圖片驗證碼!');
}
if (empty($email)) {
$this->renderAjax(1, '請填寫郵箱!');
}
// 校驗驗證碼
$imgCode = Session::get('check_code');
if (strtolower($verify) != $imgCode) {
$this->renderAjax(2, '圖片驗證碼錯誤!');
}
if (!Regex::match($email, RegexVars::EMAIL)) {
$this->renderAjax(1, '郵箱格式錯誤!');
}
// 是否存在
$userInfo = UcUserInterface::getByLoginName(array('login_name' => $email));
if (empty($userInfo)) {
$this->renderAjax(1, '用戶郵箱不存在!');
}
$code = UcAuthInterface::sendEmailCode(array('email' => $email, 'repeat_at' => time() + 60));
if (false === $code) {
$this->renderAjax(1, '服務器繁忙,請1分鍾後重試!');
}
$this->renderAjax(0);
}
示例2: ajaxSubmitAction
public function ajaxSubmitAction()
{
$username = Request::getPOST('username');
$password = Request::getPOST('password');
$verify = Request::getPOST('verify');
if (!Regex::match($username, RegexVars::USERNAME)) {
$this->renderAjax(1, '用戶名格式不正確!');
}
// 校驗密碼格式
if (!Regex::match($password, RegexVars::PASSWORD)) {
$this->renderAjax(1, '密碼長度為6-20位!');
}
// 校驗驗證碼
$code = Session::get('check_code');
if (strtolower($verify) != $code) {
$this->renderAjax(1, '驗證碼錯誤,請重試!');
}
// 過濾用戶名
if (false !== strpos(strtolower($username), 'admin')) {
$this->renderAjax(1, '用戶已經存在!');
}
// 校驗用戶是否存在
$userInfo = UcUserInterface::getByLoginName(array('login_name' => $username));
if (!empty($userInfo)) {
$this->renderAjax(1, '用戶名已經被占用!');
}
// 保存
$data = array('username' => $username, 'password' => $password, 'reg_ip' => Http::getClientIp());
UcUserInterface::save($data);
$this->renderAjax(0);
}
示例3: getController
private static function getController($location)
{
$location = strtolower($location);
$pattern = '/controller/';
$match = Regex::match($pattern, $location);
if ($match > 0) {
$location = Regex::replace($pattern, '', $location);
}
return $location;
}
示例4: ajaxUpdatePasswordAction
public function ajaxUpdatePasswordAction()
{
// 獲取參數
$oldPassword = Request::getPOST('old-password');
$password = trim(Request::getPOST('password'));
if (!Regex::match($password, RegexVars::PASSWORD)) {
$this->renderError('新密碼限製為6-20位!');
}
$encryptPassword = UserCommonInterface::encryptPassword(array('password' => $oldPassword));
if ($encryptPassword != $this->loginUserInfo['password']) {
$this->renderError('舊密碼不正確!');
}
$data = array('id' => $this->loginUserInfo['id'], 'password' => $password);
UserCommonInterface::save($data);
UserCommonInterface::logout();
$this->renderAjax(0);
}
示例5: ajaxSendEmailAction
public function ajaxSendEmailAction()
{
$email = Request::getPOST('email');
if (empty($email)) {
$this->renderError('請填寫郵箱!');
}
if (!Regex::match($email, RegexVars::EMAIL)) {
$this->renderError('郵箱格式錯誤!');
}
// 是否已經被綁定
$userInfo = UserCommonInterface::getByLoginName(array('login_name' => $email));
if (!empty($userInfo)) {
$this->renderError('該郵箱已經被綁定!');
}
$code = AuthCommonInterface::sendEmailCode(array('email' => $email, 'repeat_at' => time() + 60));
if (false === $code) {
$this->renderError('服務器繁忙,請1分鍾後重試!');
}
$this->renderAjax(0);
}