-1
最近、自分のウェブサイトのサーバーを移動しました。しかし、作業captcha.phpありえないからで引っ張られるキャプチャ機能(。アイブ氏は、権限をチェックし、すべて間違って行くことができ、他に何、罰金だ? The siteサイト移動後にCaptchaが壊れた
キャプチャフォームが底部に向かっている。その気持ちをIVE何か簡単なイム欠落
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);
}
?>
そして、ここでは修正($フォント=のrealpath($フォント)を追加;)です!
<?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] [エラー] [クライアント94.174.84.164] PHP警告:imagettftext():フォントを見つけることができませんでした/var/www/vhosts/intelligentmedia.co.uk/edexec/captcha.php 33行目、referer:http://www.edexec.co.uk/subscribe/ただし、フォントは644個のアクセス権を持っています。 。 – itsdanprice