wh_generate.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. //////////////////////////////////////////////////////////////////////////
  3. //
  4. // WikiHiero - A PHP convert from text using "Manual for the encoding of
  5. // hieroglyphic texts for computer input" syntax to HTML entities (table and
  6. // images).
  7. //
  8. // Copyright (C) 2004 Guillaume Blanchard (Aoineko)
  9. //
  10. // This program is free software; you can redistribute it and/or
  11. // modify it under the terms of the GNU General Public License
  12. // as published by the Free Software Foundation; either version 2
  13. // of the License, or any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program; if not, write to the Free Software
  22. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  23. //
  24. //////////////////////////////////////////////////////////////////////////
  25. echo "This script is insecure and shouldn't be used on a public wiki.\n";
  26. exit( 1 );
  27. include "wh_main.php";
  28. if(array_key_exists("lang", $_GET)) {
  29. $lang = $_GET["lang"];
  30. } else {
  31. $lang = "fr";
  32. }
  33. ?>
  34. <html lang=<?php echo htmlspecialchars( $lang ); ?>>
  35. <head>
  36. <title>WikiHiero - Table generator</title>
  37. <meta http-equiv="Content-type" content="text/html; charset=UTF-8">
  38. <link rel="shortcut icon" href="/favicon.ico">
  39. </head>
  40. <body bgcolor="#DDDDDD">
  41. <big><?php echo "WikiHiero v".WH_VER_MAJ.".".WH_VER_MED.".".WH_VER_MIN; ?></big>
  42. <br /><br />Parsing hieroglyph files and creating tables...<br /><br />
  43. <?php
  44. $wh_prefabs = "\$wh_prefabs = array(\n";
  45. $wh_files = "\$wh_files = array(\n";
  46. $img_dir = dirname(__FILE__) . '/img/';
  47. if(is_dir($img_dir))
  48. {
  49. if ($dh = opendir($img_dir))
  50. {
  51. while (($file = readdir($dh)) !== false)
  52. {
  53. if(stristr($file, WH_IMG_EXT))
  54. {
  55. list($width, $height, $type, $attr) = getimagesize($img_dir.$file);
  56. $wh_files .= " \"".WH_GetCode($file)."\" => array( $width, $height ),\n";
  57. if(strchr($file,'&'))
  58. $wh_prefabs .= " \"".WH_GetCode($file)."\",\n";
  59. }
  60. }
  61. closedir($dh);
  62. }
  63. }
  64. $wh_prefabs .= ");";
  65. $wh_files .= ");";
  66. echo "<pre>$wh_prefabs<br /><br />";
  67. echo "$wh_files<br /><br /></pre>";
  68. $file = fopen("wh_list.php", "w+");
  69. fwrite($file, "<?php\n\n");
  70. fwrite($file, "// File created by wh_generate.php version ".WH_VER_MAJ.".".WH_VER_MED.".".WH_VER_MIN."\n");
  71. fwrite($file, "// ".date("Y/m/d at H:i")."\n\n");
  72. fwrite($file, "global \$wh_prefabs, \$wh_files;\n\n");
  73. fwrite($file, "$wh_prefabs\n\n");
  74. fwrite($file, "$wh_files\n\n");
  75. fwrite($file, "?>");
  76. fclose($file);
  77. //if(file_exists("wh_list(0).php"))
  78. ?>
  79. <small><?php echo WH_Credit(); ?></small>
  80. </body>
  81. </html>