= 220) { $horizpos = 0; } $horizpos += rand(20, 30); } } // Horizontal lines if (!isset($_GET['grid'])) { $ypos = mt_rand(1, 5); while ($ypos <= 39) { if (isset($_GET['grey'])) { $rcolor = mt_rand(100, 240); $randcolour = imagecolorallocate($image, $rcolor, $rcolor, $rcolor); } else { $randcolour = imagecolorallocate($image, rand(100, 240), rand(100, 240), rand(100, 240)); } imageline($image, 0, $ypos, 240, $ypos, $randcolour); $ypos += mt_rand(2, 10); } // Vertical lines $xpos = mt_rand(1, 5); while ($xpos <= 249) { if (isset($_GET['grey'])) { $rcolor = mt_rand(100, 240); $randcolour = imagecolorallocate($image, $rcolor, $rcolor, $rcolor); } else { $randcolour = imagecolorallocate($image, rand(100, 240), rand(100, 240), rand(100, 240)); } imageline($image, $xpos, 0, $xpos, 40, $randcolour); $xpos += mt_rand(2, 10); } } // The real code $horizpos = mt_rand(10, 30); $realcode = ''; $realcode = md5($thekey) . md5($hash); $realcode = strtoupper(md5($realcode)); for ($i=0;$i<=30;$i+=7) { $fontface = mt_rand(0,2); if ($fontface == 0) { $vertpos = mt_rand(0, 10); } elseif ($fontface == 1) { $vertpos = (mt_rand(0, 10)) - 7; } else { $vertpos = (mt_rand(0, 20)) - 7; } $red = mt_rand(40, 140); if (isset($_GET['greyt'])) { $green = $red; $blue = $red; } else { $green = mt_rand(40, 140); $blue = mt_rand(40, 140); } $maincolor = imagecolorallocate($image, $red, $green, $blue); $hilight = imagecolorallocate($image, $red + 60, $green + 60, $blue + 60); $shadow = imagecolorallocate($image, $red - 40, $green - 40, $blue - 40); imagestring($image, $font[$fontface], $horizpos + 1, $vertpos + 1, $realcode[$i], $shadow); imagestring($image, $font[$fontface], $horizpos - 1, $vertpos - 1, $realcode[$i], $hilight); imagestring($image, $font[$fontface], $horizpos, $vertpos, $realcode[$i], $maincolor); $horizpos += mt_rand(25, 40); } } else // We've not got a hash so report an error { $red = imagecolorallocate($image, 255, 0, 0); imagestring($image, 5, 2, 3, 'ERROR! ERROR!', $red); } // Dump the image to the buffer imagepng($image); // Do our headers $date = date("D, d M Y H:i:s"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); header('Content-type: image/png'); header('Content-Length: ' . ob_get_length()); header("Expires: Sat, 1 Jan 2000 00:00:00 GMT"); header("Last-Modified: $date GMT"); // Dump the buffer ob_end_flush(); // Tidy up imagedestroy($image); ?>