Example #1
1
 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 = '';
 }
Example #2
0
 /**
  * 检查 学生的  准考证(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;
 }
Example #3
0
 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('*****@*****.**', $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();
 }
Example #4
0
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>';
        }
    }
}
Example #5
0
 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']);
     }
 }
Example #6
0
 /**
  * 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;
     }
 }
Example #7
0
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();
                }
            }
        }
    }
}
Example #8
0
 /**
  * 保存配置信息
  */
 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);
 }
/**
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;
}
Example #10
0
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;
}
Example #11
0
 /**
  * @param $email
  *
  * @return bool
  * @author Nicolas Juen
  */
 public function setEmail($email)
 {
     if (!isset($email) || empty($email) || !is_email($email)) {
         return false;
     }
     $this->email = $email;
 }
 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));
     }
 }
 /**
  * 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);
     }
 }
 /**
  * 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;
 }
Example #15
0
/**
 * 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;
}
 /**
  * Handles actions on candidate dashboard
  */
 public function lost_licence_key_form_handler()
 {
     if (!empty($_REQUEST['submit_lost_licence_form'])) {
         $activation_email = sanitize_text_field($_REQUEST['activation_email']);
         if (!is_email($activation_email)) {
             wc_add_notice(__('Invalid email address.'), 'error');
             return;
         }
         $keys = wppl_get_licences_from_activation_email($activation_email);
         if (!$keys) {
             wc_add_notice(__('No licences found.'), 'error');
         } else {
             ob_start();
             // Try to get a user name
             $user = get_user_by('email', $activation_email);
             if ($user && !empty($user->first_name)) {
                 $user_first_name = $user->first_name;
             } else {
                 $user_first_name = false;
             }
             wc_get_template('lost-licence-email.php', array('keys' => $keys, 'activation_email' => $activation_email, 'blogname' => get_option('blogname'), 'user_first_name' => $user_first_name), 'wp-plugin-licencing', WP_PLUGIN_LICENCING_PLUGIN_DIR . '/templates/');
             // Get contents
             $message = ob_get_clean();
             if (wp_mail($activation_email, __('Your licence keys for WP Job Manager', 'wp-plugin-licencing'), $message)) {
                 wc_add_notice(sprintf(__('Your licences have been emailed to %s.'), $activation_email), 'success');
             } else {
                 wc_add_notice(__('Your licences could not be sent. Please contact us for support.'), 'error');
             }
         }
     }
 }
Example #17
0
 public function subscribe()
 {
     $result = '';
     if (!$_POST || !wp_verify_nonce($_POST[$this->pluginname . "_form_nonce"], $this->pluginname . "_form_submit")) {
         $result = json_encode(array("status" => false, "type" => "request", "reason" => "Bad request"));
     } else {
         $email = $_POST['es-email'];
         if (isset($email) && is_email($email)) {
             // Register and reply with confirmation message
             $ip = $_SERVER['REMOTE_ADDR'];
             //Check IP to make sure it is valid and not spam
             $saneip = filter_var($ip, FILTER_VALIDATE_IP);
             if ($saneip) {
                 $res = $this->manager->subscribe($email, $saneip);
                 if ($res == ESMessageCode::ES_SUCCESS_SUB_ADDED) {
                     $result = json_encode(array("status" => true, "type" => "", "reason" => ""));
                 } else {
                     $result = json_encode(array("status" => false, "type" => "system", "reason" => "System error."));
                 }
             } else {
                 ice_log("in subscribe - bad ip error");
                 $result = json_encode(array("status" => false, "type" => "ip", "reason" => "Invalid IP."));
             }
         } else {
             // Reply with error
             $result = json_encode(array("status" => false, "type" => "data", "reason" => "Invalid email."));
         }
     }
     header("Content-Type: application/json");
     echo $result;
     die;
 }
