<?php
$width = "45"; // Width
$height = "20"; // Height
$bgcolor = "#ffffff"; // background color
$noise = true; // make noise
$noisenum = 100; // noise points
$border = true; // border
$bordercolor = "#000000";
$image = imageCreate($width, $height);
$back = getcolor($bgcolor);
imageFilledRectangle($image, 0, 0, $width, $height, $back);
$code = $_SESSION[authcode];
$code = 'ASDF';
$textColor = imageColorAllocate($image, rand(0,200), rand(0,200), rand(0,200));
imagestring($image, 5, 5, 2, $code, $textColor);
if ($noise == true){
for ($i = 0; $i < $noisenum; $i++) {
$randColor = imageColorAllocate($image, rand(0, 255), rand(0, 255), rand(0, 255));
imageSetPixel($image, rand(0, $width), rand(0, $height), $randColor);
}
}
if ($border == true){
$bordercolor = getcolor($bordercolor);
imageRectangle($image, 0, 0, $width-1, $height-1, $bordercolor);
}
header("Content-type: image/png");
imagePng($image);
function getcolor($color)
{
global $image;
$r = hexdec ($color[1] . $color[2]);
$b = hexdec ($color[3] . $color[4]);
$g = hexdec ($color[5] . $color[6]);
return imagecolorallocate ($image, $r, $b, $g);
}
?>