本文整理汇总了PHP中validate::email方法的典型用法代码示例。如果您正苦于以下问题:PHP validate::email方法的具体用法?PHP validate::email怎么用?PHP validate::email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validate
的用法示例。
在下文中一共展示了validate::email方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: signup
public function signup($username, $password1, $password2, $alias, $email)
{
if (!is_null($this->auth_token)) {
throw new DBException('already logged in');
}
$username = $this->db->safe($username);
$password1 = $this->db->safe($password1);
$password2 = $this->db->safe($password2);
$alias = $this->db->safe($alias);
$email = $this->db->safe($email);
$sql = sprintf("SELECT username FROM users WHERE username='%s'", $username);
if ($this->db->exists($sql)) {
throw new DBException('username already exists');
}
if (!$this->valid_alias($alias)) {
throw new DBException('invalid characters in alias');
}
if ($password1 != $password2) {
throw new DBException('passwords do not match');
}
if (!validate::email($email)) {
throw new DBException('invalid email');
}
$salt = sha1($username);
$password_hash = sha1($password1 . $salt);
$email_hash = md5($email);
$sql = sprintf("INSERT INTO users (username,alias,email,email_hash,\n\t\t\t\t\t\tpassword,salt,joindate) VALUES ('%s','%s','%s','%s',\n\t\t\t\t\t\t'%s','%s',UNIX_TIMESTAMP())", $username, $alias, $email, $email_hash, $password_hash, $salt);
$this->db->autocommit(FALSE);
if (!($uid = $this->db->insert($sql))) {
throw new DBException('failed query when adding user' . $sql);
}
if (!($nsid = $this->ns->add($alias, True))) {
debug_hook('failed to add user namespace');
throw new DBException('failed to add user namespace');
}
if (!$this->ns->acl_add($nsid, $uid, ACL_READ | ACL_WRITE | ACL_ADMIN)) {
debug_hook('failed to add namespace privileges');
debug_hook('error: ' . $this->db->error . $this->db->errno);
throw new DBException('failed to set user namespace permissions');
}
if (!$this->ns->acl_add(DB_PUBNS, $uid, ACL_READ | ACL_WRITE)) {
debug_hook('failed to add user to public namespace');
throw new DBException('failed to set global namespace permissions');
}
$this->db->commit();
$this->login($username, $password1);
}
示例2: unique_key
/**
* Allows a model to be loaded by username or email address.
*/
public function unique_key($id)
{
if (!empty($id) and is_string($id) and !ctype_digit($id)) {
return validate::email($id) ? 'email' : 'username';
}
return parent::unique_key($id);
}
示例3: unique_key
/**
* Allows a model to be loaded by username or email address.
*/
public function unique_key($id)
{
if (!empty($id) and is_string($id) and !ctype_digit($id)) {
return validate::email($id) ? 'email' : 'username';
}
return $this->_primary_key;
}