/**
  * Validate Captcha, if form had one.
  *
  * @return bool
  */
 public function validate_captcha()
 {
     // check if captcha was present and valid
     if (isset($this->internal_data['has_captcha']) && $this->internal_data['has_captcha'] == 1 && function_exists('cptch_check_custom_form') && cptch_check_custom_form() !== true) {
         return false;
     }
     return true;
 }
 /**
  * Validate Captcha, if form had one.
  *
  * @return bool
  */
 public function validate_captcha()
 {
     // check if captcha was present and valid
     if (isset($this->data['_MC4WP_HAS_CAPTCHA']) && $this->data['_MC4WP_HAS_CAPTCHA'] == 1 && function_exists('cptch_check_custom_form') && cptch_check_custom_form() !== true) {
         return false;
     }
     return true;
 }
Пример #3
0
 /**
  * Submits the form
  * Creates a subscribe request from the posted data
  *
  * @return boolean
  */
 public function submit()
 {
     // store number of submitted form
     $this->submitted_form_instance = absint($_POST['_mc4wp_form_instance']);
     // validate form nonce
     if (!isset($_POST['_mc4wp_form_nonce']) || !wp_verify_nonce($_POST['_mc4wp_form_nonce'], '_mc4wp_form_nonce')) {
         $this->error = 'invalid_nonce';
         return false;
     }
     // ensure honeypot was not filed
     if (isset($_POST['_mc4wp_required_but_not_really']) && !empty($_POST['_mc4wp_required_but_not_really'])) {
         $this->error = 'spam';
         return false;
     }
     // check if captcha was present and valid
     if (isset($_POST['_mc4wp_has_captcha']) && $_POST['_mc4wp_has_captcha'] == 1 && function_exists('cptch_check_custom_form') && cptch_check_custom_form() !== true) {
         $this->error = 'invalid_captcha';
         return false;
     }
     // allow plugins to add additional validation
     $valid_form_request = apply_filters('mc4wp_valid_form_request', true);
     if ($valid_form_request !== true) {
         $this->error = $valid_form_request;
         return false;
     }
     // setup array of data entered by user
     // not manipulating anything yet.
     $data = $this->get_posted_form_data();
     $success = $this->subscribe($data);
     // enqueue scripts (in footer)
     wp_enqueue_script('mc4wp-forms');
     wp_localize_script('mc4wp-forms', 'mc4wp', array('success' => $success ? 1 : 0, 'submittedFormId' => $this->submitted_form_instance, 'postData' => $data));
     if ($success) {
         $opts = mc4wp_get_options('form');
         // check if we want to redirect the visitor
         if (!empty($opts['redirect'])) {
             wp_redirect($opts['redirect']);
             exit;
         }
         return true;
     } else {
         return false;
     }
 }
	/**
	 * Acts on the submitted data
	 * - Validates internal fields
	 * - Formats email and merge_vars
	 * - Sends off the subscribe request to MailChimp
	 * - Returns state
	 *
	 * @return bool True on success, false on failure.
	 */
	public function act() {

		// store number of submitted form
		$this->form_instance_number = absint( $_POST['_mc4wp_form_instance'] );

		// store form options
		$this->form_options = mc4wp_get_options( 'form' );

		// validate form nonce
		if ( ! isset( $_POST['_mc4wp_form_nonce'] ) || ! wp_verify_nonce( $_POST['_mc4wp_form_nonce'], '_mc4wp_form_nonce' ) ) {
			$this->error_code = 'invalid_nonce';
			return false;
		}

		// ensure honeypot was not filed
		if ( isset( $_POST['_mc4wp_required_but_not_really'] ) && ! empty( $_POST['_mc4wp_required_but_not_really'] ) ) {
			$this->error_code = 'spam';
			return false;
		}

		// check if captcha was present and valid
		if( isset( $_POST['_mc4wp_has_captcha'] ) && $_POST['_mc4wp_has_captcha'] == 1 && function_exists( 'cptch_check_custom_form' ) && cptch_check_custom_form() !== true ) {
			$this->error_code = 'invalid_captcha';
			return false;
		}

		/**
		 * @filter mc4wp_valid_form_request
		 *
		 * Use this to perform custom form validation.
		 * Return true if the form is valid or an error string if it isn't.
		 * Use the `mc4wp_form_messages` filter to register custom error messages.
		 */
		$valid_form_request = apply_filters( 'mc4wp_valid_form_request', true );
		if( $valid_form_request !== true ) {
			$this->error_code = $valid_form_request;
			return false;
		}

		// get entered form data (sanitized)
		$this->sanitize_form_data();
		$data = $this->get_posted_data();

		// validate email
		if( ! isset( $data['EMAIL'] ) || ! is_email( $data['EMAIL'] ) ) {
			$this->error_code = 'invalid_email';
			return false;
		}

		// setup merge_vars array
		$merge_vars = $data;

		// take email out of $data array, use the rest as merge_vars
		$email = $merge_vars['EMAIL'];
		unset( $merge_vars['EMAIL'] );

		// validate groupings
		if( isset( $data['GROUPINGS'] ) && is_array( $data['GROUPINGS'] ) ) {
			$merge_vars['GROUPINGS'] = $this->format_groupings_data( $data['GROUPINGS'] );
		}

		// subscribe the given email / data combination
		$this->success = $this->subscribe( $email, $merge_vars );

		// do stuff on success
		if( true === $this->success ) {

			// check if we want to redirect the visitor
			if ( ! empty( $this->form_options['redirect'] ) ) {
				wp_redirect( $this->form_options['redirect'] );
				exit;
			}

			// return true on success
			return true;
		}

		// return false on failure
		return false;
	}
