email() static public méthode

Checks for valid email address
static public email ( string $email ) : boolean
$email string
Résultat boolean
 /**
  * Extracts the email address from an address string
  *
  * @return string
  */
 protected function extractAddress($string)
 {
     if (v::email($string)) {
         return $string;
     }
     preg_match('/<(.*?)>/i', $string, $array);
     return empty($array[1]) ? $string : $array[1];
 }
 public function sendBookingConfirmation()
 {
     $responseMessages = array();
     $fault = false;
     if (!v::required('email', get())) {
         $responseMessages[] = array('type' => 'error', 'message' => 'No email given, cheating ass bitch!');
         $fault = true;
     } else {
         if (!v::email(get('email'))) {
             $responseMessages[] = array('type' => 'error', 'message' => 'No email given, cheating ass bitch!');
             $fault = true;
         }
     }
     if (!v::required('productSelect', get())) {
         $responseMessages[] = array('type' => 'error', 'message' => 'No product given, cheating ass bitch!');
         $fault = true;
     }
     if (!v::required('date', get())) {
         $responseMessages[] = array('type' => 'error', 'message' => 'No date given, cheating ass bitch!');
         $fault = true;
     } else {
         if (!v::date(get('date'))) {
             $responseMessages[] = array('type' => 'error', 'message' => 'No valid Date, son of a bitch!');
             $fault = true;
         }
     }
     if (!v::required('name', get())) {
         $responseMessages[] = array('type' => 'error', 'message' => 'No name given, cheating ass bitch!');
         $fault = true;
     } else {
         if (!v::min(get('name'), 3)) {
             $responseMessages[] = array('type' => 'error', 'message' => 'At least 3 characters for a name, bitchass!');
             $fault = true;
         }
     }
     if ($fault) {
         s::set('response', $responseMessages);
         go($this->getOriginId());
     }
     $confirmationBody = self::buildMailText($this->getConfirmationText(), get());
     $ownerConfirmation = $confirmationBody . self::createBookingApprovalLink(get('email'), array(), array());
     $from = site()->contactmail()->value();
     // Send To Owner
     $confirmationMail = new Email(array('to' => self::getBookingMail(), 'from' => $from, 'subject' => 'Hey, some new booking', 'body' => $ownerConfirmation));
     // Send to User
     $userConfirmationMail = new Email(array('to' => get('email'), 'from' => $from, 'subject' => 'Hey, some new booking', 'body' => $confirmationBody));
     if ($userConfirmationMail->send() && $confirmationMail->send()) {
         $responseMessages[] = array('type' => 'success', 'message' => 'Successfully send a booking request.');
         s::set('response', $responseMessages);
     } else {
         go('error');
     }
     go($this->getOriginId());
 }
Exemple #3
0
 /** 
  * A set of sanitizer methods
  * 
  * @param  string  $string The string to sanitize
  * @param  string  $type The method
  * @param  string  $default The default value if the string will be empty afterwards
  * @return string  The sanitized string
  */
 static function sanitize($string, $type = 'str', $default = null)
 {
     $string = stripslashes((string) $string);
     $string = urldecode($string);
     $string = str::utf8($string);
     switch ($type) {
         case 'int':
             $string = (int) $string;
             break;
         case 'str':
             $string = (string) $string;
             break;
         case 'array':
             $string = (array) $string;
             break;
         case 'nohtml':
             $string = self::unhtml($string);
             break;
         case 'noxml':
             $string = self::unxml($string);
             break;
         case 'enum':
             $string = in_array($string, array('y', 'n')) ? $string : $default;
             $string = in_array($string, array('y', 'n')) ? $string : 'n';
             break;
         case 'checkbox':
             $string = $string == 'on' ? 'y' : 'n';
             break;
         case 'url':
             $string = v::url($string) ? $string : '';
             break;
         case 'email':
             $string = v::email($string) ? $string : '';
             break;
         case 'plain':
             $string = str::unxml($string);
             $string = str::unhtml($string);
             $string = str::trim($string);
             break;
         case 'lower':
             $string = str::lower($string);
             break;
         case 'upper':
             $string = str::upper($string);
             break;
         case 'words':
             $string = str::sanitize($string, 'plain');
             $string = preg_replace('/[^\\pL]/u', ' ', $string);
         case 'tags':
             $string = str::sanitize($string, 'plain');
             $string = preg_replace('/[^\\pL\\pN]/u', ' ', $string);
             $string = str::trim($string);
         case 'nobreaks':
             $string = str_replace('\\n', '', $string);
             $string = str_replace('\\r', '', $string);
             $string = str_replace('\\t', '', $string);
             break;
         case 'url':
             $string = self::urlify($string);
             break;
         case 'filename':
             $string = f::safe_name($string);
             break;
     }
     return trim($string);
 }
