本文整理汇总了PHP中is_email函数的典型用法代码示例。如果您正苦于以下问题:PHP is_email函数的具体用法?PHP is_email怎么用?PHP is_email使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_email函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
function send($email, $template = null, $args = array())
{
if (!$template) {
return;
}
if (um_get_option($template . '_on') != 1) {
return;
}
if (!is_email($email)) {
return;
}
$this->attachments = null;
$this->headers = 'From: ' . um_get_option('mail_from') . ' <' . um_get_option('mail_from_addr') . '>' . "\r\n";
$this->subject = um_get_option($template . '_sub');
$this->subject = $this->convert_tags($this->subject, $args);
if (isset($args['admin']) || isset($args['plain_text'])) {
$this->force_plain_text = 'forced';
}
// HTML e-mail or text
if (um_get_option('email_html') && $this->email_template($template, $args)) {
add_filter('wp_mail_content_type', array(&$this, 'set_content_type'));
$this->message = file_get_contents($this->email_template($template, $args));
} else {
$this->message = um_get_option($template);
}
// Convert tags in body
$this->message = $this->convert_tags($this->message, $args);
// Send mail
wp_mail($email, $this->subject, $this->message, $this->headers, $this->attachments);
remove_filter('wp_mail_content_type', array(&$this, 'set_content_type'));
// reset globals
$this->force_plain_text = '';
}
示例2: is_valid_student
/**
* 检查 学生的 准考证(exam_ticket)/邮箱(email) 和 登录密码是否正确
* @param string $keyword
* @param string $password
* @return boolean|array
*/
public function is_valid_student($keyword, $password = null)
{
$items = array('uid', 'email', 'first_name', 'last_name', 'exam_ticket', 'grade_id', 'sex', 'picture', 'school_id', 'password');
$this->db->select($items);
if (is_email($keyword)) {
//验证 邮箱
$query = $this->db->get_where(self::$_table_name, array('email' => $keyword), 1);
} else {
if (is_idcard($keyword)) {
//验证 邮箱
$query = $this->db->get_where(self::$_table_name, array('idcard' => $keyword), 1);
} else {
if (is_numeric($keyword)) {
//验证 准考证
$query = $this->db->get_where(self::$_table_name, array('exam_ticket' => $keyword), 1);
} else {
return false;
}
}
}
$row = $query->row_array();
if (!count($row)) {
return false;
}
if (is_null($password)) {
return $row;
}
if ($row['password'] != my_md5($password)) {
return false;
}
unset($row['password']);
return $row;
}
示例3: sendContact
public function sendContact()
{
$res = new responseGmp();
$time = time();
$prevSendTime = (int) get_option(GMP_CODE . '_last__time_contact_send');
if ($prevSendTime && $time - $prevSendTime < 5 * 60) {
// Only one message per five minutes
$res->pushError(__('Please don\'t send contact requests so often - wait for response for your previous requests.'));
$res->ajaxExec();
}
$data = reqGmp::get('post');
$fields = $this->getModule()->getContactFormFields();
foreach ($fields as $fName => $fData) {
$validate = isset($fData['validate']) ? $fData['validate'] : false;
$data[$fName] = isset($data[$fName]) ? trim($data[$fName]) : '';
if ($validate) {
$error = '';
foreach ($validate as $v) {
if (!empty($error)) {
break;
}
switch ($v) {
case 'notEmpty':
if (empty($data[$fName])) {
$error = $fData['html'] == 'selectbox' ? __('Please select %s', GMP_LANG_CODE) : __('Please enter %s', GMP_LANG_CODE);
$error = sprintf($error, $fData['label']);
}
break;
case 'email':
if (!is_email($data[$fName])) {
$error = __('Please enter valid email address', GMP_LANG_CODE);
}
break;
}
if (!empty($error)) {
$res->pushError($error, $fName);
}
}
}
}
if (!$res->error()) {
$msg = 'Message from: ' . get_bloginfo('name') . ', Host: ' . $_SERVER['HTTP_HOST'] . '<br />';
$msg .= 'Plugin: ' . GMP_WP_PLUGIN_NAME . '<br />';
foreach ($fields as $fName => $fData) {
if (in_array($fName, array('name', 'email', 'subject'))) {
continue;
}
if ($fName == 'category') {
$data[$fName] = $fData['options'][$data[$fName]];
}
$msg .= '<b>' . $fData['label'] . '</b>: ' . nl2br($data[$fName]) . '<br />';
}
if (frameGmp::_()->getModule('mail')->send('support@supsystic.team.zendesk.com', $data['subject'], $msg, $data['name'], $data['email'])) {
update_option(GMP_CODE . '_last__time_contact_send', $time);
} else {
$res->pushError(frameGmp::_()->getModule('mail')->getMailErrors());
}
}
$res->ajaxExec();
}
示例4: sendemail
function sendemail()
{
if (isset($_POST['action']) and $_POST['action'] == 'send') {
$body = BODY;
if (!is_string($_POST['name']) or $_POST['name'] == '') {
return '<p class="error">Insert correct name</p>';
}
if (!is_email($_POST['email']) or $_POST['email'] == '') {
return '<p class="error">Insert correct email</p>';
}
$subject = $_POST['subject'];
if (!is_email($subject) or $subject == '') {
$subject = 'Email without subject.';
}
foreach (array_map('stripslashes', $_POST) as $id => $var) {
if ($id == 'message') {
$var = nl2br($var);
}
$body = str_replace("%{$id}%", $var, $body);
}
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= "From: myplace@here.com\r\n";
$sendmail = mail(TO, $subject, $body, $headers);
if ($sendmail) {
return '<p class="success">Email sent correctly!</p>';
} else {
return '<p class="error">An error has been encountered. Please try again.</p>';
}
}
}
示例5: doemail
public function doemail()
{
global $_M;
if (!load::sys_class('pin', 'new')->check_pin($_M['form']['code'])) {
okinfo($_M['url']['getpassword'], $_M['word']['membercode']);
}
load::sys_func('str');
if (is_email($_M['form']['username'])) {
$user = $this->userclass->get_user_by_email($_M['form']['username']);
if (!$user) {
okinfo($_M['url']['getpassword'], $_M['word']['nouser']);
}
$valid = load::mod_class('user/class/valid', 'new');
if ($valid->get_email($_M['form']['username'], 'getpassword')) {
okinfo($_M['url']['login'], $_M['word']['emailsucpass']);
} else {
okinfo($_M['url']['login'], $_M['word']['emailfail']);
}
} elseif (is_phone($_M['form']['username'])) {
$user = $this->userclass->get_user_by_tel($_M['form']['username']);
if (!$user) {
okinfo($_M['url']['getpassword'], $_M['word']['nouser']);
}
require_once $this->template('tem/getpassword_telset');
} else {
okinfo($_M['url']['getpassword'], $_M['word']['emailvildtips3']);
}
}
示例6: validate
/**
* Field Render Function.
* Takes the vars and outputs the HTML for the field in the settings
*
* @since AvadaReduxFramework 1.0.0
*/
function validate()
{
if (!is_email($this->value)) {
$this->value = isset($this->current) ? $this->current : '';
$this->error = $this->field;
}
}
示例7: wppb_change_login_with_email
function wppb_change_login_with_email()
{
if (!empty($_POST['log'])) {
// only do this for our form
if (isset($_POST['wppb_login'])) {
global $wpdb, $_POST;
$wppb_generalSettings = get_option('wppb_general_settings');
// if this setting is active, the posted username is, in fact the user's email
if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') {
$username = $wpdb->get_var($wpdb->prepare("SELECT user_login FROM {$wpdb->users} WHERE user_email= %s LIMIT 1", trim($_POST['log'])));
if (!empty($username)) {
$_POST['log'] = $username;
} else {
// if we don't have a username for the email entered we can't have an empty username because we will receive a field empty error
$_POST['log'] = 'this_is_an_invalid_email' . time();
}
}
// if this setting is active, the posted username is, in fact the user's email or username
if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'usernameemail') {
if (is_email($_POST['log'])) {
$username = $wpdb->get_var($wpdb->prepare("SELECT user_login FROM {$wpdb->users} WHERE user_email= %s LIMIT 1", trim($_POST['log'])));
} else {
$username = $_POST['log'];
}
if (!empty($username)) {
$_POST['log'] = $username;
} else {
// if we don't have a username for the email entered we can't have an empty username because we will receive a field empty error
$_POST['log'] = 'this_is_an_invalid_email' . time();
}
}
}
}
}
示例8: save
/**
* 保存配置信息
*/
public function save()
{
$setting = array();
$setting['admin_email'] = is_email($_POST['setting']['admin_email']) ? trim($_POST['setting']['admin_email']) : showmessage(L('email_illegal'), HTTP_REFERER);
$setting['maxloginfailedtimes'] = intval($_POST['setting']['maxloginfailedtimes']);
$setting['minrefreshtime'] = intval($_POST['setting']['minrefreshtime']);
$setting['mail_type'] = intval($_POST['setting']['mail_type']);
$setting['mail_server'] = trim($_POST['setting']['mail_server']);
$setting['mail_port'] = intval($_POST['setting']['mail_port']);
$setting['category_ajax'] = intval(abs($_POST['setting']['category_ajax']));
$setting['mail_user'] = trim($_POST['setting']['mail_user']);
$setting['mail_auth'] = intval($_POST['setting']['mail_auth']);
$setting['mail_from'] = trim($_POST['setting']['mail_from']);
$setting['mail_password'] = trim($_POST['setting']['mail_password']);
$setting['errorlog_size'] = trim($_POST['setting']['errorlog_size']);
$setting = array2string($setting);
$this->db->update(array('setting' => $setting), array('module' => 'admin'));
//存入admin模块setting字段
//如果开始盛大通行证接入,判断服务器是否支持curl
$snda_error = '';
if ($_POST['setconfig']['snda_akey'] || $_POST['setconfig']['snda_skey']) {
if (function_exists('curl_init') == FALSE) {
$snda_error = L('snda_need_curl_init');
$_POST['setconfig']['snda_enable'] = 0;
}
}
set_config($_POST['setconfig']);
//保存进config文件
$this->setcache();
showmessage(L('setting_succ') . $snda_error, HTTP_REFERER);
}
示例9: sso_check
/**
Plugin Name: SSO
Author: Garth Mortensen, Mike Hansen
Version: 0.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
function sso_check()
{
if (!isset($_GET['salt']) || !isset($_GET['nonce']) || !isset($_GET['user'])) {
sso_req_login();
}
if (sso_check_blocked()) {
sso_req_login();
}
$nonce = esc_attr($_GET['nonce']);
$salt = esc_attr($_GET['salt']);
$user = esc_attr($_GET['user']);
$hash = base64_encode(hash('sha256', $nonce . $salt, false));
$hash = substr($hash, 0, 64);
if (get_transient('sso_token') == $hash) {
if (is_email($user)) {
$user = get_user_by('email', $user);
} else {
$user = get_user_by('id', (int) $user);
}
if (is_a($user, 'WP_User')) {
wp_set_current_user($user->ID, $user->user_login);
wp_set_auth_cookie($user->ID);
do_action('wp_login', $user->user_login);
delete_transient('sso_token');
wp_safe_redirect(admin_url());
} else {
sso_req_login();
}
} else {
sso_add_failed_attempt();
sso_req_login();
}
die;
}
示例10: wppb_mae_general_settings_sanitize_extra
function wppb_mae_general_settings_sanitize_extra($wppb_generalSettings)
{
if (isset($wppb_generalSettings['admin_emails']) && !empty($wppb_generalSettings['admin_emails'])) {
$invalid_email = false;
$invalid_email_count = 0;
$admin_emails = explode(',', $wppb_generalSettings['admin_emails']);
foreach ($admin_emails as $key => $admin_email) {
if (!is_email(trim($admin_email))) {
$invalid_email = true;
$invalid_email_count++;
unset($admin_emails[$key]);
}
}
if ($invalid_email) {
$wppb_generalSettings['admin_emails'] = implode(',', $admin_emails);
if ($invalid_email_count === 1) {
$invalid_email_is_are = __('is', 'profile-builder');
$invalid_email_has_have = __('has', 'profile-builder');
} else {
$invalid_email_is_are = __('are', 'profile-builder');
$invalid_email_has_have = __('have', 'profile-builder');
}
add_settings_error('wppb_general_settings', 'invalid-email', sprintf(__('%1$s of the emails provided in the Admin Emails field %2$s invalid and %3$s been removed from the list', 'profile-builder'), $invalid_email_count, $invalid_email_is_are, $invalid_email_has_have));
}
}
if (empty($wppb_generalSettings['admin_emails'])) {
$wppb_generalSettings['admin_emails'] = get_option('admin_email');
}
return $wppb_generalSettings;
}
示例11: setEmail
/**
* @param $email
*
* @return bool
* @author Nicolas Juen
*/
public function setEmail($email)
{
if (!isset($email) || empty($email) || !is_email($email)) {
return false;
}
$this->email = $email;
}
示例12: do_request
public function do_request()
{
global $wc_software;
$required = array('email', 'licence_key', 'product_id');
$this->check_required($required);
$input = $this->check_input(array('email', 'licence_key', 'product_id'));
// Validate email
if (!is_email($input['email'])) {
$this->wc_software_api->error('100', __('The email provided is invalid', 'wc_software'), null, array('reset' => false));
}
$data = $wc_software->get_licence_key($input['licence_key'], $input['product_id'], $input['email']);
if (!$data) {
$this->wc_software_api->error('101', __('No matching licence key exists', 'wc_software'), null, array('activated' => false));
}
// reset number of activations
if ($wc_software->deactivate_licence_key($data->key_id)) {
$output_data = get_object_vars($data);
$output_data['reset'] = true;
$output_data['timestamp'] = time();
$to_output = array();
$to_output['reset'] = 'reset';
$to_output['timestamp'] = 'timestamp';
$json = $this->prepare_output($to_output, $output_data);
return $json;
} else {
$this->wc_software_api->error('100', __('An undisclosed error occurred', 'wc_software'), null, array('reset' => false));
}
}
示例13: download_api_product
/**
* Check if we need to download a file and check validity
*/
public function download_api_product()
{
global $wpdb;
if (isset($_GET['download_api_product']) && isset($_GET['licence_key'])) {
$download_api_product = absint($_GET['download_api_product']);
$licence_key = sanitize_text_field($_GET['licence_key']);
$activation_email = sanitize_text_field($_GET['activation_email']);
$licence = wppl_get_licence_from_key($licence_key);
// Validation
if (!$licence) {
wp_die(__('Invalid or expired licence key.', 'wp-plugin-licencing'));
}
if (is_user_logged_in() && $licence->user_id && $licence->user_id != get_current_user_id()) {
wp_die(__('This licence does not appear to be yours.', 'wp-plugin-licencing'));
}
if (!is_email($activation_email) || $activation_email != $licence->activation_email) {
wp_die(__('Invalid activation email address.', 'wp-plugin-licencing'));
}
if (!in_array($download_api_product, wppl_get_licence_api_product_permissions($licence->product_id))) {
wp_die(__('This licence does not allow access to the requested product.', 'wp-plugin-licencing'));
}
// Get the download URL
$file_path = wppl_get_package_file_path($download_api_product);
// Log this download
$wpdb->insert($wpdb->prefix . 'wp_plugin_licencing_download_log', array('licence_key' => $licence_key, 'activation_email' => $activation_email, 'api_product_id' => $download_api_product, 'date_downloaded' => current_time('mysql'), 'user_ip_address' => sanitize_text_field(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'])));
// Download it!
$this->download($file_path);
}
}
开发者ID:ChromeOrange,项目名称:wp-plugin-licencing,代码行数:32,代码来源:class-wp-plugin-licencing-download-handler.php
示例14: guessed
/**
* Guess values for the following fields
* - EMAIL
* - NAME
* - FNAME
* - LNAME
*
* @return array
*/
public function guessed()
{
$guessed = array();
$fields = $this->fields->all();
foreach ($fields as $field => $value) {
// transform value into array to support 1-level arrays
$sub_fields = is_array($value) ? $value : array($value);
foreach ($sub_fields as $sub_field_value) {
// is this an email value? if so, assume it's the EMAIL field
if (empty($guessed['EMAIL']) && is_string($sub_field_value) && is_email($sub_field_value)) {
$guessed['EMAIL'] = $sub_field_value;
continue 2;
}
}
// remove special characters from field name
$simple_key = str_replace(array('-', '_', ' '), '', $field);
if (empty($guessed['FNAME']) && $this->string_contains($simple_key, array('FIRSTNAME', 'FNAME', 'GIVENNAME', 'FORENAME'))) {
// find first name field
$guessed['FNAME'] = $value;
} elseif (empty($guessed['LNAME']) && $this->string_contains($simple_key, array('LASTNAME', 'LNAME', 'SURNAME', 'FAMILYNAME'))) {
// find last name field
$guessed['LNAME'] = $value;
} elseif (empty($guessed['NAME']) && $this->string_contains($simple_key, 'NAME')) {
// find name field
$guessed['NAME'] = $value;
}
}
return $guessed;
}
示例15: sendMail
/**
* Validate data and send mail.
*
* @see http://codex.wordpress.org/Function_Reference/wp_mail
* @return {int} Status of message:
* -2 => Invalid data
* -1 => Failed to send
* 1 => OK
*/
function sendMail()
{
header("Content-Type: application/json");
$response = array('status' => -2, 'errors' => array());
if (!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['message'])) {
echo json_encode($response);
die;
}
$name = esc_attr($_POST['name']);
$email = sanitize_email($_POST['email']);
$message = esc_textarea($_POST['message']);
if (!strlen($name)) {
$response['errors']['name'] = "C'mon, what's your name?";
}
if (!is_email($email)) {
$response['errors']['email'] = "Please, give us valid email.";
}
if (!strlen($message)) {
$response['errors']['message'] = "No message, huh?";
}
if (empty($response['errors'])) {
$to = get_bloginfo('admin_email');
$subject = 'Contact from ' . get_bloginfo('name');
$headers[] = "From: {$name} <{$email}>";
$isSent = wp_mail($to, $subject, $message, $headers);
$response['status'] = $isSent ? 1 : -1;
}
echo json_encode($response);
die;
}