$captcha = get_input('captcha_input');
$captchab = get_input('captcha_token');echo $captcha.'<br><br>';
echo $captchab; exit;显示的是
111f6f065e275f0f1b35ac86f0b92c16650所以想问我怎么把f6f065e275f0f1b35ac86f0b92c16650解密成111或者是将111加密成f6f065e275f0f1b35ac86f0b92c16650,以便将输入的验证码正确与否进行判断。下面是有关验证码的代码<?php
/**
* Elgg captcha plugin graphics file generator
*
* @package ElggCaptcha
*/ global $CONFIG;
$token = get_input('captcha_token'); // Output captcha
if ($token)
{
// Set correct header
header("Content-type: image/jpeg");
// Generate captcha
$captcha = captcha_generate_captcha($token);
// Pick a random background image
$n = rand(1, $CONFIG->captcha_num_bg);
$image = imagecreatefromjpeg($CONFIG->pluginspath . "captcha/backgrounds/bg$n.jpg");
// Create a colour (black so its not a simple matter of masking out one colour and ocring the rest)
$colour = imagecolorallocate($image, 0,0,0);
// Write captcha to image
//imagestring($image, 5, 30, 4, $captcha, $black);
imagettftext($image, 30, 0, 10, 30, $colour, $CONFIG->pluginspath . "captcha/fonts/1.ttf", $captcha);
// Output image
imagejpeg($image);
// Free memory
imagedestroy($image);
}
?>
$captchab = get_input('captcha_token');echo $captcha.'<br><br>';
echo $captchab; exit;显示的是
111f6f065e275f0f1b35ac86f0b92c16650所以想问我怎么把f6f065e275f0f1b35ac86f0b92c16650解密成111或者是将111加密成f6f065e275f0f1b35ac86f0b92c16650,以便将输入的验证码正确与否进行判断。下面是有关验证码的代码<?php
/**
* Elgg captcha plugin graphics file generator
*
* @package ElggCaptcha
*/ global $CONFIG;
$token = get_input('captcha_token'); // Output captcha
if ($token)
{
// Set correct header
header("Content-type: image/jpeg");
// Generate captcha
$captcha = captcha_generate_captcha($token);
// Pick a random background image
$n = rand(1, $CONFIG->captcha_num_bg);
$image = imagecreatefromjpeg($CONFIG->pluginspath . "captcha/backgrounds/bg$n.jpg");
// Create a colour (black so its not a simple matter of masking out one colour and ocring the rest)
$colour = imagecolorallocate($image, 0,0,0);
// Write captcha to image
//imagestring($image, 5, 30, 4, $captcha, $black);
imagettftext($image, 30, 0, 10, 30, $colour, $CONFIG->pluginspath . "captcha/fonts/1.ttf", $captcha);
// Output image
imagejpeg($image);
// Free memory
imagedestroy($image);
}
?>
解决方案 »
- 我想知道哪里不对了,关于 preg_replace
- mootools 怎么获取div下所有的a标签
- 新手提问,绝不低级!
- 把ACCESS数据导入到MYSQL,换行不行
- php mail函数不可以设置邮件优先就级别的问题?
- 在线求教mysql问题
- 数组赋值的问题!(在线等待)
- 请问,如何将FORM中的数据在客户端加密后再提交到服务器?
- 请教!!如何修改httpd.conf ,使目录可以浏览,就是不出现"你无权查看该页" ?
- ubutun 下php 配置文件的诡异问题
- windows2003使用nginx+php服务启动的问题 我现在只能使用这样批处理启动,但是一注销用户就会停止工作。 start_nginx.bat [co
- 如何启用tokenizer?
/**
* Elgg captcha plugin
*
* @package ElggCaptcha
*/ function captcha_init()
{
global $CONFIG;
// Register page handler for captcha functionality
register_page_handler('captcha','captcha_page_handler');
// Extend CSS
elgg_extend_view('css','captcha/css');
// Number of background images
$CONFIG->captcha_num_bg = 5;
// Default length
$CONFIG->captcha_length = 5;
// Register a function that provides some default override actions
register_plugin_hook('actionlist', 'captcha', 'captcha_actionlist_hook');
// Register actions to intercept
$actions = array();
$actions = trigger_plugin_hook('actionlist', 'captcha', null, $actions);
if (($actions) && (is_array($actions)))
{
foreach ($actions as $action)
register_plugin_hook("action", $action, "captcha_verify_action_hook");
}
}
function captcha_page_handler($page)
{
global $CONFIG;
if (isset($page[0])) {
set_input('captcha_token',$page[0]);
} include($CONFIG->pluginspath . "captcha/captcha.php");
}
/**
* Generate a token to act as a seed value for the captcha algorithm.
*/
function captcha_generate_token()
{
return md5(generate_action_token(time()).rand()); // Use action token plus some random for uniqueness
}
/**
* Generate a captcha based on the given seed value and length.
*
* @param string $seed_token
* @return string
*/
function captcha_generate_captcha($seed_token)
{
global $CONFIG;
/*
* We generate a token out of the random seed value + some session data,
* this means that solving via pr0n site or indian cube farm becomes
* significantly more tricky (we hope).
*
* We also add the site secret, which is unavailable to the client and so should
* make it very very hard to guess values before hand.
*
*/
return strtolower(substr(md5(generate_action_token(0) . $seed_token), 0, $CONFIG->captcha_length));
}
/**
* Verify a captcha based on the input value entered by the user and the seed token passed.
*
* @param string $input_value
* @param string $seed_token
* @return bool
*/
function captcha_verify_captcha($input_value, $seed_token)
{
if (strcasecmp($input_value, captcha_generate_captcha($seed_token)) == 0)
return true;
return false;
}
/**
* Listen to the action plugin hook and check the captcha.
*
* @param unknown_type $hook
* @param unknown_type $entity_type
* @param unknown_type $returnvalue
* @param unknown_type $params
*/
function captcha_verify_action_hook($hook, $entity_type, $returnvalue, $params)
{
$token = get_input('captcha_token');
$input = get_input('captcha_input');
if (($token) && (captcha_verify_captcha($input, $token)))
return true;
register_error(elgg_echo('captcha:captchafail')); // forward to referrer or else action code sends to front page
forward(REFERER);
return false;
}
/**
* This function returns an array of actions the captcha will expect a captcha for, other plugins may
* add their own to this list thereby extending the use.
*
* @param unknown_type $hook
* @param unknown_type $entity_type
* @param unknown_type $returnvalue
* @param unknown_type $params
*/
function captcha_actionlist_hook($hook, $entity_type, $returnvalue, $params)
{
if (!is_array($returnvalue))
$returnvalue = array();
$returnvalue[] = 'register';
$returnvalue[] = 'user/requestnewpassword';
return $returnvalue;
}
register_elgg_event_handler('init','system','captcha_init');
?>
/**
* Elgg captcha plugin captcha hook view override.
*
* @package ElggCaptcha
*/ // Generate a token which is then passed into the captcha algorithm for verification
$token = captcha_generate_token();
?>
<div class="captcha">
<input type="hidden" name="captcha_token" value="<?php echo $token; ?>" />
<label>
<?php echo elgg_echo('captcha:entercaptcha'); ?><br /><br />
<div class="captcha-right">
<img class="captcha-input-image" src="<?php echo $vars['url'] . "pg/captcha/$token"; ?>" /><br />
</div><br />
<div class="captcha-left">
<?php echo elgg_view('input/text', array('internalname' => 'captcha_input', 'class' => 'captcha-input-text')); ?>
</div>
</label>
</div>