index.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. $IP = getenv( 'MW_INSTALL_PATH' );
  28. if ( $IP === false ) {
  29. $IP = dirname( __FILE__ ) .'/../..';
  30. }
  31. require( "$IP/includes/WebStart.php" );
  32. require('wh_language.php');
  33. require('wikihiero.php');
  34. #
  35. # Initialization from request
  36. #
  37. # FIXME : use webRequest
  38. if(isset($_POST["text"]))
  39. $text = $_POST["text"];
  40. else
  41. $text = "anx-G5-zmA:tA:tA-nbty-zmA:tA:tA-sw:t-bit:t-<-zA-ra:.-mn:n-T:w-Htp:t*p->-anx-D:t:N17-!";
  42. if(isset($_POST["scale"]))
  43. $scale = $_POST["scale"];
  44. else
  45. $scale = $wh_scale;
  46. if(isset($_POST["mode"]))
  47. $mode = $_POST["mode"];
  48. else
  49. $mode = $wh_mode;
  50. if(isset($_POST["lang"]))
  51. $lang = $_POST["lang"];
  52. else if(isset($_GET["lang"]))
  53. $lang = $_GET["lang"];
  54. else
  55. $lang = "fr";
  56. if(isset($_POST["line"]))
  57. $line = $_POST["line"];
  58. else
  59. $line = false;
  60. #
  61. # Various functions
  62. #
  63. function WH_Text( $index ) {
  64. global $wh_language;
  65. global $lang;
  66. if(isset($wh_language[$index])) {
  67. if(isset($wh_language[$index][$lang]))
  68. return $wh_language[$index][$lang];
  69. else
  70. return $wh_language[$index]["en"];
  71. }
  72. return '';
  73. }
  74. function WH_Packet( $ext ) {
  75. if(file_exists("wikihiero.$ext")) {
  76. $size = filesize("wikihiero.$ext");
  77. if($size <= 1024*1024) {
  78. return sprintf("<a href=\"wikihiero.$ext\" title=\"%.2f Kb\">%s</a>", filesize("wikihiero.$ext")/1024, strtoupper($ext));
  79. } else {
  80. return sprintf("<a href=\"wikihiero.$ext\" title=\"%.2f Mb\">%s</a>", filesize("wikihiero.$ext")/(1024*1024), strtoupper($ext));
  81. }
  82. } else {
  83. return "<font title=\"File <wikihiero.$ext> not found!\">".strtoupper($ext)."</font>";
  84. }
  85. }
  86. function WH_Table( $table ) {
  87. global $lang;
  88. $url = "wh_table.php?table=" . urlencode( $table ) . '&lang=' . urlencode( $lang );
  89. $encUrl = htmlspecialchars( Xml::encodeJsVar( $url ) );
  90. echo "<a href=\"#\" onClick=\"MyWindow=window.open($encUrl,'$table','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=300,left=20,top=20'); return false;\" title =\"".WH_Text($table)."\">$table</a>";
  91. }
  92. #
  93. # Main code
  94. #
  95. $start_time = microtime();
  96. list($a_dec, $a_sec) = explode(" ", $start_time);
  97. $html = WikiHiero($text, $mode, $scale, $line);
  98. list($b_dec, $b_sec) = explode(" ", microtime());
  99. $process_time = sprintf("%0.3f sec", $b_sec - $a_sec + $b_dec - $a_dec);
  100. ?>
  101. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  102. <HTML>
  103. <HEAD>
  104. <TITLE>WikiHiero</TITLE>
  105. <META http-equiv="Content-type" content="text/html; charset=UTF-8">
  106. <META name="Author" content="Guillaume Blanchard">
  107. <META name="Copyright" content="&copy; 2004 Guillaume Blanchard, Under free GNU Public Licence">
  108. <LINK rel="shortcut icon" href="/favicon.ico">
  109. <SCRIPT type="text/javascript">
  110. function LangLink(l)
  111. {
  112. document.wh_form.lang.value = l
  113. document.wh_form.submit()
  114. }
  115. function DisableScale(l)
  116. {
  117. document.wh_form.scale.disabled = l
  118. }
  119. </SCRIPT>
  120. </HEAD>
  121. <BODY style="background: #DDDDDD">
  122. <TABLE border="0">
  123. <TR valign="top"><TD>
  124. <BIG><?php echo "WikiHiero v".WH_VER_MAJ.".".WH_VER_MED.".".WH_VER_MIN; ?></BIG><br />
  125. <SMALL>[<?php
  126. reset($wh_language['Lang']);
  127. while($l = current($wh_language['Lang']))
  128. {
  129. if(key($wh_language['Lang']) == $lang)
  130. echo "<b>$l</b>";
  131. else
  132. echo "<a href=\"javascript:LangLink('".key($wh_language['Lang'])."');\">$l</a>";
  133. next($wh_language['Lang']);
  134. if($l = current($wh_language['Lang']))
  135. echo " | ";
  136. }
  137. ?>]</SMALL>
  138. <br /><br />
  139. <form name="wh_form" action="index.php?lang=<?php echo $lang; ?>" method="post">
  140. <textarea name="text" cols="60" rows="10" title="<?php echo WH_Text("Text"); ?>"><?php echo $text; ?></textarea>
  141. <br /><br />
  142. <input type="submit" title="<?php echo WH_Text("Convert"); ?>" value="<?php echo WH_Text("Convert"); ?>">
  143. <select title="<?php echo WH_Text("Mode"); ?>" name="mode">
  144. <option value="0" <?php if($mode==0) echo "selected"; ?> title="<?php echo WH_Text("TEXT"); ?>" onclick="javascript:DisableScale(true);">Text only
  145. <option value="1" <?php if($mode==1) echo "selected"; ?> title="<?php echo WH_Text("HTML"); ?>" onclick="javascript:DisableScale(false);">Simple HTML
  146. <option disabled value="2" <?php if($mode==2) echo "selected"; ?> title="<?php echo WH_Text("CSS"); ?>">HTML & CSS
  147. <option disabled value="3" <?php if($mode==3) echo "selected"; ?> title="<?php echo WH_Text("Image"); ?>">Image
  148. </select>
  149. <?php echo WH_Text("Scale"); ?><input type="range" name="scale" <?php if($mode==0) echo "disabled"; ?> title="<?php echo WH_Text("Size"); ?>" min="1" max="999" size="3" maxlength="3" value="<?php echo htmlspecialchars( $scale ); ?>">%
  150. <?php echo WH_Text("Line"); ?><input type="checkbox" name="line" <?php if($line) echo "checked"; ?>>
  151. <input type="hidden" name="lang" value="<?php echo htmlspecialchars( $lang ); ?>">
  152. </form>
  153. </td><td valign="top">
  154. <b><?php echo WH_Text("Syntax"); ?></b><br />
  155. <tt>-</tt> <?php echo WH_Text("-"); ?><br />
  156. <tt>:</tt> <?php echo WH_Text(":"); ?><br />
  157. <tt>*</tt> <?php echo WH_Text("*"); ?><br />
  158. <tt>!</tt> <?php echo WH_Text("!"); ?><br />
  159. <br />
  160. <b><?php echo WH_Text("Tables"); ?></b><br />
  161. <?php WH_Table("Phoneme"); ?>
  162. | <?php WH_Table("A"); ?>
  163. | <?php WH_Table("B"); ?>
  164. | <?php WH_Table("C"); ?>
  165. | <?php WH_Table("D"); ?>
  166. | <?php WH_Table("E"); ?>
  167. | <?php WH_Table("F"); ?>
  168. | <?php WH_Table("G"); ?>
  169. | <?php WH_Table("H"); ?>
  170. | <?php WH_Table("I"); ?>
  171. | <?php WH_Table("J"); ?>
  172. | <?php WH_Table("K"); ?>
  173. | <?php WH_Table("L"); ?>
  174. | <?php WH_Table("M"); ?>
  175. | <?php WH_Table("N"); ?>
  176. | <?php WH_Table("O"); ?>
  177. | <?php WH_Table("P"); ?>
  178. | <?php WH_Table("Q"); ?>
  179. | <?php WH_Table("R"); ?>
  180. | <?php WH_Table("S"); ?>
  181. | <?php WH_Table("T"); ?>
  182. | <?php WH_Table("U"); ?>
  183. | <?php WH_Table("V"); ?>
  184. | <?php WH_Table("W"); ?>
  185. | <?php WH_Table("X"); ?>
  186. | <?php WH_Table("Y"); ?>
  187. | <?php WH_Table("Z"); ?>
  188. | <?php WH_Table("Aa"); ?>
  189. | <?php WH_Table("All"); ?>
  190. <br /><br />
  191. <b><?php echo WH_Text("Download"); ?></b><br />
  192. [<?php echo WH_Packet("rar"); ?>] -
  193. [<?php echo WH_Packet("zip"); ?>] -
  194. <a href="README">ReadMe</a>
  195. </td></tr>
  196. </table>
  197. <br />
  198. <b>Images</b><br />
  199. <table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-style:solid; border-width:1px; padding:1em; border-color:gray; background:#ffffff;">
  200. <tr valign="middle"><td>
  201. <?php echo $html; ?>
  202. </td></tr>
  203. </table>
  204. <br />
  205. <b>Source</b><br />
  206. <table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-style:solid; border-width:1px; padding:1em; border-color:gray; background:#ffffff;">
  207. <tr valign="middle"><td>
  208. <pre><?php echo htmlentities($html); ?></pre>
  209. </td></tr>
  210. </table>
  211. <br />
  212. <table align="right"><tr><td>
  213. <a href="http://www.mozilla.org/products/firefox/" title="Get Firefox - The free browser">
  214. <img src="http://www.mozilla.org/products/firefox/buttons/getfirefox_88x31.png"
  215. width="88" height="31" border="0" alt="Get Firefox - The free browser"></a>
  216. </td></tr></table>
  217. <small><?php echo "Parsing duration: $process_time"; ?></small>
  218. <br /><br />
  219. <small><?php echo WH_Credit(); ?></small>
  220. </body>
  221. </html>