public function IsValid()
 {
     $this->Errors = array();
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         return false;
     }
     //check nonce
     if (!wp_verify_nonce($_POST['cscf_nonce'], 'cscf_contact')) {
         return false;
     }
     // email and confirm email are the same
     if (cscf_PluginSettings::ConfirmEmail()) {
         if ($this->Email != $this->ConfirmEmail) {
             $this->Errors['confirm-email'] = __('Sorry the email addresses do not match.', 'cleanandsimple');
         }
     }
     //email
     if (strlen($this->Email) == 0) {
         $this->Errors['email'] = __('Please give your email address.', 'cleanandsimple');
     }
     //confirm email
     if (cscf_PluginSettings::ConfirmEmail()) {
         if (strlen($this->ConfirmEmail) == 0) {
             $this->Errors['confirm-email'] = __('Please confirm your email address.', 'cleanandsimple');
         }
     }
     //name
     if (strlen($this->Name) == 0) {
         $this->Errors['name'] = __('Please give your name.', 'cleanandsimple');
     }
     //message
     if (strlen($this->Message) == 0) {
         $this->Errors['message'] = __('Please enter a message.', 'cleanandsimple');
     }
     //email invalid address
     if (strlen($this->Email) > 0 && !filter_var($this->Email, FILTER_VALIDATE_EMAIL)) {
         $this->Errors['email'] = __('Please enter a valid email address.', 'cleanandsimple');
     }
     //check recaptcha but only if we have keys
     if ($this->RecaptchaPublicKey != '' && $this->RecaptchaPrivateKey != '') {
         $resp = cscf_recaptcha_check_answer($this->RecaptchaPrivateKey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
         if (!$resp->is_valid) {
             $this->Errors['recaptcha'] = __('Sorry the code wasn\'t entered correctly please try again.', 'cleanandsimple');
         }
     }
     return count($this->Errors) == 0;
 }
示例#2
0
 public function IsValid()
 {
     $this->Errors = array();
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         return false;
     }
     //check nonce
     if (!wp_verify_nonce($_POST['cscf_nonce'], 'cscf_contact')) {
         return false;
     }
     // email and confirm email are the same
     if (cscf_PluginSettings::ConfirmEmail()) {
         if ($this->Email != $this->ConfirmEmail) {
             $this->Errors['confirm-email'] = __('ელ-ფოსტა არ ემთხვევა.', 'cleanandsimple');
         }
     }
     //email
     if (strlen($this->Email) == 0) {
         $this->Errors['email'] = __('ელ-ფოსტა ცარიელია.', 'cleanandsimple');
     }
     //confirm email
     if (cscf_PluginSettings::ConfirmEmail()) {
         if (strlen($this->ConfirmEmail) == 0) {
             $this->Errors['confirm-email'] = __('გთხოვთ, გაიმეოროთ ელ-ფოსტა.', 'cleanandsimple');
         }
     }
     //name
     if (strlen($this->Name) == 0) {
         $this->Errors['name'] = __('სახელი ცარიელია.', 'cleanandsimple');
     }
     //message
     if (strlen($this->Message) == 0) {
         $this->Errors['message'] = __('შეტყობინება ცარიელია.', 'cleanandsimple');
     }
     //email invalid address
     if (strlen($this->Email) > 0 && !filter_var($this->Email, FILTER_VALIDATE_EMAIL)) {
         $this->Errors['email'] = __('ელ-ფოსტა არასწორია.', 'cleanandsimple');
     }
     //check recaptcha but only if we have keys
     if ($this->RecaptchaPublicKey != '' && $this->RecaptchaPrivateKey != '') {
         $resp = cscf_recaptcha_check_answer($this->RecaptchaPrivateKey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
         if (!$resp->is_valid) {
             $this->Errors['recaptcha'] = __('კოდი არასწორია. გთხოვთ, სცადოთ თავიდან.', 'cleanandsimple');
         }
     }
     return count($this->Errors) == 0;
 }