PHP - Button builder script example


SUBMITTED BY: efbee

DATE: Oct. 5, 2016, 7:02 p.m.

FORMAT: PHP

SIZE: 2.4 kB

HITS: 1018

  1. Button builder
  2. <?php
  3. # Here we check to see if someone is uploading a new png to build a button on.
  4. if ($userfile){
  5. # print $userfile_name."<BR>\n";
  6. copy ($userfile,"button.png");
  7. # print $userfile;
  8. # exit;
  9. }
  10. if (!$text) $text="ABCD";
  11. if (!$size) $size=25;
  12. if (!$color) $color="ffffff";
  13. if ($test_font){
  14. print "Now displaying font: $test_font<BR>";
  15. $tmp=str_replace(" ","+",$test_font);
  16. $tmp2=urlencode($text);
  17. print "<img src=button.html?font=$tmp&text=$tmp2&size=$size&color=$color>";
  18. }
  19. /*
  20. print $test_font;
  21. if (!$text) $text="Testing: Sxooter";
  22. if (!$font) $font="acme_explosive/acme.TTF";
  23. */
  24. # Here we find all the fonts installed in the font_path directory and make a list of them.
  25. # Note that ttf fonts are represented by a directory here..
  26. $font_path="/usr/share/fonts/ttf/";
  27. $dp=opendir($font_path);
  28. while (false!=($file = readdir($dp))){
  29. if ($file!="." && $file!=".."){
  30. if (is_dir($font_path.$file)){
  31. $font_name[]=$file;
  32. }
  33. }
  34. }
  35. closedir($dp);
  36. # Next we look in each directory fir a file, each one being a font, and build a list of those fonts
  37. # stored by font directory name.
  38. foreach($font_name as $font){
  39. $dp=opendir($font_path.$font);
  40. while (false!=($file = readdir($dp))){
  41. if ($file!="." && $file!=".."){
  42. if (eregi("ttf$",$file)){
  43. $faces[$font][]=$file;
  44. }
  45. }
  46. }
  47. }
  48. if (!$test_font) $test_font=$font_name[0]."/".$faces[$font_faces[$font_name[0]]][0];
  49. ?>
  50. <form name=form method=post>
  51. <input type=text name=text value="<?php print $text;?>"><BR>
  52. Pick a font:<select name=test_font onChange=document.form.submit();>
  53. <option value=0>Please Choose</option>
  54. <?php
  55. foreach ($font_name as $font){
  56. for ($i=0;$i<count($faces[$font]);$i++){
  57. print "<option value=\"".$font."/".$faces[$font][$i]."\"";
  58. if ($test_font==$font."/".$faces[$font][$i]) print " SELECTED";
  59. print ">".$faces[$font][$i]."</option>\n";
  60. }
  61. }
  62. ?>
  63. </select><BR>
  64. Size:<input type=text name=size value="<?php print $size;?>"><BR>
  65. Color (6 digit hex 000000 to ffffff or white, black, blue etc...):<input type=text name=color value="<?php print $color;?>"><BR>
  66. Execute: <input type=submit name=action value="Show me!">
  67. </form>
  68. <HR>
  69. Upload a new button background image:<BR>
  70. <FORM ENCTYPE="multipart/form-data" METHOD=POST>
  71. Send this file: <INPUT NAME="userfile" TYPE="file">
  72. <INPUT TYPE="submit" VALUE="Send File">
  73. </FORM>

comments powered by Disqus