Example #18
0
 public function save()
 {
     require_once WD_BWG_DIR . "/frontend/models/BWGModelGalleryBox.php";
     $model = new BWGModelGalleryBox();
     $option_row = $model->get_option_row_data();
     if ($option_row->popup_enable_email) {
         // Email validation.
         $email = isset($_POST['bwg_email']) ? is_email(stripslashes($_POST['bwg_email'])) : FALSE;
     } else {
         $email = TRUE;
     }
     if ($option_row->popup_enable_captcha) {
         $bwg_captcha_input = isset($_POST['bwg_captcha_input']) ? esc_html(stripslashes($_POST['bwg_captcha_input'])) : '';
         @session_start();
         $bwg_captcha_code = isset($_SESSION['bwg_captcha_code']) ? esc_html(stripslashes($_SESSION['bwg_captcha_code'])) : '';
         if ($bwg_captcha_input === $bwg_captcha_code) {
             $captcha = TRUE;
         } else {
             $captcha = FALSE;
         }
     } else {
         $captcha = TRUE;
     }
     if ($email && $captcha) {
         global $wpdb;
         $image_id = isset($_POST['image_id']) ? (int) $_POST['image_id'] : 0;
         $name = isset($_POST['bwg_name']) ? esc_html(stripslashes($_POST['bwg_name'])) : '';
         $bwg_comment = isset($_POST['bwg_comment']) ? esc_html(stripslashes($_POST['bwg_comment'])) : '';
         $bwg_email = isset($_POST['bwg_email']) ? esc_html(stripslashes($_POST['bwg_email'])) : '';
         $published = current_user_can('manage_options') || !$option_row->comment_moderation ? 1 : 0;
         $save = $wpdb->insert($wpdb->prefix . 'bwg_image_comment', array('image_id' => $image_id, 'name' => $name, 'date' => date('Y-m-d H:i'), 'comment' => $bwg_comment, 'url' => '', 'mail' => $bwg_email, 'published' => $published), array('%d', '%s', '%s', '%s', '%s', '%s', '%d'));
         $wpdb->query($wpdb->prepare('UPDATE ' . $wpdb->prefix . 'bwg_image SET comment_count=comment_count+1 WHERE id="%d"', $image_id));
     }
     $this->display();
 }
Example #19
0
function wppb_check_email_value($message, $field, $request_data, $form_location)
{
    global $wpdb;
    if (isset($request_data['email']) && trim($request_data['email']) == '' && $field['required'] == 'Yes') {
        return wppb_required_field_error($field["field-title"]);
    }
    if (isset($request_data['email']) && !is_email(trim($request_data['email']))) {
        return __('The email you entered is not a valid email address.', 'profilebuilder');
    }
    if (is_multisite() || !is_multisite() && (isset($wppb_generalSettings['emailConfirmation']) && $wppb_generalSettings['emailConfirmation'] == 'yes')) {
        $user_signup = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "signups WHERE user_email = %s", $request_data['email']));
        if (!empty($user_signup)) {
            return __('This email is already reserved to be used soon.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder');
        }
    }
    $users = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE user_email = %s", $request_data['email']));
    if (!empty($users)) {
        if ($form_location == 'register') {
            return __('This email is already in use.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder');
        }
        if ($form_location == 'edit_profile') {
            $current_user = wp_get_current_user();
            foreach ($users as $user) {
                if ($user->ID != $current_user->ID) {
                    return __('This email is already in use.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder');
                }
            }
        }
    }
    return $message;
}
 /**
  * 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) {
         // is this an email value? assume email field
         if (empty($guessed['EMAIL']) && is_string($value) && is_email($value)) {
             $guessed['EMAIL'] = $value;
             continue;
         }
         // remove special characters from field name
         $simple_key = str_replace(array('-', '_'), '', $field);
         if (empty($guessed['NAME']) && in_array($simple_key, array('NAME', 'YOURNAME', 'USERNAME', 'FULLNAME', 'CONTACTNAME'))) {
             // find name field
             $guessed['NAME'] = $value;
         } elseif (empty($guessed['FNAME']) && in_array($simple_key, array('FIRSTNAME', 'FNAME', 'GIVENNAME', 'FORENAME'))) {
             // find first name field
             $guessed['FNAME'] = $value;
         } elseif (empty($guessed['LNAME']) && in_array($simple_key, array('LASTNAME', 'LNAME', 'SURNAME', 'FAMILYNAME'))) {
             // find last name field
             $guessed['LNAME'] = $value;
         }
     }
     return $guessed;
 }
Example #21
0
 /**
  * Check if ANY Newsletter Sign-Up form has been submitted.
  */
 public function submit()
 {
     $opts = $this->options['form'];
     $errors = array();
     $email = isset($_POST['nsu_email']) ? sanitize_text_field($_POST['nsu_email']) : '';
     $name = isset($_POST['nsu_name']) ? sanitize_text_field($_POST['nsu_name']) : '';
     // has the honeypot been filled?
     if (!empty($_POST['nsu_robocop'])) {
         return false;
     }
     // if name is required, check it it was given
     if ($this->options['mailinglist']['subscribe_with_name'] == 1 && $opts['name_required'] == 1 && empty($name)) {
         $errors['name-field'] = $opts['text_empty_name'];
     }
     // validate email
     if (empty($email)) {
         $errors['email-field'] = $opts['text_empty_email'];
     } elseif (!is_string($email) || !is_email($email)) {
         $errors['email-field'] = $opts['text_invalid_email'];
     }
     // store errors as property
     $this->validation_errors = $errors;
     // send request to service if no errors occured
     if (count($this->validation_errors) == 0) {
         NSU::instance()->send_post_data($email, $name, 'form');
         return true;
     }
     return false;
 }
