本文整理匯總了PHP中v::email方法的典型用法代碼示例。如果您正苦於以下問題:PHP v::email方法的具體用法?PHP v::email怎麽用?PHP v::email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類v
的用法示例。
在下文中一共展示了v::email方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: extractAddress
/**
* 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];
}
示例2: sendBookingConfirmation
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());
}
示例3: sanitize
/**
* 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);
}
示例4: validate
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');
}
}
示例5: header
<?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 = "hello@chrish-dunne.co.uk";
$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."}');
示例6: testEmail
public function testEmail()
{
$this->assertTrue(v::email('bastian@getkirby.com'));
$this->assertFalse(v::email('http://getkirby.com'));
}
示例7: validate
public function validate()
{
return v::email($this->result());
}
示例8: html
<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>
*/
?>
示例9: validate
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;
}
示例10: extractAddress
private function extractAddress($string)
{
if (v::email($string)) {
return $string;
}
preg_match('/<(.*?)>/i', $string, $array);
$address = @$array[1];
return v::email($address) ? $address : false;
}
示例11: resetPassword
/**
* 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;
}
}