本文整理匯總了PHP中captcha::getCaptchaString方法的典型用法代碼示例。如果您正苦於以下問題:PHP captcha::getCaptchaString方法的具體用法?PHP captcha::getCaptchaString怎麽用?PHP captcha::getCaptchaString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類captcha
的用法示例。
在下文中一共展示了captcha::getCaptchaString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: captcha
/******************************************************************
Projectname: CAPTCHA class
Version: 2.0
Author: Pascal Rehfeldt <Pascal@Pascal-Rehfeldt.com>
modified for Sphider-plus by Tec 2009.11.26
******************************************************************/
//Start the session
session_start();
//Create a CAPTCHA
$captcha = new captcha();
//Store the String in a session
$_SESSION['CAPTCHAString'] = $captcha->getCaptchaString();
class captcha
{
var $Length;
var $CaptchaString;
var $fontpath;
var $fonts;
function captcha($length = 6)
{
header('Content-type: image/png');
$this->Length = $length;
$this->fontpath = 'images/';
$this->fonts = $this->getFonts();
$errormgr = new error();
if ($this->fonts == FALSE) {
//$errormgr = new error;
示例2: getCaptchaHtml
function getCaptchaHtml()
{
global $uploadFolder, $sourceFolder, $moduleFolder, $cmsFolder, $urlRequestRoot;
$captcha_query = "SELECT * FROM `" . MYSQL_DATABASE_PREFIX . "global` WHERE `attribute` = 'recaptcha'";
$captcha_res = mysql_fetch_assoc(mysql_query($captcha_query));
$recaptcha = 0;
if ($captcha_res['value']) {
if (!fsockopen("www.google.com", 80)) {
$recaptcha = 0;
} else {
$recaptcha = 1;
$query = "SELECT `value` FROM `" . MYSQL_DATABASE_PREFIX . "global` WHERE `attribute`='recaptcha_public'";
$res = mysql_fetch_assoc(mysql_query($query));
$public_key = $res['value'];
$query = "SELECT `value` FROM `" . MYSQL_DATABASE_PREFIX . "global` WHERE `attribute`='recaptcha_private'";
$res = mysql_fetch_assoc(mysql_query($query));
$private_key = $res['value'];
if ($public_key == NULL || $private_key == NULL) {
$recaptcha = 0;
}
}
if (isset($_GET['recaptcha']) && $_GET['recaptcha'] == "off") {
$recaptcha = 0;
}
}
if ($recaptcha) {
require_once "{$sourceFolder}/{$moduleFolder}/form/captcha/recaptcha/recaptchalib.php";
$body = "<tr><td colspan=2><center>" . recaptcha_get_html($public_key) . "</center></td></tr>";
$body .= "<tr><td colspan=2>Click <a href='" . selfURI() . "&recaptcha=off'>here</a> if you can't see the ReCAPTCHA</td></tr>";
$body .= "<input type='hidden' name='captcha' value='1'>";
} else {
require_once "{$sourceFolder}/{$moduleFolder}/form/captcha/class/captcha.class.php";
$captcha = new captcha($sourceFolder, $moduleFolder, $uploadFolder, $urlRequestRoot, $cmsFolder, 6);
$_SESSION['CAPTCHAString'] = $captcha->getCaptchaString();
$body = '<tr><td>Enter the text as shown in the image :</td><td>' . '<img style="border:1px solid;padding:0px" src="' . $captcha->getCaptchaUrl() . '" alt="CAPTCHA" border="1"/><br/>' . '<input type="text" class="required" name="txtCaptcha" /><td></tr>';
$body .= "<input type='hidden' name='captcha' value='0'>";
}
return $body;
}