本文整理汇总了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;
}