验证码不能在我的CentOS服务器上运行

时间:2014-12-27 16:23:26

标签: php

我在我的注册表格上使用验证码.....代码本身很好......我已经在几台服务器上使用它了今天我重新测试jsut以确保.....但我有这一台服务器除了验证码不想要出现之外,evrything运行得很好.... PHP:5.5.11 操作系统:CentOS(5.11) 我认为这是服务器相关问题的任何想法?我认为问题出在GD Libraries上......但它们也显示为已安装且运行良好

<?php
// Set the header
header("Content-type: image/jpeg");

// Start the session
session_start(); 

// Generate the 5 digits string
$text = rand(10000,99999); 

// Store the generated code into the _SESSION captcha
$_SESSION['captcha'] = $text;

// Define the Image Height & Width
$width = 75;
$height = 37;  

// Create the Image
$image = imagecreate($width, $height); 

// Set the background color
//$black = imagecolorallocate($image, 88, 180, 22);
//$black = imagecolorallocate($image, 233, 98, 67);
    $black = imagecolorallocate($image, 68, 138, 191);
// Set the text color
$white = imagecolorallocate($image, 255, 255, 255);

// Set the font size
$font_size = rand(); 

// Generate noise
// for($noise = 0; $noise <= 20; $noise++) {
    // $x = mt_rand(10, $width-10);
    // $y = mt_rand(10, $height-10);
    // imageline($image, $x, $y, $x, $y, $white);
// }

// Draw the string with the given coordinates
imagestring($image, $font_size, 15, 10, $text, $white);

imageline($image, 0, mt_rand(5, $height-5), $width, mt_rand(5, $height-5), $white);
imageline($image, mt_rand(10, $width-10), 0, 0, mt_rand(10, $width-10), $white);

// Output the $image, don't save the file name, set quality
imagejpeg($image, null, 100); 
?>

1 个答案:

答案 0 :(得分:0)

它变成了GD库,我不得不重新编译我的php