<?php

session_start();
$st= rand(0,2000);
$sto = rand(200,6000);
$sta = $st* $sto;
$string = substr($sta,0,5);
$captcha = imagecreatefrompng("./images/captcha.png");

function Hxdec_arr($color){
$int = hexdec($color);
$arr = array("red" => 0xFF & ($int >> 0x10),
             "green" => 0xFF & ($int >> 0x8),
             "blue" => 0xFF & $int);
return $arr;
}



$black = imagecolorallocate($captcha, 0, 0, 0);

$c1 = Hxdec_arr('DAEDF6');
$c2 = Hxdec_arr('9CB7C4');

$line = imagecolorallocate($captcha,$c1["red"],$c1["green"],$c1["blue"]);
$line2 = imagecolorallocate($captcha,$c2["red"],$c2["green"],$c2["blue"]);



imagestring($captcha,5, 10, 1, $string, $black);


$_SESSION['key'] = md5($string);

header("Content-type: image/png");
imagepng($captcha);


?>
