<?php
    /*************************************************************
    Author: Amit Deo Panwar
    Updated: March 31, 2005
    *************************************************************/

    $g=&$GLOBALS;        

    header("Content-type: image/jpeg");
    require_once("../../includes/site.php");
    //  error_reporting(0);

     // error_reporting(E_ALL);
    require_once(AM_LIB_PATH.'/am_general.php');
    require_once(AM_LIB_PATH.'/am_utils.php');
    am_dont_cachepage();


      
    function create_pic()
    {
        $g=&$GLOBALS;        
        
        //echo "value of  code".$g['code'];
        
        $g['code']=101010;
        
        if(!empty($g['code']))
        {
            $_SESSION['_UNIQ_CODE']=$g['code'];
        }                                      

        //       dbug($_SESSION['_UNIQ_CODE']);

        $im  = imagecreatetruecolor(150, 30); /* Create a blank image */
        $bgc = imagecolorallocate($im,0xff,0xff,0xff);//mt_rand(180,234), mt_rand(180,234), mt_rand(180,234));
        $tc  = imagecolorallocate($im, 0x00, 0x00, 0x00);
        imagefilledrectangle($im, 0, 0, mt_rand(150,200), 30, $bgc);
        
        /* Output an errmsg */
        //imagepsslantfont(5,mt_rand(100,200));
        //$f=imageloadfont("./tahoma.ttf");
        //imagestring($im, $f,mt_rand(5,10), 5, $_SESSION['_UNIQ_CODE'], $tc);
        for($i=0;$i<strlen($_SESSION['_UNIQ_CODE']);$i++)
        {
            imagettftext ( $im, 20, mt_rand(0,50), 15+$i*20,25, $tc, "./tahoma.ttf", $_SESSION['_UNIQ_CODE'][$i]);
        } 
        for($y=0;$y<=30;$y+=5)
        {
            imageline($im,0,$y,150,$y,$tc);
        }
        for($x=0;$x<=150;$x+=10)
        {
            imageline($im,$x,0,$x,30,$tc);
        }

        imagejpeg($im,'',100); // output to browser
        imageDestroy($im);
    }
    create_pic();
?>
