Location: PHPKode > scripts > Lexperts Contact Form > lexperts-contact-form/captcha.php
<?php
@ini_set('session.use_cookies', '1');
@ini_set('session.use_trans_sid', 'false');
	
@session_set_cookie_params(0, '/');
@session_start();

if (ini_get('register_globals')) {
	$globals = array('_SESSION');

	foreach ($globals as $global) {
		foreach ($GLOBALS[$global] as $key => $value) {
			if ($value === @$GLOBALS[$key]) {
				unset($GLOBALS[$key]);
			}
		}
	}
}

header('Content-type: image/png');

$fonts  					= array ("arial.ttf", "verdana.ttf");
$im 						= @imagecreate(140, 26)or die("Cannot Initialize new GD image stream");
$white              		= imagecolorallocate($im, 255, 255, 255);
$black              		= imagecolorallocate($im, 79, 77, 79);
$links						= 6;

function generate_captcha($data) {
	$value	     			= '';  
	$charset     			= 'abcdefghijklmnopqrstuvwxyz1234567890';
    $charset_len			= strlen($charset) - 1;
    srand(microtime() * 1000000);
    
    for ($i=0;$i<$data;$i++)
    $value .= $charset{rand(0, $charset_len)};
    return $value;
}

for ($q=1; $q < 7; $q++){
    $generate_captcha[$q]   = generate_captcha(1);
    $size   	 			= rand (10,14);       
    $corner      			= rand (-15,15);
    $top     				= rand (16,20);
    $random_font    		= array_rand($fonts);
    imagettftext($im, $size, $corner, $links, $top, $black, 'font/'.$fonts[$random_font], $generate_captcha[$q]);
    $links 					= $links + 20;  
}

$_SESSION['captcha']		= $generate_captcha[1] . $generate_captcha[2] . $generate_captcha[3] . $generate_captcha[4] . $generate_captcha[5] . $generate_captcha[6];

imagepng($im);
imagedestroy($im);
?>
Return current item: Lexperts Contact Form