Example #1
0
function dekoBokoActivate()
{
    $autoLoaderPath = dirname(__FILE__) . '/../toppa-plugin-libraries-for-wordpress/ToppaAutoLoaderWp.php';
    if (!function_exists('spl_autoload_register')) {
        trigger_error('You must have at least PHP 5.1.2 to use Deko Boko (this is not actually a PHP error)', E_USER_ERROR);
    } else {
        if (version_compare(get_bloginfo('version'), '3.0', '<')) {
            trigger_error('You must have at least WordPress 3.0 to use Deko Boko (this is not actually a PHP error)', E_USER_ERROR);
        } else {
            if (!file_exists($autoLoaderPath)) {
                trigger_error('You must install the plugin "Toppa Plugin Libraries for WordPress" to use Deko Boko (this is not actually a PHP error)', E_USER_ERROR);
            } else {
                require_once $autoLoaderPath;
                $toppaAutoLoader = new ToppaAutoLoaderWp('/toppa-plugin-libraries-for-wordpress');
                $dekoBokoAutoLoader = new ToppaAutoLoaderWp('/deko-boko-a-recaptcha-contact-form-plugin');
                $functionsFacade = new ToppaFunctionsFacadeWp();
                $dekoBoko = new DekoBoko($functionsFacade);
                $dekoBoko->install();
            }
        }
    }
}
Example #2
0
 /**
  * Checks the re-captcha response and checks for bad or malicious data
  * submissions.
  *
  * @static
  * @access public
  * @uses recaptchalib::recaptcha_check_answer()
  * @uses recaptchalib::is_valid()
  * @uses DekoBoko::checkHeader()
  * @uses DekoBoko::checkEmail()
  * @returns boolean|array true if message is safe; array of error messages if not
  */
 function checkMessage($recaptcha_options, $headers)
 {
     $errors = array();
     $resp = recaptcha_check_answer($recaptcha_options['privkey'], $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
     if (!$resp->is_valid) {
         $errors[] = "<strong>" . __("ReCAPTCHA error", DEKOBOKO_L10N_NAME) . ":</strong> " . __("your captcha response was incorrect - please try again", DEKOBOKO_L10N_NAME);
     }
     if (!wp_verify_nonce($_POST['dekoboko_nonce'], 'dekoboko_nonce')) {
         $errors[] = "<strong>" . __("Invalid Nonce", DEKOBOKO_L10N_NAME) . "</strong>";
     }
     foreach ($headers as $header) {
         if (DekoBoko::checkHeader($_POST['dekoboko_required'][$header]) === false) {
             $errors[] = "<strong>{$header}</strong> " . __("header contains malicious data", DEKOBOKO_L10N_NAME);
         }
         if (DekoBoko::checkHeader($_POST['dekoboko_optional'][$header]) === false) {
             $errors[] = "<strong>{$header}</strong> " . __("header contains malicious data", DEKOBOKO_L10N_NAME);
         }
     }
     foreach ($_POST['dekoboko_required'] as $k => $v) {
         if (!strlen($v)) {
             $errors[] = __("Required field", DEKOBOKO_L10N_NAME) . " <strong>{$k}</strong> " . __("is blank", DEKOBOKO_L10N_NAME);
         }
         if (strlen($v) && $k == 'email') {
             if (DekoBoko::checkEmail($v) == 0) {
                 // htmlentities for XSS protection
                 $errors[] = "<strong>" . htmlentities($v) . "</strong> " . __("is not a valid email address", DEKOBOKO_L10N_NAME);
             }
         }
     }
     if (!empty($errors)) {
         return $errors;
     }
     return true;
 }