Пример #5
0
 /**
  * Validates the request
  *
  * - Nonce validity
  * - Honeypot
  * - Captcha
  * - Email address
  * - Lists (POST and options)
  * - Additional validation using a filter.
  *
  * @return bool
  */
 private function validate()
 {
     // detect caching plugin
     $using_caching = defined('WP_CACHE') && WP_CACHE;
     // validate form nonce, but only if not using caching
     if (!$using_caching && (!isset($this->data['_MC4WP_FORM_NONCE']) || !wp_verify_nonce($this->data['_MC4WP_FORM_NONCE'], '_mc4wp_form_nonce'))) {
         $this->error_code = 'invalid_nonce';
         return false;
     }
     // ensure honeypot was given but not filled
     if (!isset($this->data['_MC4WP_REQUIRED_BUT_NOT_REALLY']) || '' !== $this->data['_MC4WP_REQUIRED_BUT_NOT_REALLY']) {
         $this->error_code = 'spam';
         return false;
     }
     // check timestamp difference, token should be generated at least 2 seconds before form submit
     if (!isset($this->data['_MC4WP_TIMESTAMP']) || time() < intval($this->data['_MC4WP_TIMESTAMP']) + 2) {
         $this->error_code = 'spam';
         return false;
     }
     // check if captcha was present and valid
     if (isset($this->data['_MC4WP_HAS_CAPTCHA']) && $this->data['_MC4WP_HAS_CAPTCHA'] == 1 && function_exists('cptch_check_custom_form') && cptch_check_custom_form() !== true) {
         $this->error_code = 'invalid_captcha';
         return false;
     }
     // validate email
     if (!isset($this->data['EMAIL']) || !is_string($this->data['EMAIL']) || !is_email($this->data['EMAIL'])) {
         $this->error_code = 'invalid_email';
         return false;
     }
     // get lists to subscribe to
     $lists = $this->get_lists();
     if (empty($lists)) {
         $this->error_code = 'no_lists_selected';
         return false;
     }
     /**
      * @filter mc4wp_valid_form_request
      *
      * Use this to perform custom form validation.
      * Return true if the form is valid or an error string if it isn't.
      * Use the `mc4wp_form_messages` filter to register custom error messages.
      */
     $valid_form_request = apply_filters('mc4wp_valid_form_request', true, $this->data);
     if ($valid_form_request !== true) {
         $this->error_code = $valid_form_request;
         return false;
     }
     return true;
 }
										<div id="pass-strength-result" class="hide-if-no-js"><?php 
        _e('Strength indicator', APP_TD);
        ?>
</div>
										<span class="description indicator-hint"><?php 
        _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).', APP_TD);
        ?>
</span>
									</div>
								<?php 
    }
    ?>
								<div class="captchadiv">
                            		<p class="captcha_login" style="text-align:center">
                            	<?php 
    if (function_exists('cptch_check_custom_form') && cptch_check_custom_form() !== true || function_exists('cptchpr_check_custom_form') && cptchpr_check_custom_form() !== true) {
        echo "Please complete the CAPTCHA.";
    }
    ?>
                            		</p>
                            	
                    		 </div>
								<?php 
    do_action('register_form');
    ?>

								<div id="checksave">

									<p class="submit" style="float:right;">
										<input tabindex="6" class="btn_orange" type="submit" name="register" id="register" value="<?php 
    _e('Create Account', APP_TD);
