Location: PHPKode > projects > mBlog > visual.php
<?php
require './includes/user_init.php';
$font = $config['abs_path'].'/conman.ttf';

// imageTTFtext supported?
if (function_exists ('imageTTFtext')) $ttf = 1; else $ttf = 0;

// init vars
$confirm_ses = get_param ('confirm_ses');
$t = random_str (5);
$w = 100;
$h = 30;
$now = mktime ();
$was = mktime () - 600;

sql_query ("DELETE FROM m_confirm WHERE confirm_time < $was");
sql_query ("INSERT IGNORE INTO m_confirm VALUES ('$confirm_ses', '$now', '$t')");

header ('Content-Type: image/png');
$gb = imagecreate ($w, $h);
$bgc = imagecolorallocate ($gb, 255, 255, 255);
$grc = imagecolorallocate ($gb, 200, 200, 200);

for ($i = 0; $i < 5; $i++)
{
	$fgc = imagecolorallocate ($gb, mt_rand (0,128), mt_rand (0,128), mt_rand (0,128));
	$y = 21 - mt_rand (0, 5);
	$x = $i * 16;
	$c = mt_rand (0, 6);
	$d = (mt_rand (0, 10)) * 2;
	$q = (mt_rand (0, 1)); if ($q) $d = $d * -1;
	if ($ttf)
		imageTTFtext ($gb, 16, $d, $x + 5, $y, $fgc, $font, $t[$i]);
	else
		imagechar ($gb, 5, $x, $y-15, $t[$i], $fgc);
}
imagePNG ($gb);
imagedestroy ($gb);
?>
Return current item: mBlog