本文整理汇总了PHP中Validate::email方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::email方法的具体用法?PHP Validate::email怎么用?PHP Validate::email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::email方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate()
{
Debug::show(Validate::email('demo@demo.com'));
Debug::show(Validate::email('demo'));
Debug::show(Validate::mobilephone('15555555555'));
Debug::show(Validate::mobilephone('1555555555'));
}
示例2: validate
function validate($values)
{
$return = true;
$validate = new Validate();
if (!$validate->string($values['navn'], array('min_length' => 1))) {
$return = false;
}
if (!$validate->string($values['adresse'], array('min_length' => 1))) {
$return = false;
}
if (!$validate->number($values['postnr'], array('min' => 100))) {
$return = false;
}
if (!$validate->string($values['postby'], array('min_length' => 1))) {
$return = false;
}
if (!empty($values['email']) and !$validate->email($values['email'])) {
$return = false;
}
/*
if (isset($values['langekurser']) != "" && $values['langekurser'] != "1") $return = false;
if (isset($values['kortekurser']) != "" && $values['kortekurser'] != "1") $return = false;
if (isset($values['efterskole']) != "" && $values['efterskole'] != "1") $return = false;
if (isset($values['kursuscenter']) != "" && $values['kursuscenter'] != "1") $return = false;
*/
return $return;
}
示例3: prepare
/**
* Check for an API key, and throw an exception if it's not set
*
* @param array $args URL and POST params
*
* @return boolean continuation flag
*/
function prepare($args)
{
GNUsocial::setApi(true);
// reduce exception reports to aid in debugging
parent::prepare($args);
if (!common_config('globalapi', 'enabled')) {
throw new ClientException(_('Global API not enabled.'), 403);
}
$apikey = $this->trimmed('apikey');
if (empty($apikey)) {
throw new ClientException(_('No API key.'), 403);
}
$expected = common_config('globalapi', 'key');
if ($expected != $apikey) {
// FIXME: increment a counter by IP address to prevent brute-force
// attacks on the key.
throw new ClientException(_('Bad API key.'), 403);
}
$email = common_canonical_email($this->trimmed('email'));
if (empty($email)) {
throw new ClientException(_('No email address.'));
}
if (!Validate::email($email, common_config('email', 'check_domain'))) {
throw new ClientException(_('Invalid email address.'));
}
$this->email = $email;
return true;
}
示例4: __default
public function __default()
{
if (count($_POST)) {
$errors = array();
if (Validate::email($_POST['email'])) {
$sql = "SELECT *\n FROM fr_users\n WHERE email='" . $_POST['email'] . "'";
$user = $this->db->getRow($sql);
if (!PEAR::isError($result) && is_array($user)) {
if ($user['status'] == 'active') {
if ($user['password'] == $_POST['password']) {
if (isset($_GET['pg'])) {
$go = urldecode($_GET['pg']);
} elseif (isset($_POST['pg'])) {
$go = urldecode($_POST['pg']);
} else {
$go = '/';
}
$this->session->userID = $user['userID'];
header("Location: {$go}");
exit;
} else {
$errors[] = 'Your password is invalid';
}
} else {
$errors[] = 'Your account has been disabled';
}
} else {
$errors[] = 'Email does not exist in database';
}
$this->set('errors', $errors);
}
}
}
示例5: action_index
public function action_index()
{
if ($_POST) {
$message = html::chars((string) arr::get($_POST, 'message', ''));
if ($message) {
// Append user information
if ($user = $this->auth->get_user()) {
$message .= '<h2>Användarinfo</h2>';
$message .= '<dl>';
foreach (array('id', 'username', 'email') as $field) {
$message .= sprintf('<dt>%s</dt><dd>%s</dd>', $field, html::chars($user->{$field}));
}
$message .= '</dl>';
}
$from = arr::extract($_POST, array('e-mail', 'name'));
if (!Validate::email($from['e-mail'])) {
$from['name'] .= " ({$from['e-mail']})";
$from['e-mail'] = 'svara-inte@anglarna.se';
}
$sent = Email::send('stockholm@anglarna.se', array($from['e-mail'], $from['name']), '[Änglarna Stockholm] Meddelande från kontaktsidan', $message, TRUE);
if ($sent >= 1) {
$this->message_add('Ditt meddelande har skickats till ' . html::mailto('stockholm@anglarna.se') . '!');
} else {
$this->message_add('Något blev fel. Försök igen eller skicka ett vanligt mail till ' . html::mailto('stockholm@anglarna.se') . ' istället.', 'error');
}
} else {
$this->message_add('Du måste ange ett meddelande.', 'error');
}
$this->request->reload();
}
$this->template->title = 'Kontakta Änglarna Stockholm';
$this->template->content = View::factory('kontakt/index');
}
示例6: postForm
function postForm()
{
if ($this->getForm()->validate()) {
$bestilling = new VIH_Model_MaterialeBestilling();
if (!$bestilling->save($this->body())) {
throw new Exception('Det gik ikke ret godt. Vores webmaster skammer sig sikkert.');
}
if (defined('EMAIL_STATUS') && EMAIL_STATUS == 'online') {
if (Validate::email($this->body('email')) and trim($this->body('email')) != '') {
$error = '';
if (!defined('VIH_KONTAKTANSVARLIG_EMAIL') || VIH_KONTAKTANSVARLIG_EMAIL == '') {
throw new Exception('Konstanten VIH_KONTAKTANSVARLIG_EMAIL er ikke sat eller udfyldt');
} elseif (trim($this->body('besked')) != '') {
$body = "Besked sendt i forbindelse med bestilling af materiale:\n\n" . $this->body('besked') . "\n\n Sendt af " . $this->body('navn') . "\n\nSend gerne videre til fagansvarlig lærer.";
$mailer = new VIH_Email();
$mailer->setSubject('Fra hjemmesiden');
$mailer->setFrom($this->body('email'), $this->body('navn'));
$mailer->setBody($body);
// i sommerperioden sendes e-mailen andetsteds hen.
if ((int) $this->body('langekurser') == 1 and (date('Y-m-d') < date('y') . '-06-25' or date('Y-m-d') > date('y') . '-08-01')) {
$mailer->addAddress(VIH_KONTAKTANSVARLIG_EMAIL, VIH_KONTAKTANSVARLIG);
} elseif ((int) $this->body('kursuscenter') == 1) {
$mailer->addAddress('kursuscenter@vih.dk', 'Kursuscenteret');
} else {
$mailer->addAddress('kontor@vih.dk', 'Vejle Idrætshøjskole');
}
if (!$mailer->send()) {
throw new Exception("Der er opstået en fejl i email-senderen i forbindelse bestilling af materiale. E-mail til VIH_KONTAKTANSVARLIG er ikke sendt. Det drejer sig om en forespørgsel fra " . $this->body('navn'));
}
}
if (trim($this->body('email')) != '') {
$body = "Kære " . $this->body('navn') . "\n\nVi har modtaget din bestilling af materiale, og vi sender det så hurtigt som muligt.\n\nHvis du har nogen spørgsmål, er du meget velkommen til at ringe til os på 7582 0811.\n\nMed venlig hilsen\nVejle Idrætshøjskole";
$mailer = new VIH_Email();
$mailer->setSubject("Bestilling af materiale fra VIH");
$mailer->addAddress($this->body('email'), $this->body('navn'));
$mailer->setBody($body);
if (!$mailer->send()) {
throw new Exception("Der er opstået en fejl i email-senderen i forbindelse bestilling af materiale. Der er ikke sendt en bekræftelse til " . $this->body('navn'));
$error = "<p>Det var ikke muligt at sende dig en bekræftelse på din bestilling, men bare rolig vi har modtaget den, og sender hurtigst muligt materialet. Imens hænger vi webmasteren op i flagstangen, indtil han siger undskyld.";
}
}
}
}
$data = array('content' => '<h1>Tak for din bestilling</h1>
<p>Vi vil skynde os at pakke noget materiale til dig, og vi sender det så hurtigt som muligt. Du skulle gerne have det i løbet af 2-3 arbejdsdage alt efter hvor hurtigt postvæsenet arbejder.</p>
<h2>Nyhedsbrev</h2>
<p>Hvis det har nogen interesse, kan du <a href="' . $this->url('/nyhedsbrev/') . '">tilmelde dig vores nyhedsbrev</a>.</p>
' . $error);
$tpl = $this->template->create('wrapper');
return $tpl->render($this, $data);
} else {
$form = $this->getForm();
$tpl = $this->template->create('Materialebestilling/index');
$content = $tpl->render($this, array('text' => 'Der var fejl i formularen.', 'form' => $this->getRenderer()->toHtml()));
$data = array('content' => $content, 'content_sub' => $this->getSubContent());
$tpl = $this->template->create('sidebar-wrapper');
return $tpl->render($this, $data);
}
}
示例7: to
/**
* Set the To Address.
*
* Validates and sets who the email should be sent to.
*
* @param string $email
* @return bool
*/
public function to($email)
{
if (Validate::email($email)) {
$this->to = $email;
return true;
}
return false;
}
示例8: unique_key
/**
* Get unique key based on value
* @param mixed $value Kay value for match
* @return string Unique key name to attempt to match against
*/
public function unique_key($value)
{
if (Validate::email($value)) {
return 'email';
} elseif (is_string($value)) {
return 'username';
}
return 'id';
}
示例9: testEmail
public function testEmail()
{
$this->assertTrue(Validate::email('ax@jentian.com'));
$this->assertTrue(Validate::email('ax@jentian.com.cn'));
$this->assertTrue(Validate::email('123_ax@jentian.com.cn'));
$this->assertTrue(Validate::email('t123@163.cn'));
$this->assertFalse(Validate::email('t123@163.cn.'));
$this->assertFalse(Validate::email('@163.cn'));
$this->assertFalse(Validate::email('t123@163'));
}
示例10: execute
public function execute()
{
$this->checkDefaultApp($this->aid);
if (isset($this->email) && !Validate::email($this->email)) {
throw new OpenFBAPIException('Email address "' . $this->email . '" not valid.');
}
if (isset($this->phone) && !Validate_US::phoneNumber($this->phone)) {
throw new OpenFBAPIException('Phone number "' . $this->phone . '" not valid.');
}
$result = Api_Bo_Subscriptions::createAppSubscription($this->uid, $this->nid, $this->aid, $this->planid, $this->ccn, $this->cctype, $this->expdate, $this->firstname, $this->lastname, $this->email, $this->phone);
return $result;
}
示例11: prepare
protected function prepare(array $args = array())
{
parent::prepare($args);
$this->email = $this->trimmed('email');
if (!Validate::email($this->email, common_config('email', 'check_domain'))) {
$this->clientError('Not a valid email address.', 400);
}
if (common_config('site', 'private')) {
$this->clientError(_('This site is private.'), 403);
}
return true;
}
示例12: login
/**
* Validates login information from an array, and optionally redirects
* after a successful login.
*
* @param array values to check
* @param string URI or URL to redirect to
* @return boolean
*/
public function login(array &$array, $redirect = FALSE)
{
// This is what core Auth does to allow both email and username logins
$fieldname = Validate::email($array['username']) ? 'email' : 'username';
$array = Validate::factory($array)->label('username', $this->_labels[$fieldname])->label('password', $this->_labels['password'])->filter(TRUE, 'trim')->rules('username', $this->_rules[$fieldname])->rules('password', $this->_rules['password']);
// Login starts out invalid
$status = FALSE;
if ($array->check()) {
// Attempt to load the user
$this->where($fieldname, '=', $array['username'])->find();
/* Note: failed_login_count and last_failed_login do not exist in the default schema, so it is disabled here. failed_login_count is a int field, and last_failed_login is a datetime field.
*
// if there are too many recent failed logins, fail now
if (($this->failed_login_count > 5) && (strtotime($this->last_failed_login) > strtotime("-5 minutes") )) {
// do nothing, and fail (too many failed logins within 5 minutes).
return FALSE;
}
*/
// if you want to allow 5 logins again after 5 minutes, then set the failed login count to zero here, if it is too high.
if ($this->loaded() and Auth::instance()->login($this, $array['password'])) {
// Login is successful
$status = TRUE;
// set the number of failed logins to 0
// $this->failed_login_count = 0;
if (is_numeric($this->id) && $this->id != 0) {
// only save if the user already exists
$this->save();
}
if (is_string($redirect)) {
// Redirect after a successful login
Request::instance()->redirect($redirect);
}
} else {
/*
// login failed: update failed login count
$this->failed_login_count = $this->failed_login_count+1;
$this->last_failed_login = date('Y-m-d H:i:s');
if(is_numeric($this->id) && ($this->id != 0) ) {
// only save if the user already exists
$this->save();
}
*/
// set error status
$array->error('username', 'invalid');
}
}
return $status;
}
示例13: isValid
function isValid()
{
if (strlen($this->value)) {
if (Validate::email($this->value)) {
return true;
}
$this->errors[] = 'Email ' . $this->value . ' appears to be invalid!';
return false;
} else {
if ($this->required) {
$this->errors[] = 'Email is a required field!';
return false;
}
}
return true;
}
示例14: action_signin
public function action_signin()
{
if (!empty($_POST['usermail']) and Validate::email($_POST['usermail'])) {
$user = array('uid' => $_SERVER['REQUEST_TIME'], 'mail' => $_POST['usermail']);
Cookie::set('user', json_encode($user));
Session::instance()->set('user', $user);
$this->request->redirect('server/index');
} elseif ($user = Cookie::get('user')) {
Session::instance()->set('user', json_decode($user, TRUE));
$this->request->redirect('server/index');
}
$template = new View('oauth');
$view = new View('oauth-server-signin');
$template->content = $view->render();
$this->request->response = $template;
}
示例15: addRegUser
/**
* add new regular user
* @param string $email user email.
* @param string $firstname user first name.
* @param string $lastname user lasname.
* @param string $password user password.
* @return array success
*/
public function addRegUser($email, $firstname, $lastname, $password)
{
if (Validate::email($email) && Validate::password($password)) {
$arr = $this->escapeString(array($email, $firstname, $lastname, $password));
$e = $arr[0];
$f = $arr[1];
$l = $arr[2];
$p = md5($arr[3]);
$query = "INSERT INTO users (`user_email`, `user_password`, `user_firstname`, `user_lastname`) \n\t\t\t\t\t\tVALUES ('{$e}', '{$p}', '{$f}', '{$l}')";
if ($this->_db->query($query)) {
return $this->loginReg($email, $password);
}
$this->_db->close();
apiConf::$ERROR = 'facebook registration failed';
}
apiConf::$ERROR = 'validation failed';
}