Esempio n. 1
0
function captchaRes($CaptchaRes)
{
    //Define the keys for the api, you can get them from https://www.google.com/recaptcha/
    $keys = array('site_key' => RECAPTCHA_GOOGLE_API_KEY, 'secret_key' => RECAPTCHA_GOOGLE_API_SECRET);
    //Instantiate the Recaptcha class as $recaptcha
    $recaptcha = new Recaptcha($keys);
    //If the form is submitted, then check if the response was correct
    return $recaptcha->verify($CaptchaRes);
}
 function it_fails_on_recaptcha_fail(Request $request, Recaptcha $recaptcha, Response $response)
 {
     $recaptcha->verify(Argument::any(), Argument::any())->willReturn($response);
     $response->isSuccess()->willReturn(false);
     $this->validate($request)->shouldReturn(false);
 }
Esempio n. 3
0
	<?php 
require_once 'classes/recaptcha.php';
require_once 'classes/jsonRPCClient.php';
require_once 'config.php';
$link = mysqli_connect($hostDB, $userDB, $passwordDB, $database);
function GetRandomValue($min, $max)
{
    $range = $max - $min;
    $num = $min + $range * mt_rand(0, 32767) / 32767;
    $num = round($num, 8);
    return (double) $num;
}
//Instantiate the Recaptcha class as $recaptcha
$recaptcha = new Recaptcha($keys);
if ($recaptcha->set()) {
    if ($recaptcha->verify($_POST['g-recaptcha-response'])) {
        //Checking address and payment ID characters
        $wallet = $str = trim(preg_replace('/[^a-zA-Z0-9]/', '', $_POST['wallet']));
        $paymentidPost = $str = trim(preg_replace('/[^a-zA-Z0-9]/', '', $_POST['paymentid']));
        //Getting user IP
        $direccionIP = $_SERVER["REMOTE_ADDR"];
        if (empty($wallet) or strlen($wallet) < 95) {
            header("Location: ./?msg=wallet");
            exit;
        }
        if (empty($paymentidPost)) {
            $paymentID = "";
        } else {
            if (strlen($paymentidPost) > 64 or strlen($paymentidPost) < 64) {
                header("Location: ./?msg=paymentID");
                exit;
 /**
  * Returns true if and only if $value meets the validation requirements
  *
  * If $value fails validation, then this method returns false, and
  * getMessages() will return an array of messages that explain why the
  * validation failed.
  *
  * @param  mixed $value
  * @return bool
  * @throws Exception\RuntimeException If validation of $value is impossible
  */
 public function isValid($value)
 {
     $resp = $this->recaptcha->verify($value);
     return $resp->isSuccess();
 }
Esempio n. 5
0
 /**
  * Processes the form submit. Is called automatically from render() if not called before
  * @return true if handled
  */
 public function handle()
 {
     $p = array();
     // fetch GET parameters before processing POST
     foreach ($_GET as $key => $val) {
         foreach ($this->elems as $e) {
             if (!is_object($e['obj'])) {
                 throw new \Exception('XXX not an obj!');
             }
             if (!isset($e['obj']->name)) {
                 continue;
             }
             if ($e['obj']->name == $key) {
                 $p[$key] = htmlspecialchars_decode($val);
             }
         }
     }
     foreach ($_POST as $key => $val) {
         foreach ($this->elems as $e) {
             if (!is_object($e['obj'])) {
                 throw new \Exception('XXX not an obj!');
             }
             if (!isset($e['obj']->name)) {
                 continue;
             }
             if ($e['obj']->name == $key) {
                 if (is_array($val)) {
                     foreach ($val as $idx => $v) {
                         $val[$idx] = htmlspecialchars_decode($v);
                     }
                     $p[$key] = $val;
                 } else {
                     $p[$key] = htmlspecialchars_decode($val);
                 }
             } else {
                 if ($e['obj'] instanceof YuiDateInterval) {
                     if ($e['obj']->name . '_from' == $key) {
                         $e['obj']->selectFrom($val);
                         $p[$key] = htmlspecialchars_decode($val);
                     }
                     if ($e['obj']->name . '_to' == $key) {
                         $e['obj']->selectTo($val);
                         $p[$key] = htmlspecialchars_decode($val);
                     }
                 } else {
                     if ($e['obj']->name == $key . '[]') {
                         // handle input arrays
                         if (is_array($val)) {
                             foreach ($val as $idx => $v) {
                                 $val[$idx] = htmlspecialchars_decode($v);
                             }
                             $p[$key] = $val;
                         } else {
                             $p[$key] = htmlspecialchars_decode($val);
                         }
                     }
                 }
             }
         }
     }
     // include FILES uploads
     foreach ($this->elems as $e) {
         if (isset($e['obj']) && is_object($e['obj']) && $e['obj'] instanceof XhtmlComponentFile && !empty($_FILES[$e['obj']->name])) {
             $key = $_FILES[$e['obj']->name];
             $p[$e['obj']->name] = $key;
             // to avoid further processing of this file upload elsewhere
             unset($_FILES[$e['obj']->name]);
         }
     }
     if ($this->using_captcha && !empty($_POST)) {
         $captcha = new Recaptcha();
         if (!$captcha->verify()) {
             return false;
         }
     }
     if (!$p) {
         return false;
     }
     $this->form_data = $p;
     $error = ErrorHandler::getInstance();
     if (!$error->getErrorCount() && $this->post_handler) {
         if (call_user_func($this->post_handler, $this->form_data, $this)) {
             $this->handled = true;
         }
     }
     if ($error->getErrorCount()) {
         return false;
     }
     return $this->handled;
 }