function handle() { global $upme_captcha_loader, $upme_save; require_once ABSPATH . 'wp-includes/pluggable.php'; if (get_option('users_can_register') == '1') { foreach ($this->usermeta as $key => $value) { /* Validate username */ if ($key == 'user_login') { /* UPME Action for validating username before creating new user */ do_action('upme_validate_username', $value); // End Action if (esc_attr($value) == '') { $this->errors[] = __('Please enter a username.', 'upme'); } elseif (username_exists($value)) { $this->errors[] = __('This username is already registered. Please choose another one.', 'upme'); } } /* Validate email */ if ($key == 'user_email') { if (esc_attr($value) == '') { $this->errors[] = __('Please type your e-mail address.', 'upme'); } elseif (!is_email($value)) { $this->errors[] = __('The email address isn\'t correct.', 'upme'); } elseif (email_exists($value)) { $this->errors[] = __('This email is already registered, please choose another one.', 'upme'); } } /* UPME filter for adding restrictions before custom field type saving */ $registration_custom_field_type_restrictions_params = array('meta' => $key, 'value' => $value); $this->errors = apply_filters('upme_registration_custom_field_type_restrictions', $this->errors, $registration_custom_field_type_restrictions_params); /* END filter */ } if (!upme_is_in_post('no_captcha', 'yes')) { if (!$upme_captcha_loader->validate_captcha(upme_post_value('captcha_plugin'))) { $this->errors[] = __('Please complete Captcha Test first.', 'upme'); } } // Handle file upload field validations $upload_params = array('username' => $this->usermeta['user_login']); $upme_save->process_registration_upload($_FILES, '1', $upload_params); $reg_upload_errors = isset($upme_save->errors) ? $upme_save->errors : ''; if (is_array($reg_upload_errors)) { $this->errors = (array) $this->errors; foreach ($reg_upload_errors as $error) { array_push($this->errors, $error); } } } else { $this->errors[] = __('Registration is disabled for this site.', 'upme'); } }
public function upme_reset_module_settings() { global $upme_admin; if (upme_is_post() && upme_is_in_post('current_tab')) { if (isset($upme_admin->default_module_settings[upme_post_value('current_tab')])) { $current_options = get_option('upme_options'); foreach ($upme_admin->default_module_settings[upme_post_value('current_tab')] as $key => $value) { $current_options[$key] = $value; } update_option('upme_options', $current_options); echo json_encode(array('status' => 'success')); exit; } } }
function handle() { global $upme_captcha_loader; /* Validate whether login form name is modified in unauthorized methods */ $login_verify_status = $this->verify_login_form_hash(); if (!$login_verify_status) { return; } /* Validate login form default fields */ require_once ABSPATH . 'wp-includes/pluggable.php'; foreach ($this->usermeta as $key => $value) { if ($key == 'user_login') { if (sanitize_user($value) == '') { $this->errors[] = __('The username field is empty.', 'upme'); } } if ($key == 'user_pass') { if (esc_attr($value) == '') { $this->errors[] = __('The password field is empty.', 'upme'); } } } /* UPME action for adding restrictions before login */ $before_login_validation_params = array(); do_action('upme_before_login_restrictions', $this->usermeta, $before_login_validation_params); /* END action */ /* Check approval status and activation status before login */ $this->verify_activation_approval_status(); // Check captcha first if (!upme_is_in_post('no_captcha', 'yes')) { if (!$upme_captcha_loader->validate_captcha(upme_post_value('captcha_plugin'))) { $this->errors[] = __('Please complete Captcha Test first.', 'upme'); } } /* attempt to signon */ $this->signon(); }
function upme_reset_settings() { if (upme_is_post() && upme_is_in_post('current_tab')) { if (isset($this->default_settings[upme_post_value('current_tab')])) { $current_options = get_option('upme_options'); foreach ($this->default_settings[upme_post_value('current_tab')] as $key => $value) { $current_options[$key] = $value; } update_option('upme_options', $current_options); echo "success"; die; } } }
/** * Enable/ Disable restriction rules for site content * * @param - * @return - */ function upme_enable_site_restriction_rules() { $rule_id = upme_post_value('rule_id'); $rule_status = upme_post_value('rule_status'); $this->restriction_rules = get_option('upme_site_restriction_rules'); if (!get_option('upme_site_restriction_rules')) { update_option('upme_site_restriction_rules', array()); $this->restriction_rules = array(); } $this->restriction_rules[$rule_id]['site_restriction_rule_status'] = $rule_status; $res = update_option('upme_site_restriction_rules', $this->restriction_rules); $rules = $this->upme_restriction_rules_list(); if ($res) { echo json_encode(array('status' => 'success', 'rules' => $rules, 'msg' => __('Restriction rule staus updated.', 'upme'))); } else { echo json_encode(array('status' => 'fail', 'rules' => $rules, 'msg' => __('Failed to update restriction rule status.', 'upme'))); } exit; }
function check_search_input() { if (upme_is_post()) { if (upme_is_in_post('upme_combined_search') && upme_post_value('upme_combined_search') != '') { return true; } if (upme_is_in_post('upme_search')) { foreach ($_POST['upme_search'] as $key => $value) { if (is_array($value) && count($value) > 0) { return true; } else { if ($value != '' && $value != '0') { return true; } } } } } return false; }
public function upme_upload_import_settings() { global $upme_admin; if (upme_is_in_get('current_tab')) { $allowed = array('text/csv', 'application/csv'); if (isset($_FILES['settings_file']) && $_FILES['settings_file']['error'] == 0) { if (!in_array(strtolower($_FILES['settings_file']['type']), $allowed)) { echo '{"status":"error"}'; exit; } else { //read CSV $csvData = $this->csv_to_array($_FILES['settings_file']['tmp_name'], ',', 'columns'); $optionArray = get_option('upme_options'); $updatedArray = array(); if (upme_is_in_post('site_import_settings') && count(upme_post_value('site_import_settings') > 0)) { //get option array foreach (upme_post_value('site_import_settings') as $postedVal) { $updatedArray[$postedVal] = $csvData[$postedVal]; } } else { $csvData['choose_roles_for_registration'] = explode(',', $csvData['choose_roles_for_registration']); $csvData['site_lockdown_allowed_pages'] = explode(',', $csvData['site_lockdown_allowed_pages']); $csvData['site_lockdown_allowed_posts'] = explode(',', $csvData['site_lockdown_allowed_posts']); $csvData['site_lockdown_allowed_urls'] = str_replace(',', "\n", $csvData['site_lockdown_allowed_urls']); $updatedArray = $csvData; } $mergedArray = $updatedArray + $optionArray; ksort($mergedArray); update_option('upme_options', $mergedArray); echo '{"status":"success"}'; exit; } echo '{"status":"error"}'; } else { echo '{"status":"error"}'; exit; } exit; } }
private function validate_recaptcha() { global $upme; $this->load_recaptcha_class(); // Getting the Private Key to validate reCaptcha $private_key = ''; $private_key = $upme->get_option('recaptcha_private_key'); if ($private_key != '') { if (upme_is_in_post('recaptcha_response_field')) { $resp = recaptcha_check_answer($private_key, $_SERVER["REMOTE_ADDR"], upme_post_value("recaptcha_challenge_field"), upme_post_value("recaptcha_response_field")); // Captcha is Valid if ($resp->is_valid) { return true; } else { return false; } } else { return true; } } else { // Private key is not set in admin return true; } }