本文整理汇总了PHP中Securimage::checkByCaptchaId方法的典型用法代码示例。如果您正苦于以下问题:PHP Securimage::checkByCaptchaId方法的具体用法?PHP Securimage::checkByCaptchaId怎么用?PHP Securimage::checkByCaptchaId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Securimage
的用法示例。
在下文中一共展示了Securimage::checkByCaptchaId方法的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: error_reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);
// defines Securimage class
require_once '../securimage.php';
// define options for securimage
$options = array('database_driver' => Securimage::SI_DRIVER_MYSQL, 'database_host' => 'localhost', 'database_user' => 'securimage', 'database_pass' => 'password1234', 'database_name' => 'test', 'no_session' => true);
// get the captcha ID from the url (if supplied)
$captchaId = isset($_GET['id']) ? $_GET['id'] : '';
// if the validate option is set
if (isset($_GET['validate'])) {
// $_GET['id'] should also be set
// get the user input of the captcha code
$input = isset($_GET['input']) ? $_GET['input'] : '';
// call Securimage::checkCaptchaId to validate input
// returns true if the code and id are a valid pair, false if not
if (Securimage::checkByCaptchaId($captchaId, $input, $options) == true) {
echo "<h2>Success</h2>" . "<span style='color: #33cc00'>The captcha code entered was correct!</span>" . "<br /><br />";
} else {
echo "<h2>Incorrect Code</h2>" . "<span style='color: #f00'>Incorrect captcha code, try again.</span>" . "<br /><br />";
}
} else {
if (isset($_GET['refresh'])) {
$captcha = Securimage::getCaptchaId(true, $options);
$data = array('captchaId' => $captcha);
echo json_encode($data);
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
示例3: error_reporting
* to securimage_show.php providing the captcha ID.
*/
// set debugging
error_reporting(E_ALL);
ini_set('display_errors', 1);
// defines Securimage class
require_once '../securimage.php';
// get the captcha ID from the url (if supplied)
$captchaId = isset($_GET['id']) ? $_GET['id'] : '';
// if the validate option is set
if (isset($_GET['validate'])) {
// get the user input of the captcha code
$input = isset($_GET['input']) ? $_GET['input'] : '';
// call Securimage::checkCaptchaId to validate input
// returns true if the code and id are a valid pair, false if not
if (Securimage::checkByCaptchaId($captchaId, $input) == true) {
echo "<h2>Success</h2>" . "<span style='color: #33cc00'>The captcha code entered was correct!</span>" . "<br /><br />";
} else {
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;
}