Przykladowa sygnatura

To jest kod
Kod
<?php
// ustawienia //
$tlo = 'http://img355.imageshack.us/img355/4425/rosejv8.jpg';
$nick_x = 70;
$nick_y = 24;
$level_x = 70;
$level_y = 38;
$serwer_x = 70;
$serwer_y = 52;
$profesja_x = 70;
$profesja_y = 66;
$font_color = 'black';
$quality = 80; // [0..100]
function color($img, $hex='black')
{
$colors = array('aqua' => '#00FFFF', 'black' => '#000000', 'blue' => '#0000FF', 'fuchsia' => '#FF00FF',
'gray' => '#808080', 'green' => '#008000', 'lime' => '#00FF00', 'maroon' => '#800000',
'navy' => '#000080', 'olive' => '#808000', 'purple' => '#800080', 'red' => '#FF0000',
'teal' => '#008080', 'silver' => '#E0DFE3', 'white' => '#FFFFFF', 'yellow' => '#FFFF00');
// walidacja podanego koloru //
$hex = ($colors[strtolower($hex)]) ? $colors[strtolower($hex)] : strtoupper($hex);
$hex = ($hex{0} == '#') ? substr($hex, 1, 6) : substr($hex, 0, 6);
$hex = $hex.str_repeat('0', (6-strlen($hex)));
$hex = (preg_match('#[^0-9A-F]#', $hex)) ? '000000' : $hex;
list($r, $g, $b) = array(hexdec($hex{0}.$hex{1}), hexdec($hex{2}.$hex{3}), hexdec($hex{4}.$hex{5}));
return(imagecolorallocate($img, $r, $g, $b));
}
if(!$_POST['nick'] || !$_POST['level'] || !$_POST['serwer'] || !$_POST['profesja'])
{
echo('
<form action="" method="POST">
Nick:<input type="text" value="'.htmlentities(stripslashes($_POST['nick'])).'" name="nick" maxlength="30" /><br />
Level:<input type="text" value="'.htmlentities(stripslashes($_POST['level'])).'" name="level" maxlength="5" /><br />
Profesja:<input type="text" value="'.htmlentities(stripslashes($_POST['serwer'])).'" name="serwer" maxlength="50" /><br />
Clan:<input type="text" value="'.htmlentities(stripslashes($_POST['profesja'])).'" name="profesja" maxlength="30" /><br />
<input type="submit" name="send" value="Twórz sygnaturkę" />
</form>');
}
else
{
$nick = substr(trim(stripslashes($_POST['nick'])), 0, 30);
$level = substr(trim(stripslashes($_POST['level'])), 0, 5);
$serwer = substr(trim(stripslashes($_POST['serwer'])), 0, 50);
$profesja = substr(trim(stripslashes($_POST['profesja'])), 0, 30);
$img = imagecreatefromjpeg($tlo);
color($img, 'white');
$font_color = color($img, $font_color);
imagestring($img, 5, $nick_x, $nick_y, $nick, $font_color);
imagestring($img, 5, $level_x, $level_y, $level, $font_color);
imagestring($img, 5, $serwer_x, $serwer_y, $serwer, $font_color);
imagestring($img, 5, $profesja_x, $profesja_y, $profesja, $font_color);
$filename = preg_replace('#[^a-zA-Z0-9_-]#', '', $nick);
do
{
$filename = './sygnaturki/tibia/'.$filename.'_'.substr(md5(uniqid(null, true)), 0, 5).'.jpg';
if(file_exists($filename))
continue;
else
break;
}
while(1==1);
imagejpeg($img, $filename, $quality);
imagedestroy($img);
echo('<img src="'.$filename.'" alt="Image" /><br /><br /><b>Link: </b>http://'.$_SERVER['SERVER_NAME'].preg_replace('#^(.*?)/([^/]*?)$#', '\1/', $_SERVER['PHP_SELF']).substr($filename, 2).'<br /><br /><a href="">Powrót</a>');
}
?>
// ustawienia //
$tlo = 'http://img355.imageshack.us/img355/4425/rosejv8.jpg';
$nick_x = 70;
$nick_y = 24;
$level_x = 70;
$level_y = 38;
$serwer_x = 70;
$serwer_y = 52;
$profesja_x = 70;
$profesja_y = 66;
$font_color = 'black';
$quality = 80; // [0..100]
function color($img, $hex='black')
{
$colors = array('aqua' => '#00FFFF', 'black' => '#000000', 'blue' => '#0000FF', 'fuchsia' => '#FF00FF',
'gray' => '#808080', 'green' => '#008000', 'lime' => '#00FF00', 'maroon' => '#800000',
'navy' => '#000080', 'olive' => '#808000', 'purple' => '#800080', 'red' => '#FF0000',
'teal' => '#008080', 'silver' => '#E0DFE3', 'white' => '#FFFFFF', 'yellow' => '#FFFF00');
// walidacja podanego koloru //
$hex = ($colors[strtolower($hex)]) ? $colors[strtolower($hex)] : strtoupper($hex);
$hex = ($hex{0} == '#') ? substr($hex, 1, 6) : substr($hex, 0, 6);
$hex = $hex.str_repeat('0', (6-strlen($hex)));
$hex = (preg_match('#[^0-9A-F]#', $hex)) ? '000000' : $hex;
list($r, $g, $b) = array(hexdec($hex{0}.$hex{1}), hexdec($hex{2}.$hex{3}), hexdec($hex{4}.$hex{5}));
return(imagecolorallocate($img, $r, $g, $b));
}
if(!$_POST['nick'] || !$_POST['level'] || !$_POST['serwer'] || !$_POST['profesja'])
{
echo('
<form action="" method="POST">
Nick:<input type="text" value="'.htmlentities(stripslashes($_POST['nick'])).'" name="nick" maxlength="30" /><br />
Level:<input type="text" value="'.htmlentities(stripslashes($_POST['level'])).'" name="level" maxlength="5" /><br />
Profesja:<input type="text" value="'.htmlentities(stripslashes($_POST['serwer'])).'" name="serwer" maxlength="50" /><br />
Clan:<input type="text" value="'.htmlentities(stripslashes($_POST['profesja'])).'" name="profesja" maxlength="30" /><br />
<input type="submit" name="send" value="Twórz sygnaturkę" />
</form>');
}
else
{
$nick = substr(trim(stripslashes($_POST['nick'])), 0, 30);
$level = substr(trim(stripslashes($_POST['level'])), 0, 5);
$serwer = substr(trim(stripslashes($_POST['serwer'])), 0, 50);
$profesja = substr(trim(stripslashes($_POST['profesja'])), 0, 30);
$img = imagecreatefromjpeg($tlo);
color($img, 'white');
$font_color = color($img, $font_color);
imagestring($img, 5, $nick_x, $nick_y, $nick, $font_color);
imagestring($img, 5, $level_x, $level_y, $level, $font_color);
imagestring($img, 5, $serwer_x, $serwer_y, $serwer, $font_color);
imagestring($img, 5, $profesja_x, $profesja_y, $profesja, $font_color);
$filename = preg_replace('#[^a-zA-Z0-9_-]#', '', $nick);
do
{
$filename = './sygnaturki/tibia/'.$filename.'_'.substr(md5(uniqid(null, true)), 0, 5).'.jpg';
if(file_exists($filename))
continue;
else
break;
}
while(1==1);
imagejpeg($img, $filename, $quality);
imagedestroy($img);
echo('<img src="'.$filename.'" alt="Image" /><br /><br /><b>Link: </b>http://'.$_SERVER['SERVER_NAME'].preg_replace('#^(.*?)/([^/]*?)$#', '\1/', $_SERVER['PHP_SELF']).substr($filename, 2).'<br /><br /><a href="">Powrót</a>');
}
?>
I chcialbym zrobic mozliwosc wybierania koloru czcionki , czcionki oraz tla ( tak jak na http://www.tibia.org.pl/static/out/stat.php )
Z gory dziekuje za pomoc