/** * Validate a captcha code input against a captcha ID * * @param string $id The captcha ID to check * @param string $value The captcha value supplied by the user * @param array $options Array of options to construct Securimage with. * Options must include database options if they are not set in securimage.php * * @see Securimage::$database_driver * @return bool true if the code was valid for the given captcha ID, false if not or if database failed to open */ public static function checkByCaptchaId($id, $value, array $options = array()) { $opts = array('captchaId' => $id, 'no_session' => true, 'use_database' => true); if (sizeof($options) > 0) { $opts = array_merge($options, $opts); } $si = new self($opts); if ($si->openDatabase()) { $code = $si->getCodeFromDatabase(); if (is_array($code)) { $si->code = $code['code']; $si->code_display = $code['code_disp']; } if ($si->check($value)) { $si->clearCodeFromDatabase(); return true; } else { return false; } } else { return false; } }