isEmail() public static method

验证是否是合法的email
public static isEmail ( string $string ) : boolean
$string string 待验证的字串
return boolean 如果是email则返回true,否则返回false
 /**
  * 检查用户是否存在
  *
  * @param  strint $user 用户标识 uid|phone|uname|email
  * @return array
  * @author Medz Seven <*****@*****.**>
  **/
 public function hasUser($user, $isUid = false)
 {
     if ($isUid) {
         $users = Models\User::existent()->audit()->byUid($user)->get();
     } elseif (MedzValidator::isEmail($user)) {
         $users = Models\User::existent()->audit()->byEmail($user)->get();
     } else {
         $users = Models\User::existent()->audit()->where('uid', '=', intval($user))->orWhere('uname', '=', EmojiFormat::en($user))->orWhere('phone', '=', EmojiFormat::en($user))->get();
     }
     return $users;
 }
 /**
  * 使用本地帐号登陆,无密码
  * @param string $login 登录名称,邮箱或用户名
  * @param boolean $is_remember_me 是否记录登录状态,默认为false
  * @return boolean 是否登录成功
  */
 public function loginLocalWithoutPassword($login, $is_remember_me = false)
 {
     $login = addslashes($login);
     if (empty($login)) {
         $this->error = L('PUBLIC_ACCOUNT_NOTEMPTY');
         // 帐号不能为空
         return false;
     }
     // if($this->isValidEmail($login)){
     // 	$map = " (login='******' OR email='{$login}' ) AND is_del=0 ";
     // }else{
     // 	$map = " (login='******' OR uname='{$login}' ) AND is_del=0 ";
     // }
     // # 判断是否是email
     if (MedzValidator::isEmail($login)) {
         $map = '`email` LIKE "' . $login . '" AND `is_del` = 0';
         // # 判断是否是手机号码
     } elseif (MedzValidator::isTelNumber($login)) {
         $map = '`phone` = ' . $login . ' AND `is_del` = 0';
         // # 默认userName方式查询用户
     } else {
         $map = '`uname` LIKE "' . $login . '" AND `is_del` = 0';
     }
     $user = M('User')->where($map)->find();
     if (!$user) {
         $this->error = L('PUBLIC_ACCOUNT_NOEXIST');
         // 帐号不存在
         return false;
     }
     return $user['uid'] > 0 ? $this->_recordLogin($user['uid'], $is_remember_me) : false;
 }
Beispiel #3
0
/**
 * 检查Email地址是否合法
 *
 * @return bool
 */
function isValidEmail($email)
{
    return MedzValidator::isEmail($email);
}