예제 #1
0
 public function check()
 {
     $config = RMFunctions::get()->plugin_settings('recaptcha', true);
     $this->set_config();
     include_once RMCPATH . '/plugins/ayah/include/ayah.php';
     $ayah = new AYAH();
     $ayah->debug_mode($config['debug']);
     $resp = $ayah->scoreResult();
     return $resp;
 }
예제 #2
0
 public function eventRmcommonCaptchaCheck($value)
 {
     global $xoopsUser;
     $config = RMFunctions::get()->plugin_settings('ayah', true);
     if ($xoopsUser && $xoopsUser->isAdmin() && !$config['show']) {
         return $value;
     }
     self::set_config();
     include_once RMCPATH . '/plugins/ayah/include/ayah.php';
     $ayah = new AYAH();
     $ayah->debug_mode($config['debug']);
     $resp = $ayah->scoreResult();
     return $resp;
 }
예제 #3
0
         }
         break;
     case 'reCaptcha':
         $data["captcha"] = str_replace('<:: your_site_key ::>', $data["recaptcha_public_key"], $recaptcha_template);
         if (array_key_exists('address', $_POST)) {
             $url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . $data["recaptcha_private_key"] . '&response=' . (array_key_exists('g-recaptcha-response', $_POST) ? $_POST["g-recaptcha-response"] : '') . '&remoteip=' . getIP();
             $resp = json_decode(file_get_contents($url), true);
             $data['captcha_valid'] = $resp['success'];
         }
         break;
     case 'AreYouAHuman':
         require_once "libs/ayahlib.php";
         $ayah = new AYAH(array('publisher_key' => $data['ayah_publisher_key'], 'scoring_key' => $data['ayah_scoring_key'], 'web_service_host' => 'ws.areyouahuman.com', 'debug_mode' => false, 'use_curl' => !$connection_options['disable_curl']));
         $data['captcha'] = $ayah->getPublisherHTML();
         if (array_key_exists('address', $_POST)) {
             $score = $ayah->scoreResult();
             $data['captcha_valid'] = $score;
         }
         break;
     case 'FunCaptcha':
         require_once "libs/funcaptcha.php";
         $funcaptcha = new FUNCAPTCHA();
         $data["captcha"] = $funcaptcha->getFunCaptcha($data["funcaptcha_public_key"]);
         if (array_key_exists('address', $_POST)) {
             $data['captcha_valid'] = $funcaptcha->checkResult($data["funcaptcha_private_key"]);
         }
         break;
 }
 $data['captcha_info'] = $captcha;
 if ($data['captcha'] && $data['apikey'] && $data['rewards']) {
     $data['enabled'] = true;
예제 #4
0
         if (!$theDropbox->authorizedUser()) {
             NSSError($smarty->getConfigVariable('ErrorRequestUsed'), "Verify error");
         } else {
             NSSError($smarty->getConfigVariable('ErrorRequestUsedLogin'), "Request Code error");
         }
     }
 }
 //
 // If posted form data is around, creating a new dropoff instance
 // creates a new dropoff using said form data.
 //
 if (!$theDropbox->authorizedUser()) {
     $captcha = $theDropbox->captcha();
     $resp = FALSE;
     if ($captcha === 'areyouahuman') {
         $resp = $ayah->scoreResult();
     } elseif ($captcha === 'google' || $captcha === '') {
         // Google or not set at all, so using old version
         $reCaptchaPrivateKey = $theDropbox->recaptchaPrivateKey();
         if ($reCaptchaPrivateKey === 'disabled') {
             $resp = TRUE;
         } else {
             $resp = recaptcha_check_answer($reCaptchaPrivateKey, $_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
         }
     } else {
         // Must be disabled
         $resp = TRUE;
     }
     if ($resp && ($theVerify = new Verify($theDropbox))) {
         // They passed the Captcha so send them on their way if at all possible!
         if ($theVerify->formInitError() != "") {
예제 #5
0
 /**
  * Internal element validation
  *
  * @param   array $data          form data
  * @param   int   $repeatCounter repeat group counter
  *
  * @return bool
  */
 public function validate($data, $repeatCounter = 0)
 {
     $params = $this->getParams();
     $input = $this->app->input;
     if (!$this->canUse()) {
         return true;
     }
     if ($params->get('captcha-method') == 'recaptcha') {
         if (!function_exists('_recaptcha_qsencode')) {
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/recaptcha-php-1.11/recaptchalib.php';
         }
         $privateKey = $params->get('recaptcha_privatekey');
         if ($input->get('recaptcha_response_field')) {
             $challenge = $input->get('recaptcha_challenge_field');
             $response = $input->get('recaptcha_response_field');
             $resp = recaptcha_check_answer($privateKey, FabrikString::filteredIp(), $challenge, $response);
             return $resp->is_valid ? true : false;
         }
         return false;
     } elseif ($params->get('captcha-method') == 'nocaptcha') {
         if ($input->get('g-recaptcha-response')) {
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/ReCaptcha.php';
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/RequestMethod.php';
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/RequestMethod/Post.php';
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/RequestParameters.php';
             require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ReCaptcha/Response.php';
             $privateKey = $params->get('recaptcha_privatekey');
             $noCaptcha = new \ReCaptcha\ReCaptcha($privateKey);
             $response = $input->get('g-recaptcha-response');
             $server = $input->server->get('REMOTE_ADDR');
             $resp = $noCaptcha->verify($response, $server);
             if ($resp->isSuccess()) {
                 return true;
             } else {
                 if (FabrikHelperHTML::isDebug()) {
                     $msg = "noCaptcha error: ";
                     foreach ($resp->getErrorCodes() as $code) {
                         $msg .= '<tt>' . $code . '</tt> ';
                     }
                     $this->app->enqueueMessage($msg);
                 }
                 return false;
             }
         }
         if (FabrikHelperHTML::isDebug()) {
             $this->app->enqueueMessage("No g-recaptcha-response!");
         }
         return false;
     } elseif ($params->get('captcha-method') == 'playthru') {
         if (!defined('AYAH_PUBLISHER_KEY')) {
             define('AYAH_PUBLISHER_KEY', $params->get('playthru_publisher_key', ''));
             define('AYAH_SCORING_KEY', $params->get('playthru_scoring_key', ''));
         }
         require_once JPATH_SITE . '/plugins/fabrik_element/captcha/libs/ayah_php_bundle_1.1.7/ayah.php';
         $ayah = new AYAH();
         return $ayah->scoreResult();
     } else {
         $this->getParams();
         if ($this->session->get('com_' . $this->package . '.element.captcha.security_code', null) != $data) {
             return false;
         }
         return true;
     }
 }
예제 #6
0
 public function doCaptcha($display = true)
 {
     $captcha = parent::getOption('integration-captcha');
     switch ($captcha) {
         case 'reCAPTCHA':
             require_once 'captcha/recaptcha-1.11/recaptchalib.php';
             $publickey = parent::getOption('reCAPTCHA-public-key');
             $privatekey = parent::getOption('reCAPTCHA-private-key');
             /* Captcha has been submitted. */
             if (!empty($_POST['recaptcha_response_field'])) {
                 $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
                 if (!$resp->is_valid) {
                     $this->captchaError = $resp->error;
                 }
             } else {
                 $this->captchaError = true;
             }
             if ($display) {
                 echo recaptcha_get_html($publickey, $this->captchaError);
             }
             break;
         case 'playThru':
             if (!defined('AYAH_PUBLISHER_KEY')) {
                 define('AYAH_PUBLISHER_KEY', parent::getOption('playThru-publisher-key'));
             }
             if (!defined('AYAH_SCORING_KEY')) {
                 define('AYAH_SCORING_KEY', parent::getOption('playThru-scoring-key'));
             }
             if (!defined('AYAH_WEB_SERVICE_HOST')) {
                 define('AYAH_WEB_SERVICE_HOST', 'ws.areyouahuman.com');
             }
             require_once 'captcha/ayah-1.0.2/ayah.php';
             $integration = new AYAH();
             if (!$display && !empty($_POST) && !$integration->scoreResult()) {
                 $this->captchaError = true;
             }
             /* Show the captcha form. */
             if ($display) {
                 echo $integration->getPublisherHTML();
             }
             break;
     }
 }
예제 #7
0
 /**
  * @return bool
  */
 function validate_captcha()
 {
     global $db, $lang, $mybb, $session, $plugins;
     $plugins->run_hooks('captcha_validate_start', $this);
     if ($this->type == 1) {
         // We have a normal CAPTCHA to handle
         $imagehash = $db->escape_string($mybb->input['imagehash']);
         $imagestring = $db->escape_string(my_strtolower($mybb->input['imagestring']));
         switch ($db->type) {
             case 'mysql':
             case 'mysqli':
                 $field = 'imagestring';
                 break;
             default:
                 $field = 'LOWER(imagestring)';
                 break;
         }
         $query = $db->simple_select("captcha", "*", "imagehash = '{$imagehash}' AND {$field} = '{$imagestring}'");
         $imgcheck = $db->fetch_array($query);
         if (!$imgcheck) {
             $this->set_error($lang->invalid_captcha_verify);
             $db->delete_query("captcha", "imagehash = '{$imagehash}'");
         }
     } elseif ($this->type == 2) {
         $challenge = $mybb->input['recaptcha_challenge_field'];
         $response = $mybb->input['recaptcha_response_field'];
         if (!$challenge || strlen($challenge) == 0 || !$response || strlen($response) == 0) {
             $this->set_error($lang->invalid_captcha);
         } else {
             // We have a reCAPTCHA to handle
             $data = $this->_qsencode(array('privatekey' => $mybb->settings['captchaprivatekey'], 'remoteip' => $session->ipaddress, 'challenge' => $challenge, 'response' => $response));
             // Contact Google and see if our reCAPTCHA was successful
             $http_request = "POST /recaptcha/api/verify HTTP/1.0\r\n";
             $http_request .= "Host: {$this->verify_server}\r\n";
             $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
             $http_request .= "Content-Length: " . strlen($data) . "\r\n";
             $http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
             $http_request .= "\r\n";
             $http_request .= $data;
             $fs = @fsockopen($this->verify_server, 80, $errno, $errstr, 10);
             if ($fs == false) {
                 $this->set_error($lang->invalid_captcha_transmit);
             } else {
                 // We connected, but is it correct?
                 fwrite($fs, $http_request);
                 while (!feof($fs)) {
                     $response .= fgets($fs, 1160);
                 }
                 fclose($fs);
                 $response = explode("\r\n\r\n", $response, 2);
                 $answer = explode("\n", $response[1]);
                 if (trim($answer[0]) != 'true') {
                     // We got it wrong! Oh no...
                     $this->set_error($lang->invalid_captcha_verify);
                 }
             }
         }
     } elseif ($this->type == 4) {
         $response = $mybb->input['g-recaptcha-response'];
         if (!$response || strlen($response) == 0) {
             $this->set_error($lang->invalid_nocaptcha);
         } else {
             // We have a noCAPTCHA to handle
             // Contact Google and see if our reCAPTCHA was successful
             $response = fetch_remote_file($this->verify_server, array('secret' => $mybb->settings['captchaprivatekey'], 'remoteip' => $session->ipaddress, 'response' => $response));
             if ($response == false) {
                 $this->set_error($lang->invalid_nocaptcha_transmit);
             } else {
                 $answer = json_decode($response, true);
                 if ($answer['success'] != 'true') {
                     // We got it wrong! Oh no...
                     $this->set_error($lang->invalid_nocaptcha);
                 }
             }
         }
     } elseif ($this->type == 3) {
         define('AYAH_PUBLISHER_KEY', $this->ayah_publisher_key);
         define('AYAH_SCORING_KEY', $this->ayah_scoring_key);
         define('AYAH_USE_CURL', $this->ayah_use_curl);
         define('AYAH_DEBUG_MODE', $this->ayah_debug_mode);
         define('AYAH_WEB_SERVICE_HOST', $this->ayah_web_service_host);
         require_once MYBB_ROOT . "inc/3rdparty/ayah/ayah.php";
         $ayah = new AYAH();
         $result = $ayah->scoreResult();
         if ($result == false) {
             $this->set_error($lang->invalid_ayah_result);
         }
     }
     $plugins->run_hooks('captcha_validate_end', $this);
     if (count($this->errors) > 0) {
         return false;
     } else {
         return true;
     }
 }
예제 #8
0
function form_antibot($title = false, $input_name, $input_id, $input_value = false, $array = false)
{
    /* To do
    * To do: label off
    * Note: DO NOT USE DISABLED, it will not pass information to server. Use "readonly" instead.
    */
    global $_POST;
    if (isset($title) && $title !== "") {
        $title = stripinput($title);
    } else {
        $title = "";
    }
    if (isset($input_name) && $input_name !== "") {
        $input_name = stripinput($input_name);
    } else {
        $input_name = "";
    }
    if (isset($input_id) && $input_id !== "") {
        $input_id = stripinput($input_id);
    } else {
        $input_id = "";
    }
    if (isset($input_value) && $input_value !== "") {
        $input_value = stripinput($input_value);
    } else {
        $input_value = "";
    }
    // 4 choices to sub-array
    // a. icon, b. button, c.dropdown list d.dropdown with modal
    if (!is_array($array)) {
        $array = array();
        $state_validation = "";
        $before = "";
        $after = "";
        $required = "";
        $placeholder = "";
        $deactivate = "";
        $width = "";
        $class = "input-sm";
        $well = "";
        $type = "";
        $stacking = "";
    } else {
        $before = array_key_exists('before', $array) ? $array['before'] : "";
        $after = array_key_exists('after', $array) ? $array['after'] : "";
        $placeholder = array_key_exists('placeholder', $array) ? $array['placeholder'] : "";
        $deactivate = array_key_exists('deactivate', $array) ? $array['deactivate'] : "";
        $class = array_key_exists('class', $array) ? $array['class'] : "input-sm";
        $required = array_key_exists('required', $array) ? $array['required'] : "";
        $width = array_key_exists('width', $array) ? "style='width: " . $array['width'] . "'" : "";
        $well = array_key_exists('well', $array) ? "style='margin-top:-10px;'" : "";
        $type = array_key_exists('password', $array) && $array['password'] == "1" ? "password" : "text";
        $stacking = array_key_exists("stacking", $array) ? 1 : "";
    }
    if ($required == "1" && (isset($_POST[$input_name]) && empty($_POST[$input_name]))) {
        $state_validation = "has-error";
    } else {
        $state_validation = "";
    }
    if ($stacking == "1") {
        $col = "col-sm-12 col-md-12 col-lg-12";
        $col2 = "col-sm-12 col-md-12 col-lg-12";
    } else {
        $col = "col-sm-12 col-md-3 col-lg-3 control-label";
        $col2 = "col-sm-12 col-md-9 col-lg-9";
    }
    // Append/Prepend Plugin API
    if (!empty($before) || !empty($after)) {
        $init_bs3 = "<div class='input-group'>";
        $end_bs3 = "</div>";
    } else {
        // cancel plugin
        $init_bs3 = "";
        $end_bs3 = "";
    }
    $html = "";
    if (!empty($title)) {
        $html .= "<div class='form-group " . $state_validation . "'>";
        $html .= "<label for='{$input_id}-0' class='{$col}'>{$title}</label>";
        $html .= "<div class='{$col2}' {$well}>";
    }
    // Are you a human
    require_once INCLUDES . "captchas/ayah/ayah.php";
    $ayah = new AYAH();
    if (array_key_exists('ayah_submit', $_POST)) {
        $score = $ayah->scoreResult();
        if ($score) {
            $html = "Congratulations: you are a human!";
        } else {
            $html = "Sorry, but we were not able to verify you as human. Please try again.";
        }
    }
    $html .= "<div class='row'>";
    $html .= "<div class='col-sm-12 col-md-12 col-lg-12'>";
    $html .= $ayah->getPublisherHTML();
    $html .= "</div>";
    $html .= "</div>";
    if (!empty($title)) {
        $html .= "</div></div>";
    }
    return $html;
}
예제 #9
0
function ust_signup_errorcheck_bp()
{
    global $bp;
    $ust_settings = get_site_option("ust_settings");
    if ($ust_settings['signup_protect'] == 'recaptcha') {
        //check reCAPTCHA
        $recaptcha = get_site_option('ust_recaptcha');
        require_once 'includes/recaptchalib.php';
        $resp = rp_recaptcha_check_answer($recaptcha['privkey'], $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
        if (!$resp->is_valid) {
            $bp->signup->errors['recaptcha'] = __("The reCAPTCHA wasn't entered correctly. Please try again.", 'ust');
        }
    } else {
        if ($ust_settings['signup_protect'] == 'asirra') {
            require_once 'includes/asirra.php';
            $asirra = new AsirraValidator($_POST['Asirra_Ticket']);
            if (!$asirra->passed) {
                $bp->signup->errors['asirra'] = __("Please try to correctly identify the cats again.", 'ust');
            }
        } else {
            if ($ust_settings['signup_protect'] == 'questions') {
                $ust_qa = get_site_option("ust_qa");
                if (is_array($ust_qa) && count($ust_qa)) {
                    //check the encrypted answer field
                    $salt = get_site_option("ust_salt");
                    $datesalt = strtotime(date('Y-m-d H:00:00'));
                    $valid_fields = false;
                    foreach ($ust_qa as $qkey => $answer) {
                        $field_name = 'qa_' . md5($qkey . $salt . $datesalt);
                        if (isset($_POST[$field_name])) {
                            if (strtolower(trim($_POST[$field_name])) != strtolower(stripslashes($answer[1]))) {
                                $bp->signup->errors['qa'] = __("Incorrect Answer. Please try again.", 'ust');
                            }
                            $valid_fields = true;
                        }
                    }
                    //if no fields are valid try again for previous hour
                    if (!$valid_fields) {
                        $datesalt = strtotime('-1 hour', $datesalt);
                        foreach ($ust_qa as $qkey => $answer) {
                            $field_name = 'qa_' . md5($qkey . $salt . $datesalt);
                            if (isset($_POST[$field_name])) {
                                if (strtolower(trim($_POST[$field_name])) != strtolower(stripslashes($answer[1]))) {
                                    $bp->signup->errors['qa'] = __("Incorrect Answer. Please try again.", 'ust');
                                }
                            }
                        }
                    }
                }
            } else {
                if ($ust_settings['signup_protect'] == 'ayah') {
                    $ust_ayah = get_site_option("ust_ayah");
                    require_once "includes/ayah.php";
                    $integration = new AYAH(array("publisher_key" => @$ust_ayah['pubkey'], "scoring_key" => @$ust_ayah['privkey']));
                    $score = $integration->scoreResult();
                    if (!$score) {
                        $bp->signup->errors['ayah'] = __("The Are You a Human test wasn't entered correctly. Please try again.", 'ust');
                    }
                }
            }
        }
    }
}
 /**
  * Determines if the Catpcha was a pass.
  *
  * @return {bool} True if the Catpcha was a pass
  */
 function passCaptcha()
 {
     $ayah = new AYAH();
     return $ayah->scoreResult();
 }