示例#1
0
 public static function checkAnswer()
 {
     // global private key of ThinPHP subscription from reCAPTCHA. You can use this.
     $privatekey = "6LfUVcISAAAAABtSNKYdZIcbfo8-_qA5kkg8ONPM";
     $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
     return $resp->is_valid;
 }
 private function reCaptcha()
 {
     require_once '/var/www/html/laravel/app/library/recaptchalib.php';
     $privatekey = "6LdaP_oSAAAAAE3zyUWf_XpZmVE_Qbbj7ggRIoiC";
     $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], Input::get("recaptcha_challenge_field"), Input::get("recaptcha_response_field"));
     return array('valid' => $resp->is_valid, 'error' => $resp->error);
 }
 function ValidateCaptcha($Value = NULL)
 {
     require_once PATH_LIBRARY . '/vendors/recaptcha/functions.recaptchalib.php';
     $CaptchaPrivateKey = C('Garden.Registration.CaptchaPrivateKey', '');
     $Response = recaptcha_check_answer($CaptchaPrivateKey, Gdn::Request()->IpAddress(), Gdn::Request()->Post('recaptcha_challenge_field', ''), Gdn::Request()->Post('recaptcha_response_field', ''));
     return $Response->is_valid ? TRUE : 'The reCAPTCHA value was not entered correctly. Please try again.';
 }
示例#4
0
 function grab_value()
 {
     if ($this->keys_available()) {
         $request = $this->get_request();
         if (!empty($request["recaptcha_challenge_field"]) && !empty($request["recaptcha_response_field"])) {
             $resp = recaptcha_check_answer($this->get_private_key(), $_SERVER["REMOTE_ADDR"], $request["recaptcha_challenge_field"], $request["recaptcha_response_field"]);
             if ($resp->is_valid) {
                 return 1;
             } else {
                 if ($resp->error == 'invalid-site-private-key') {
                     trigger_error("The reCAPTCHA challenge was ignored - reCAPTCHA reports that your site private key is invalid.");
                 } elseif ($resp->error == 'invalid-request-cookie') {
                     // lets remove this trigger since this can happens often with the non-javascript version.
                     //trigger_error ("Recaptcha challenge parameter was not correctly passed - make sure reCAPTCHA is properly configured.");
                     $this->set_error("The reCAPTCHA wasn't entered correctly. Please try again.");
                 } elseif ($resp->error == 'incorrect-captcha-sol') {
                     $this->set_error("The reCAPTCHA wasn't entered correctly. Please try again.");
                 }
             }
         } else {
             $this->set_error("You must respond to the reCAPTCHA challenge question to complete the form");
         }
         return 0;
     }
 }
 public function conta_click($url, $captcha)
 {
     global $db_host, $db_user, $db_pass, $db_name;
     $this->Open($db_host, $db_user, $db_pass, $db_name);
     if (@$_POST['send'] == 1) {
         //Anti Flood
         $privatekey = "6Lc7yMASAAAAANiJ4_F-BbnxvC3hUlxdAT85PCUE";
         $userip = $_SERVER["REMOTE_ADDR"];
         $reCAPTCHA_f = $_POST["recaptcha_challenge_field"];
         $reCAPTCHA_r = $_POST["recaptcha_response_field"];
         $resp = recaptcha_check_answer($privatekey, $userip, $reCAPTCHA_f, $reCAPTCHA_r);
         if (!$resp->is_valid) {
             die("<br /><br /><center>Errore! Captcha Inserito non corretto!\n<br />Errore reCaptcha: " . $resp->error . "<br />\n<a href=\"index.php?page=visita&go_url=" . @$_GET['go_url'] . "\">Riprova</a></center>");
         }
         //Hijacking control - Thanks gabry9191 for the bug
         $this->check_url($this->mysql_parse($url));
         $url = $this->mysql_parse($url);
         $num_click = $this->Query("SELECT `num_click` FROM page_rank_hack WHERE site = '{$url}'");
         $row = mysql_fetch_row($num_click);
         $app = $row[0] + 1;
         $sql = $this->Query("UPDATE `page_rank_hack` SET num_click = '{$app}' WHERE site = '{$url}'");
         die(header('Location: ' . $url));
     } else {
         $publickey = "6Lc7yMASAAAAAPYmegj3CxwkLJlg3demRNHEzsUd";
         print "\n<center>" . "\n<h2 align=\"center\">Captcha Security (Anti-Flood)</h2><br /><br />\n" . "\n<form method=\"POST\" action=\"index.php?page=visita&go_url=" . htmlspecialchars($_GET['go_url']) . "\" />" . "\n";
         print recaptcha_get_html($publickey);
         print "<br />" . "\n<input type=\"hidden\" name=\"send\" value=\"1\" />" . "\n<input type=\"submit\" value=\"Visita\" />" . "\n</form>" . "\n</center>" . "";
     }
 }
