下面是调用验证图片的代码
<td>
<div id="captchaimage">
<a href="<?php echo $_SERVER['PHP_SELF']; ?>" onclick="refreshimg(); return false;" title="Click to refresh image">
<img class="cimage" src="captcha/GD_Security_image.php?<?php echo time(); ?>" alt="Captcha image" />
</a>
</div>
</td>下面是GD_Security_image.php的内容
<?php function show_gd_img($content="")
{
$content = ' '. preg_replace( "/(\w)/", "\\1 ", $content ) .' ';
$gd_version = 2;
@header("Content-Type: image/jpeg");
$tmp_x = 140;
$tmp_y = 20;
$image_x = 210;
$image_y = 65;
$circles = 3;
if ( $gd_version == 1 )
{
$tmp = imagecreate($tmp_x, $tmp_y);
$im = imagecreate($image_x, $image_y);
}
else
{
$tmp = imagecreatetruecolor($tmp_x, $tmp_y);
$im = imagecreatetruecolor($image_x, $image_y);
}
$white = ImageColorAllocate($tmp, 255, 255, 255);
$black = ImageColorAllocate($tmp, 0, 0, 0);
$grey = ImageColorAllocate($tmp, 210, 210, 210 );
imagefill($tmp, 0, 0, $white);
for ( $i = 1; $i <= $circles; $i++ )
{
$values = array(
0 => rand(0, $tmp_x - 10),
1 => rand(0, $tmp_y - 3),
2 => rand(0, $tmp_x - 10),
3 => rand(0, $tmp_y - 3),
4 => rand(0, $tmp_x - 10),
5 => rand(0, $tmp_y - 3),
6 => rand(0, $tmp_x - 10),
7 => rand(0, $tmp_y - 3),
8 => rand(0, $tmp_x - 10),
9 => rand(0, $tmp_y - 3),
10 => rand(0, $tmp_x - 10),
11 => rand(0, $tmp_y - 3),
);
$randomcolor = imagecolorallocate( $tmp, rand(100,255), rand(100,255),rand(100,255) );
imagefilledpolygon($tmp, $values, 6, $randomcolor );
} imagestring($tmp, 5, 0, 2, $content, $black);
//-----------------------------------------
// Distort by resizing
//-----------------------------------------
imagecopyresized($im, $tmp, 0, 0, 0, 0, $image_x, $image_y, $tmp_x, $tmp_y);
imagedestroy($tmp);
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
$grey = ImageColorAllocate($im, 100, 100, 100 );
$random_pixels = $image_x * $image_y / 10;
for ($i = 0; $i < $random_pixels; $i++)
{
ImageSetPixel($im, rand(0, $image_x), rand(0, $image_y), $black);
}
$no_x_lines = ($image_x - 1) / 5;
for ( $i = 0; $i <= $no_x_lines; $i++ )
{
// X lines
ImageLine( $im, $i * $no_x_lines, 0, $i * $no_x_lines, $image_y, $grey );
// Diag lines
ImageLine( $im, $i * $no_x_lines, 0, ($i * $no_x_lines)+$no_x_lines, $image_y, $grey );
}
$no_y_lines = ($image_y - 1) / 5;
for ( $i = 0; $i <= $no_y_lines; $i++ )
{
ImageLine( $im, 0, $i * $no_y_lines, $image_x, $i * $no_y_lines, $grey );
}
ImageJPEG($im);
ImageDestroy($im);
exit();
}if(!isset($_SESSION))
require_once('newsession.php');
$_SESSION['captcha_id'] = $str;
$_SESSION['captcha_time'] = time();show_gd_img($str);
?>----------------------我是分割线-------------------------图片显示不了,一个大X。 各位高手救命啊!!!!!!!!!1
<td>
<div id="captchaimage">
<a href="<?php echo $_SERVER['PHP_SELF']; ?>" onclick="refreshimg(); return false;" title="Click to refresh image">
<img class="cimage" src="captcha/GD_Security_image.php?<?php echo time(); ?>" alt="Captcha image" />
</a>
</div>
</td>下面是GD_Security_image.php的内容
<?php function show_gd_img($content="")
{
$content = ' '. preg_replace( "/(\w)/", "\\1 ", $content ) .' ';
$gd_version = 2;
@header("Content-Type: image/jpeg");
$tmp_x = 140;
$tmp_y = 20;
$image_x = 210;
$image_y = 65;
$circles = 3;
if ( $gd_version == 1 )
{
$tmp = imagecreate($tmp_x, $tmp_y);
$im = imagecreate($image_x, $image_y);
}
else
{
$tmp = imagecreatetruecolor($tmp_x, $tmp_y);
$im = imagecreatetruecolor($image_x, $image_y);
}
$white = ImageColorAllocate($tmp, 255, 255, 255);
$black = ImageColorAllocate($tmp, 0, 0, 0);
$grey = ImageColorAllocate($tmp, 210, 210, 210 );
imagefill($tmp, 0, 0, $white);
for ( $i = 1; $i <= $circles; $i++ )
{
$values = array(
0 => rand(0, $tmp_x - 10),
1 => rand(0, $tmp_y - 3),
2 => rand(0, $tmp_x - 10),
3 => rand(0, $tmp_y - 3),
4 => rand(0, $tmp_x - 10),
5 => rand(0, $tmp_y - 3),
6 => rand(0, $tmp_x - 10),
7 => rand(0, $tmp_y - 3),
8 => rand(0, $tmp_x - 10),
9 => rand(0, $tmp_y - 3),
10 => rand(0, $tmp_x - 10),
11 => rand(0, $tmp_y - 3),
);
$randomcolor = imagecolorallocate( $tmp, rand(100,255), rand(100,255),rand(100,255) );
imagefilledpolygon($tmp, $values, 6, $randomcolor );
} imagestring($tmp, 5, 0, 2, $content, $black);
//-----------------------------------------
// Distort by resizing
//-----------------------------------------
imagecopyresized($im, $tmp, 0, 0, 0, 0, $image_x, $image_y, $tmp_x, $tmp_y);
imagedestroy($tmp);
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
$grey = ImageColorAllocate($im, 100, 100, 100 );
$random_pixels = $image_x * $image_y / 10;
for ($i = 0; $i < $random_pixels; $i++)
{
ImageSetPixel($im, rand(0, $image_x), rand(0, $image_y), $black);
}
$no_x_lines = ($image_x - 1) / 5;
for ( $i = 0; $i <= $no_x_lines; $i++ )
{
// X lines
ImageLine( $im, $i * $no_x_lines, 0, $i * $no_x_lines, $image_y, $grey );
// Diag lines
ImageLine( $im, $i * $no_x_lines, 0, ($i * $no_x_lines)+$no_x_lines, $image_y, $grey );
}
$no_y_lines = ($image_y - 1) / 5;
for ( $i = 0; $i <= $no_y_lines; $i++ )
{
ImageLine( $im, 0, $i * $no_y_lines, $image_x, $i * $no_y_lines, $grey );
}
ImageJPEG($im);
ImageDestroy($im);
exit();
}if(!isset($_SESSION))
require_once('newsession.php');
$_SESSION['captcha_id'] = $str;
$_SESSION['captcha_time'] = time();show_gd_img($str);
?>----------------------我是分割线-------------------------图片显示不了,一个大X。 各位高手救命啊!!!!!!!!!1
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货