Exemple #4
0
 public static function validate($data = array(), $mode = 'insert')
 {
     if ($mode == 'insert') {
         if (empty($data['username'])) {
             throw new Exception('Invalid username');
         }
         if (empty($data['password'])) {
             throw new Exception('Invalid password');
         }
     }
     if (!empty($data['email']) and !v::email($data['email'])) {
         throw new Exception('Invalid email');
     }
 }
Exemple #5
0
<?php

header('Content-type: application/json');
//validate using Kirby toolkit
$errors = array();
if (!get('form-name')) {
    die('{"error":"' . (l::get('error.name-required') ?: 'Please include your name.') . '"}');
}
if (!v::email(get('form-email'))) {
    die('{"error":"' . (l::get('error.email-invalid') ?: 'Please enter a valid e-mail address.') . '"}');
}
if (!get('form-message')) {
    die('{"error":"' . (l::get('error.message-required') ?: 'Message is required.') . '"}');
}
$name = get('form-name');
$email = get('form-email');
$telephone = get('form-telephone');
$message = get('form-message');
$from = "From: Locum Vet Staff Limited";
$to = "*****@*****.**";
$subject = "[Contact Form] New message from {$name}";
$body = "From: {$name}\n E-mail: {$email}\n Telephone: {$telephone}\n\n Message:\n{$message}";
mail($to, $subject, $body, $from);
die('{"success":"Your message has been sent. We will reply as soon as possible, thank you."}');
Exemple #6
0
 public function testEmail()
 {
     $this->assertTrue(v::email('*****@*****.**'));
     $this->assertFalse(v::email('http://getkirby.com'));
 }
Exemple #7
0
 public function validate()
 {
     return v::email($this->result());
 }
Exemple #8
0
			<li class="Form-item Form-item--stacked<?php 
if (param('status') == 'go' && (!$email || !v::email($email))) {
    echo ' is-error';
}
?>
">
				<label for="contactform-email" class="Form-label">Email address</label>
				<input type="email" id="contactform-email" name="email" class="Form-input" value="<?php 
if (param('status') == 'go') {
    echo html($email);
}
?>
" spellcheck="false" />
				<?php 
if (param('status') == 'go' && (!$email || !v::email($email))) {
    ?>
<small class="Form-helperError">Please enter a valid email address</small><?php 
}
?>
			</li>

			<?php 
/*
<li class="Form-item Form-item--stacked">
	<label for="contactform-subject" class="Form-label">Subject</label>
	<input type="text" id="contactform-subject" name="subject" class="Form-input" value="<?php if(param('status') == 'go'): echo html(get('subject')); endif; ?>" spellcheck="true" />
</li>
*/
?>
 static function validate($method, $value)
 {
     switch ($method) {
         case 'date':
             return v::date($value);
             break;
         case 'url':
             return v::url($value);
             break;
         case 'email':
             return v::email($value);
             break;
         default:
             if (is_array($method)) {
                 $match = null;
                 $minlength = $maxlength = 0;
                 extract($method);
                 if ($match && !preg_match($match, $value)) {
                     return false;
                 }
                 if ($minlength && str::length($value) < $minlength) {
                     return false;
                 }
                 if ($maxlength && str::length($value) > $maxlength) {
                     return false;
                 }
             }
             break;
     }
     return true;
 }
 private function extractAddress($string)
 {
     if (v::email($string)) {
         return $string;
     }
     preg_match('/<(.*?)>/i', $string, $array);
     $address = @$array[1];
     return v::email($address) ? $address : false;
 }
Exemple #11
0
/**
 * Send an email to reset a user's password.
 * Used for opt-in verification of new accounts, and for password resets.
 */
function resetPassword($email, $firstTime = false)
{
    // Find the user
    $user = site()->users()->findBy('email', $email);
    if (!$user) {
        return false;
    }
    // Generate a secure random 32-character hex token
    do {
        $bytes = openssl_random_pseudo_bytes(16, $crypto_strong);
        $token = bin2hex($bytes);
    } while (!$crypto_strong);
    // Add the token to the user's profile
    $user->update(['token' => $token]);
    // Set the reset link
    $resetLink = site()->url() . '/token/' . $token;
    // Build the email text
    if ($firstTime) {
        $subject = l::get('activate-account');
        $body = l::get('activate-message-first') . "\n\n" . $resetLink . "\n\n" . l::get('activate-message-last');
    } else {
        $subject = l::get('reset-password');
        $body = l::get('reset-message-first') . "\n\n" . $resetLink . "\n\n" . l::get('reset-message-last');
    }
    // Send the confirmation email
    $email = new Email(array('to' => $user->email(), 'from' => 'noreply@' . server::get('server_name'), 'subject' => $subject, 'body' => $body));
    if (v::email($email->from()) and $email->send()) {
        return true;
    } else {
        return false;
    }
}