Пример #7
0
/**
 * Check form input
 *
 * @param $captcha
 * @param $errors
 *
 * @return mixed
 */
function wpmtst_captcha_check($captcha, $errors)
{
    switch ($captcha) {
        // Captcha by BestWebSoft
        case 'bwsmath':
            if (function_exists('cptch_check_custom_form') && cptch_check_custom_form() !== true) {
                $errors['captcha'] = __('The Captcha failed. Please try again.', 'strong-testimonials');
            }
            break;
            // Really Simple Captcha by Takayuki Miyoshi
        // Really Simple Captcha by Takayuki Miyoshi
        case 'miyoshi':
            if (class_exists('ReallySimpleCaptcha')) {
                $captcha_instance = new ReallySimpleCaptcha();
                $prefix = isset($_POST['captchac']) ? (string) $_POST['captchac'] : '';
                $response = isset($_POST['captchar']) ? (string) $_POST['captchar'] : '';
                $correct = $captcha_instance->check($prefix, $response);
                if (!$correct) {
                    $errors['captcha'] = __('The Captcha failed. Please try again.', 'strong-testimonials');
                }
                // remove the temporary image and text files (except on Windows)
                if ('127.0.0.1' != $_SERVER['SERVER_ADDR']) {
                    $captcha_instance->remove($prefix);
                }
            }
            break;
            // Advanced noCaptcha reCaptcha by Shamim Hasan
        // Advanced noCaptcha reCaptcha by Shamim Hasan
        case 'advnore':
            if (function_exists('anr_verify_captcha') && !anr_verify_captcha()) {
                $errors['captcha'] = __('The Captcha failed. Please try again.', 'strong-testimonials');
            }
            break;
        default:
    }
    return $errors;
}
Пример #8
0
 public function __actionWPAjaxContactForm()
 {
     if (!isset($this->features['contact-form'])) {
         exit;
     }
     $contact_form = $this->features['contact-form'];
     $options = $this->theme_options->child(array($contact_form['group'], $contact_form['name']));
     $output = function ($result, $message) use($contact_form) {
         echo json_encode(array($contact_form['result_var'] => $result, $contact_form['message_var'] => $message));
         exit;
     };
     $values = array();
     foreach ($options->value('fields') as $field) {
         $value = isset($_POST[$field]) ? trim(strip_tags($_POST[$field])) : '';
         switch ($field) {
             case 'name':
                 if (empty($value)) {
                     $output(false, __('Please enter your name.', $this->domain));
                 }
                 break;
             case 'email':
                 if (!preg_match('/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)+$/i', $value)) {
                     $output(false, __('Invalid email address.', $this->domain));
                 }
                 break;
             case 'website':
                 if (!empty($value) && !preg_match('|^(https?://)?(www\\.)?([-_a-z0-9]+\\.)+[-_a-z0-9]+$|i', $value)) {
                     $output(false, __('Invalid website address.', $this->domain));
                 }
                 break;
             case 'phone':
                 if (!empty($value) && !preg_match('/^[-_#\\+\\*\\(\\)0-9 ]+$/', $value)) {
                     $output(false, __('Invalid phone number.', $this->domain));
                 }
                 break;
             case 'message':
                 if (strlen($value) < 3) {
                     $output(false, __('Please write your message.', $this->domain));
                 }
                 break;
             case 'captcha':
                 if (function_exists('cptch_check_custom_form') && !cptch_check_custom_form()) {
                     $output(false, __('Please complete the captcha.', $this->domain));
                 }
                 break;
         }
         $values[$field] = $value;
     }
     $to = $options->value('to');
     switch ($options->value('from')) {
         case 'to':
             $from = $to;
             break;
         case 'field':
             $from = $values['email'];
             break;
         default:
             $from = get_option('admin_email');
     }
     $reply_to = $values['email'];
     $author = isset($values['name']) ? $values['name'] : '';
     $subject = $options->value('subject');
     $subject = str_replace(array('%blogname%', '%blogurl%'), array(get_bloginfo('name'), home_url()), $subject);
     $subject = preg_replace_callback('/%([a-z]+)%/i', function ($m) use($values) {
         return isset($values[$m[1]]) ? $values[$m[1]] : '';
     }, $subject);
     $subject = wp_specialchars_decode(trim(str_replace(array("\r", "\n"), ' ', $subject)));
     $message = "{$values['message']}\r\n\r\n---\r\n" . implode("\r\n", array_intersect_key($values, array_flip(array_intersect($options->value('fields'), array('name', 'email', 'website', 'phone')))));
     if ($options->child('settings')->value('akismet') && function_exists('akismet_get_key') && akismet_get_key()) {
         $comment = array('blog' => home_url(), 'blog_lang' => get_locale(), 'blog_charset' => get_option('blog_charset'), 'user_ip' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'comment_type' => 'contactform');
         if (isset($values['name'])) {
             $comment['comment_author'] = $values['name'];
         }
         if (isset($values['email'])) {
             $comment['comment_author_email'] = $values['email'];
         }
         if (isset($values['comment_author_url'])) {
             $comment['comment_author_email'] = $values['website'];
         }
         if (isset($values['message'])) {
             $comment['comment_content'] = $values['message'];
         }
         foreach ($_SERVER as $key => $value) {
             if (!in_array($key, array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW')) && is_string($value)) {
                 $comment[$key] = $value;
             } else {
                 $comment[$key] = '';
             }
         }
         $query_string = Func::arraySerialize(array_map('stripslashes', $comment));
         $response = akismet_http_post($query_string, $GLOBALS['akismet_api_host'], '/1.1/comment-check', $GLOBALS['akismet_api_port']);
         if ($response[1] == 'true') {
             $output(false, __('Your message is recognized as spam.', $this->domain));
         }
     }
     $result = @wp_mail($to, $subject, $message, ($options->child('settings')->value('from_header') ? "From: \"{$author}\" <{$from}>\r\n" : '') . "Reply-to: {$reply_to}\r\n" . "Content-type: text/plain; charset=\"" . get_bloginfo('charset') . "\"\r\n");
     if ($result) {
         $output(true, __('Message sent.', $this->domain));
     } else {
         $output(false, __("Error occured. Message couldn't be sent.", $this->domain));
     }
 }
 private function validate_captchabestwebsoft()
 {
     if (function_exists('cptch_check_custom_form') && cptch_check_custom_form() !== true || function_exists('cptchpr_check_custom_form') && cptchpr_check_custom_form() !== true) {
         return false;
     } else {
         return true;
     }
 }
Пример #10
0
 /**
  * Acts on the submitted data
  * - Validates internal fields
  * - Formats email and merge_vars
  * - Sends off the subscribe request to MailChimp
  * - Returns state
  *
  * @return bool True on success, false on failure.
  */
 public function act()
 {
     // detect caching plugin
     $using_caching = defined('WP_CACHE') && WP_CACHE;
     // validate form nonce
     if (!$using_caching && (!isset($_POST['_mc4wp_form_nonce']) || !wp_verify_nonce($_POST['_mc4wp_form_nonce'], '_mc4wp_form_nonce'))) {
         $this->error_code = 'invalid_nonce';
         return false;
     }
     // ensure honeypot was not filed
     if (isset($_POST['_mc4wp_required_but_not_really']) && !empty($_POST['_mc4wp_required_but_not_really'])) {
         $this->error_code = 'spam';
         return false;
     }
     // check if captcha was present and valid
     if (isset($_POST['_mc4wp_has_captcha']) && $_POST['_mc4wp_has_captcha'] == 1 && function_exists('cptch_check_custom_form') && cptch_check_custom_form() !== true) {
         $this->error_code = 'invalid_captcha';
         return false;
     }
     /**
      * @filter mc4wp_valid_form_request
      *
      * Use this to perform custom form validation.
      * Return true if the form is valid or an error string if it isn't.
      * Use the `mc4wp_form_messages` filter to register custom error messages.
      */
     $valid_form_request = apply_filters('mc4wp_valid_form_request', true);
     if ($valid_form_request !== true) {
         $this->error_code = $valid_form_request;
         return false;
     }
     // get entered form data (sanitized)
     $this->sanitize_form_data();
     $data = $this->get_posted_data();
     // validate email
     if (!isset($data['EMAIL']) || !is_string($data['EMAIL']) || !is_email($data['EMAIL'])) {
         $this->error_code = 'invalid_email';
         return false;
     }
     // setup merge_vars array
     $merge_vars = $data;
     // take email out of $data array, use the rest as merge_vars
     $email = $merge_vars['EMAIL'];
     unset($merge_vars['EMAIL']);
     // validate groupings
     if (isset($data['GROUPINGS']) && is_array($data['GROUPINGS'])) {
         $merge_vars['GROUPINGS'] = $this->format_groupings_data($data['GROUPINGS']);
     }
     // subscribe the given email / data combination
     $this->success = $this->subscribe($email, $merge_vars);
     // do stuff on success
     if (true === $this->success) {
         // check if we want to redirect the visitor
         if (!empty($this->form_options['redirect'])) {
             wp_redirect($this->form_options['redirect']);
             exit;
         }
         // return true on success
         return true;
     }
     /**
      * @action mc4wp_form_error_{ERROR_CODE}
      *
      * Use to hook into various sign-up errors. Hook names are:
      *
      * - mc4wp_form_error_error                     General errors
      * - mc4wp_form_error_invalid_email             Invalid email address
      * - mc4wp_form_error_already_subscribed        Email is already on selected list(s)
      * - mc4wp_form_error_required_field_missing    One or more required fields are missing
      * - mc4wp_form_error_no_lists_selected         No MailChimp lists were selected
      *
      * @param   int     $form_id        The ID of the submitted form
      * @param   string  $email          The email of the subscriber
      * @param   array   $merge_vars     Additional list fields, like FNAME etc (if any)
      */
     do_action('mc4wp_form_error_' . $this->get_error_code(), 0, $email, $merge_vars);
     // return false on failure
     return false;
 }
  $_POST["company_name"] =  stripslashes(trim($_POST["company_name"]));
 $_POST["address"] =  stripslashes(trim($_POST["address"]));
  $_POST["phone"] =  stripslashes(trim($_POST["phone"]));
  $_POST["company_type"] =  stripslashes(trim($_POST["company_type"]));
  $_POST["country"] =  stripslashes(trim($_POST["country"]));
   $_POST["email"] =  stripslashes(trim($_POST["email"]));
  $_POST["password"] =  stripslashes(trim($_POST["password"]));
  $_POST["repassword"] =  stripslashes(trim($_POST["repassword"]));
  
  // Clear any prior errors
  // Do not proceed reasons
  // 1: empty field
  // 2: invalid email
  // 3: passwords are different
  // 4: email already in database
   if( function_exists( 'cptch_check_custom_form' ) && cptch_check_custom_form() !== true ) {    $proceed = false;    $reason = 5;  }
  // test if email is already registered
  if (qcs_email_exists($_POST["email"])) {
    $proceed = false;
    $reason = 4;      
  }

  // Check the name input for problems.
  if ( !is_email($_POST["email"])) { 
    $proceed = false;
    $reason = 2;  
  }

  if (empty($_POST["firstname"])) {
    $proceed = false;
    $reason = 1;
Пример #12
0
 /**
 * login user into website
 # used wp_signon
 # used AE_Users function convert
 * @param   array $user data
 # wordpress user fields data
 # user custom meta data
 * @return  user object after insert
 # wp_error object if user data invalid
 * @author Dakachi
 * @since 1.0
 */
 public function login($user_data)
 {
     global $current_user;
     // echo 'login';
     // check users if he is member of this blog
     $user = get_user_by('login', $user_data['user_login']);
     // if login by username failed check by email
     if (is_wp_error($user) || !$user) {
         $user = get_user_by('email', $user_data['user_login']);
     }
     /**
      * check user infomation
      */
     if (!$user) {
         return new WP_Error('login_failed', __("The login information you entered were incorrect. Please try again!", 'aecore-class-ae-users-backend'));
     }
     if (function_exists('cptch_check_custom_form') && cptch_check_custom_form() !== true || function_exists('cptchpr_check_custom_form') && cptchpr_check_custom_form() !== '') {
         return new WP_Error('cptch_check_custom_form', __("Please complete the CAPTCHA.", 'aecore-class-ae-users-backend'));
     }
     if (is_multisite() && !is_user_member_of_blog($user->ID)) {
         $roles = $user->roles;
         $role = array_pop($roles);
         add_user_to_blog(get_current_blog_id(), $user->ID, $role);
     }
     $user_login = $user->user_login;
     $creds = array();
     $creds['user_login'] = $user_login;
     $creds['user_password'] = $user_data['user_pass'];
     $creds['remember'] = true;
     $result = wp_signon($creds, false);
     /**
      * get user data and return a full profile
      */
     if ($result && !is_wp_error($result)) {
         // set current user to logged in
         wp_set_current_user($result->ID);
         $result = $this->convert($result);
         /**
          * action ae_login_user 
          * @param Object $result User object
          * @author Dakachi
          */
         do_action('ae_login_user', $result);
     }
     if (!isset($result->msg)) {
         $result->msg = __("You have signed in successfully!", 'aecore-class-ae-users-backend');
     }
     return apply_filters('ae_after_login_user', $result);
 }