#native_company# #native_desc#

button builder

By Scott Marlowe
on February 16, 2001

Version: 1.0

Type: Sample Code (HOWTO)

Category: Graphics

License: GNU General Public License

Description: Allows you to upload a button background, then select a font, text, size, and color to place on top. Very simple little script.

# Here we check to see if someone is uploading a new png to build a button on.
if ($userfile){
#	print $userfile_name."<BR>n";
	copy ($userfile,"button.png");
#	print $userfile;
#	exit;
if (!$text) $text="ABCD";
if (!$size) $size=25;
if (!$color) $color="ffffff";
if ($test_font){
	print "Now displaying font: $test_font<BR>";
	$tmp=str_replace(" ","+",$test_font);
	print "<img src=button.html?font=$tmp&text=$tmp2&size=$size&color=$color>";
print $test_font;
if (!$text) $text="Testing: Sxooter";
if (!$font) $font="acme_explosive/acme.TTF";
# Here we find all the fonts installed in the font_path directory and make a list of them.
# Note that ttf fonts are represented by a directory here..

while (false!=($file = readdir($dp))){
	if ($file!="." && $file!=".."){
		if (is_dir($font_path.$file)){

# Next we look in each directory fir a file, each one being a font, and build a list of those fonts
# stored by font directory name.

foreach($font_name as $font){
	while (false!=($file = readdir($dp))){
		if ($file!="." && $file!=".."){
			if (eregi("ttf$",$file)){
if (!$test_font) $test_font=$font_name[0]."/".$faces[$font_faces[$font_name[0]]][0];
<form name=form method=post>
<input type=text name=text value="<?php print $text;?>"><BR>
Pick a font:<select name=test_font onChange=document.form.submit();>
<option value=0>Please Choose</option>
foreach ($font_name as $font){
	for ($i=0;$i<count($faces[$font]);$i++){
		print "<option value="".$font."/".$faces[$font][$i].""";
		if ($test_font==$font."/".$faces[$font][$i]) print " SELECTED";
		print ">".$faces[$font][$i]."</option>n";
Size:<input type=text name=size value="<?php print $size;?>"><BR>
Color (6 digit hex 000000 to ffffff or white, black, blue etc...):<input type=text name=color value="<?php print $color;?>"><BR>
Execute: <input type=submit name=action value="Show me!">
Upload a new button background image:<BR>
<FORM ENCTYPE="multipart/form-data" METHOD=POST>
Send this file: <INPUT NAME="userfile" TYPE="file">
<INPUT TYPE="submit" VALUE="Send File">