Example #22
0
function iron_newsletter_subscribe()
{
    global $wpdb;
    extract($_POST);
    // Create table if not exist
    $wpdb->query("\r\n\tCREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "iron_newsletter (\r\n\t  `email` varchar(255) NOT NULL DEFAULT '',\r\n\t  `time` varchar(255) DEFAULT NULL,\r\n\t  PRIMARY KEY (`email`)\r\n\t) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
    // Check if email is valid
    if (isset($email) && is_email($email)) {
        /* check if exists */
        $query = $wpdb->prepare('SELECT COUNT(*) FROM ' . $wpdb->prefix . 'iron_newsletter  WHERE email = %s', array($email));
        $count = $wpdb->get_var($query);
        if ($count == 0) {
            // Email does not exist.
            $query = $wpdb->prepare('INSERT INTO ' . $wpdb->prefix . 'iron_newsletter  (email, time) VALUES (%s, %s)', array($email, date('Y-m-d H:i:s')));
            $wpdb->query($query);
            // Send notification to admin
            $admin_email = get_option('admin_email');
            $subject = _x('New subscriber', IRON_TEXT_DOMAIN);
            // Subject
            $message = _x(sprintf('Hello admin, you have one new subscriber. This is his/her e-mail address: %s.', $email), IRON_TEXT_DOMAIN);
            // Message
            $headers[] = 'From: ' . $email . ' <' . $email . '>';
            wp_mail($admin_email, $subject, $message, $headers);
            die('success');
        } else {
            die('subscribed');
        }
    } else {
        die('invalid');
    }
}
Example #23
0
/**
 * Adds a new client from the event field.
 *
 * @since	1.3.7
 * @global	arr		$_POST
 */
function mdjm_add_client_ajax()
{
    $client_id = false;
    $client_list = '';
    $result = array();
    $message = array();
    if (!is_email($_POST['client_email'])) {
        $message[] = __('Email address is invalid', 'mobile-dj-manager');
    } elseif (email_exists($_POST['client_email'])) {
        $message[] = __('Email address is already in use', 'mobile-dj-manager');
    } else {
        $user_data = array('first_name' => ucwords($_POST['client_firstname']), 'last_name' => !empty($_POST['client_lastname']) ? ucwords($_POST['client_lastname']) : '', 'user_email' => $_POST['client_email'], 'client_phone' => !empty($_POST['client_phone']) ? $_POST['client_phone'] : '', 'client_phone2' => !empty($_POST['client_phone2']) ? $_POST['client_phone2'] : '');
        $user_data = apply_filters('mdjm_event_new_client_data', $user_data);
        $client_id = mdjm_add_client($user_data);
    }
    $clients = mdjm_get_clients('client');
    if (!empty($clients)) {
        foreach ($clients as $client) {
            $client_list .= sprintf('<option value="%1$s"%2$s>%3$s</option>', $client->ID, $client->ID == $client_id ? ' selected="selected"' : '', $client->display_name);
        }
    }
    if (empty($client_id)) {
        $result = array('type' => 'error', 'message' => explode("\n", $message));
    } else {
        $result = array('type' => 'success', 'client_id' => $client_id, 'client_list' => $client_list);
        do_action('mdjm_after_add_new_client', $user_data);
    }
    echo json_encode($result);
    die;
}
Example #24
0
/**
 * @param $options
 * @return mixed
 */
function nowMail_validate_options($options)
{
    global $nowMailSettings;
    if (isset($options['nowmail_update'])) {
        $result = __("Options saved successfully.", "nowmail");
        $status = 'updated';
        $nowMailSettings = array();
        $nowMailSettings["from"] = trim($options['nowmail_from']);
        $nowMailSettings["fromname"] = trim($options['nowmail_fromname']);
        $nowMailSettings["host"] = trim($options['nowmail_host']);
        $nowMailSettings["smtpsecure"] = trim($options['nowmail_smtpsecure']);
        $nowMailSettings["port"] = trim($options['nowmail_port']);
        $nowMailSettings["smtpauth"] = trim($options['nowmail_smtpauth']);
        $nowMailSettings["username"] = trim($options['nowmail_username']);
        $nowMailSettings["password"] = trim($options['nowmail_password']);
        $nowMailSettings["deactivate"] = isset($options['nowmail_deactivate']) ? trim($options['nowmail_deactivate']) : "";
        update_option("nowMail_settings", $nowMailSettings);
        if (!is_email($nowMailSettings["from"])) {
            $result = __("The field 'From' must be a valid email address!", "nowmail");
            $status = 'error';
        } elseif (empty($nowMailSettings["host"])) {
            $result = __("The field 'SMTP Host' can not be left blank!", "nowmail");
            $status = 'error';
        }
        return '<div id="message" class="' . $status . ' fade"><p><strong>' . $result . '</strong></p></div>';
    }
}
 function aiowps_send_file_change_alert_email()
 {
     global $aio_wp_security;
     if ($aio_wp_security->configs->get_value('aiowps_send_fcd_scan_email') == '1') {
         //Get the right email address.
         if (is_email($aio_wp_security->configs->get_value('aiowps_fcd_scan_email_address'))) {
             $toaddress = $aio_wp_security->configs->get_value('aiowps_fcd_scan_email_address');
         } else {
             $toaddress = get_site_option('admin_email');
         }
         $to = $toaddress;
         $site_title = get_bloginfo('name');
         $from_name = empty($site_title) ? 'WordPress' : $site_title;
         $headers = 'From: ' . $from_name . ' <' . get_option('admin_email') . '>' . PHP_EOL;
         $subject = __('All In One WP Security - File change detected!', 'aiowpsecurity') . ' ' . date('l, F jS, Y \\a\\t g:i a', current_time('timestamp'));
         //$attachment = array();
         $message = __('A file change was detected on your system for site URL', 'aiowpsecurity') . ' ' . get_option('siteurl') . __('. Scan was generated on', 'aiowpsecurity') . ' ' . date('l, F jS, Y \\a\\t g:i a', current_time('timestamp'));
         $message .= "\r\n\r\n" . __('A summary of the scan results is shown below:', 'aiowpsecurity');
         $scan_res_unserialized = self::get_file_change_data();
         $scan_results_message = '';
         if ($scan_res_unserialized !== false) {
             $scan_results_message = self::get_file_change_summary($scan_res_unserialized);
         }
         $message .= "\r\n\r\n";
         $message .= $scan_results_message;
         $message .= "\r\n" . __('Login to your site to view the scan details.', 'aiowpsecurity');
         wp_mail($to, $subject, $message, $headers);
     }
 }
Example #26
0
/**
 * Return the count of all customer orders through WC.
 *
 * If no $user_id is provided, or no orders exist for the given user and an
 * email address is provided, we can query the PayPal address to query previous orders
 * to cover guest checkout.
 *
 * @param int $user_id		Optional: The user ID to query.
 * @param str $email		Optional: The user email address.
 * 
 * @since	0.0.1
 * @return	int		Total number of orders from this customer.
 */
function wc_nod_get_customer_purchase_count($user_id = '', $email = '')
{
    if (empty($user_id) && empty($email)) {
        return false;
    }
    $orders = 0;
    // Retrieve the WP user
    if (!empty($user_id)) {
        $field = 'id';
    } elseif (is_email(trim($email))) {
        $field = 'email';
    }
    if (empty($field)) {
        return $orders;
    }
    $user = get_user_by($field, $user_id);
    // If we did not retrieve a user by ID and we have an email, try that.
    if (!$user && $field == 'id' && !empty($email)) {
        $user = get_user_by('email', trim($email));
    }
    if ($user) {
        $orders += nod_get_order_count_by('id', $user->ID);
    }
    // If an email is provided query orders by email
    if (!empty($email)) {
        $orders += nod_get_order_count_by('email', trim($email));
    }
    return $orders;
}
Example #27
0
/**
 * WordPress register with email only, make it possible to register with email 
 * as username in a multisite installation
 *
 * @param  Array $result Result array of the wpmu_validate_user_signup-function
 * @return Array         Altered result array
 */
function custom_register_with_email($result)
{
    if ($result['user_name'] != '' && is_email($result['user_name'])) {
        unset($result['errors']->errors['user_name']);
    }
    return $result;
}
Example #28
0
 /**
  *
  * @param string $email
  * @param string $name
  *
  * @return false|int|void
  */
 public function insertSubscriber($email, $name = '')
 {
     if (!is_email($email) || $this->emailExists($email)) {
         return false;
     }
     return $this->wpdb->insert($this->table, ['email' => $email, 'name' => $name]);
 }
function um_add_user_frontend($args)
{
    global $ultimatemember;
    extract($args);
    if (isset($user_email) && !isset($user_login)) {
        $user_login = $user_email;
    }
    if (isset($username) && !isset($args['user_login'])) {
        $user_login = $username;
    }
    if (isset($username) && is_email($username)) {
        $user_email = $username;
    }
    if (!isset($user_password)) {
        $user_password = $ultimatemember->validation->generate();
    }
    $unique_userID = $ultimatemember->query->count_users() + 1;
    if (!isset($user_email)) {
        $user_email = 'nobody' . $unique_userID . '@' . get_bloginfo('name');
    }
    if (!isset($user_login)) {
        $user_login = '******' . $unique_userID;
    }
    $creds['user_login'] = $user_login;
    $creds['user_password'] = $user_password;
    $creds['user_email'] = $user_email;
    $args['submitted'] = array_merge($args['submitted'], $creds);
    $args = array_merge($args, $creds);
    do_action('um_before_new_user_register', $args);
    $user_id = wp_create_user($user_login, $user_password, $user_email);
    do_action('um_after_new_user_register', $user_id, $args);
    return $user_id;
}
function um_submit_form_errors_hook_login($args)
{
    global $ultimatemember;
    $is_email = false;
    $form_id = $args['form_id'];
    $mode = $args['mode'];
    if (isset($args['username']) && $args['username'] == '') {
        $ultimatemember->form->add_error('username', __('Please enter your username or email', 'ultimatemember'));
    }
    if (isset($args['user_login']) && $args['user_login'] == '') {
        $ultimatemember->form->add_error('user_login', __('Please enter your username', 'ultimatemember'));
    }
    if (isset($args['user_email']) && $args['user_email'] == '') {
        $ultimatemember->form->add_error('user_email', __('Please enter your email', 'ultimatemember'));
    }
    if (isset($args['username'])) {
        $field = 'username';
        if (is_email($args['username'])) {
            $is_email = true;
            $data = get_user_by('email', $args['username']);
            $user_name = isset($data->user_login) ? $data->user_login : null;
        } else {
            $user_name = $args['username'];
        }
    } else {
        if (isset($args['user_email'])) {
            $field = 'user_email';
            $is_email = true;
            $data = get_user_by('email', $args['user_email']);
            $user_name = isset($data->user_login) ? $data->user_login : null;
        } else {
            $field = 'user_login';
            $user_name = $args['user_login'];
        }
    }
    if (!username_exists($user_name)) {
        if ($is_email) {
            $ultimatemember->form->add_error($field, __(' Sorry, we can\'t find an account with that email address', 'ultimatemember'));
        } else {
            $ultimatemember->form->add_error($field, __(' Sorry, we can\'t find an account with that username', 'ultimatemember'));
        }
    } else {
        if ($args['user_password'] == '') {
            $ultimatemember->form->add_error('user_password', __('Please enter your password', 'ultimatemember'));
        }
    }
    $user = get_user_by('login', $user_name);
    if ($user && wp_check_password($args['user_password'], $user->data->user_pass, $user->ID)) {
        $ultimatemember->login->auth_id = username_exists($user_name);
    } else {
        $ultimatemember->form->add_error('user_password', __('Password is incorrect. Please try again.', 'ultimatemember'));
    }
    // add a way for other plugins like wp limit login
    // to limit the login attempts
    $user = apply_filters('authenticate', null, $user_name, $args['user_password']);
    // if there is an error notify wp
    if ($ultimatemember->form->has_error($field) || $ultimatemember->form->has_error($user_password)) {
        do_action('wp_login_failed', $user_name);
    }
}