-1
我最近移动了我的网站的服务器。然而,验证码的功能(这是从captcha.php心不是工作。伊夫拉查权限,这一切似乎好,还有什么可以去错了吗? The site网站移动后破解验证码
的验证码的形式是向底部。香港专业教育学院一种感觉,它的!简单的东西我在想念
Captcha.php:
<?php
//Start the session so we can store what the security code actually is
session_start();
//Send a generated image to the browser
create_image();
exit();
function create_image()
{
// Set the content-type
header("Content-type: image/jpg");
// Create the image
$im = imagecreatetruecolor(100, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = $_SESSION["captcha"];
// Replace path by your own font path
$font = 'caviardreams.ttf';
// Add some shadow to the text
imagettftext($im, 15, 0, 11, 21, $grey, $font, $text);
// Add the text
imagettftext($im, 15, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
}
?>
这里是修复(添加$字体=真实路径($字体);):
<?php
//Start the session so we can store what the security code actually is
session_start();
//Send a generated image to the browser
create_image();
exit();
function create_image()
{
// Set the content-type
header("Content-type: image/jpg");
// Create the image
$im = imagecreatetruecolor(100, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = $_SESSION["captcha"];
// Replace path by your own font path
$font = 'caviardreams.ttf';
$font = realpath($font);
// Add some shadow to the text
imagettftext($im, 15, 0, 11, 21, $grey, $font, $text);
// Add the text
imagettftext($im, 15, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
}
?>
新服务器是否有GD?我强烈建议实施类似reCaptcha的方法,以使您和用户更轻松(因为它具有内置的辅助功能)。 – MetalFrog
你的[图像生成脚本](http://www.edexec.co.uk/captcha.php)正在生产看起来是有效的PNG,所以我的钱是在服务器上有正确的字体(我假设它使用摇晃的文本来实现验证码测试)。 – halfer
看看错误日志后,它看起来是字体:[Tue May 08 18:24:28 2012] [error] [client 94.174.84.164] PHP Warning:imagettftext():找不到/打开字体在/var/www/vhosts/intelligentmedia.co.uk/edexec/captcha.php 33行,referer:http://www.edexec.co.uk/subscribe/然而,字体在那里,有644个权限.. – itsdanprice