Пример #1
0
 /**
  * Shows a Captcha with a text Field
  *
  * @param bool $ShowImage If true Shows the captcha otherwise validates
  * @return bool
  */
 public static function StaticCaptcha($ShowImage = false)
 {
     require_once __DIR__ . '/captcha/securimage.php';
     $options = array('database_driver' => Securimage::SI_DRIVER_MYSQL, 'database_host' => HOST_Name, 'database_user' => MySQL_User, 'database_pass' => MySQL_Pass, 'database_name' => MySQL_DB, 'database_table' => MySQL_Pre . 'CaptchaCodes', 'captcha_type' => Securimage::SI_CAPTCHA_MATHEMATIC, 'no_session' => true);
     if ($ShowImage) {
         $captchaId = Securimage::getCaptchaId(true, $options);
         $Captcha = '<input type="hidden" id="captchaId" name="captchaId"' . ' value="' . $captchaId . '" />' . '<img id="siimage"' . ' src="ShowCaptcha.php?captchaId=' . $captchaId . '"' . ' alt="captcha image" />' . '<input class="form-TxtInput" placeholder="Solve the math above" ' . 'type="text" name="captcha_code" value="" required />';
         echo $Captcha;
     } else {
         $captcha_code = self::GetVal($_POST, 'captcha_code');
         if ($captcha_code !== null) {
             $VerifyID = self::GetVal($_POST, 'captchaId');
             $ValidCaptcha = Securimage::checkByCaptchaId($VerifyID, $captcha_code, $options);
             return $ValidCaptcha;
         }
     }
 }
Пример #2
0
        exit;
    } else {
        if (isset($_GET['display'])) {
            // display the captcha with the supplied ID from the URL
            // construct options specifying the existing captcha ID
            // also tell securimage not to start a session
            $options['captchaId'] = $captchaId;
            $captcha = new Securimage($options);
            // show the image, this sends proper HTTP headers
            $captcha->show();
            exit;
        }
    }
}
// generate a new captcha ID and challenge
$captchaId = Securimage::getCaptchaId(true, $options);
// output the captcha ID, and a form to validate it
// the form submits to itself and is validated above
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Static Captcha Example</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
 
    <script type="text/javascript">
    /* jQuery ajax example of refreshing a static captcha */
    function refreshCaptcha() {
        $.ajax({ url: '?refresh=1',
            dataType: 'json', 
Пример #3
0
        echo "<h2>Incorrect Code</h2>" . "<span style='color: #f00'>Incorrect captcha code, try again.</span>" . "<br /><br />";
    }
} else {
    if (isset($_GET['display'])) {
        // display the captcha with the supplied ID from the URL
        // construct options specifying the existing captcha ID
        // also tell securimage not to start a session
        $options = array('captchaId' => $captchaId, 'no_session' => true);
        $captcha = new Securimage($options);
        // show the image, this sends proper HTTP headers
        $captcha->show();
        exit;
    }
}
// generate a new captcha ID and challenge
$captchaId = Securimage::getCaptchaId();
// output the captcha ID, and a form to validate it
// the form submits to itself and is validated above
echo <<<EOD
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>Static Captcha Example</title>
    </head>
    <body>
    <h2>Static Captcha Example</h2>

    <div>
      Synopsis:
      <ul>