本文整理汇总了PHP中Securimage::getCaptchaId方法的典型用法代码示例。如果您正苦于以下问题:PHP Securimage::getCaptchaId方法的具体用法?PHP Securimage::getCaptchaId怎么用?PHP Securimage::getCaptchaId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Securimage
的用法示例。
在下文中一共展示了Securimage::getCaptchaId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: StaticCaptcha
/**
* 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: Securimage
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: array
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>