2012-05-08 15 views
-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); 
} 

?> 
+1

新しいサーバーにはGDがありますか? ReCaptchaのようなものを実装することを強くお勧めします(ユーザー補助機能が組み込まれているため)。 – MetalFrog

+2

あなたの[画像生成スクリプト](http://www.edexec.co.uk/captcha.php)が有効なPNGであると思われるものを生成していますので、私のお金はサーバー上に正しいフォントを持っています(私はそれを推測していますキャプチャテストを実装するために不安定なテキストを使用します)。 – halfer

+0

エラーログを見た後、それはフォントです:[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

答えて

1

私はPHPにGD installedが必要だと思いますが、captchaをレンダリングしようとしているときにサーバが遭遇しているエラーを知らずにはわかりません。ログを確認してください。

関連する問題