當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Securimage::checkByCaptchaId方法代碼示例

本文整理匯總了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;
         }
     }
 }
開發者ID:somnathraj1989,項目名稱:sgc,代碼行數:23,代碼來源:lib.inc.php

示例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
開發者ID:ishawge,項目名稱:cxpcms,代碼行數:31,代碼來源:test.mysql.static.php

示例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;
    }
開發者ID:josl,項目名稱:CGE-File-Sharing,代碼行數:31,代碼來源:static_captcha.php


注:本文中的Securimage::checkByCaptchaId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。