示例#6
0
function faucet_valid_captcha($SETTINGS, $remote_address, $captcha_data = array())
{
    $isGood = false;
    if ($SETTINGS->config["use_captcha"]) {
        if ($SETTINGS->config["captcha"] == "recaptcha") {
            //Load re-captcha library
            require_once './libraries/recaptchalib.php';
            $resp = @recaptcha_check_answer($SETTINGS->config["captcha_config"]["recpatcha_private_key"], $remote_address, $captcha_data['recaptcha_challenge_field'], $captcha_data['recaptcha_response_field']);
            $isGood = $resp->is_valid;
            // $resp->error;
        } elseif ($SETTINGS->config["captcha"] == "solvemedia") {
            //Load solvemedia library
            require_once './libraries/solvemedialib.php';
            $resp = @solvemedia_check_answer($SETTINGS->config["captcha_config"]["solvemedia_private_key"], $remote_address, $captcha_data['adcopy_challenge'], $captcha_data['adcopy_response'], $SETTINGS->config["captcha_config"]["solvemedia_hash_key"]);
            $isGood = $resp->is_valid;
            // $resp->error;
        } else {
            //Load simple captcha library
            @session_name($SETTINGS->config["captcha_config"]["simple_captcha_session_name"]);
            @session_start();
            $isGood = $captcha_data['captcha_code'] == @$_SESSION['captcha']['code'];
            //Prevent re-submissions
            unset($_SESSION['captcha']['code']);
        }
    } else {
        //If no CAPTCHA is in use, then return true
        $isGood = true;
    }
    return $isGood;
}
 public function validate($row, $postData)
 {
     $ret = parent::validate($row, $postData);
     $sess = new Kwf_Session_Namespace('recaptcha');
     if ($sess->validated) {
         //if user did solve one captcha we store that in session and don't annoy him again
         return $ret;
     }
     if (empty($_POST["recaptcha_challenge_field"]) || empty($_POST["recaptcha_response_field"])) {
         $ret[] = array('message' => trlKwf('Please solve captcha correctly'), 'field' => $this);
         return $ret;
     }
     require_once 'vendor/koala-framework/recaptcha-php/recaptchalib.php';
     $resp = recaptcha_check_answer(Kwf_Config::getValue('recaptcha.privateKey'), $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
     if (!$resp->is_valid) {
         $msg = $resp->error;
         if ($msg == 'incorrect-captcha-sol') {
             $msg = trlKwf('Please solve captcha correctly');
         }
         $ret[] = array('message' => $msg, 'field' => $this);
     } else {
         $sess->validated = true;
     }
     return $ret;
 }
 public function postContact()
 {
     require_once public_path() . '/recaptcha/recaptchalib.php';
     $private_key = "6LeqigQTAAAAAG8dmp7aH1HuPeJqB3lfJ_Fjx3xw";
     $resp = recaptcha_check_answer($private_key, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
     if (!$resp->is_valid) {
         // What happens when the CAPTCHA was entered incorrectly
         return Redirect::route('get-contact')->with('global', 'Human user verification did not match. Try again!');
     } else {
         // Your code here to handle a successful verification
         $validator = Validator::make(Input::all(), array('name' => 'required|max:50', 'email' => 'required|email', 'comments' => 'required', 'phone' => 'numeric'));
         if ($validator->fails()) {
             return Redirect::route('get-contact')->withInput()->withErrors($validator);
         } else {
             $name = Input::get('name');
             $email = Input::get('email');
             $phone = Input::get('phone');
             $comments = Input::get('comments');
             Mail::send('emails.contact', array('name' => $name, 'email' => $email, 'comments' => $comments), function ($message) use($name, $email, $comments, $phone) {
                 $message->from($email, $name);
                 $message->to('*****@*****.**', 'Thilina Herath')->subject('Contact us emails');
             });
             // Redirect to page
             return Redirect::route('default-message')->with('global', 'Your message has been sent. Thank You!');
         }
     }
 }
 function checkCaptcha($input, $options = array())
 {
     $this->load();
     $privatekey = $options['privatekey'];
     $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
     return $resp->is_valid;
 }
示例#10
0
 private function performRegistration()
 {
     global $config, $userdb, $user;
     // Check recaptcha answer
     $resp = recaptcha_check_answer($this->options["recaptcha_privatekey"], $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
     if (empty($_POST["user"])) {
         echo "<p>Es wurde kein Nutzername angegeben.</p>";
     } else {
         if (strlen($_POST["user"]) < 3) {
             echo "<p>Der Nutzername muss aus mindestens 3 Zeichen bestehen.</p>";
         } else {
             if (!preg_match("/^[-a-zA-Z0-9\\.]+\$/", $_POST["user"])) {
                 echo "<p>Der Nutzername darf nur Buchstaben (A-Z), Zahlen (0-9), Bindestriche und Punkte enthalten.</p>";
             } else {
                 if ($userdb->userExists($_POST["user"])) {
                     echo "<p>Der angegebene Nutzername ist leider schon vergeben.</p>";
                 } else {
                     if (empty($_POST["mail"])) {
                         echo "<p>Es wurde keine E-Mail Adresse angegeben.</p>";
                     } else {
                         if (!$userdb->isValidMailAddress($_POST["mail"])) {
                             echo "<p>Die angegebene E-Mail Adresse ist ung&uuml;ltig.</p>";
                         } else {
                             if ($config["misc"]["singletonmail"] && $userdb->mailUsed($_POST["mail"])) {
                                 echo "<p>Die angegebene E-Mail Adresse wird bereits bei einem anderen Account verwendet.</p>";
                             } else {
                                 if (empty($_POST["pass"])) {
                                     echo "<p>Es wurde kein Passwort angegeben.</p>";
                                 } else {
                                     if ($_POST["pass"] != $_POST["pass_repeat"]) {
                                         echo "<p>Die beiden Passw&ouml;rter stimmen nicht &uuml;berein.</p>";
                                     } else {
                                         if (strlen($_POST["pass"]) < 6) {
                                             echo "<p>Das Passwort muss mindestens 6 Zeichen lang sein.</p>";
                                         } else {
                                             if (empty($_POST["recaptcha_challenge_field"]) || empty($_POST["recaptcha_response_field"])) {
                                                 echo "<p>Der Captcha muss gel&ouml;st werden!</p>";
                                             } else {
                                                 if (!$resp->is_valid) {
                                                     echo "<p>Falsche Captcha-L&ouml;sung.</p>";
                                                 } else {
                                                     if ($user = $userdb->registerUser($_POST["user"], $_POST["pass"], $_POST["mail"])) {
                                                         header("Location: index.php?module=profile&do=verify_mail&mail=" . urlencode($_POST["mail"]));
                                                         return;
                                                     } else {
                                                         echo "<p>Fehler beim Registrieren!</p>";
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
示例#11
0
文件: forms.php 项目: eflip/Forms
    public function submit($vars)
    {
        $form = $this->db->fetch("SELECT * FROM lf_forms WHERE id = " . intval($this->ini));
        $pos = strpos($form['content'], '{recaptcha}');
        if ($pos !== false) {
            if (!isset($_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"])) {
                return 'Invalid POST';
            }
            $privatekey = "6LffguESAAAAACsudOF71gJLJE_qmvl4ey37qx8l";
            $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
            if (!$resp->is_valid) {
                return 'Invalid recaptcha';
            }
            unset($_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
        }
        $data = json_encode($_POST);
        $result = $this->db->query("INSERT INTO lf_formdata (`id`, `form_id`, `data`, `date`) VALUES (\n\t\t\tNULL, " . intval($this->ini) . ", '" . $this->db->escape($data) . "', NOW()\n\t\t)");
        if (!$result) {
            return '<p>Failed to submit. Contact an admin.</p>';
        }
        if ($form['email'] != '') {
            $msg = "Hello,\n\t\t\t\nNew form data has been submitted for '" . $form['title'] . "':\n\n";
            foreach ($_POST as $var => $val) {
                $msg .= $var . ": " . $val . "\n";
            }
            $msg .= '
Do not reply to this message. It was automated.';
            mail($form['email'], "New form data submitted: " . $form['title'], $msg, 'From: noreply@' . $_SERVER['SERVER_NAME']);
        }
        echo '<p>Form submitted successfully. Thank you!</p>';
    }
示例#12
0
 public function book()
 {
     require_once 'recaptchalib.php';
     $privatekey = "6LdEweMSAAAAAGI1hyasxa4pPu_Fd_HP0QXU9rEY";
     $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
     $this->load->model("bookingtaxi_model");
     $precount = $this->bookingtaxi_model->count_order_temp();
     if ($this->input->post('rad_Ready_to_go') == 'Now') {
         $string = date('Y-m-d h:m:s A');
     } else {
         $select_date = $this->input->post("ddl_Select_Date");
         $am = $this->input->post("ddl_AM");
         $hours = $this->input->post("ddl_hours");
         $minutes = $this->input->post("ddl_minutes");
         $string = $select_date . " " . $hours . ":" . $minutes . ":" . '00' . ' ' . $am;
     }
     $object = array("passenger" => $this->input->post("rad_passenger"), "name" => $this->input->post("txt_Name"), "contact_number" => $this->input->post("txt_Contact_Number"), "start_address" => $this->input->post("txt_Start_Address"), "unit_or_flat" => $this->input->post("txt_Unit_or_Flat"), "building_type" => $this->input->post("rad_Building_Type"), "business_name" => $this->input->post("txt_Business_name"), "remember_detail" => $this->input->post("chk_Remember_Details"), "end_address" => $this->input->post("txt_End_Address"), "distance" => $this->input->post("txt_Distance"), "car_type" => $this->input->post("rad_Car_Type"), "node_for_driver" => $this->input->post("ddl_Notes"), "time_to_go" => $string, "price" => floatval($this->input->post("txt_Distance")) * '1.617', "status_id" => "1", "payment" => $this->input->post("rad_Payment"), "driver" => "null");
     $inform = array("passenger" => $this->input->post("rad_passenger"), "name" => $this->input->post("txt_Name"), "contact_number" => $this->input->post("txt_Contact_Number"), "address" => $this->input->post("txt_Start_Address"), "unit_or_flat" => $this->input->post("txt_Unit_or_Flat"), "building_type" => $this->input->post("rad_Building_Type"), "business_name" => $this->input->post("txt_Business_name"));
     $this->bookingtaxi_model->booking($object);
     $lastcount = $this->bookingtaxi_model->count_order_temp();
     if ($lastcount > $precount) {
         echo 'booking success!!!';
         echo '<meta http-equiv="refresh" content="2;' . base_url() . '" />';
     } else {
         echo 'bookingfail!!!';
         break;
     }
     if ($this->input->post("chk_Remember_Details") == '1') {
         $this->bookingtaxi_model->addcustomer_temp($inform);
     }
 }
示例#13
0
 function doPost(&$post)
 {
     $id = 0;
     // reCAPTCHA.
     if ($this->conf['useRecaptcha']) {
         $resp = recaptcha_check_answer($this->conf['privkey'], $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
         if (!$resp->is_valid) {
             $this->errors[] = "The CAPTCHA you entered was incorrect. If you have trouble with the image you can refresh it, or simply use the speaker icon to hear it.";
             return $id;
         }
     }
     // Validate some inputs.
     $post["title"] = $this->_cleanUsername($post["title"]);
     $post["format"] = $this->_cleanFormat($post["format"]);
     $post["expiry"] = $this->_cleanExpiry($post["expiry"]);
     // Set/clear the persistName cookie.
     if (isset($post["remember"])) {
         $value = $post["title"] . '#' . $post["format"] . '#' . $post['expiry'];
         // Set cookie if not set.
         if (!isset($_COOKIE["persistName"]) || $value != $_COOKIE["persistName"]) {
             setcookie("persistName", $value, time() + 3600 * 24 * 365);
         }
     } else {
         // Clear cookie if set.
         if (isset($_COOKIE['persistName'])) {
             setcookie('persistName', '', 0);
         }
     }
     if (strlen($post['code'])) {
         $title = preg_replace('/[^A-Za-z0-9_ \\-]/', '', $post['title']);
         $title = $post['title'];
         if (strlen($title) == 0) {
             $title = 'Untitled';
         }
         $format = $post['format'];
         if (!array_key_exists($format, $this->conf['geshiformats'])) {
             $format = '';
         }
         $code = $post["code"];
         if (empty($post["password"]) || $post["password"] == "") {
             $password = "******";
         } else {
             $password = sha1($post["password"] . $salt);
         }
         // Now insert..
         $parent_pid = 0;
         if (isset($post["parent_pid"])) {
             $parent_pid = intval($post["parent_pid"]);
         }
         if ($logged_in == 1) {
             $user_id = $user->id;
         } else {
             $user_id = 0;
         }
         $id = $this->db->addPost($title, $format, $code, $parent_pid, $post["expiry"], $password, $user_id);
     } else {
         $this->errors[] = "Please specify a paste to submit.";
     }
     return $id;
 }
 function checkCode($checkarray, $captchatype = 'myCaptcha')
 {
     if ($captchatype == 'myCaptcha') {
         // First, delete old captchas
         $expiration = time() - 3600;
         // Two hour limit
         $db =& JFactory::getDBO();
         $db->setQuery("DELETE FROM #__cb_mycaptcha WHERE captcha_time < " . $expiration);
         $db->query();
         // Then see if a captcha exists:
         $sql = "SELECT COUNT(*) AS count " . "\n FROM #__cb_mycaptcha " . "\n WHERE word = '{$checkarray['word']}' AND ip_address = '{$checkarray['ip']}' AND captcha_time > {$expiration}";
         $query = $db->setQuery($sql);
         if ($db->loadResult()) {
             return true;
         } else {
             return false;
         }
     }
     if ($captchatype == 'reCaptcha') {
         require_once 'recaptcha' . DS . 'recaptchalib.php';
         $res = recaptcha_check_answer($checkarray['privatekey'], CbmycaptchaModel::GetUserIp(), $checkarray["rec_ch_field"], $checkarray["rec_res_field"]);
         if (!$res->is_valid) {
             return false;
         } else {
             return true;
         }
     }
 }
 function send()
 {
     $mail = HTTP::_GP('mail', '', true);
     $errorMessages = array();
     if (empty($mail)) {
         $errorMessages[] = t('passwordErrorMailEmpty');
     }
     if (Config::get('capaktiv') === '1') {
         require_once 'includes/libs/reCAPTCHA/recaptchalib.php';
         $resp = recaptcha_check_answer(Config::get('capprivate'), $_SERVER['REMOTE_ADDR'], $_REQUEST['recaptcha_challenge_field'], $_REQUEST['recaptcha_response_field']);
         if (!$resp->is_valid) {
             $errorMessages[] = t('registerErrorCaptcha');
         }
     }
     if (!empty($errorMessages)) {
         $message = implode("<br>\r\n", $errorMessages);
         $this->printMessage($message, NULL, array(array('label' => t('passwordBack'), 'url' => 'index.php?page=lostPassword')));
     }
     $userID = $GLOBALS['DATABASE']->getFirstCell("SELECT id FROM " . USERS . " WHERE universe = " . $GLOBALS['UNI'] . " AND  email_2 = '" . $GLOBALS['DATABASE']->escape($mail) . "';");
     if (empty($userID)) {
         $this->printMessage(t('passwordErrorUnknown'), NULL, array(array('label' => t('passwordBack'), 'url' => 'index.php?page=lostPassword')));
     }
     $hasChanged = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . LOSTPASSWORD . " WHERE userID = " . $userID . " AND time > " . (TIMESTAMP - 86400) . " AND hasChanged = 0;");
     if (!empty($hasChanged)) {
         $this->printMessage(t('passwordErrorOnePerDay'), NULL, array(array('label' => t('passwordBack'), 'url' => 'index.php?page=lostPassword')));
     }
     $validationKey = md5(uniqid());
     $MailRAW = $GLOBALS['LNG']->getTemplate('email_lost_password_validation');
     $MailContent = str_replace(array('{USERNAME}', '{GAMENAME}', '{VALIDURL}'), array($mail, Config::get('game_name') . ' - ' . Config::get('uni_name'), HTTP_PATH . 'index.php?page=lostPassword&mode=newPassword&u=' . $userID . '&k=' . $validationKey), $MailRAW);
     require 'includes/classes/Mail.class.php';
     Mail::send($mail, $mail, t('passwordValidMailTitle', Config::get('game_name')), $MailContent);
     $GLOBALS['DATABASE']->query("INSERT INTO " . LOSTPASSWORD . " SET userID = " . $userID . ", `key` = '" . $validationKey . "', time = " . TIMESTAMP . ", fromIP = '" . $_SERVER['REMOTE_ADDR'] . "';");
     $this->printMessage(t('passwordValidMailSend'), NULL, array(array('label' => t('passwordNext'), 'url' => 'index.php')));
 }
 function checkRecaptcha(&$model, $data, $target)
 {
     App::import('Vendor', 'Recaptcha.recaptchalib');
     $privatekey = Configure::read('Recaptcha.Private');
     $res = recaptcha_check_answer($privatekey, $_SERVER['REMOTE_ADDR'], $model->data[$model->alias][$target], $data['recaptcha_response_field']);
     return $res->is_valid;
 }
 /**
  * Handle post request of Contact form
  * @return [type] [description]
  */
 public function postAction()
 {
     if (Mage::getStoreConfigFlag(self::XML_PATH_CFC_ENABLED)) {
         try {
             $post = $this->getRequest()->getPost();
             $formData = new Varien_Object();
             $formData->setData($post);
             Mage::getSingleton('core/session')->setData('contactForm', $formData);
             if ($post) {
                 //include reCaptcha library
                 require_once Mage::getBaseDir('lib') . DS . 'reCaptcha' . DS . 'recaptchalib.php';
                 //validate captcha
                 $privatekey = Mage::getStoreConfig(self::XML_PATH_CFC_PRIVATE_KEY);
                 $remote_addr = $this->getRequest()->getServer('REMOTE_ADDR');
                 $captcha = recaptcha_check_answer($privatekey, $remote_addr, $post["recaptcha_challenge_field"], $post["recaptcha_response_field"]);
                 if (!$captcha->is_valid) {
                     throw new Exception($this->__("The reCAPTCHA wasn't entered correctly. Go back and try it again."), 1);
                 }
                 Mage::getSingleton('core/session')->unsetData('contactForm');
             } else {
                 throw new Exception('', 1);
             }
         } catch (Exception $e) {
             if (strlen($e->getMessage()) > 0) {
                 Mage::getSingleton('customer/session')->addError($this->__($e->getMessage()));
             }
             $this->_redirect('*/*/');
             return;
         }
     }
     //everything is OK - call parent action
     parent::postAction();
 }
示例#18
0
function formCheck($params)
{
    global $_keys;
    $recaptcha_valid = FALSE;
    $errs = array();
    if (!is_null($params["recaptcha_response_field"])) {
        $resp = recaptcha_check_answer($_keys['private'], $_SERVER["REMOTE_ADDR"], $params["recaptcha_challenge_field"], $params["recaptcha_response_field"]);
        if ($resp->is_valid) {
            $recaptcha_valid = TRUE;
        } else {
            $errs['recaptcha_error'] = $resp->error;
        }
    }
    if (!$recaptcha_valid) {
        $errs['recaptcha'] = "Please complete the anti-spam test";
    }
    if (!$params['email']) {
        $errs['email'] = "Please enter the recipient's email address";
    } else {
        if (!validate_email($params['email'])) {
            $errs['email'] = "Please enter a valid email address for the recipient";
        }
    }
    if (!$params['name']) {
        $errs['name'] = "Please enter your name";
    }
    return $errs;
}
示例#19
0
/**
 * @param $hook
 * @param $type
 * @param $returnvalue
 * @param $params
 *
 * @return bool
 *
 * function called when the below plugin trigger is initiated
 * @see /engine/lib/actions.php
 * @see elgg_trigger_plugin_hook('action', $action, null, $event_result);
 *
 * this hook is triggered for the action = "register"
 * this hooks is called before the default "register" action handler at /actions/register.php
 * checks if recaptcha is valid - if not register an error
 */
function recaptcha_check_form($hook, $type, $returnvalue, $params)
{
    // retain entered form values and re-populate form fields if validation error
    elgg_make_sticky_form('register');
    /*-- check if the 'Use Recaptcha for user registration' Plugin setting is enabled --*/
    //fetch the plugin settings
    $plugin_entity = elgg_get_plugin_from_id('recaptcha');
    $plugin_settings = $plugin_entity->getAllSettings();
    if (array_key_exists('recaptcha_verified', $_SESSION) && $_SESSION['recaptcha_verified'] == 1) {
        //do nothing
    } else {
        if ($plugin_settings['require_recaptcha'] == 'on') {
            //if the setting is enabled
            // include the recaptcha lib
            require_once 'lib/recaptchalib.php';
            // check the recaptcha
            $resp = recaptcha_check_answer($plugin_settings['recaptcha_private_key'], $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
            if (!$resp->is_valid) {
                register_error(elgg_echo('recaptcha:human_verification_failed'));
                forward(REFERER);
            } else {
                /* note that the user has successfully passed the captcha
                 * in case the form submission fails due to other factors, we do not want to
                 * ask the user to fill in the captcha details again
                 * so we store it in a session variable and destroy it after the form is successfully submitted
                 */
                $_SESSION['recaptcha_verified'] = 1;
            }
        }
    }
    return true;
}
示例#20
0
	public function checkHash($sCode = null)
	{
		if (Phpfox::getParam('captcha.recaptcha'))
		{
			require_once(PHPFOX_DIR_LIB . 'recaptcha' . PHPFOX_DS . 'recaptchalib.php');		
		
			if (isset($_POST["recaptcha_response_field"])) 
			{			
		        $oResp = recaptcha_check_answer(Phpfox::getParam('captcha.recaptcha_private_key'), $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
		
		        if ($oResp->is_valid) 
		        {        	
		        	return true;
		        } 
		        else 
		        {               
		        	return false;
		        }	        
			}	
	
			return false;
		}		
		
		if ($this->_getHash(strtolower($sCode), $this->_oSession->getSessionId()) == $this->_oSession->get('captcha_hash'))
		{
			return true;
		}
		return false;
	}
示例#21
0
 /**
  * Validates a ReCaptcha
  *
  * In the code that processes the form submission, you need to add code to validate the CAPTCHA.
  */
 public function validate()
 {
     $response = recaptcha_check_answer($this->privateKey, $this->request->getRemoteAddress(), $this->request->getParameterFromPost('recaptcha_challenge_field'), $this->request->getParameterFromPost('recaptcha_response_field'));
     if ($response->is_valid == false) {
         return _('The reCAPTCHA was not entered correctly. Go back and try again. (reCAPTCHA said: ' . $resp->error . ')');
     }
 }
 protected function action()
 {
     if (!TAKEDOWN_TOOL) {
         throw new Exception(__METHOD__ . ' TAKEDOWN TOOL is not enabled!');
     }
     $view_data = ['recaptcha' => recaptcha_get_html(RECAPTCHA_PUBLIC_KEY, null, true), 'links' => $this->request->getPostVar('links'), 'reporter_id' => $this->request->getPostVar('reporter_id')];
     if (!is_null($this->request->getPostVar('links'))) {
         if (recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY, $this->request->getServerVar('REMOTE_ADDR'), $this->request->getPostVar('recaptcha_challenge_field'), $this->request->getPostVar('recaptcha_response_field'))->is_valid) {
             if ($reporter_data = $this->_isValidReporterId($this->request->getPostVar('reporter_id'))) {
                 $links_to_be_removed = $this->_genRemoveLinkList($this->request->getPostVar('links'));
                 if (!empty($links_to_be_removed)) {
                     $this->_removeLinks($links_to_be_removed, $reporter_data);
                     $view_data = ['recaptcha' => recaptcha_get_html(RECAPTCHA_PUBLIC_KEY, null, true), 'tot_removed_links' => count($links_to_be_removed)];
                 } else {
                     $view_data['error'] = 'No valid URLs to remove!';
                 }
             } else {
                 $view_data['error'] = 'Your reporter ID is not valid!';
             }
         } else {
             $view_data['error'] = 'Captcha code was not valid!';
         }
     }
     $this->setViewData($view_data);
 }
示例#23
0
 public function checkHash($sCode = null)
 {
     if (Phpfox::getParam('captcha.recaptcha')) {
         require_once PHPFOX_DIR_LIB . 'recaptcha' . PHPFOX_DS . 'recaptchalib.php';
         if (isset($_POST["recaptcha_response_field"])) {
             $oResp = recaptcha_check_answer(Phpfox::getParam('captcha.recaptcha_private_key'), $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
             if ($oResp->is_valid) {
                 return true;
             } else {
                 return false;
             }
         }
         return false;
     }
     if (Phpfox::getParam('core.store_only_users_in_session')) {
         $oSession = Phpfox::getLib('session');
         $sSessionHash = $oSession->get('sessionhash');
         $aRow = $this->database()->select('*')->from(Phpfox::getT('log_session'))->where('session_hash = \'' . $this->database()->escape($sSessionHash) . '\'')->execute('getSlaveRow');
         if (isset($aRow['session_hash']) && $this->_getHash(strtolower($sCode), $aRow['session_hash']) == $aRow['captcha_hash']) {
             return true;
         }
     } else {
         if ($this->_getHash(strtolower($sCode), $this->_oSession->getSessionId()) == $this->_oSession->get('captcha_hash')) {
             return true;
         }
     }
     return false;
 }
示例#24
0
文件: bbs.php 项目: h16o2u9u/rtoss
function reCAPTCHA($title, $desc)
{
    global $key, $FROM1, $mail, $subject, $MESSAGE, $c_pass;
    require_once './recaptchalib.php';
    $publickey = "";
    // you got this from the signup page
    $privatekey = "";
    // (same as above)
    $error = '';
    if ($_POST["recaptcha_response_field"]) {
        $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
        if ($resp->is_valid) {
            return true;
        } else {
            $error = $resp->error;
        }
    }
    echo '<html><head><title>' . $title . '</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<body>' . $desc . '
<form method="post" action="' . $_SERVER['PHP_SELF'] . '">
<input type="hidden" name="key" value="' . $key . '"><input type="hidden" name="nick" value="' . $FROM1 . '"><input type="hidden" name="mail" value="' . $mail . '"><br>
<input type="hidden" name="subject" value="' . $subject . '">
<input type="hidden" name="content" value="' . $MESSAGE . '"><input type="hidden" name="url" value="">
<input type="hidden" name="delk" value="' . $c_pass . '">';
    echo recaptcha_get_html($publickey, $error);
    echo '<input type="submit" value="確認">
</form>
</body></html>';
    return false;
}
示例#25
0
 function verifica_captcha()
 {
     //aquí debemos la clave privada que recaptcha nos ha dado
     $privatekey = "6LcJAPUSAAAAABsytFmd3-n5h9oQ4NEoJY0Nbwmj";
     $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $this->input->post("recaptcha_challenge_field"), $this->input->post("recaptcha_response_field"));
     if (!$resp->is_valid) {
         //si el captcha introducido es incorrecto se lo decimos
         echo json_encode(array("success" => false));
     } else {
         if ($this->input->post("seleccion") == 1) {
             $usuario = $this->usuario_model->getUsuarioFuncionario($this->input->post("cedula"), $this->input->post("nacionalidad"), $this->input->post("correo"));
         } else {
             if ($this->input->post("seleccion") == 2) {
                 $usuario = $this->usuario_model->getUsuarioPersona($this->input->post("cedula"), $this->input->post("nacionalidad"), $this->input->post("correo"));
             } else {
                 if ($this->input->post("seleccion") == 3) {
                     $usuario = $this->usuario_model->getUsuarioComunidad($this->input->post("cedula"), $this->input->post("nacionalidad"), $this->input->post("correo"));
                 }
             }
         }
         if ($usuario != false) {
             foreach ($usuario as $row) {
                 $id = $row->id;
             }
             $success = $this->usuario_model->updateContrasena($id, $this->input->post("contrasena"));
             $this->emailUsuario($id, $this->input->post("correo"));
             echo json_encode(array("success" => true));
         } else {
             echo json_encode(array("success" => false));
         }
     }
 }
 /**
  * Submit new review action
  *
  */
 public function postAction()
 {
     if (Mage::getStoreConfigFlag(self::XML_PATH_PRC_ENABLED)) {
         try {
             $post = $this->getRequest()->getPost();
             if ($post) {
                 //include reCaptcha library
                 require_once Mage::getModuleDir('', 'OlegKoval_ProductReviewCaptcha') . DS . 'Helper' . DS . 'recaptchalib.php';
                 //validate captcha
                 $privatekey = Mage::getStoreConfig(self::XML_PATH_PRC_PRIVATE_KEY);
                 $remote_addr = $this->getRequest()->getServer('REMOTE_ADDR');
                 $captcha = recaptcha_check_answer($privatekey, $remote_addr, $post["recaptcha_challenge_field"], $post["recaptcha_response_field"]);
                 if (!$captcha->is_valid) {
                     throw new Exception($this->__("The reCAPTCHA wasn't entered correctly."), 1);
                 }
             } else {
                 throw new Exception('', 1);
             }
         } catch (Exception $e) {
             if (strlen($e->getMessage()) > 0) {
                 Mage::getSingleton('core/session')->addError($this->__($e->getMessage()));
                 Mage::getSingleton('core/session')->setFormData($post);
             }
             if ($redirectUrl = Mage::getSingleton('review/session')->getRedirectUrl(true)) {
                 $this->_redirectUrl($redirectUrl);
                 return;
             }
             $this->_redirectReferer();
             return;
         }
     }
     //everything is OK - call parent action
     parent::postAction();
 }
示例#27
0
 public function showRecaptcha($key = null, $error = null, $check = false)
 {
     if ($this->config['reCAPTCHA_enabled']) {
         if ($key == null) {
             $key = $this->config['reCAPTCHA_publickey'];
         }
         if ($error == null) {
             $error = $this->captcha_error;
         }
         ## Initiate the reCaptcha ##
         require_once SYSTEM_PATH . '/recaptcha/recaptchalib.php';
         if (!$check) {
             return '<div id="recaptcha">' . recaptcha_get_html($key, $error) . '</div>';
         }
         if (isset($_POST['recaptcha_response_field'])) {
             $captcha_resp = recaptcha_check_answer($this->config['reCAPTCHA_privatekey'], $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
             if (!$captcha_resp->is_valid) {
                 //$captcha_error = $captcha_resp->error; //Just in case of debugging
                 $status = false;
             } else {
                 $status = true;
             }
             $this->captcha_success = $status;
         }
     } else {
         $this->captcha_success = true;
     }
 }
示例#28
0
 /**
  * Validate the recaptcha code received by the user.
  * 
  * @return boolean Success
  */
 public function validate()
 {
     App::import('Vendor', 'Recaptcha.recaptcha/recaptchalib');
     $resp = recaptcha_check_answer($this->privateKey, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
     $error = $resp->error;
     return $resp->is_valid;
 }
 public function check()
 {
     $config = RMFunctions::get()->plugin_settings('recaptcha', true);
     include_once RMCPATH . '/plugins/recaptcha/recaptchalib.php';
     $privatekey = $config['private'];
     $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
     return $resp->is_valid;
 }
示例#30
0
function login_check_is_captcha_valid()
{
    require 'recaptcha.php';
    $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE, $_SERVER["REMOTE_ADDR"], $_REQUEST["recaptcha_challenge_field"], $_REQUEST["recaptcha_response_field"]);
    if (!$resp->is_valid) {
        login_redirect($GLOBALS['url'], 'invalidcaptcha');
    }
}