<?php
require_once './engine/common.inc.php';
if($update){
	updateauthcode();
}


function updateauthcode(){
	global $db,$sid;
$one=rand(0,9);
$two=rand(0,9);
$three=rand(0,9);
$four=rand(0,9);
$authnum=$one.$two.$three.$four;
$db->query("update g_sessions set authcode='$authnum' where sid='$sid'");
@gheader("Expires: -1");
@gheader("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
@gheader("Pragma: no-cache");
@gheader("Content-type: image/PNG"); 
$im = imagecreatetruecolor(60,23);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 250,250,250);
$gray = ImageColorAllocate($im, 100,100,100);
//imagefill($im,380,200,$gray);
imagestring($im, rand(6,14), rand(2,8), rand(2,8), $one, $white);
imagestring($im, rand(6,14), rand(14,18), rand(2,8), $two, $white);
imagestring($im, rand(6,14), rand(26,34), rand(2,8), $three, $white);
imagestring($im, rand(6,14), rand(42,50), rand(2,8), $four, $white);
for($i=0;$i<300;$i++)  
{
    $randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
    imagesetpixel($im, rand()%100 , rand()%40 , $randcolor);
}
ImagePNG($im);
imagedestroy($im);
}

?>

