/** * Validates a email value. * * @param string $value The value to validate. * * @return bool|string Returns boolean TRUE upon successfull validation, and an error message string upon failure. */ public function validate(&$value) { $return = parent::validate($value); if ($return !== true) { return $return; } if (isset($value) && strlen(trim($value)) > 0) { $valid = is::email($value, get::array_def($this->attributes, 'multiple', false) == 'multiple'); if (!is_object($valid) || !($valid instanceof emailAddressList || $valid instanceof emailAddress)) { $msglbl = get::array_def($this->attributes, 'msglbl', get::array_def($this->attributes, 'name', $this->getId())); return sprintf('"%s" has an invalid email address.', $msglbl); } $value = $valid; } return true; }
private function getEmailAddressArray(array $addr, $emailOnly = false) { if (!(isset($addr[1]) && is::email($addr[1], false) || isset($addr['email']) && is::email($addr['email'], false))) { return false; } $name = isset($addr[0]) ? $addr[0] : (isset($addr['name']) ? $addr['name'] : null); $eml = isset($addr[1]) ? $addr[1] : (isset($addr['email']) ? $addr['email'] : null); if (isset($name) && !$emailOnly) { return sprintf('"%s" <%s>', str_replace('"', '', $name), $eml); } return $eml; }
public function forgot() { $email = $this->request->post('email'); $type = $this->request->post('type'); if (empty($email) || empty($type)) { return false; } switch ($type) { case 'email': if (!is::email($email)) { return false; } $sql = 'SELECT id,code FROM UserLogin WHERE email=:id'; break; case 'phone': if (!is::phone($email)) { return false; } $sql = 'SELECT id,code FROM UserLogin WHERE phone=:id'; break; default: return false; } }