<?php
// This file is a part of PunBB mod by xfir [xfir.net]
// Improved by mik01aj [m01.pl].
$imgx = 170; // Image width
$imgy = 40; // Image height
$size = 20; // Font size
$anglevariation = 30; // Minimum/maximum angle of text (random per character)
$color = array(246,182,32); // Text color
$bc = array(56,56,56); // Background color, (made transparent, used for antialiasing)
define('PUN_ROOT', '../');
require PUN_ROOT.'include/common.php';
// get all fonts from the ./fonts dir
$fonts = array();
$dir = opendir('./fonts');
while ($file=readdir($dir))
if (substr($file,-4)=='.ttf')
$fonts[]=$file;
closedir($dir);
// get the text to show
if ($_GET['example']==1)
$key = strtr(substr(strtoupper(base64_encode(md5(rand(),true))),4,6),'=+/','ASD');
else if(!$pun_user['reg_key']) $key = "ERROR!";
else $key = getregkey();
// create the image
$image = imagecreatetruecolor( $imgx, $imgy );
$color = imagecolorallocate($image, $color[0], $color[1], $color[2]);
$bc = imagecolorallocate( $image, $bc[0], $bc[1], $bc[2] );
imagecolortransparent( $image, $bc );
imagefill( $image, 0, 0, $bc );
$space = $imgx / 8; // space between chars
// paint chars
for ($i=0; $i<6; $i++) {
$angle = rand(-$anglevariation, $anglevariation);
$x = $space*($i+1) + $size*.5*sin(deg2rad($angle));
$y = ($imgy/2) + $size*.5*(cos(deg2rad($angle)));
imagettftext( $image, $size, $angle, $x, $y, $color, 'fonts/'.$fonts[array_rand($fonts)], $key{$i} );
}
// send it to the user
header ("Content-type: image/png");
imagepng($image);
imagedestroy($image);
?>