rendered paste body<?php
define('DIR', '../../img/font');
define('FONT_SIZE', 12);
define('SPACE_PIX', 20);
define('IMG_WIDTH', 500);
define('IMG_HEIGHT', 100);
$fonts = array();
// Indexing
if(is_dir(DIR)) {
if($dh = opendir(DIR)) {
while (($file = readdir($dh)) !== false)
if(preg_match('/\.ttf$/', $file))
$fonts[] = $file;
closedir($dh);
}
}
// Image Creating
if(in_array($_GET['f'].'.ttf', $fonts)) {
$text = array('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz', '123456789');
header('Content-type: image/png');
$img = imagecreate(IMG_WIDTH, IMG_HEIGHT);
$bg = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
$txt = imagecolorallocate($img, 0x00, 0x00, 0x00);
imagettftext($img, FONT_SIZE, 0, 10 , 10, $txt, DIR.'/'.$_GET['f'].'.ttf', $text[0]);
imagettftext($img, FONT_SIZE, 0, 10 , 10 + SPACE_PIX, $txt, DIR.'/'.$_GET['f'].'.ttf', $text[1]);
imagettftext($img, FONT_SIZE, 0, 10 , 10 + SPACE_PIX + SPACE_PIX, $txt, DIR.'/'.$_GET['f'].'.ttf', $text[2]);
imagepng($img);
imagedestroy($img);
}
?>