本文整理汇总了PHP中PhpCaptcha类的典型用法代码示例。如果您正苦于以下问题:PHP PhpCaptcha类的具体用法?PHP PhpCaptcha怎么用?PHP PhpCaptcha使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PhpCaptcha类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getReCaptchaImage
public function getReCaptchaImage()
{
$fontsDirectory = __DIR__ . '/../../../../include/captcha/';
$aFonts = array($fontsDirectory . 'fonts/VeraBd.ttf', $fontsDirectory . 'fonts/VeraIt.ttf', $fontsDirectory . 'fonts/Vera.ttf');
$oVisualCaptcha = new \PhpCaptcha($aFonts, 200, 60);
$oVisualCaptcha->Create(__DIR__ . '/../../../../images/cache/recaptcha.png');
return '/images/cache/recaptcha.png';
}
示例2: image
function image()
{
$imagesPath = ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'PhpCaptcha' . DS . 'fonts' . DS;
$aFonts = array($imagesPath . 'VeraBd.ttf', $imagesPath . 'VeraIt.ttf', $imagesPath . 'Vera.ttf');
$oVisualCaptcha = new PhpCaptcha($aFonts, 200, 60);
$oVisualCaptcha->UseColour(true);
//$oVisualCaptcha->SetOwnerText('Source: '.FULL_BASE_URL);
$oVisualCaptcha->SetNumChars(6);
$oVisualCaptcha->Create();
}
示例3: image
function image()
{
$imagesPath = realpath(VENDORS . 'phpcaptcha') . '/fonts/';
$aFonts = array($imagesPath . 'VeraBd.ttf', $imagesPath . 'VeraIt.ttf', $imagesPath . 'Vera.ttf');
$oVisualCaptcha = new PhpCaptcha($aFonts, 200, 60);
$oVisualCaptcha->UseColour(true);
//$oVisualCaptcha->SetOwnerText('Source: '.FULL_BASE_URL);
$oVisualCaptcha->SetNumChars(6);
$oVisualCaptcha->Create();
}
示例4: executeImage
public function executeImage()
{
$theme = sfConfig::get("app_phpcaptcha_theme", "Small");
if (class_exists("PHPCaptcha" . $theme . "Theme")) {
eval("\$theme = new PHPCaptcha" . $theme . "Theme();");
} else {
$theme = new PHPCaptchaSmallTheme();
}
$oVisualCaptcha = new PhpCaptcha($theme);
$oVisualCaptcha->setOwnerText(sfConfig::get("app_phpcaptcha_ownertext", ""));
$oVisualCaptcha->setHeight(sfConfig::get("app_phpcaptcha_height", $theme->getOption('height')));
$oVisualCaptcha->setWidth(sfConfig::get("app_phpcaptcha_width", $theme->getOption('width')));
$oVisualCaptcha->Create();
return sfView::NONE;
}
示例5: isFlooding
public function isFlooding()
{
$uid = GWF_Session::getUserID();
$uname = GWF_Shoutbox::generateUsername();
$euname = GDO::escape($uname);
$table = GDO::table('GWF_Shoutbox');
$max = $uid === 0 ? $this->module->cfgMaxPerDayGuest() : $this->module->cfgMaxPerDayUser();
// $cut = GWF_Time::getDate(GWF_Time::LEN_SECOND, time()-$this->module->cfgTimeout());
// $cnt = $table->countRows("shout_uname='$euname' AND shout_date>'$cut'");
# Check captcha
if ($this->module->cfgCaptcha()) {
require_once GWF_CORE_PATH . 'inc/3p/Class_Captcha.php';
if (!PhpCaptcha::Validate(Common::getPostString('captcha'), true)) {
return GWF_HTML::err('ERR_WRONG_CAPTCHA');
}
}
# Check date
$timeout = $this->module->cfgTimeout();
$last_date = $table->selectVar('MAX(shout_date)', "shout_uid={$uid} AND shout_uname='{$euname}'");
$last_time = $last_date === NULL ? 0 : GWF_Time::getTimestamp($last_date);
$next_time = $last_time + $timeout;
if ($last_time + $timeout > time()) {
return $this->module->error('err_flood_time', array(GWF_Time::humanDuration($next_time - time())));
}
# Check amount
$today = GWF_Time::getDate(GWF_Date::LEN_SECOND, time() - $timeout);
$count = $table->countRows("shout_uid={$uid} AND shout_date>='{$today}'");
if ($count >= $max) {
return $this->module->error('err_flood_limit', array($max));
}
# All fine
return false;
}
示例6: _processCaptcha
/**
* @return void
*/
private function _processCaptcha()
{
@session_start();
$captchaHandler = CampRequest::GetVar('f_captcha_handler', '', 'POST');
if (!empty($captchaHandler)) {
$captcha = Captcha::factory($captchaHandler);
if (!$captcha->validate()) {
$this->m_error = new PEAR_Error('The code you entered is not the same as the one shown.',
ACTION_SUBMIT_COMMENT_ERR_INVALID_CAPTCHA_CODE);
return FALSE;
}
} else {
$f_captcha_code = CampRequest::GetVar('f_captcha_code');
if (is_null($f_captcha_code) || empty($f_captcha_code)) {
$this->m_error = new PEAR_Error('Please enter the code shown in the image.',
ACTION_SUBMIT_COMMENT_ERR_NO_CAPTCHA_CODE);
return FALSE;
}
if (!PhpCaptcha::Validate($f_captcha_code, true)) {
$this->m_error = new PEAR_Error('The code you entered is not the same with the one shown in the image.',
ACTION_SUBMIT_COMMENT_ERR_INVALID_CAPTCHA_CODE);
return FALSE;
}
}
return TRUE;
}
示例7: doClean
protected function doClean($value)
{
$clean = (string) $value;
if (!PhpCaptcha::Validate($clean)) {
throw new sfValidatorError($this, 'invalid', array('value' => $value));
}
return $clean;
}
示例8: execute
public function execute()
{
# Don't store this url.
GWF3::setConfig('store_last_url', false);
# Load the Captcha class
require GWF_CORE_PATH . 'inc/3p/Class_Captcha.php';
# disable Logging
GWF3::setConfig('log_request', false);
# disable HTTP Caching
GWF_HTTP::noCache();
# Setup Font, Color, Size
$aFonts = $this->module->cfgCaptchaFont();
$rgbcolor = $this->module->cfgCaptchaBG();
$width = $this->module->cfgCaptchaWidth();
$height = $this->module->cfgCaptchaHeight();
$oVisualCaptcha = new PhpCaptcha($aFonts, $width, $height, $rgbcolor);
# Output the captcha
die($oVisualCaptcha->Create('', Common::getGetString('chars', true)));
}
示例9: crackcha_next
function crackcha_next(WC_Challenge $chall)
{
if (crackcha_round_over()) {
header('Content-Type: text/plain');
if (false === crackcha_insert_high($chall)) {
echo GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
return;
} else {
echo $chall->lang('msg_insert_high') . PHP_EOL;
echo crackcha_reset($chall);
return;
}
}
require_once GWF_CORE_PATH . 'inc/3p/Class_Captcha.php';
$chars = GWF_Random::randomKey(5, GWF_Random::ALPHAUP);
crackcha_increase_count();
GWF_Session::set('WCC_CRACKCHA_CHARS', $chars);
$aFonts = array(GWF_PATH . 'extra/font/teen.ttf');
$rgbcolor = GWF_CAPTCHA_COLOR_BG;
$oVisualCaptcha = new PhpCaptcha($aFonts, 210, 42, $rgbcolor);
$oVisualCaptcha->Create('', $chars);
}
示例10: image
function image()
{
$imagesPath = APP . 'vendors' . DS . 'phpcaptcha' . '/fonts/';
$aFonts = array($imagesPath . 'VeraBd.ttf', $imagesPath . 'VeraIt.ttf', $imagesPath . 'Vera.ttf');
$oVisualCaptcha = new PhpCaptcha($aFonts, 220, 60);
$oVisualCaptcha->UseColour(true);
$oVisualCaptcha->SetNumLines(false);
$oVisualCaptcha->DisplayShadow(false);
//$oVisualCaptcha->SetOwnerText('Source: '.FULL_BASE_URL);
$oVisualCaptcha->SetNumChars(5);
$oVisualCaptcha->Create();
}
示例11: __construct
/**
* Reads the input parameters and sets up the blogcomment action.
*
* @param array $p_input
*/
public function __construct(array $p_input)
{
$this->m_name = 'submit_blogcomment';
$this->m_defined = true;
$this->m_properties['blogentry_id'] = $p_input['f_blogentry_id'];
$BlogEntry = new BlogEntry($this->m_properties['blogentry_id']);
if (!$BlogEntry->exists()) {
$this->m_error = new PEAR_Error('None or invalid blogentry was given.', ACTION_BLOGCOMMENT_ERR_INVALID_ENTRY);
return;
}
/*
if (!isset($p_input['f_blogcomment_title']) || empty($p_input['f_blogcomment_title'])) {
$this->m_error = new PEAR_Error('The comment subject was not filled in.', ACTION_BLOGCOMMENT_ERR_NO_TITLE);
return;
}
*/
if (!isset($p_input['f_blogcomment_content']) || empty($p_input['f_blogcomment_content'])) {
$this->m_error = new PEAR_Error('The comment content was not filled in.', ACTION_BLOGCOMMENT_ERR_NO_CONTENT);
return;
}
if (SystemPref::Get('PLUGIN_BLOGCOMMENT_USE_CAPTCHA') == 'Y') {
@session_start();
$f_captcha_code = $p_input['f_captcha_code'];
if (is_null($f_captcha_code) || empty($f_captcha_code)) {
$this->m_error = new PEAR_Error('Please enter the code shown in the image.', ACTION_BLOGCOMMENT_ERR_NO_CAPTCHA_CODE);
return false;
}
if (!PhpCaptcha::Validate($f_captcha_code, true)) {
$this->m_error = new PEAR_Error('The code you entered is not the same with the one shown in the image.', ACTION_BLOGCOMMENT_ERR_INVALID_CAPTCHA_CODE);
return false;
}
}
$this->m_properties['title'] = $p_input['f_blogcomment_title'];
$this->m_properties['content'] = $p_input['f_blogcomment_content'];
$this->m_properties['mood_id'] = $p_input['f_blogcomment_mood_id'];
$this->m_properties['user_name'] = $p_input['f_blogcomment_user_name'];
$this->m_properties['user_email'] = $p_input['f_blogcomment_user_email'];
$this->m_blogcomment = new BlogComment($p_input['f_blogcomment_id']);
}
示例12: validate
public static function validate($checkType, $value)
{
$blnReturn = FALSE;
if (array_key_exists($checkType, self::$checks)) {
if (empty(self::$checks[$checkType])) {
$blnReturn = TRUE;
} else {
switch ($checkType) {
case VFORM_CAPTCHA:
$blnReturn = PhpCaptcha::Validate(ValidForm::get($value));
break;
default:
$blnReturn = preg_match(self::$checks[$checkType], $value);
}
}
} else {
$blnReturn = preg_match($checkType, $value);
}
return $blnReturn;
}
示例13: checkCommentWithCaptcha
/**
* Check posted comment with CAPTCHA
*/
function checkCommentWithCaptcha()
{
global $config, $pathToIndex, $userName, $sessionState, $app;
require $pathToIndex . '/plugins/captcha/php-captcha.inc.php';
switch ($config['language']) {
case 'japanese':
$textParts = array('コメント認証', 'コメント内容が認証出来ません。');
break;
default:
$textParts = array('Not Allowed', 'Request Not Allowed.');
break;
}
if (PhpCaptcha::Validate($_POST['captcha_phrase'])) {
return true;
} else {
$additionalTitle = $textParts[0];
$content = '<h2>' . $textParts[0] . '</h2>' . "\n" . '<div class="important warning">' . "\n" . '<p>' . $textParts[1] . '</p>' . "\n" . '</div>' . "\n";
$item = array('title' => $app->setTitle($additionalTitle), 'contents' => $content, 'result' => '', 'pager' => '');
$app->display($item, $sessionState);
exit;
}
}
示例14: CaptchaCheck
static function CaptchaCheck($text)
{
return PhpCaptcha::Validate($text);
}
示例15: PhpCaptchaColour
function PhpCaptchaColour($aFonts, $iWidth = CAPTCHA_WIDTH, $iHeight = CAPTCHA_HEIGHT)
{
// call parent constructor
parent::PhpCaptcha($aFonts, $iWidth, $iHeight);
// set options
$this->UseColour(true);
}