gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r639 - Extractor-docs/WWW GNUnet-docs/WWW GNUnet-docs/WWW/g


From: grothoff
Subject: [GNUnet-SVN] r639 - Extractor-docs/WWW GNUnet-docs/WWW GNUnet-docs/WWW/gnu.org i18nHTML i18nHTML/src i18nHTML-docs/WWW
Date: Sun, 10 Apr 2005 23:26:03 -0700 (PDT)

Author: grothoff
Date: 2005-04-10 23:25:43 -0700 (Sun, 10 Apr 2005)
New Revision: 639

Added:
   i18nHTML/src/update0_1_0.php
   i18nHTML/src/update0_2_0.php
Removed:
   i18nHTML/src/update.php
Modified:
   Extractor-docs/WWW/commitMassTranslation.php
   Extractor-docs/WWW/commitTranslation.php
   Extractor-docs/WWW/editor.php
   Extractor-docs/WWW/i18nhtml.inc
   Extractor-docs/WWW/index.php
   Extractor-docs/WWW/translate.php
   Extractor-docs/WWW/vote.php
   GNUnet-docs/WWW/commitMassTranslation.php
   GNUnet-docs/WWW/commitTranslation.php
   GNUnet-docs/WWW/editor.php
   GNUnet-docs/WWW/gnu.org/commitMassTranslation.php
   GNUnet-docs/WWW/gnu.org/commitTranslation.php
   GNUnet-docs/WWW/gnu.org/editor.php
   GNUnet-docs/WWW/gnu.org/i18nhtml.inc
   GNUnet-docs/WWW/gnu.org/i18nhtml_config.inc
   GNUnet-docs/WWW/gnu.org/index.php
   GNUnet-docs/WWW/gnu.org/status.php
   GNUnet-docs/WWW/gnu.org/translate.php
   GNUnet-docs/WWW/gnu.org/vote.php
   GNUnet-docs/WWW/i18nhtml.inc
   GNUnet-docs/WWW/index.php
   GNUnet-docs/WWW/status.php
   GNUnet-docs/WWW/translate.php
   GNUnet-docs/WWW/vote.php
   i18nHTML-docs/WWW/commitMassTranslation.php
   i18nHTML-docs/WWW/commitTranslation.php
   i18nHTML-docs/WWW/editor.php
   i18nHTML-docs/WWW/i18nhtml.inc
   i18nHTML-docs/WWW/index.php
   i18nHTML-docs/WWW/status.php
   i18nHTML-docs/WWW/translate.php
   i18nHTML-docs/WWW/vote.php
   i18nHTML/README
   i18nHTML/src/commitMassTranslation.php
   i18nHTML/src/commitTranslation.php
   i18nHTML/src/editor.php
   i18nHTML/src/i18nhtml.inc
   i18nHTML/src/status.php
   i18nHTML/src/translate.php
   i18nHTML/src/vote.php
Log:
update

Modified: Extractor-docs/WWW/commitMassTranslation.php
===================================================================
--- Extractor-docs/WWW/commitMassTranslation.php        2005-04-11 06:23:40 UTC 
(rev 638)
+++ Extractor-docs/WWW/commitMassTranslation.php        2005-04-11 06:25:43 UTC 
(rev 639)
@@ -26,6 +26,7 @@
   W("Translating to English currently not allowed.\n");
   die();
 }
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
 TITLE("WWW translation: commit");
 echo "</head><body>";
@@ -37,6 +38,7 @@
     continue;
   if ( ($dec == "xlang") || ($dec == "start") )
     continue;
+  $val = fix($val);
   $query = "SELECT c FROM pending WHERE lang=\"$xlang\"";
   $result = mysql_query($query, $connection);
   $num = 0;
@@ -45,8 +47,10 @@
   while ($num > 0) {
     $num--;
     $row = mysql_fetch_array($result);
-    if ($dec == bin2hex(md5(urldecode($row["c"])))) {
-      $enc = mysql_real_escape_string($row["c"]);
+    $cx_plain = fix($row["c"]);
+    $cx_sql = mysql_real_escape_string($cx_plain);
+    if ($dec == bin2hex(md5($cx_plain))) {
+      $enc_sql = $cx_sql;
       break;
     }
   }
@@ -56,30 +60,32 @@
     P();
     continue;
   }  
-  $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$enc\"";
+  $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$enc_sql\"";
   mysql_query($query, $connection); 
-  $t = mysql_real_escape_string(to_unicode($val));
-  $query = "SELECT ranking FROM map WHERE name=\"$enc\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+  $val_sql = mysql_real_escape_string(to_unicode($val));
+  $query = "SELECT ranking FROM map WHERE name=\"$enc_sql\"" .
+           " AND lang=\"$lang\" AND translation=\"$val_sql\"";
   $result = mysql_query($query, $connection);
   $num = 0;
   if ($result) 
     $num = mysql_numrows($result);
   if ($num == 0) {
-    $txtCnt = count_chars(urldecode($enc), 1);
-    $tCnt = count_chars($t, 1);
+    $txtCnt = count_chars(stripslashes($enc_sql), 1);
+    $tCnt = count_chars(stripslashes($val_sql), 1);
     if ($txtCnt[ord('%')] != $tCnt[ord('%')]) {
-      W("Commit '%s->%s' failed.", $enc, $t);
+      W("Commit '%s->%s' failed.", stripslashes($enc_sql), 
stripslashes($val_sql));
       W("The number of percent signs in source text and translation do not 
match.");     
       W("Note that you must preserve all %%s expressions unchanged.");
       W("Also, a single displayed %% sign must be translated into two (%%%%) 
such signs.");
       P();
     } else {
-      $query = "INSERT INTO map VALUES(\"$enc\", \"$lang\", \"$t\", 1, \"" . 
$_SERVER['REMOTE_ADDR'] . "\");";
+      $query = "INSERT INTO map VALUES(\"$enc_sql\", \"$lang\", " .
+               "\"$val_sql\", 1, \"" . $_SERVER['REMOTE_ADDR'] . "\");";
       mysql_query($query, $connection);
       $done++;
       W("Storing translation for &quot;%s&quot = &quot;%s&quot;.",
-        ARRAY(urldecode($enc),
-             urldecode($t)));
+        ARRAY(stripslashes($enc_sql),
+             stripslashes($val_sql)));
       BR();  
     }
   }  

Modified: Extractor-docs/WWW/commitTranslation.php
===================================================================
--- Extractor-docs/WWW/commitTranslation.php    2005-04-11 06:23:40 UTC (rev 
638)
+++ Extractor-docs/WWW/commitTranslation.php    2005-04-11 06:25:43 UTC (rev 
639)
@@ -18,9 +18,6 @@
      Boston, MA 02111-1307, USA.
 */
 include("i18nhtml.inc");
-$text = mysql_real_escape_string($_REQUEST['text']);
-$translation = $_REQUEST['translation'];
-$back = $_REQUEST['back'];
 if (!$connection) {
   echo "Database is down. Cannot edit translations.";
   die();
@@ -29,39 +26,47 @@
   W("Translating to English is not allowed.\n");
   die();
 }
+$text            = urldecode($_REQUEST['text']);
+$text_sql        = mysql_real_escape_string($text);
+$translation     = fix($_REQUEST['translation']);
+$translation_sql = mysql_real_escape_string(to_unicode($translation));
 
-$t = mysql_real_escape_string(to_unicode($translation));
+$back            = $_REQUEST['back'];
 // check for identical translation
-$query = "SELECT ranking FROM map WHERE name=\"$text\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+$query = "SELECT ranking FROM map WHERE name=\"$text_sql\"" . 
+         " AND lang=\"$lang\" AND translation=\"$translation_sql\"";
 $result = mysql_query($query, $connection);
 $num = 0;
-if ($result) {
+if ($result) 
   $num = mysql_numrows($result);
-}
 if ($num > 0) {
   echo "<html><head>";
   TITLE("Translation exists.");
   echo "</head><body>";
-  W("Translation exists.");   
+  W("Translation '%s' of sentence '%s' exists.",
+    fix($translation), $text);   
   extlink($back, "Back...");
   generateFooter();
   echo "</body></html>";
 } else {
-  $txtCnt = count_chars(urldecode($text), 1);
-  $tCnt = count_chars($t, 1);
+  $txtCnt = count_chars($text, 1);
+  $tCnt   = count_chars($translation, 1);
   if ($txtCnt[ord('%')] != $tCnt[ord('%')]) {
       echo "<html><head>";
       TITLE("Commit failed.");
       echo "</head><body>";
-      W("Commit failed.");
-      W("The number of percent signs in source text and translation do not 
match.");     
+      W("Commit failed ('%s' and '%s').", ARRAY($text, $translation));
+      W("The number of percent signs in source text and translation does not 
match.");     
       W("Note that you must preserve all %%s expressions unchanged.");
       W("Also, a single displayed %% sign must be translated into two (%%%%) 
such signs.");
       echo "</body></html>";
   } else {
-    $query = "INSERT INTO map VALUES(\"$text\", \"$lang\", \"$t\", 1, \"" . 
$_SERVER['REMOTE_ADDR'] . "\");";
+    $query = "INSERT INTO map VALUES(\"$text_sql\", \"$lang\", " .
+             "\"$translation_sql\", 1, \"" . $_SERVER['REMOTE_ADDR'] . "\");";
     $result = mysql_query($query, $connection);
     if ($result) {
+      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$text_sql\"";
+      mysql_query($query, $connection); 
       header("Location: " . $back); /* Redirect browser */
     } else {
       echo "<html><head>";

Modified: Extractor-docs/WWW/editor.php
===================================================================
--- Extractor-docs/WWW/editor.php       2005-04-11 06:23:40 UTC (rev 638)
+++ Extractor-docs/WWW/editor.php       2005-04-11 06:25:43 UTC (rev 639)
@@ -22,6 +22,7 @@
   echo "Database is down. Cannot edit translations.";
   die();
 }
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
 TITLE("WWW translation");
 echo "</head><body>";
@@ -51,12 +52,12 @@
   $start = $end - $max;
   if ($start < 0)
     $start = 0;
- }
+}
 
 if ($num == 0) {
   P();
   W("No missing translations for the selected target language were found.");
- } else {
+} else {
   P();
   W("%s translations to %s have been requested and were not available.",
     ARRAY($num,
@@ -71,45 +72,39 @@
   echo "<input type=hidden name=\"start\" value=\"$endp\">";
   
   echo "<table border=5>";
-  echo "<tr><th>";
-  W("Original");
-  echo "</th><th>";
-  W("Translation");
-  echo "</th></tr>";
+  echo "<tr>";
+  TH("Original");
+  TH("Translation");
+  echo "</tr>";
   for ($ii=0;$ii<$end;$ii++) {
     $row = mysql_fetch_array($result);
     if ($ii < $start)
       continue;
-    $cx = $row["c"];
+    $cx_plain = fix($row["c"]);
+    $cx_sql = mysql_real_escape_string($cx_sql);
     
-    $query = "SELECT ranking FROM map WHERE name=\"$cx\" AND lang=\"$lang\"";
+    $query = "SELECT ranking FROM map WHERE name=\"$cx_sql\" AND 
lang=\"$lang\"";
     $result2 = mysql_query($query, $connection);
     $num2 = 0;
     if ($result2) 
       $num2 = mysql_numrows($result2);
+    echo "<tr><td width=\"45%\">";
+    echo "&quot;$cx_plain&quot;";
+    echo "</td>\n\t<td width\"50\%\">";
     if ($num2 > 0) {
-      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$cx\"";
-      mysql_query($query, $connection); 
-      
-      echo "<tr><td width=\"45%\">";
-      $dec = urldecode($cx);
-      echo "&quot;" . $dec . "&quot;";
-      echo "</td>\n\t<td width\"50\%\">";
+      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$cx_sql\"";
+      mysql_query($query, $connection);      
       W("Skipped (already translated).");
+    } else {
+      echo "<input size=\"40\" maxlength=\"65535\" name=\"" . 
bin2hex(md5($cx_plain)) . "\"></td></tr>\n";
     }
-    else {
-      echo "<tr><td width=\"45%\">";
-      $dec = urldecode($cx);
-      echo "&quot;" . $dec . "&quot;";
-      echo "</td>\n\t<td width\"50\%\">";
-      echo "<input size=\"40\" maxlength=\"65535\" name=\"" . 
bin2hex(md5($dec)) . "\"></td></tr>\n";
-    }
   }
   echo "</tr></table>";
-  echo "<input type=submit value=\"I hereby give all these translations into 
the Public Domain (commit)\">";
+  echo "<input type=submit value=\"" . 
+       TRANSLATE_("I hereby give all these translations into the Public Domain 
(commit)") . 
+       "\">";
   echo "</form>";
-  
- }
+}
 if ($end < $num) {
   P();
   echo "<a href=\"" . $i18nHTMLbase . "editor.php?xlang=" . $lang . "&start=" 
. ($end + 1) . "\">";
@@ -117,10 +112,10 @@
   echo "</a>";
   if ($t == 1)
     translateLink($b);
- } else {
+} else {
   W("Statistics about translation progress can be found %s.\n",
     intlink_($i18nHTMLbase . "status.php", "here"));
- }
+}
 P();
 H2("Remarks");
 H3("The percent sign");

Modified: Extractor-docs/WWW/i18nhtml.inc
===================================================================
--- Extractor-docs/WWW/i18nhtml.inc     2005-04-11 06:23:40 UTC (rev 638)
+++ Extractor-docs/WWW/i18nhtml.inc     2005-04-11 06:25:43 UTC (rev 639)
@@ -17,7 +17,6 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-
   // This file defines the functions that will be used
   // to build the webpage.  The set may not contain everything
   // you might want, so feel free to define your own extensions.
@@ -35,13 +34,13 @@
   // Most of the code should be straight forward. Look
   // at some of the example files that use it and compare with
   // the generated pages. 
-
-
 // obtain user db specific configuration parameters
 include("i18nhtml_config.inc");
-
 header("Content-type: text/html; charset=utf-8");
 
+if (get_magic_quotes_gpc())
+  die('PHP misconfigured.  Disable get_magic_quotes.');
+
 // establish default connection to database server
 $connection = @mysql_connect($i18nHTMLsqlServer,
                             $i18nHTMLsqlUser,
@@ -57,24 +56,24 @@
   if (!$db_selected) {
      die ('Error selecting db : ' . mysql_error());
   }
- }
+}
 
 // ensure the mapping and pending tables exist, creating them if not
 $query="CREATE TABLE IF NOT EXISTS map" .
        " (name BLOB, lang TINYBLOB, translation BLOB, ranking INT, ip 
TINYTEXT, " .
        "INDEX(name(10)), INDEX(lang(4)), INDEX(ranking), 
INDEX(translation(10)))";
 $result = mysql_query($query, $connection);
-//if (!$result) {
-//   die('Unable to validate mapping table.  Invalid query: ' . mysql_error());
-//}
+if (($i18nHTMLdebug == 1) && (!$result)) {
+  die('Unable to validate map table.  Invalid query: ' . mysql_error());
+}
 
 $query="CREATE TABLE IF NOT EXISTS pending" .
        " (c BLOB, lang TINYBLOB, count INT, " .
        "INDEX(c(10)), INDEX(lang(4)), INDEX(count))";
 $result = mysql_query($query, $connection);
-//if (!$result) {
-//   die('Unable to validate pending table.  Invalid query: ' . mysql_error());
-//}
+if (($i18nHTMLdebug == 1) && (!$result)) {
+  die('Unable to validate pending table.  Invalid query: ' . mysql_error());
+}
 
 /* mapping of real-names to language codes */
 $languagecodes = array("English"=>"en",
@@ -102,7 +101,7 @@
                       "Swedish"=>"sv");
 
 /* try to automagically figure out user preferences */
-$hlang=$_SERVER["HTTP_ACCEPT_LANGUAGE"];
+$hlang = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
 if ($hlang) {
   $tok = strtok($hlang, ";");
   while ($tok) {
@@ -114,7 +113,7 @@
     }
     $tok = strtok(";");
   }
- }
+}
 // If no language is specified, use english.
 if ( (! $lang) || ($lang=="") )
   $lang = "English";
@@ -124,21 +123,24 @@
 $lang = ucfirst(strtolower($lang));
 $lang = mysql_real_escape_string($lang);
 $editor = $_REQUEST['editor'];
+$i18nHTMLhasTranslation = 0; // set by last call to translation_query()
 
-
-$htmlin  = array("&rsquo;", "&gt;", "&quot;", "&prime;", "&amp;");
-$htmlout = array("&#8217;" , "&#62;", "&#34;" , "&#8242" , "&#38;");
-
 /**
  * Replace certain HTML named special characters with their
  * numeric codes (some browsers don't work with the symbolic names).
  */
+$htmlin  = array("&rsquo;", "&gt;",  "&quot;", "&prime;", "&amp;", "\"",    
"'",      "`",       "&lsquo;");
+$htmlout = array("&#8217;", "&#62;", "&#34;" , "&#8242;", "&#38;", "&#34;", 
"&#8242;", "&#8217;", "&#8216;");
 function fix($a) {
   global $htmlin;
   global $htmlout;
   return str_replace($htmlin, $htmlout, $a);
 }
 
+// *************************************************
+// i18nHTML configuration API functions 
+// *************************************************
+
 // change the marker text shown to indicate text
 // is translatable (link to translate page text)
 function setTranslateLinkMarker($marker) {
@@ -150,46 +152,18 @@
     $i18nHTMLmarker = $marker;
 }
 
+// ***************************************************
+// i18nHTML _internal_ API functions (don't look here)
+// ***************************************************
 
-// editor = ?         ;      // set by URL parameter, indicates in translation 
mode
-$i18nHTMLhasTranslation = 0; // set by last call to isTranslated() or 
translation_query()
-$i18nHTMLallowedits = 1;
-
-// indicate translate link should only be shown for untranslated items.
-function editOnlyUntranslatedText() {
-  global $i18nHTMLallowedits;
-  $i18nHTMLallowedits = 0;
-}
-
-// indicate translate link should always be shown (or set to indicated value).
-function editAllTranslations($v=null) {
-  global $i18nHTMLallowedits;
-  if ($v == "")
-    $i18nHTMLallowedits = 1;
-  else
-    $i18nHTMLallowedits = $v;
-}
-
-
-// displays a link to the page to enable one to
-// translate the given text ($a)
-// see translateLink_
-function translateLink($a, $hasTranslation=null) {
-  echo translateLink_($a, $hasTranslation);
-}
-
-// returns a HTML string to link to enable one to
-// translate the given text ($a) when
-// $editor has a nonzero value and either
-// $hasTranslation is 0 or $allowedits is nonzero;
-// otherwise and empty string ("") is returned.
-// $hasTranslation may be omitted to use result of
-// last isTranslated() or translation_query() call;
-function translateLink_($a, $hasTranslation=null) {
+// returns a HTML string to link to enable one to translate the given
+// text ($a) when $editor has a nonzero value or
+// $i18nHTMLhasTranslation is 0; otherwise and empty string ("") is
+// returned.
+function translateLink_($a) {
   global $lang;
   global $HTTP_SERVER_VARS;
   global $editor;
-  global $i18nHTMLallowedits;
   global $i18nHTMLhasTranslation;
   global $i18nHTMLmarker;
   global $i18nHTMLbase;
@@ -200,112 +174,21 @@
     $back = "http://"; . $HTTP_SERVER_VARS["HTTP_HOST"] . 
$HTTP_SERVER_VARS["REQUEST_URI"];
     return "<a href=\"" . $i18nHTMLbase . "translate.php?xlang=" 
       . $lang 
-      . "&amp;text=" . urlencode($a)
+      . "&amp;text=" . urlencode(fix($a))
       . "&amp;back=" . urlencode($back) 
       . "\">" . $i18nHTMLmarker . "</a>\n";
   } else
     return "";   
 }
 
-// return 1 if translation is available (or DB down)
-// assumes passed the original text as appears in source
-function isTranslated($a, $charset=null) {
-  global $connection;
-  global $lang;
-  global $editor;
-  global $i18nHTMLhasTranslation;
-
-  $i18nHTMLhasTranslation = 1; // assume translation until failure
-
-  if ( ("English" == $lang) || (!$connection) ) {
-    // Either hard-wired source language (so available) or
-    // database not available.
-    return 1;
-  }
-
-  //  $a = htmlentities($a, ENT_QUOTES, $charset);
-  $u = urlencode($a);
-
-  $query = "SELECT translation FROM map WHERE name=\"$u\" AND lang=\"$lang\" 
ORDER BY ranking DESC";
-  $result = mysql_query($query, $connection);
-  if (!$result) {
-    if ($i18nHTMLdebug != 0)
-      echo 'Unable to execute query $query: ' . mysql_error();
-  }
-
-  $num = 0;
-  if ($result)
-    $num = mysql_numrows($result);
-  if ($num > 0)
-    return 1;
-  else {
-    $i18nHTMLhasTranslation = 0; // no translation was found
-    return 0;   
-  }
+// displays a link to the page to enable one to
+// translate the given text ($a)
+// see translateLink_
+function translateLink($a) {
+  echo translateLink_($a);
 }
 
-
 /**
- * restore UTF-8 from HTML Unicode entities
- *
- * This function is triggered by the YACS handler during page
- * rendering.  It is aiming to transcode HTML Unicode entities
- * (eg, &amp;#8364;) back to actual UTF-8 encoding (eg, �).
- *
- * @param string a string with a mix of UTF-8 and of HTML Unicode entities
- * @return an UTF-8 string
- */
-function from_unicode($text) {
-  // translate extended ISO8859-1 chars, if any
-  $text = utf8_encode($text);
-  
-  // translate Unicode entities
-  $areas = preg_split('/&#(\d+?);/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
-  $text = '';
-  $index = 0;
-  foreach($areas as $area) {
-    switch($index%2) {
-    case 0: // before entity
-      $text .= $area;
-      break;
-    case 1: // the entity itself
-      
-      // get the integer value
-      $unicode = intval($area);
-      
-      // one byte
-      if($unicode < 0x80) {
-       
-       $text .= chr($unicode);
-       
-       // two bytes
-      } elseif($unicode < 0x800) {
-       
-       $text .= chr( 0xC0 +  ( ( $unicode - ( $unicode % 0x40 ) ) / 0x40 ) );
-       $text .= chr( 0x80 + ( $unicode % 0x40 ) );
-       
-       // three bytes
-      } elseif($unicode < 0x10000) {
-       
-       $text .= chr( 0xE0 + ( ( $unicode - ( $unicode % 0x1000 ) ) / 0x1000 ) 
);
-       $text .= chr( 0x80 + ( ( ( $unicode % 0x1000 ) - ( $unicode % 0x40 ) ) 
/ 0x40 ) );
-       $text .= chr( 0x80 + ( $unicode % 0x40 ) );
-       
-       // more bytes, keep it as it is...
-      } else
-         $text .= '&#'.$unicode.';';
-      
-      break;
-    }
-    $index++;
-  }
-  
-  // the updated string
-  return $text;
-}
-
-
-/**
  * transcode unicode entities to/from HTML entities
  *
  * Also, this function transforms HTML entities into their equivalent Unicode 
entities.
@@ -318,8 +201,7 @@
  * @param boolean TRUE to transcode to Unicode, FALSE to transcode to HTML
  * @return a transcoded string
  */
-function transcode($input, $to_unicode=TRUE) {
-  
+function transcode($input, $to_unicode=TRUE) { 
   // initialize tables only once
   static $html_entities, $unicode_entities;
   if(!is_array($html_entities)) {
@@ -582,8 +464,7 @@
       $unicode_entities[] = $unicode_entity;
       $html_entities[] = $html_entity;
     }
-  }
-  
+  }  
   // transcode HTML entities to Unicode
   if($to_unicode)
     return str_replace($html_entities, $unicode_entities, $input);
@@ -593,9 +474,6 @@
     return str_replace($unicode_entities, $html_entities, $input);
 }
 
-
-
-
 /**
  * transcode multi-byte characters to HTML representations for Unicode
  *
@@ -617,119 +495,79 @@
  * @param string the original UTF-8 string
  * @return a string acceptable in an ISO-8859-1 storage system (ie., PHP4 + 
MySQl 3)
  */
-function to_unicode($input) {
-  
+function to_unicode($input) { 
   // transcode HTML entities to Unicode entities
-  $input = transcode($input);
-  
+  $input = transcode($input);  
   // scan the whole string
   $output = '';
   $index = 0;
-  while($index < strlen($input)) {
-    
+  while($index < strlen($input)) {  
     // look at one char
-    $char = ord($input[$index]);
-    
+    $char = ord($input[$index]);    
     // one byte (0xxxxxxx)
-    if($char < 0x80) {
-      
+    if ($char < 0x80) {      
       // some chars may be undefined
       $output .= chr($char);
-      $index += 1;
-      
+      $index += 1;      
       // two bytes (110xxxxx 10xxxxxx)
-    } elseif($char < 0xE0) {
-      
+    } else if ($char < 0xE0) {      
       // strip weird sequences (eg, C0 80 -> NUL)
       if($value = (($char % 0x20) * 0x40) + (ord($input[$index + 1]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 2;
-      
+      $index += 2;      
       // three bytes (1110xxxx 10xxxxxx 10xxxxxx) example: euro sign = 
\xE2\x82\xAC -> &#8364;
-    } elseif($char < 0xF0) {
-      
+    } else if ($char < 0xF0) {      
       // strip weird sequences
       if($value = (($char % 0x10) * 0x1000) + ((ord($input[$index + 1]) % 
0x40) * 0x40) + (ord($input[$index + 2]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 3;
-      
+      $index += 3;      
       // four bytes (11110xxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } elseif($char < 0xF8) {
-      
+    } else if($char < 0xF8) {      
       // strip weird sequences
-      if($value = (($char % 0x08) * 0x40000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000) + ((ord($input[$index + 2]) % 0x40) * 0x40)
+      if ($value = (($char % 0x08) * 0x40000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000) + ((ord($input[$index + 2]) % 0x40) * 0x40)
         + (ord($input[$index + 3]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 4;
-      
+      $index += 4;      
       // five bytes (111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } elseif($char < 0xFC) {
-      
+    } else if($char < 0xFC) {      
       // strip weird sequences
-      if($value = (($char % 0x04) * 0x1000000) + ((ord($input[$index + 1]) % 
0x40) * 0x40000) + ((ord($input[$index + 2]) % 0x40) * 0x1000)
+      if ($value = (($char % 0x04) * 0x1000000) + ((ord($input[$index + 1]) % 
0x40) * 0x40000) + ((ord($input[$index + 2]) % 0x40) * 0x1000)
         + ((ord($input[$index + 3]) % 0x40) * 0x40) + (ord($input[$index + 4]) 
% 0x40))
        $output .= '&#' . $value . ';';
-      $index += 5;
-      
+      $index += 5;      
       // six bytes (1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } else {
-      
+    } else {      
       // strip weird sequences
-      if($value = (($char % 0x02) * 0x40000000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000000) + ((ord($input[$index + 2]) % 0x40) * 0x40000)
+      if ($value = (($char % 0x02) * 0x40000000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000000) + ((ord($input[$index + 2]) % 0x40) * 0x40000)
         + ((ord($input[$index + 3]) % 0x40) * 0x1000) + ((ord($input[$index + 
4]) % 0x40) * 0x40) + (ord($input[$index + 4]) % 0x40))
        $output .= '&#' . $value . ';';
       $index += 6;
-    }
-    
-  }
- 
+    }    
+  } 
   // return the translated string
   return $output;
 }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-// returns either the translated string
-// or the original string.  Assumes we
-// are passed the original string as occurs
-// in text; result will be html tokenized by
-// htmlentities() using default charset or
-// one indicated by $charset, to ensure all
-// required entities are converted for valid html output.
-// Note: it is assumed value in DB have already
-// ran through equivalent of htmlentities().
-// $i18nHTMLhasTranslation is set to nonzero value
-// if a translation is available or failure connecting
-// to database, otherwise it is set to 0.
-function translation_query($a, $charset=null) {
+// returns either the translated string or the original string.
+// Assumes we are passed the original string as occurs in text; result
+// will be html tokenized by htmlentities() using UTF8.
+// $i18nHTMLhasTranslation is set to nonzero value if a translation is
+// available or failure connecting to database, otherwise it is set to
+// 0.
+function translation_query($a) {
   global $connection;
   global $lang;
   global $i18nHTMLrecordMode;
   global $i18nHTMLhasTranslation;
   
   $i18nHTMLhasTranslation = 1; // assume translation until failure
-
   if ($a == "")
     return $a;
-
-  $u = mysql_real_escape_string(urlencode($a));
-  
+  $a = fix($a);
+  $a_sql = mysql_real_escape_string($a);
   if (!$connection) {
     // database not available, just print English
-    return fix($a);
+    return $a;
   }
   if ("English" == $lang) {
     // no need to translate english, that's the
@@ -737,20 +575,20 @@
     if ($i18nHTMLrecordMode == 2) {
       // if not already in pending table (and recordMode set to allow us)
       // then insert this string into it
-      $query = "SELECT count FROM pending WHERE c=\"$u\" AND lang=\"$lang\"";
+      $query = "SELECT count FROM pending WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       $result = mysql_query($query, $connection);
       $num = 0;
       if ($result)
         $num = mysql_num_rows($result);
       if (0 == $num) {
-        $query = "INSERT INTO pending VALUES(\"$u\", \"$lang\", 0)";
+        $query = "INSERT INTO pending VALUES(\"$a_sql\", \"$lang\", 0)";
         mysql_query($query, $connection);
       }
     }
-    return fix($a);
+    return $a;
   }
   // attempt to get translations, ranked for best
-  $query = "SELECT translation FROM map WHERE name=\"$u\" AND lang=\"$lang\" 
ORDER BY ranking DESC";
+  $query = "SELECT translation FROM map WHERE name=\"$a_sql\" AND 
lang=\"$lang\" ORDER BY ranking DESC";
   $result = mysql_query($query, $connection);
   $num = 0;
   if ($result)
@@ -760,7 +598,7 @@
       // either insert untranslated item into pending table or update
       // referenced count; count is used to display more used strings
       // during mass translation before less common ones.
-      $query = "SELECT count FROM pending WHERE c=\"$u\" AND lang=\"$lang\"";
+      $query = "SELECT count FROM pending WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       $result = mysql_query($query, $connection);
       $num = 0;
       if ($result)
@@ -769,20 +607,24 @@
       if ($num > 0) {
         $row = mysql_fetch_array($result);
         $count = $row["count"] + 1;
-        $query = "UPDATE pending SET count=$count WHERE c=\"$u\" AND 
lang=\"$lang\"";
+        $query = "UPDATE pending SET count=$count WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       } else {
-        $query = "INSERT INTO pending VALUES(\"$u\", \"$lang\", 1)";
+        $query = "INSERT INTO pending VALUES(\"$a_sql\", \"$lang\", 1)";
       }
       mysql_query($query, $connection);       
     }
     $i18nHTMLhasTranslation = 0; // no translation was found
-    return fix($a);              // just return English string
+    return $a;              // just return English string
   } else { // translation available
     $row = mysql_fetch_array($result);
     return $row["translation"];
   }
 }
 
+// *************************************************
+// Fundamental i18nHTML API functions 
+// *************************************************
+
 // translate the sentence $a and return the result.
 function TRANSLATE_($a,$args=null) {
   if ($a == "")
@@ -790,6 +632,12 @@
   return vsprintf(translation_query($a), $args);
 }
 
+// translate the sentence $a and output just
+// the translated text (without link to translate.php)
+function TRANSLATE($a,$args=null) {
+  echo TRANSLATE_($a);
+}
+
 // translate the sentence $a adding a link
 // to enable editing translations and return the result.
 function W_($a,$args=null) {
@@ -798,81 +646,16 @@
   return TRANSLATE_($a,$args) . translateLink_($a);
 }
 
-// translate the sentence $a and output just
-// the translated text
-function TRANSLATE($a,$args=null) {
-  echo TRANSLATE_($a);
-}
-
 // translate the sentence $a appending a link
 // to enable edit the translation and output the
-// result. Returns 1 if a translation is needed.
+// result.
 function W($a, $args=NULL) {
-  global $i18nHTMLhasTranslation;
-
-  if ($a == "")
-    return 0;
-  echo W_($a, $args) . "\n";
-  return $i18nHTMLhasTranslation;
+  if ($a != "")
+    echo W_($a, $args) . "\n";
 }
 
-function LI($a,$b="") {
-  echo "<li>" . W_($a,$b) . "</li>\n";
-}
-
-function TITLE($a,$b="") {
-  global $lang;
-  global $languagecodes;
-  echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" 
>";
-  echo "<title>" . TRANSLATE_($a,$b) . "</title>\n";
-  if (isset($languagecodes[$lang])) {
-    echo "<meta name=\"content-language\" content=\"" . 
-         $languagecodes[$lang] . "\">";
-    echo "<meta name=\"language\" content=\"" . 
-         $languagecodes[$lang] . "\">";
-  }
-}
-
-
-function DT($a,$b="") {
-  echo "<dt>" . W_($a,$b) . "</dt>\n";
-}
-function DD($a,$b="") {
-  echo "<dd>" . W_($a,$b) . "</dd>\n";
-}
-function H1($a,$b="") {
-  echo "<h1>" . W_($a,$b) . "</h1>\n";
-}
-function H2($a,$b="") {
-  echo "<h2>" . W_($a,$b) . "</h2>\n";
-}
-function H3($a,$b="") {
-  echo "<h3>" . W_($a,$b) . "</h3>\n";
-}
-function H4($a,$b="") {
-  echo "<h4>" . W_($a,$b) . "</h4>\n";
-}
-function H5($a,$b="") {
-  echo "<h5>" . W_($a,$b) . "</h5>\n";
-}
-// 'verbatim' (untranslated) "pre"
-function PRE($a) {
-  echo "<pre>" . $a . "</pre>";
-}
-// 'verbatim' (untranslated) "li"
-function LIV($a) {
-  echo "<li>" . $a . "</li>\n";
-}
-
-
 // create internationalized, internal link to
 // $a.php with description $b 
-function intlink($a, $b) {  
-  echo intlink_($a, $b);
-}
-
-// create internationalized, internal link to
-// $a.php with description $b 
 function intlink_($a, $b) {  
   global $lang;
   
@@ -881,10 +664,10 @@
   return $ret;
 }
 
-// create internationalized, external link to
-// $a with description $b 
-function extlink($a, $b) {  
-  echo extlink_($a, $b);
+// create internationalized, internal link to
+// $a.php with description $b 
+function intlink($a, $b) {  
+  echo intlink_($a, $b);
 }
 
 // create internationalized, external link to
@@ -894,46 +677,17 @@
   return $ret;
 }
 
-function P($attr="") {
-  echo "<p $attr>\n";
+// create internationalized, external link to
+// $a with description $b 
+function extlink($a, $b) {  
+  echo extlink_($a, $b);
 }
 
-function BR() {
-  echo "<br />\n";
-}
 
-function HR() {
-  echo "<hr>\n";
-}
-function DTDD($a,$b) {
-  DT($a);
-  DD($b);
-}
-function LILI($a,$b) {
-  echo "<li>" . extlink_($a,$b) . "</li>\n";
-}
-function IMG($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
-  echo IMG_($src, $alt, $align, $width, $height, $border, $hspace, $vspace);
-}
+// *************************************************
+// global, call-once helper functions
+// *************************************************
 
-function IMG_($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
-  $ret = "";
-  
-  if ($align == "CENTER") 
-    $ret = $ret . "<p><center>\n";
-  $ret = $ret . "<img src=\"" . $src . "\" alt=\"";
-  $ret = $ret . TRANSLATE_($alt);
-  $ret = $ret . "\" align=\"" . $align . "\" width=$width height=$height 
border=$border hspace=$hspace vspace=$vspace>\n";
-  $ret = $ret . translateLink_($alt);
-  if ($align == "CENTER") 
-    $ret = $ret . "</center><p>\n";
-  return $ret;
-}
-
-function ANCHOR($a) {
-  echo "<a name=\"$a\"></a>\n";
-}
-
 // outputs appropriate DOCTYPE declaration for the document
 // this should be the 1st line in your php file after including
 // i18nhtml.inc.  Valid types are: HTML for HTML 4 documents,
@@ -943,62 +697,68 @@
 // "Strict", or "Frameset", defaulting to "Transitional".
 // Note for XHTML1.1 $mode is ignored.
 // example:  
-//           -?php 
-//           include("../src/i18nhtml.inc");
+//           include("i18nhtml.inc");
 //           DOCTYPE("XHTML1");
-//           echo "<head><title>Blah</title><body>Blah...</body></html>";
-//           ?-
 function DOCTYPE($type=null, $mode=null) {
   // depending on $mode, use appropriate dtd
   if ($mode == "Strict") {
     $dtd = "strict";
     if ($type != "XHTML1") // Strict not specified except for XHTML1.0
       $mode = "";
-  }
-  elseif ($mode == "Frameset") {
+  } else if ($mode == "Frameset") {
     $dtd = "frameset";
-  }
-  else { // $mode == Transitional, default, or unknown
+  } else { // $mode == Transitional, default, or unknown
     $dtd = "loose";
     $mode = "Transitional";
   }
-
   if ($type == "XHTML1")
     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 " . $mode . "//EN\" 
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-"; . $dtd . ".dtd\">\n";
-  elseif ($type == "XHTML1.1")
+  else if ($type == "XHTML1.1")
     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" 
\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\";>\n";
   else
     echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " . $mode . "//EN\" 
\"http://www.w3.org/TR/html4/"; . $dtd . ".dtd\">\n";
 }
 
+function TITLE($a,$b="") {
+  global $lang;
+  global $languagecodes;
+  echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" 
>";
+  echo "<title>" . TRANSLATE_($a,$b) . "</title>\n";
+  if (isset($languagecodes[$lang])) {
+    echo "<meta name=\"content-language\" content=\"" . 
+         $languagecodes[$lang] . "\">";
+    echo "<meta name=\"language\" content=\"" . 
+         $languagecodes[$lang] . "\">";
+  }
+}
 
 // displays a list of all languages currently available with
 // at least 1 translated string.
 function generateLanguageBar() {
   global $connection;
 
-if ($connection) {
-  echo "<center>[";
-  $query = "SELECT DISTINCT lang FROM map ORDER BY lang";
-  $result = mysql_query($query, $connection);
-  $num = 0;
-  if ($result)   
-    $num = mysql_numrows($result);
-  echo "<a href=\"?xlang=English\">";
-  W("English");
-  echo "</a>";
-  $last = "English";
-  for ($i=0;$i<$num;$i++) {
-    $row = mysql_fetch_array($result);
-    $next = $row["lang"];
-    if ($next == $last)
-      continue;
-    echo " | ";
-    echo "<a href=\"?xlang=$next\">" . W_($next) . "</a>";
-    $last = $next;
+  if ($connection) {
+    echo "<center>[";
+    $query = "SELECT DISTINCT lang FROM map ORDER BY lang";
+    $result = mysql_query($query, $connection);
+    $num = 0;
+    if ($result)   
+      $num = mysql_numrows($result);
+    echo "<a href=\"?xlang=English\">";
+    W("English");
+    echo "</a>";
+    $last = "English";
+    for ($i=0;$i<$num;$i++) {
+      $row = mysql_fetch_array($result);
+      $next = $row["lang"];
+      if ($next == $last)
+        continue;
+      echo " | ";
+      echo "<a href=\"?xlang=$next\">" . W_($next) . "</a>";
+      $last = $next;
+    }
+    echo "]</center>";
   }
-  echo "]</center>";
- }
 }
 
 
@@ -1008,24 +768,97 @@
 function generateFooter() {
   global $xlang;
   global $editor;
-  global $back;
   global $HTTP_SERVER_VARS;
 
   P();
   echo "Translation engine based on <a 
href=\"http://gnunet.org/i18nHTML/\";>i18nHTML</a> (C) 2003, 2004, 2005 
Christian Grothoff.<br />\n";
   if ( ($xlang) && ($xlang != "English") ) {
     $back = "http://"; . $HTTP_SERVER_VARS["HTTP_HOST"] . 
$HTTP_SERVER_VARS["REQUEST_URI"];
-    // echo "<span align=\"center\"><small>";
     echo "<center><small>\n";
     if ($editor != 1)
       echo " <a href=\"$back&amp;editor=1\">" . W_("enter translation mode") . 
"</a>";
     else
       W(" Translation Mode Active (for this page only)");
-    //echo "</small></span>";
     echo "</small></center>\n";
   }
   echo "</p>\n";
 }
 
-   
-?>
+// *************************************************
+// HTML construct helper functions
+// *************************************************
+
+function LI($a,$b="") {
+  echo "<li>" . W_($a,$b) . "</li>\n";
+}
+function TH($a,$b="") {
+  echo "<th>" . W_($a,$b) . "</th>\n";
+}
+function TD($a,$b="") {
+  echo "<td>" . W_($a,$b) . "</td>\n";
+}
+function DT($a,$b="") {
+  echo "<dt>" . W_($a,$b) . "</dt>\n";
+}
+function DD($a,$b="") {
+  echo "<dd>" . W_($a,$b) . "</dd>\n";
+}
+function H1($a,$b="") {
+  echo "<h1>" . W_($a,$b) . "</h1>\n";
+}
+function H2($a,$b="") {
+  echo "<h2>" . W_($a,$b) . "</h2>\n";
+}
+function H3($a,$b="") {
+  echo "<h3>" . W_($a,$b) . "</h3>\n";
+}
+function H4($a,$b="") {
+  echo "<h4>" . W_($a,$b) . "</h4>\n";
+}
+function H5($a,$b="") {
+  echo "<h5>" . W_($a,$b) . "</h5>\n";
+}
+function PRE($a) {
+  echo "<pre>" . $a . "</pre>";
+}
+// 'verbatim' (untranslated) "li"
+function LIV($a) {
+  echo "<li>" . $a . "</li>\n";
+}
+function P($attr="") {
+  echo "<p $attr>\n";
+}
+function BR() {
+  echo "<br />\n";
+}
+function HR() {
+  echo "<hr>\n";
+}
+function DTDD($a,$b) {
+  DT($a);
+  DD($b);
+}
+function LILI($a,$b) {
+  echo "<li>" . extlink_($a,$b) . "</li>\n";
+}
+function ANCHOR($a) {
+  echo "<a name=\"$a\"></a>\n";
+}
+function IMG_($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
+  $ret = "";
+  
+  if ($align == "CENTER") 
+    $ret = $ret . "<p><center>\n";
+  $ret = $ret . "<img src=\"" . $src . "\" alt=\"";
+  $ret = $ret . TRANSLATE_($alt);
+  $ret = $ret . "\" align=\"" . $align . "\" width=$width height=$height 
border=$border hspace=$hspace vspace=$vspace>\n";
+  $ret = $ret . translateLink_($alt);
+  if ($align == "CENTER") 
+    $ret = $ret . "</center><p>\n";
+  return $ret;
+}
+function IMG($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
+  echo IMG_($src, $alt, $align, $width, $height, $border, $hspace, $vspace);
+}
+
+?>
\ No newline at end of file

Modified: Extractor-docs/WWW/index.php
===================================================================
--- Extractor-docs/WWW/index.php        2005-04-11 06:23:40 UTC (rev 638)
+++ Extractor-docs/WWW/index.php        2005-04-11 06:25:43 UTC (rev 639)
@@ -1,108 +1,199 @@
 <?php
-$title="libextractor - a simple library for keyword extraction";
-$description="a simple library for keyword extraction";
-$email="address@hidden";       
-$keywords="keyword, extraction, mp3, html, pdf, images, jpeg, gif, ps, mime, 
real, qt, asf, mpeg, avi, riff, tiff, summary, summaries, kbps, format, 
mime-type, zip, elf, doc, ppt, xls, sha-1, md5, open office, sxw, dvi, id3, 
id3v2, id3v2.3, id3v2.4, thumbnails";
-$author="Vids Samanta and Christian Grothoff"; 
-$page="home";  
-include("html_header.php3");
+include("i18nhtml.inc");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>\n";
+if ($title) {
+  echo "<title>";
+  TRANSLATE("Doodle: find information on your computer");
+  echo "</title>";
+ }
+if ($description) {
+  echo "<meta name=\"description\" content=\"";
+  TRANSLATE("A tool to index and search the files on your disk.");
+  echo "\">";
+ }
+echo "<meta name=\"content-language\" content=\"" . 
+     $languagecodes[$lang] . "\">";
+echo "<meta name=\"language\" content=\"" . 
+     $languagecodes[$lang] . "\">";
+?>
+<meta name="author" content="Christian Grothoff">
+<meta name="keywords" 
content="doodle,desktop,search,suffix,tree,meta,data,libextractor,keywords,fam,index,database,free,Linux,GNU,GPL">
+<meta name="robots" content="index,follow">
+<meta name="revisit-after" content="28 days">
+<meta name="publisher" content="Christian Grothoff">
+<meta name="date" content="2004-12-31">
+<meta name="rights" content="(C) 2004 by Christian Grothoff>";
+<meta http-equiv="expires" content="43200">
+<meta http-equiv="content-type" content="text/html">
+</head>
+<body>
+<?php
+generateLanguageBar();
 
+H1("Doodle");
 ANCHOR("about");
-H2("About libextractor");
+H2("About");
 
-IMG("extractor_logo.png", "libextractor", "right", "136", "94", "0");
+W("Doodle is a tool to quickly search the documents on a computer.");
+W("Doodle builds an index using meta-data contained in the documents and 
allows fast searches on the resulting database.");
+W("Doodle uses %s to support obtaining meta-data from various file-formats.",
+  extlink_("/libextractor/","libextractor"));
+W("The database used by doodle is a %s, resulting in fast lookups.",
+  extlink_("http://www.nist.gov/dads/HTML/suffixtree.html","suffix tree"));
+W("Doodle supports approximate searches.");
+BR();
+W("Features that Doodle does not have at the moment include:");
+echo "<ul>";
+LI("A web interface");
+LI("Ordering of search results");
+LI("Spidering (indexing the Internet or websites)");
+echo "</ul>";
+W("If you need these features, have a look at the %s section.",
+  extlink_("#links", "links"));
+
 P();
-W("libextractor is a library used to extract meta-data from files of arbitrary 
type.");
-W("It is designed to use helper-libraries to perform the actual extraction, 
and to be trivially extendable by linking against external extractors for 
additional file types.");
-W("libextractor is part of the %s.",
-  extlink_("http://www.gnu.org/";, "GNU project"));
-//W("Our official GNU website can be found at %s.",
-//  
extlink_("http://www.gnu.org/software/libextractor/","http://www.gnu.org/software/libextractor/";));
-W("libextractor can be downloaded from this site or the %s.",
-  extlink_("http://www.gnu.org/prep/ftp.html","GNU mirrors"));
+W("Doodle is licensed under the %s.",
+  extlink_("http://www.gnu.org/licenses/gpl.html","GNU GPL"));
+W("Indexing large volumes can take several hundred MBs of memory (depending on 
the amount of meta-data found).");
+W("Searching should nevertheless require almost no memory.");
+W("Using the latest version of libextractor is recommended.");
+W("Doodle has so far only been tested under %s and %s %s %s.",
+  ARRAY(extlink_("http://www.debian.org/";, "Debian"),
+        extlink_("http://www.redhat.com/";, "RedHat"),
+        extlink_("http://www.gnu.org/";, "GNU"),
+        extlink_("http://www.linux.org/";, "Linux")));
+W("Doodle is expected it to work under any platform supported by %s.",
+  extlink_("/libextractor/", "libextractor"));
+P();
 
+ANCHOR("download");
+H2("Download");
+W("You can find the current release %s.",
+  extlink_("download/doodle-0.6.2.tar.gz", "here"));
+W("Man-pages for %s, %s and %s are also on-line.",
+  ARRAY(extlink_("man/doodle.html", "doodle"),
+        extlink_("man/doodled.html", "doodled"),
+        extlink_("man/libdoodle", "libdoodle")));
+
+W("The latest version can be obtained using");
+PRE("$ svn checkout https://gnunet.org/svn/doodle/";);
+P();    
+W("If you want to be notified about updates, subscribe to %s",
+  extlink_("http://freshmeat.net/projects/doodle/";, "doodle on freshmeat"));
 P();
-W("The goal is to provide developers of file-sharing networks or WWW-indexing 
bots with a universal library to obtain simple keywords to match against 
queries.");
-W("libextractor contains a shell-command &quot;extract&quot; that, similar to 
the well-known &quot;file&quot; command, can extract meta-data from a file an 
print the results to stdout.");
+W("Debian packages provided by Daniel Baumann can be found %s.",
+  extlink_("http://packages.debian.org/doodle";, "here"));
+W("RedHat/Fedora RPM packages provided by Dag Wieers can be found %s.",
+  extlink_("http://dag.wieers.com/packages/doodle/","here";));
 P();
 
-W("Currently, libextractor supports the following formats:");
-include("plugins_list");
+ANCHOR("using");
+H2("Using doodle");
+W("First the doodle database needs to be created.");
+W("The simplest way to create the database is to run doodle with the 
<tt>-b</tt> option on the directories that are to be indexed.");
+W("For example:");
+PRE("$ doodle -b $HOME");
+W("This will create the doodle database under <tt>~/.doodle</tt>.");
 BR();
-W("Also, various additional MIME types are detected.");
+W("After creating the doodle database, you can search it.");
+W("For example:");
+PRE("$ doodle keyword");
+BR();
+H3("Keeping the database up-to-date");
+W("If you want to keep your doodle database up-to-date, you can either 
periodically re-run doodle with the <tt>-b</tt> option, or you can use doodled, 
the doodle daemon.");
+W("doodled uses %s to notice whenever a file is changed and instantly updates 
the doodle database.",
+  "fam");
+W("In order to use doodled, you must have famd running.");
+W("If famd is running, you can start doodled by passing the same arguments 
that you would pass to doodle to construct the database, but without the 
<tt>-b</tt> option:");
+PRE("$ doodled $HOME");
+W("You can also use doodled to construct the initial database.");
+W("While doodled is updating the database, any doodle search will block until 
the update is complete.");
+W("Note that while you may want to index your entire disk (i.e., <tt>doodle -b 
/</tt>), it is typically not a great idea to have doodled monitor your entire 
system for changes -- especially since <tt>/usr</tt> is unlikely to change 
frequently.");
+W("You can address this issue by first indexing <tt>/</tt> and then using 
doodled to monitor only directories that change frequently:");
+PRE("$ doodle -b /\n" .
+    "$ doodled $HOME");
+W("This way, your entire system will be in the index, and your home directory 
will be always up-to-date.");
 P();
+H3("Full-text search");
+W("You can achieve a (limited) form of full-text search with doodle.");
+W("For that, the dictionary-based plaintext extractors from %s are used.",
+  extlink_("/libextractor/","libextractor"));
+W("In order to use them, you need to pass the option <tt>-b LANG</tt> to 
doodle.");
+W("LANG is a two letter language code that selects the dictionary.");
+W("Available languages at the moment are en, es, fr, it and no.");
+W("Words and sentences that are available in the respective dictionaries for 
these languages will then be added to the index.");
+W("While libextractor attempts to avoid full-text extraction for certain kown 
binary formats, it may still find words in non-text files.");
+W("Running with this option will dramatically increase the size of the index 
and the time it takes to build the index.");
+W("Note that if you change the options used to build a database will not (!) 
result in doodle re-indexing files that were processed with other options 
previously.");
+W("The only way to force doodle to re-index files with different options is to 
either touch the files (change modification timestamp) or to delete the old 
database and start from scratch.");
 
-W("libextractor is free software; you can redistribute it and/or modify it 
under the terms of the GNU General Public License as published by the Free 
Software Foundation; either version 2 of the License, or (at your option) any 
later version.");
-ANCHOR("news");
-H2("Recent News");
 P();
-echo "<dl>";
-DTDD("Thu Feb 24 01:23:31 EST 2005 | libextractor v0.4.2 released.",
-     "This release fixes some bugs in the ID3, PDF, PNG and REAL extractors.  
The REAL extractor now also handles the new Helix formats.  libextractor can 
now also be used to extract thumbnails from images (using ImageMagick).");
-DTDD("Wed Jan 26 19:51:44 EST 2005 | libextractor v0.4.1 released.",
-     "This release fixes a security issue (inherited from xpdf).  It also 
extracts more meta-data from files of TAR or QuickTime format.");
-DTDD("Sat Dec 25 21:42:26 CET 2004 | libextractor v0.4.0 released.",
-     "This release improves support for character sets (plugins are now 
expected to convert to UTF-8).  It also improves support for mp3 (adding 
genres) and png (handling of compressed comments).");
-DTDD("Sat Nov 13 13:23:23 EST 2004 | libextractor v0.3.11 released.",
-     "This release fixes bugs in the dvi, man, ID3v2.3, ole2 and pdf 
extractors.");
-DTDD("Sun Oct 18 13:23:35 EST 2004 | libextractor v0.3.10 released.", 
-     "This release adds support for ID3v2.3 and ID3v2.4.  It fixes bugs in the 
tar, man, deb, mp3 and ole2 extractors.");
-DTDD("Sat Oct 17 18:12:11 EST 2004 | libextractor v0.3.9 released.", 
-     "This release adds support for the man, tar (including tar.gz) and deb 
formats.  It fixes bugs in the id3v2 and jpeg extractors.  The size of jpeg 
images is now also extracted.  This version adds support for 64-bit file 
sizes.");
-DTDD("Sat Oct 02 20:00:04 EST 2004 | libextractor v0.3.8 released.",
- "This release adds support for dvi (from TeX).  The plugins are now installed 
in a separate plugin directory.  libextractor now works under OS X (10.3)."); 
-DTDD("Fri Sep 23 23:30:33 EST 2004 | libextractor v0.3.7 released.",
-     "This release adds support for StarOffice formats, ID3v2 tags and the 
Ripe160MD hash function.  It also improves the performance of the HTML and ZIP 
extractors.");
-DTDD("Fri Sep 10 20:10:38 EST 2004 | libextractor v0.3.6 released.",
-     "This release adds support for OpenOffice formats, hash functions (md5, 
sha-1) and fixes some build problems.");
-DTDD("Mon Aug 30 23:18:49 IST 2004 | libextractor v0.3.5 released.",
-     "This release adds support for OLE2 (WinWord, PowerPoint, Excel formats) 
and fixes various minor bugs.  For OLE2 support you will have to have glib 2.0 
installed (yes, that is glib from GTK/Gnome, not glibc!).");
-DTDD("Thu Aug 26 20:27:24 IST 2004 | Bugtracking using Mantis enabled.",
-     "You can now report and view bug-reports about libextractor on %s.",
-     extlink_("https://gnunet.org/mantis/","Mantis";));
-DTDD("Wed Aug 25 19:02:07 IST 2004 | libextractor v0.3.4 released.",
-     "This release fixes a minor linking error (<tt>-lm</tt> for 
<tt>floor</tt>), improves performance and adds support for GNU gettext 
(internationalization).");
-DTDD("Wed May 31 19:22:07 EST 2004 | libextractor v0.3.3 released.",
-     "This release fixes various minor bugs (segmentation faults and 
non-termination of mpeg and riff extractors for malformed files) and adds 
support for WAV files.");
-DTDD("Wed May 31 19:22:07 EST 2004 | libextractor v0.3.2 released.",
-     "This release fixes various minor bugs (plugins misbehaving for malformed 
files) and improves portability to Cygwin/MinGW.");
-echo "</dl>";
+H3("Hints for system administrators");
+W("If you are the system administrator, you might want to run doodle on the 
entire system periodically (cron job) and have doodled monitor the home 
directories in the background.");
+W("In that case, it is suggested to have the doodle database be group-readable 
for a group doodle.");
+W("Set the permissions for the doodle binary to SGID to allow users to poll 
the database.");
+W("Doodle will ensure that information about files not accessible to the user 
are not leaked by checking if files found in the database are accessible to the 
user.");
+W("doodled has to run as root since otherwise it would be impossible to index 
the personal files of all users.");
+W("If that it too risky, doodled will still work, but only index the files 
readable to the user that runs doodled.");
+
+
 P();
-W("%s",
-  intlink_("oldnews","Older news archive"));
+H3("Using different options for different directories");
+W("You can build a database from multiple doodle runs over distinct sets of 
files with different options.");
+W("For example, the following can make sense:");
+PRE("$ doodle -B en -b /usr/share/doc # full-text index over documentation\n" .
+    "$ doodle -b /usr /opt /bin /lib # normal index over other system files\n" 
.
+    "$ doodled -B en /home # monitor /home, with full-text support\n");
+W("A simple doodle search will then find files in all listed directories.");
+W("You can also build multiple disjoint databases and search all of them in 
one run (see %s for option <tt>-d</tt>).",
+  extlink_("man/doodle.html", "doodle"));
 
+P();
+ANCHOR("mantis");
+H2("Bugtrack");
+W("Doodle uses Mantis for bugtracking.");
+W("Visit %s to report bugs.",
+  extlink_("https://gnunet.org/mantis/","https://gnunet.org/mantis/";));
+W("You need to sign up for a reporter account.");
+W("Please make sure you report bugs under <strong>Doodle</strong> and not 
under any of the other projects.");
+P();
+W("If you dislike Mantis and need to report a bug contact %s via e-mail.",
+  extlink_("mailto:address@hidden","address@hidden";));
+
+
 ANCHOR("links");
 H2("Links");
-P();
-W("Related work:");
 echo "<ul>";
-LILI("http://www.wotsit.org","File format database");
-LILI("http://getid3.sf.net/","getid3, similar project for PHP");
-LILI("download/php/",
-     "PHP wrapper for libextractor (mirrored, not written by us, see README)");
-LILI("http://dublincore.org/documents/dcmi-terms/","Meta-data categorization 
standard");
-LILI("http://hul.harvard.edu/jhove/","JHOVE, Harvard Object Validation 
Environment");
+LILI("http://members.cox.net/sinzui/medusa/";, 
+     "Medusa, similar project for Gnome");
+LILI("http://swish-e.org/";, 
+     "Swish-e, indexing tool with focus on the WWW");
+LILI("http://www.gnome.org/~seth/storage/";,
+     "GNOME Storage");
+LILI("http://www.gnome.org/projects/beagle/";,
+     "Beagle");
+LILI("http://sourceforge.net/projects/rlocate/";,
+     "rlocate, version of locate that is always up-to-date");
+LILI("http://www.htdig.org/";,
+     "HTDig");
+LILI("http://jakarta.apache.org/lucene/";,
+     "Lucene");
+LILI("http://homepage.mac.com/pauljlucas/software/swish/";,
+     "Swish++");
+LILI("http://webglimpse.net/";,
+     "Glimpse");
+LILI("http://evidence.sf.net/";,
+     "Evidence, file-manager with support for doodle");
+LILI("http://www.linux-magazin.de/Artikel/ausgabe/2004/09/bgw/bgw.html";,
+     "Article about doodle (and other things) in the German Linux-Magazin");
 echo "</ul>";
-W("Projects that use libextractor:");
-echo "<ul>";
-LILI("http://witme.sourceforge.net/libferris.web/","libferris, a virtual file 
system");
-LILI("http://evidence.sf.net/","Evidence, enlightened file manager");
-LILI("http://gnunet.org/","GNUnet, secure P2P file sharing");
-LILI("http://gnunet.org/doodle/","doodle, index your disk");
-echo "</ul>";
-
-ANCHOR("contact");
-H2("Contact");
-P();
-W("libextractor is developed by %s and %s.",
-  ARRAY(extlink_("http://grothoff.org/christian/";,
-                "Christian Grothoff"),
-       extlink_("http://compilers.cs.purdue.edu/~vids/";,
-                "Vids Samanta")));
-W("For questions about libextractor send email to %s.",
-  extlink_("mailto:address@hidden";,
-          "address@hidden"));
-
-include("html_footer.php3");
+HR();
+echo "<address><a href=\"mailto:address@hidden";>Christian 
Grothoff</a></address>";
+PRE("Copyright (C) 2004 Christian Grothoff.\n" .
+    "Verbatim copying and distribution of this entire article\n" .
+    "is permitted in any medium, provided this notice is preserved.");
+BR();
+generateFooter();
+echo "</body></html>\n";
 ?>
-

Modified: Extractor-docs/WWW/translate.php
===================================================================
--- Extractor-docs/WWW/translate.php    2005-04-11 06:23:40 UTC (rev 638)
+++ Extractor-docs/WWW/translate.php    2005-04-11 06:25:43 UTC (rev 639)
@@ -1,6 +1,6 @@
 <?php
 /*
-     (C) 2003, 2004 Christian Grothoff
+     (C) 2003, 2004, 2005 Christian Grothoff
 
      This code is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -22,9 +22,10 @@
   echo "Database is down. Cannot edit translations.";
   die();
 }
-$text = $_REQUEST['text'];
+$text     = fix($_REQUEST['text']);
+$text_sql = mysql_real_escape_string($text);
+$text_url = urlencode($text);
 $back = $_REQUEST['back'];
-
 DOCTYPE("HTML", "Transitional");
 echo "<html><head>\n";
 TITLE("WWW translation");
@@ -37,65 +38,43 @@
   die();
  } 
 H2("Original Text");
-// if (get_magic_quotes_gpc()) $text = stripslashes($text);
 echo $text;
 H2("Translation");
 W("Destination language: ");
 W($lang);
 P();
 echo "<form method=\"POST\" action=\"" . $i18nHTMLbase . 
"commitTranslation.php\">\n";
-echo "<input type=hidden name=\"text\" value=\"" . urlencode($text) . "\">\n";
+echo "<input type=hidden name=\"text\" value=\"$text_url\">\n";
 echo "<input type=hidden name=\"xlang\" value=\"$xlang\">\n";
 echo "<input type=hidden name=\"back\" value=\"$back\">\n";
-/* 
-P();
-W("Character set:");
-<select size="1" name="charset">
-  <option value="UTF-8">Unicode UTF-8 encoding</option>
-  <option selected value="ISO-8859-1">ISO-8859-1 Western European, 
Latin-1</option>
-  <option value="ISO-8859-15">ISO-8859-15 Extended Western European</option>
-  <option value="cp1252">cp1252 Windows Western Europen</option>
-  <option value="cp866">cp866 DOS Cyrillic</option>
-  <option value="cp1251">cp1251 Windows Cyrillic</option>
-  <option value="KOI8-R">koi8-ru Russian</option>
-  <option value="BIG5">BIG5 Traditional Chinese</option>
-  <option value="GB2312">GB2312 Simplified Chinese</option>
-  <option value="Shift-JIS">Shift-JIS Japanese</option>
-  <option value="EUC-JP">EUC-JP Japanese</option>
-</select><br> */
 W("Translated text:");
-?>
-<input size="80" maxlength="65535" name="translation">
-<input type=submit value="I hereby give this translation into the Public 
Domain (commit)">
-</form>
-<?php
+echo "<input size=\"80\" maxlength=\"65535\" name=\"translation\">\n";
+echo "<input type=submit value=\"" . 
+     TRANSLATE_("I hereby give this translation into the Public Domain 
(commit)") . 
+     "\">\n";
+echo "</form>\n";
 P();
 
 H2("All available translations");
-?>
-<table border=5 width=95%>
-<tr><th><?php W("Language"); ?></th><th><?php W("Translation"); ?></th></tr>
-<?php
- $u = urlencode($text);
- $query = "SELECT translation,lang FROM map WHERE name=\"$u\" ORDER BY ranking 
DESC";
- $result = mysql_query($query, $connection);
- $num = 0;
- if ($result) 
-   $num = mysql_num_rows($result);
- for ($i=0;$i<$num;$i++) {
-   $row = mysql_fetch_array($result);
-
-   $translation = $row["translation"];
-
-   printf("<tr><td>%s</td><td><a href=\"" . $i18nHTMLbase . 
"vote.php?xlang=%s&text=%s&translation=%s\">%s</a></td></tr>\n",
-          W_($row["lang"]),
-          urlencode($row["lang"]),
-         $u, // urlencoded $text
-         urlencode(stripslashes($translation)),
-         fix(stripslashes($translation)));
- }
+echo "<table border=5 width=95%>\n";
+echo "<tr><th>" . W_("Language") . "</th><th>" . W_("Translation") . 
"</th></tr>\n";
+$query = "SELECT translation,lang FROM map WHERE name=\"$text_sql\" ORDER BY 
ranking DESC";
+$result = mysql_query($query, $connection);
+$num = 0;
+if ($result) 
+  $num = mysql_num_rows($result);
+for ($i=0;$i<$num;$i++) {
+  $row = mysql_fetch_array($result);
+  $translation = $row["translation"];
+  printf("<tr><td>%s</td><td><a href=\"" . $i18nHTMLbase . 
+         "vote.php?xlang=%s&text=%s&translation=%s\">%s</a></td></tr>\n",
+         W_($row["lang"]),
+         urlencode($row["lang"]),
+         urlencode($text_url),  // yes, we need urlencode twice!
+         urlencode(urlencode($translation)), // yes, we need urlencode twice!
+         fix($translation));
+}
 echo "</table>";
-
 H2("Remarks");
 H3("The percent sign");
 W("The %% sign is a special character.");
@@ -103,19 +82,15 @@
 W("The sequence %%s is used as a placeholder for links.");
 W("Currently, the translation can only access the links in the same order as 
the original text.");
 P();
-
 H3("Language specific special characters");
 W("Various languages use special characters.");
 W("The code has not been tested with certain character sets, such as 
Chinese.");
 W("If you are trying to translate the page to such a language, please contact 
the developerws if you encounter any problems.");
 P();
-
 H3("Copyright");
 W("The original english text is released under the GNU Free Documentation 
License (FDL).");
 W("Translations submitted to the webpage must be released to the public domain 
to ensure that we will not have any legal trouble.");
 W("If you have concerns or remarks regarding this policy, feel free to bring 
them to our attention.");
-
 generateFooter();
 echo "</body></html>";
-
 ?>

Modified: Extractor-docs/WWW/vote.php
===================================================================
--- Extractor-docs/WWW/vote.php 2005-04-11 06:23:40 UTC (rev 638)
+++ Extractor-docs/WWW/vote.php 2005-04-11 06:25:43 UTC (rev 639)
@@ -17,24 +17,25 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-  // This file records votes from users for translations.
-  // For sentences with multiple translations, the one with the most
-  // votes is displayed.
+// This file records votes from users for translations.
+// For sentences with multiple translations, the one with the most
+// votes is displayed.
 include("i18nhtml.inc");
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
-echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" >";
 TITLE("WWW translation: vote");
 echo "</head><body>";
 if (!$connection) {
   echo "Database is down. Cannot edit translations.";
   die();
  } 
-$text = $_REQUEST['text'];
-$translation = $_REQUEST['translation'];
-$u = mysql_real_escape_string($text);
-$t = mysql_real_escape_string(to_unicode($translation));
+$text            = fix(urldecode($_REQUEST['text']));
+$translation     = fix(urldecode($_REQUEST['translation']));
+$text_sql        = mysql_real_escape_string($text);
+$translation_sql = mysql_real_escape_string(to_unicode($translation));
 
-$query = "SELECT ranking FROM map WHERE name=\"$u\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+$query = "SELECT ranking FROM map WHERE " .
+         "name=\"$text_sql\" AND lang=\"$lang\" AND 
translation=\"$translation_sql\"";
 $result = mysql_query($query, $connection);
 $num = 0;
 if ($result) 
@@ -42,17 +43,13 @@
 if ($num > 0) {
   $row = mysql_fetch_array($result);
   $ranking = $row["ranking"] + 1;
-  $query = "UPDATE map SET ranking=\"$ranking\" WHERE name=\"$u\" AND 
lang=\"$lang\" AND translation=\"$t\"";
+  $query = "UPDATE map SET ranking=\"$ranking\" WHERE " .
+           "name=\"$text_sql\" AND lang=\"$lang\" AND 
translation=\"$translation_sql\"";
   mysql_query($query, $connection);
   W("Ranking of translation is now: ");
   echo "$ranking";
- } else {
-  W("Translation does not exist (bug?).");
-  W("Diagnostics:");
-  P();
-  echo "Text = " . $u . "<br>\n";
-  echo "Translation = " . $translation . "<br>\n";
-  echo "Unicode = " . to_unicode($translation) . "<br>\n";
-  echo "T = " . $t . "<br>\n";
- }
+} else {
+  W("Translation '%s' of '%s' does not exist (bug?).",
+    ARRAY($translation, $text));
+}
 ?>

Modified: GNUnet-docs/WWW/commitMassTranslation.php
===================================================================
--- GNUnet-docs/WWW/commitMassTranslation.php   2005-04-11 06:23:40 UTC (rev 
638)
+++ GNUnet-docs/WWW/commitMassTranslation.php   2005-04-11 06:25:43 UTC (rev 
639)
@@ -26,6 +26,7 @@
   W("Translating to English currently not allowed.\n");
   die();
 }
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
 TITLE("WWW translation: commit");
 echo "</head><body>";
@@ -37,6 +38,7 @@
     continue;
   if ( ($dec == "xlang") || ($dec == "start") )
     continue;
+  $val = fix($val);
   $query = "SELECT c FROM pending WHERE lang=\"$xlang\"";
   $result = mysql_query($query, $connection);
   $num = 0;
@@ -45,8 +47,10 @@
   while ($num > 0) {
     $num--;
     $row = mysql_fetch_array($result);
-    if ($dec == bin2hex(md5(urldecode($row["c"])))) {
-      $enc = mysql_real_escape_string($row["c"]);
+    $cx_plain = fix($row["c"]);
+    $cx_sql = mysql_real_escape_string($cx_plain);
+    if ($dec == bin2hex(md5($cx_plain))) {
+      $enc_sql = $cx_sql;
       break;
     }
   }
@@ -56,30 +60,32 @@
     P();
     continue;
   }  
-  $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$enc\"";
+  $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$enc_sql\"";
   mysql_query($query, $connection); 
-  $t = mysql_real_escape_string(to_unicode($val));
-  $query = "SELECT ranking FROM map WHERE name=\"$enc\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+  $val_sql = mysql_real_escape_string(to_unicode($val));
+  $query = "SELECT ranking FROM map WHERE name=\"$enc_sql\"" .
+           " AND lang=\"$lang\" AND translation=\"$val_sql\"";
   $result = mysql_query($query, $connection);
   $num = 0;
   if ($result) 
     $num = mysql_numrows($result);
   if ($num == 0) {
-    $txtCnt = count_chars(urldecode($enc), 1);
-    $tCnt = count_chars($t, 1);
+    $txtCnt = count_chars(stripslashes($enc_sql), 1);
+    $tCnt = count_chars(stripslashes($val_sql), 1);
     if ($txtCnt[ord('%')] != $tCnt[ord('%')]) {
-      W("Commit '%s->%s' failed.", $enc, $t);
+      W("Commit '%s->%s' failed.", stripslashes($enc_sql), 
stripslashes($val_sql));
       W("The number of percent signs in source text and translation do not 
match.");     
       W("Note that you must preserve all %%s expressions unchanged.");
       W("Also, a single displayed %% sign must be translated into two (%%%%) 
such signs.");
       P();
     } else {
-      $query = "INSERT INTO map VALUES(\"$enc\", \"$lang\", \"$t\", 1, \"" . 
$_SERVER['REMOTE_ADDR'] . "\");";
+      $query = "INSERT INTO map VALUES(\"$enc_sql\", \"$lang\", " .
+               "\"$val_sql\", 1, \"" . $_SERVER['REMOTE_ADDR'] . "\");";
       mysql_query($query, $connection);
       $done++;
       W("Storing translation for &quot;%s&quot = &quot;%s&quot;.",
-        ARRAY(urldecode($enc),
-             urldecode($t)));
+        ARRAY(stripslashes($enc_sql),
+             stripslashes($val_sql)));
       BR();  
     }
   }  

Modified: GNUnet-docs/WWW/commitTranslation.php
===================================================================
--- GNUnet-docs/WWW/commitTranslation.php       2005-04-11 06:23:40 UTC (rev 
638)
+++ GNUnet-docs/WWW/commitTranslation.php       2005-04-11 06:25:43 UTC (rev 
639)
@@ -18,9 +18,6 @@
      Boston, MA 02111-1307, USA.
 */
 include("i18nhtml.inc");
-$text = mysql_real_escape_string($_REQUEST['text']);
-$translation = $_REQUEST['translation'];
-$back = $_REQUEST['back'];
 if (!$connection) {
   echo "Database is down. Cannot edit translations.";
   die();
@@ -29,39 +26,47 @@
   W("Translating to English is not allowed.\n");
   die();
 }
+$text            = urldecode($_REQUEST['text']);
+$text_sql        = mysql_real_escape_string($text);
+$translation     = fix($_REQUEST['translation']);
+$translation_sql = mysql_real_escape_string(to_unicode($translation));
 
-$t = mysql_real_escape_string(to_unicode($translation));
+$back            = $_REQUEST['back'];
 // check for identical translation
-$query = "SELECT ranking FROM map WHERE name=\"$text\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+$query = "SELECT ranking FROM map WHERE name=\"$text_sql\"" . 
+         " AND lang=\"$lang\" AND translation=\"$translation_sql\"";
 $result = mysql_query($query, $connection);
 $num = 0;
-if ($result) {
+if ($result) 
   $num = mysql_numrows($result);
-}
 if ($num > 0) {
   echo "<html><head>";
   TITLE("Translation exists.");
   echo "</head><body>";
-  W("Translation exists.");   
+  W("Translation '%s' of sentence '%s' exists.",
+    fix($translation), $text);   
   extlink($back, "Back...");
   generateFooter();
   echo "</body></html>";
 } else {
-  $txtCnt = count_chars(urldecode($text), 1);
-  $tCnt = count_chars($t, 1);
+  $txtCnt = count_chars($text, 1);
+  $tCnt   = count_chars($translation, 1);
   if ($txtCnt[ord('%')] != $tCnt[ord('%')]) {
       echo "<html><head>";
       TITLE("Commit failed.");
       echo "</head><body>";
-      W("Commit failed.");
-      W("The number of percent signs in source text and translation do not 
match.");     
+      W("Commit failed ('%s' and '%s').", ARRAY($text, $translation));
+      W("The number of percent signs in source text and translation does not 
match.");     
       W("Note that you must preserve all %%s expressions unchanged.");
       W("Also, a single displayed %% sign must be translated into two (%%%%) 
such signs.");
       echo "</body></html>";
   } else {
-    $query = "INSERT INTO map VALUES(\"$text\", \"$lang\", \"$t\", 1, \"" . 
$_SERVER['REMOTE_ADDR'] . "\");";
+    $query = "INSERT INTO map VALUES(\"$text_sql\", \"$lang\", " .
+             "\"$translation_sql\", 1, \"" . $_SERVER['REMOTE_ADDR'] . "\");";
     $result = mysql_query($query, $connection);
     if ($result) {
+      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$text_sql\"";
+      mysql_query($query, $connection); 
       header("Location: " . $back); /* Redirect browser */
     } else {
       echo "<html><head>";

Modified: GNUnet-docs/WWW/editor.php
===================================================================
--- GNUnet-docs/WWW/editor.php  2005-04-11 06:23:40 UTC (rev 638)
+++ GNUnet-docs/WWW/editor.php  2005-04-11 06:25:43 UTC (rev 639)
@@ -22,6 +22,7 @@
   echo "Database is down. Cannot edit translations.";
   die();
 }
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
 TITLE("WWW translation");
 echo "</head><body>";
@@ -51,12 +52,12 @@
   $start = $end - $max;
   if ($start < 0)
     $start = 0;
- }
+}
 
 if ($num == 0) {
   P();
   W("No missing translations for the selected target language were found.");
- } else {
+} else {
   P();
   W("%s translations to %s have been requested and were not available.",
     ARRAY($num,
@@ -71,45 +72,39 @@
   echo "<input type=hidden name=\"start\" value=\"$endp\">";
   
   echo "<table border=5>";
-  echo "<tr><th>";
-  W("Original");
-  echo "</th><th>";
-  W("Translation");
-  echo "</th></tr>";
+  echo "<tr>";
+  TH("Original");
+  TH("Translation");
+  echo "</tr>";
   for ($ii=0;$ii<$end;$ii++) {
     $row = mysql_fetch_array($result);
     if ($ii < $start)
       continue;
-    $cx = $row["c"];
+    $cx_plain = fix($row["c"]);
+    $cx_sql = mysql_real_escape_string($cx_sql);
     
-    $query = "SELECT ranking FROM map WHERE name=\"$cx\" AND lang=\"$lang\"";
+    $query = "SELECT ranking FROM map WHERE name=\"$cx_sql\" AND 
lang=\"$lang\"";
     $result2 = mysql_query($query, $connection);
     $num2 = 0;
     if ($result2) 
       $num2 = mysql_numrows($result2);
+    echo "<tr><td width=\"45%\">";
+    echo "&quot;$cx_plain&quot;";
+    echo "</td>\n\t<td width\"50\%\">";
     if ($num2 > 0) {
-      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$cx\"";
-      mysql_query($query, $connection); 
-      
-      echo "<tr><td width=\"45%\">";
-      $dec = urldecode($cx);
-      echo "&quot;" . $dec . "&quot;";
-      echo "</td>\n\t<td width\"50\%\">";
+      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$cx_sql\"";
+      mysql_query($query, $connection);      
       W("Skipped (already translated).");
+    } else {
+      echo "<input size=\"40\" maxlength=\"65535\" name=\"" . 
bin2hex(md5($cx_plain)) . "\"></td></tr>\n";
     }
-    else {
-      echo "<tr><td width=\"45%\">";
-      $dec = urldecode($cx);
-      echo "&quot;" . $dec . "&quot;";
-      echo "</td>\n\t<td width\"50\%\">";
-      echo "<input size=\"40\" maxlength=\"65535\" name=\"" . 
bin2hex(md5($dec)) . "\"></td></tr>\n";
-    }
   }
   echo "</tr></table>";
-  echo "<input type=submit value=\"I hereby give all these translations into 
the Public Domain (commit)\">";
+  echo "<input type=submit value=\"" . 
+       TRANSLATE_("I hereby give all these translations into the Public Domain 
(commit)") . 
+       "\">";
   echo "</form>";
-  
- }
+}
 if ($end < $num) {
   P();
   echo "<a href=\"" . $i18nHTMLbase . "editor.php?xlang=" . $lang . "&start=" 
. ($end + 1) . "\">";
@@ -117,10 +112,10 @@
   echo "</a>";
   if ($t == 1)
     translateLink($b);
- } else {
+} else {
   W("Statistics about translation progress can be found %s.\n",
     intlink_($i18nHTMLbase . "status.php", "here"));
- }
+}
 P();
 H2("Remarks");
 H3("The percent sign");

Modified: GNUnet-docs/WWW/gnu.org/commitMassTranslation.php
===================================================================
--- GNUnet-docs/WWW/gnu.org/commitMassTranslation.php   2005-04-11 06:23:40 UTC 
(rev 638)
+++ GNUnet-docs/WWW/gnu.org/commitMassTranslation.php   2005-04-11 06:25:43 UTC 
(rev 639)
@@ -26,6 +26,7 @@
   W("Translating to English currently not allowed.\n");
   die();
 }
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
 TITLE("WWW translation: commit");
 echo "</head><body>";
@@ -37,6 +38,7 @@
     continue;
   if ( ($dec == "xlang") || ($dec == "start") )
     continue;
+  $val = fix($val);
   $query = "SELECT c FROM pending WHERE lang=\"$xlang\"";
   $result = mysql_query($query, $connection);
   $num = 0;
@@ -45,8 +47,10 @@
   while ($num > 0) {
     $num--;
     $row = mysql_fetch_array($result);
-    if ($dec == bin2hex(md5(urldecode($row["c"])))) {
-      $enc = mysql_real_escape_string($row["c"]);
+    $cx_plain = fix($row["c"]);
+    $cx_sql = mysql_real_escape_string($cx_plain);
+    if ($dec == bin2hex(md5($cx_plain))) {
+      $enc_sql = $cx_sql;
       break;
     }
   }
@@ -56,30 +60,32 @@
     P();
     continue;
   }  
-  $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$enc\"";
+  $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$enc_sql\"";
   mysql_query($query, $connection); 
-  $t = mysql_real_escape_string(to_unicode($val));
-  $query = "SELECT ranking FROM map WHERE name=\"$enc\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+  $val_sql = mysql_real_escape_string(to_unicode($val));
+  $query = "SELECT ranking FROM map WHERE name=\"$enc_sql\"" .
+           " AND lang=\"$lang\" AND translation=\"$val_sql\"";
   $result = mysql_query($query, $connection);
   $num = 0;
   if ($result) 
     $num = mysql_numrows($result);
   if ($num == 0) {
-    $txtCnt = count_chars(urldecode($enc), 1);
-    $tCnt = count_chars($t, 1);
+    $txtCnt = count_chars(stripslashes($enc_sql), 1);
+    $tCnt = count_chars(stripslashes($val_sql), 1);
     if ($txtCnt[ord('%')] != $tCnt[ord('%')]) {
-      W("Commit '%s->%s' failed.", $enc, $t);
+      W("Commit '%s->%s' failed.", stripslashes($enc_sql), 
stripslashes($val_sql));
       W("The number of percent signs in source text and translation do not 
match.");     
       W("Note that you must preserve all %%s expressions unchanged.");
       W("Also, a single displayed %% sign must be translated into two (%%%%) 
such signs.");
       P();
     } else {
-      $query = "INSERT INTO map VALUES(\"$enc\", \"$lang\", \"$t\", 1, \"" . 
$_SERVER['REMOTE_ADDR'] . "\");";
+      $query = "INSERT INTO map VALUES(\"$enc_sql\", \"$lang\", " .
+               "\"$val_sql\", 1, \"" . $_SERVER['REMOTE_ADDR'] . "\");";
       mysql_query($query, $connection);
       $done++;
       W("Storing translation for &quot;%s&quot = &quot;%s&quot;.",
-        ARRAY(urldecode($enc),
-             urldecode($t)));
+        ARRAY(stripslashes($enc_sql),
+             stripslashes($val_sql)));
       BR();  
     }
   }  

Modified: GNUnet-docs/WWW/gnu.org/commitTranslation.php
===================================================================
--- GNUnet-docs/WWW/gnu.org/commitTranslation.php       2005-04-11 06:23:40 UTC 
(rev 638)
+++ GNUnet-docs/WWW/gnu.org/commitTranslation.php       2005-04-11 06:25:43 UTC 
(rev 639)
@@ -18,9 +18,6 @@
      Boston, MA 02111-1307, USA.
 */
 include("i18nhtml.inc");
-$text = mysql_real_escape_string($_REQUEST['text']);
-$translation = $_REQUEST['translation'];
-$back = $_REQUEST['back'];
 if (!$connection) {
   echo "Database is down. Cannot edit translations.";
   die();
@@ -29,39 +26,47 @@
   W("Translating to English is not allowed.\n");
   die();
 }
+$text            = urldecode($_REQUEST['text']);
+$text_sql        = mysql_real_escape_string($text);
+$translation     = fix($_REQUEST['translation']);
+$translation_sql = mysql_real_escape_string(to_unicode($translation));
 
-$t = mysql_real_escape_string(to_unicode($translation));
+$back            = $_REQUEST['back'];
 // check for identical translation
-$query = "SELECT ranking FROM map WHERE name=\"$text\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+$query = "SELECT ranking FROM map WHERE name=\"$text_sql\"" . 
+         " AND lang=\"$lang\" AND translation=\"$translation_sql\"";
 $result = mysql_query($query, $connection);
 $num = 0;
-if ($result) {
+if ($result) 
   $num = mysql_numrows($result);
-}
 if ($num > 0) {
   echo "<html><head>";
   TITLE("Translation exists.");
   echo "</head><body>";
-  W("Translation exists.");   
+  W("Translation '%s' of sentence '%s' exists.",
+    fix($translation), $text);   
   extlink($back, "Back...");
   generateFooter();
   echo "</body></html>";
 } else {
-  $txtCnt = count_chars(urldecode($text), 1);
-  $tCnt = count_chars($t, 1);
+  $txtCnt = count_chars($text, 1);
+  $tCnt   = count_chars($translation, 1);
   if ($txtCnt[ord('%')] != $tCnt[ord('%')]) {
       echo "<html><head>";
       TITLE("Commit failed.");
       echo "</head><body>";
-      W("Commit failed.");
-      W("The number of percent signs in source text and translation do not 
match.");     
+      W("Commit failed ('%s' and '%s').", ARRAY($text, $translation));
+      W("The number of percent signs in source text and translation does not 
match.");     
       W("Note that you must preserve all %%s expressions unchanged.");
       W("Also, a single displayed %% sign must be translated into two (%%%%) 
such signs.");
       echo "</body></html>";
   } else {
-    $query = "INSERT INTO map VALUES(\"$text\", \"$lang\", \"$t\", 1, \"" . 
$_SERVER['REMOTE_ADDR'] . "\");";
+    $query = "INSERT INTO map VALUES(\"$text_sql\", \"$lang\", " .
+             "\"$translation_sql\", 1, \"" . $_SERVER['REMOTE_ADDR'] . "\");";
     $result = mysql_query($query, $connection);
     if ($result) {
+      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$text_sql\"";
+      mysql_query($query, $connection); 
       header("Location: " . $back); /* Redirect browser */
     } else {
       echo "<html><head>";

Modified: GNUnet-docs/WWW/gnu.org/editor.php
===================================================================
--- GNUnet-docs/WWW/gnu.org/editor.php  2005-04-11 06:23:40 UTC (rev 638)
+++ GNUnet-docs/WWW/gnu.org/editor.php  2005-04-11 06:25:43 UTC (rev 639)
@@ -22,6 +22,7 @@
   echo "Database is down. Cannot edit translations.";
   die();
 }
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
 TITLE("WWW translation");
 echo "</head><body>";
@@ -51,12 +52,12 @@
   $start = $end - $max;
   if ($start < 0)
     $start = 0;
- }
+}
 
 if ($num == 0) {
   P();
   W("No missing translations for the selected target language were found.");
- } else {
+} else {
   P();
   W("%s translations to %s have been requested and were not available.",
     ARRAY($num,
@@ -71,45 +72,39 @@
   echo "<input type=hidden name=\"start\" value=\"$endp\">";
   
   echo "<table border=5>";
-  echo "<tr><th>";
-  W("Original");
-  echo "</th><th>";
-  W("Translation");
-  echo "</th></tr>";
+  echo "<tr>";
+  TH("Original");
+  TH("Translation");
+  echo "</tr>";
   for ($ii=0;$ii<$end;$ii++) {
     $row = mysql_fetch_array($result);
     if ($ii < $start)
       continue;
-    $cx = $row["c"];
+    $cx_plain = fix($row["c"]);
+    $cx_sql = mysql_real_escape_string($cx_sql);
     
-    $query = "SELECT ranking FROM map WHERE name=\"$cx\" AND lang=\"$lang\"";
+    $query = "SELECT ranking FROM map WHERE name=\"$cx_sql\" AND 
lang=\"$lang\"";
     $result2 = mysql_query($query, $connection);
     $num2 = 0;
     if ($result2) 
       $num2 = mysql_numrows($result2);
+    echo "<tr><td width=\"45%\">";
+    echo "&quot;$cx_plain&quot;";
+    echo "</td>\n\t<td width\"50\%\">";
     if ($num2 > 0) {
-      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$cx\"";
-      mysql_query($query, $connection); 
-      
-      echo "<tr><td width=\"45%\">";
-      $dec = urldecode($cx);
-      echo "&quot;" . $dec . "&quot;";
-      echo "</td>\n\t<td width\"50\%\">";
+      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$cx_sql\"";
+      mysql_query($query, $connection);      
       W("Skipped (already translated).");
+    } else {
+      echo "<input size=\"40\" maxlength=\"65535\" name=\"" . 
bin2hex(md5($cx_plain)) . "\"></td></tr>\n";
     }
-    else {
-      echo "<tr><td width=\"45%\">";
-      $dec = urldecode($cx);
-      echo "&quot;" . $dec . "&quot;";
-      echo "</td>\n\t<td width\"50\%\">";
-      echo "<input size=\"40\" maxlength=\"65535\" name=\"" . 
bin2hex(md5($dec)) . "\"></td></tr>\n";
-    }
   }
   echo "</tr></table>";
-  echo "<input type=submit value=\"I hereby give all these translations into 
the Public Domain (commit)\">";
+  echo "<input type=submit value=\"" . 
+       TRANSLATE_("I hereby give all these translations into the Public Domain 
(commit)") . 
+       "\">";
   echo "</form>";
-  
- }
+}
 if ($end < $num) {
   P();
   echo "<a href=\"" . $i18nHTMLbase . "editor.php?xlang=" . $lang . "&start=" 
. ($end + 1) . "\">";
@@ -117,10 +112,10 @@
   echo "</a>";
   if ($t == 1)
     translateLink($b);
- } else {
+} else {
   W("Statistics about translation progress can be found %s.\n",
     intlink_($i18nHTMLbase . "status.php", "here"));
- }
+}
 P();
 H2("Remarks");
 H3("The percent sign");

Modified: GNUnet-docs/WWW/gnu.org/i18nhtml.inc
===================================================================
--- GNUnet-docs/WWW/gnu.org/i18nhtml.inc        2005-04-11 06:23:40 UTC (rev 
638)
+++ GNUnet-docs/WWW/gnu.org/i18nhtml.inc        2005-04-11 06:25:43 UTC (rev 
639)
@@ -17,7 +17,6 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-
   // This file defines the functions that will be used
   // to build the webpage.  The set may not contain everything
   // you might want, so feel free to define your own extensions.
@@ -35,13 +34,13 @@
   // Most of the code should be straight forward. Look
   // at some of the example files that use it and compare with
   // the generated pages. 
-
-
 // obtain user db specific configuration parameters
 include("i18nhtml_config.inc");
-
 header("Content-type: text/html; charset=utf-8");
 
+if (get_magic_quotes_gpc())
+  die('PHP misconfigured.  Disable get_magic_quotes.');
+
 // establish default connection to database server
 $connection = @mysql_connect($i18nHTMLsqlServer,
                             $i18nHTMLsqlUser,
@@ -57,24 +56,24 @@
   if (!$db_selected) {
      die ('Error selecting db : ' . mysql_error());
   }
- }
+}
 
 // ensure the mapping and pending tables exist, creating them if not
 $query="CREATE TABLE IF NOT EXISTS map" .
        " (name BLOB, lang TINYBLOB, translation BLOB, ranking INT, ip 
TINYTEXT, " .
        "INDEX(name(10)), INDEX(lang(4)), INDEX(ranking), 
INDEX(translation(10)))";
 $result = mysql_query($query, $connection);
-//if (!$result) {
-//   die('Unable to validate mapping table.  Invalid query: ' . mysql_error());
-//}
+if (($i18nHTMLdebug == 1) && (!$result)) {
+  die('Unable to validate map table.  Invalid query: ' . mysql_error());
+}
 
 $query="CREATE TABLE IF NOT EXISTS pending" .
        " (c BLOB, lang TINYBLOB, count INT, " .
        "INDEX(c(10)), INDEX(lang(4)), INDEX(count))";
 $result = mysql_query($query, $connection);
-//if (!$result) {
-//   die('Unable to validate pending table.  Invalid query: ' . mysql_error());
-//}
+if (($i18nHTMLdebug == 1) && (!$result)) {
+  die('Unable to validate pending table.  Invalid query: ' . mysql_error());
+}
 
 /* mapping of real-names to language codes */
 $languagecodes = array("English"=>"en",
@@ -102,7 +101,7 @@
                       "Swedish"=>"sv");
 
 /* try to automagically figure out user preferences */
-$hlang=$_SERVER["HTTP_ACCEPT_LANGUAGE"];
+$hlang = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
 if ($hlang) {
   $tok = strtok($hlang, ";");
   while ($tok) {
@@ -114,7 +113,7 @@
     }
     $tok = strtok(";");
   }
- }
+}
 // If no language is specified, use english.
 if ( (! $lang) || ($lang=="") )
   $lang = "English";
@@ -124,21 +123,23 @@
 $lang = ucfirst(strtolower($lang));
 $lang = mysql_real_escape_string($lang);
 $editor = $_REQUEST['editor'];
+$i18nHTMLhasTranslation = 0; // set by last call to translation_query()
 
-
-$htmlin  = array("&rsquo;", "&gt;", "&quot;", "&prime;", "&amp;");
-$htmlout = array("&#8217;" , "&#62;", "&#34;" , "&#8242" , "&#38;");
-
 /**
  * Replace certain HTML named special characters with their
  * numeric codes (some browsers don't work with the symbolic names).
  */
+$htmlin  = array("&rsquo;", "&gt;",  "&quot;", "&prime;", "&amp;", "\"",    
"'",      "`",       "&lsquo;");
+$htmlout = array("&#8217;", "&#62;", "&#34;" , "&#8242;", "&#38;", "&#34;", 
"&#8242;", "&#8217;", "&#8216;");
 function fix($a) {
   global $htmlin;
   global $htmlout;
   return str_replace($htmlin, $htmlout, $a);
 }
 
+// *************************************************
+// i18nHTML configuration API functions 
+// *************************************************
 
 // change the marker text shown to indicate text
 // is translatable (link to translate page text)
@@ -151,46 +152,18 @@
     $i18nHTMLmarker = $marker;
 }
 
+// ***************************************************
+// i18nHTML _internal_ API functions (don't look here)
+// ***************************************************
 
-// editor = ?         ;      // set by URL parameter, indicates in translation 
mode
-$i18nHTMLhasTranslation = 0; // set by last call to isTranslated() or 
translation_query()
-$i18nHTMLallowedits = 1;
-
-// indicate translate link should only be shown for untranslated items.
-function editOnlyUntranslatedText() {
-  global $i18nHTMLallowedits;
-  $i18nHTMLallowedits = 0;
-}
-
-// indicate translate link should always be shown (or set to indicated value).
-function editAllTranslations($v=null) {
-  global $i18nHTMLallowedits;
-  if ($v == "")
-    $i18nHTMLallowedits = 1;
-  else
-    $i18nHTMLallowedits = $v;
-}
-
-
-// displays a link to the page to enable one to
-// translate the given text ($a)
-// see translateLink_
-function translateLink($a, $hasTranslation=null) {
-  echo translateLink_($a, $hasTranslation);
-}
-
-// returns a HTML string to link to enable one to
-// translate the given text ($a) when
-// $editor has a nonzero value and either
-// $hasTranslation is 0 or $allowedits is nonzero;
-// otherwise and empty string ("") is returned.
-// $hasTranslation may be omitted to use result of
-// last isTranslated() or translation_query() call;
-function translateLink_($a, $hasTranslation=null) {
+// returns a HTML string to link to enable one to translate the given
+// text ($a) when $editor has a nonzero value or
+// $i18nHTMLhasTranslation is 0; otherwise and empty string ("") is
+// returned.
+function translateLink_($a) {
   global $lang;
   global $HTTP_SERVER_VARS;
   global $editor;
-  global $i18nHTMLallowedits;
   global $i18nHTMLhasTranslation;
   global $i18nHTMLmarker;
   global $i18nHTMLbase;
@@ -201,112 +174,21 @@
     $back = "http://"; . $HTTP_SERVER_VARS["HTTP_HOST"] . 
$HTTP_SERVER_VARS["REQUEST_URI"];
     return "<a href=\"" . $i18nHTMLbase . "translate.php?xlang=" 
       . $lang 
-      . "&amp;text=" . urlencode($a)
+      . "&amp;text=" . urlencode(fix($a))
       . "&amp;back=" . urlencode($back) 
       . "\">" . $i18nHTMLmarker . "</a>\n";
   } else
     return "";   
 }
 
-// return 1 if translation is available (or DB down)
-// assumes passed the original text as appears in source
-function isTranslated($a, $charset=null) {
-  global $connection;
-  global $lang;
-  global $editor;
-  global $i18nHTMLhasTranslation;
-
-  $i18nHTMLhasTranslation = 1; // assume translation until failure
-
-  if ( ("English" == $lang) || (!$connection) ) {
-    // Either hard-wired source language (so available) or
-    // database not available.
-    return 1;
-  }
-
-  //  $a = htmlentities($a, ENT_QUOTES, $charset);
-  $u = urlencode($a);
-
-  $query = "SELECT translation FROM map WHERE name=\"$u\" AND lang=\"$lang\" 
ORDER BY ranking DESC";
-  $result = mysql_query($query, $connection);
-  if (!$result) {
-    if ($i18nHTMLdebug != 0)
-      echo 'Unable to execute query $query: ' . mysql_error();
-  }
-
-  $num = 0;
-  if ($result)
-    $num = mysql_numrows($result);
-  if ($num > 0)
-    return 1;
-  else {
-    $i18nHTMLhasTranslation = 0; // no translation was found
-    return 0;   
-  }
+// displays a link to the page to enable one to
+// translate the given text ($a)
+// see translateLink_
+function translateLink($a) {
+  echo translateLink_($a);
 }
 
-
 /**
- * restore UTF-8 from HTML Unicode entities
- *
- * This function is triggered by the YACS handler during page
- * rendering.  It is aiming to transcode HTML Unicode entities
- * (eg, &amp;#8364;) back to actual UTF-8 encoding (eg, �).
- *
- * @param string a string with a mix of UTF-8 and of HTML Unicode entities
- * @return an UTF-8 string
- */
-function from_unicode($text) {
-  // translate extended ISO8859-1 chars, if any
-  $text = utf8_encode($text);
-  
-  // translate Unicode entities
-  $areas = preg_split('/&#(\d+?);/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
-  $text = '';
-  $index = 0;
-  foreach($areas as $area) {
-    switch($index%2) {
-    case 0: // before entity
-      $text .= $area;
-      break;
-    case 1: // the entity itself
-      
-      // get the integer value
-      $unicode = intval($area);
-      
-      // one byte
-      if($unicode < 0x80) {
-       
-       $text .= chr($unicode);
-       
-       // two bytes
-      } elseif($unicode < 0x800) {
-       
-       $text .= chr( 0xC0 +  ( ( $unicode - ( $unicode % 0x40 ) ) / 0x40 ) );
-       $text .= chr( 0x80 + ( $unicode % 0x40 ) );
-       
-       // three bytes
-      } elseif($unicode < 0x10000) {
-       
-       $text .= chr( 0xE0 + ( ( $unicode - ( $unicode % 0x1000 ) ) / 0x1000 ) 
);
-       $text .= chr( 0x80 + ( ( ( $unicode % 0x1000 ) - ( $unicode % 0x40 ) ) 
/ 0x40 ) );
-       $text .= chr( 0x80 + ( $unicode % 0x40 ) );
-       
-       // more bytes, keep it as it is...
-      } else
-         $text .= '&#'.$unicode.';';
-      
-      break;
-    }
-    $index++;
-  }
-  
-  // the updated string
-  return $text;
-}
-
-
-/**
  * transcode unicode entities to/from HTML entities
  *
  * Also, this function transforms HTML entities into their equivalent Unicode 
entities.
@@ -319,8 +201,7 @@
  * @param boolean TRUE to transcode to Unicode, FALSE to transcode to HTML
  * @return a transcoded string
  */
-function transcode($input, $to_unicode=TRUE) {
-  
+function transcode($input, $to_unicode=TRUE) { 
   // initialize tables only once
   static $html_entities, $unicode_entities;
   if(!is_array($html_entities)) {
@@ -583,8 +464,7 @@
       $unicode_entities[] = $unicode_entity;
       $html_entities[] = $html_entity;
     }
-  }
-  
+  }  
   // transcode HTML entities to Unicode
   if($to_unicode)
     return str_replace($html_entities, $unicode_entities, $input);
@@ -594,9 +474,6 @@
     return str_replace($unicode_entities, $html_entities, $input);
 }
 
-
-
-
 /**
  * transcode multi-byte characters to HTML representations for Unicode
  *
@@ -618,119 +495,79 @@
  * @param string the original UTF-8 string
  * @return a string acceptable in an ISO-8859-1 storage system (ie., PHP4 + 
MySQl 3)
  */
-function to_unicode($input) {
-  
+function to_unicode($input) { 
   // transcode HTML entities to Unicode entities
-  $input = transcode($input);
-  
+  $input = transcode($input);  
   // scan the whole string
   $output = '';
   $index = 0;
-  while($index < strlen($input)) {
-    
+  while($index < strlen($input)) {  
     // look at one char
-    $char = ord($input[$index]);
-    
+    $char = ord($input[$index]);    
     // one byte (0xxxxxxx)
-    if($char < 0x80) {
-      
+    if ($char < 0x80) {      
       // some chars may be undefined
       $output .= chr($char);
-      $index += 1;
-      
+      $index += 1;      
       // two bytes (110xxxxx 10xxxxxx)
-    } elseif($char < 0xE0) {
-      
+    } else if ($char < 0xE0) {      
       // strip weird sequences (eg, C0 80 -> NUL)
       if($value = (($char % 0x20) * 0x40) + (ord($input[$index + 1]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 2;
-      
+      $index += 2;      
       // three bytes (1110xxxx 10xxxxxx 10xxxxxx) example: euro sign = 
\xE2\x82\xAC -> &#8364;
-    } elseif($char < 0xF0) {
-      
+    } else if ($char < 0xF0) {      
       // strip weird sequences
       if($value = (($char % 0x10) * 0x1000) + ((ord($input[$index + 1]) % 
0x40) * 0x40) + (ord($input[$index + 2]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 3;
-      
+      $index += 3;      
       // four bytes (11110xxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } elseif($char < 0xF8) {
-      
+    } else if($char < 0xF8) {      
       // strip weird sequences
-      if($value = (($char % 0x08) * 0x40000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000) + ((ord($input[$index + 2]) % 0x40) * 0x40)
+      if ($value = (($char % 0x08) * 0x40000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000) + ((ord($input[$index + 2]) % 0x40) * 0x40)
         + (ord($input[$index + 3]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 4;
-      
+      $index += 4;      
       // five bytes (111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } elseif($char < 0xFC) {
-      
+    } else if($char < 0xFC) {      
       // strip weird sequences
-      if($value = (($char % 0x04) * 0x1000000) + ((ord($input[$index + 1]) % 
0x40) * 0x40000) + ((ord($input[$index + 2]) % 0x40) * 0x1000)
+      if ($value = (($char % 0x04) * 0x1000000) + ((ord($input[$index + 1]) % 
0x40) * 0x40000) + ((ord($input[$index + 2]) % 0x40) * 0x1000)
         + ((ord($input[$index + 3]) % 0x40) * 0x40) + (ord($input[$index + 4]) 
% 0x40))
        $output .= '&#' . $value . ';';
-      $index += 5;
-      
+      $index += 5;      
       // six bytes (1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } else {
-      
+    } else {      
       // strip weird sequences
-      if($value = (($char % 0x02) * 0x40000000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000000) + ((ord($input[$index + 2]) % 0x40) * 0x40000)
+      if ($value = (($char % 0x02) * 0x40000000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000000) + ((ord($input[$index + 2]) % 0x40) * 0x40000)
         + ((ord($input[$index + 3]) % 0x40) * 0x1000) + ((ord($input[$index + 
4]) % 0x40) * 0x40) + (ord($input[$index + 4]) % 0x40))
        $output .= '&#' . $value . ';';
       $index += 6;
-    }
-    
-  }
- 
+    }    
+  } 
   // return the translated string
   return $output;
 }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-// returns either the translated string
-// or the original string.  Assumes we
-// are passed the original string as occurs
-// in text; result will be html tokenized by
-// htmlentities() using default charset or
-// one indicated by $charset, to ensure all
-// required entities are converted for valid html output.
-// Note: it is assumed value in DB have already
-// ran through equivalent of htmlentities().
-// $i18nHTMLhasTranslation is set to nonzero value
-// if a translation is available or failure connecting
-// to database, otherwise it is set to 0.
-function translation_query($a, $charset=null) {
+// returns either the translated string or the original string.
+// Assumes we are passed the original string as occurs in text; result
+// will be html tokenized by htmlentities() using UTF8.
+// $i18nHTMLhasTranslation is set to nonzero value if a translation is
+// available or failure connecting to database, otherwise it is set to
+// 0.
+function translation_query($a) {
   global $connection;
   global $lang;
   global $i18nHTMLrecordMode;
   global $i18nHTMLhasTranslation;
   
   $i18nHTMLhasTranslation = 1; // assume translation until failure
-
   if ($a == "")
     return $a;
-
-  $u = mysql_real_escape_string(urlencode($a));
-  
+  $a = fix($a);
+  $a_sql = mysql_real_escape_string($a);
   if (!$connection) {
     // database not available, just print English
-    return fix($a);
+    return $a;
   }
   if ("English" == $lang) {
     // no need to translate english, that's the
@@ -738,20 +575,20 @@
     if ($i18nHTMLrecordMode == 2) {
       // if not already in pending table (and recordMode set to allow us)
       // then insert this string into it
-      $query = "SELECT count FROM pending WHERE c=\"$u\" AND lang=\"$lang\"";
+      $query = "SELECT count FROM pending WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       $result = mysql_query($query, $connection);
       $num = 0;
       if ($result)
         $num = mysql_num_rows($result);
       if (0 == $num) {
-        $query = "INSERT INTO pending VALUES(\"$u\", \"$lang\", 0)";
+        $query = "INSERT INTO pending VALUES(\"$a_sql\", \"$lang\", 0)";
         mysql_query($query, $connection);
       }
     }
-    return fix($a);
+    return $a;
   }
   // attempt to get translations, ranked for best
-  $query = "SELECT translation FROM map WHERE name=\"$u\" AND lang=\"$lang\" 
ORDER BY ranking DESC";
+  $query = "SELECT translation FROM map WHERE name=\"$a_sql\" AND 
lang=\"$lang\" ORDER BY ranking DESC";
   $result = mysql_query($query, $connection);
   $num = 0;
   if ($result)
@@ -761,7 +598,7 @@
       // either insert untranslated item into pending table or update
       // referenced count; count is used to display more used strings
       // during mass translation before less common ones.
-      $query = "SELECT count FROM pending WHERE c=\"$u\" AND lang=\"$lang\"";
+      $query = "SELECT count FROM pending WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       $result = mysql_query($query, $connection);
       $num = 0;
       if ($result)
@@ -770,20 +607,24 @@
       if ($num > 0) {
         $row = mysql_fetch_array($result);
         $count = $row["count"] + 1;
-        $query = "UPDATE pending SET count=$count WHERE c=\"$u\" AND 
lang=\"$lang\"";
+        $query = "UPDATE pending SET count=$count WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       } else {
-        $query = "INSERT INTO pending VALUES(\"$u\", \"$lang\", 1)";
+        $query = "INSERT INTO pending VALUES(\"$a_sql\", \"$lang\", 1)";
       }
       mysql_query($query, $connection);       
     }
     $i18nHTMLhasTranslation = 0; // no translation was found
-    return fix($a);              // just return English string
+    return $a;              // just return English string
   } else { // translation available
     $row = mysql_fetch_array($result);
     return $row["translation"];
   }
 }
 
+// *************************************************
+// Fundamental i18nHTML API functions 
+// *************************************************
+
 // translate the sentence $a and return the result.
 function TRANSLATE_($a,$args=null) {
   if ($a == "")
@@ -791,6 +632,12 @@
   return vsprintf(translation_query($a), $args);
 }
 
+// translate the sentence $a and output just
+// the translated text (without link to translate.php)
+function TRANSLATE($a,$args=null) {
+  echo TRANSLATE_($a);
+}
+
 // translate the sentence $a adding a link
 // to enable editing translations and return the result.
 function W_($a,$args=null) {
@@ -799,81 +646,16 @@
   return TRANSLATE_($a,$args) . translateLink_($a);
 }
 
-// translate the sentence $a and output just
-// the translated text
-function TRANSLATE($a,$args=null) {
-  echo TRANSLATE_($a);
-}
-
 // translate the sentence $a appending a link
 // to enable edit the translation and output the
-// result. Returns 1 if a translation is needed.
+// result.
 function W($a, $args=NULL) {
-  global $i18nHTMLhasTranslation;
-
-  if ($a == "")
-    return 0;
-  echo W_($a, $args) . "\n";
-  return $i18nHTMLhasTranslation;
+  if ($a != "")
+    echo W_($a, $args) . "\n";
 }
 
-function LI($a,$b="") {
-  echo "<li>" . W_($a,$b) . "</li>\n";
-}
-
-function TITLE($a,$b="") {
-  global $lang;
-  global $languagecodes;
-  echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" 
>";
-  echo "<title>" . TRANSLATE_($a,$b) . "</title>\n";
-  if (isset($languagecodes[$lang])) {
-    echo "<meta name=\"content-language\" content=\"" . 
-         $languagecodes[$lang] . "\">";
-    echo "<meta name=\"language\" content=\"" . 
-         $languagecodes[$lang] . "\">";
-  }
-}
-
-
-function DT($a,$b="") {
-  echo "<dt>" . W_($a,$b) . "</dt>\n";
-}
-function DD($a,$b="") {
-  echo "<dd>" . W_($a,$b) . "</dd>\n";
-}
-function H1($a,$b="") {
-  echo "<h1>" . W_($a,$b) . "</h1>\n";
-}
-function H2($a,$b="") {
-  echo "<h2>" . W_($a,$b) . "</h2>\n";
-}
-function H3($a,$b="") {
-  echo "<h3>" . W_($a,$b) . "</h3>\n";
-}
-function H4($a,$b="") {
-  echo "<h4>" . W_($a,$b) . "</h4>\n";
-}
-function H5($a,$b="") {
-  echo "<h5>" . W_($a,$b) . "</h5>\n";
-}
-// 'verbatim' (untranslated) "pre"
-function PRE($a) {
-  echo "<pre>" . $a . "</pre>";
-}
-// 'verbatim' (untranslated) "li"
-function LIV($a) {
-  echo "<li>" . $a . "</li>\n";
-}
-
-
 // create internationalized, internal link to
 // $a.php with description $b 
-function intlink($a, $b) {  
-  echo intlink_($a, $b);
-}
-
-// create internationalized, internal link to
-// $a.php with description $b 
 function intlink_($a, $b) {  
   global $lang;
   
@@ -882,10 +664,10 @@
   return $ret;
 }
 
-// create internationalized, external link to
-// $a with description $b 
-function extlink($a, $b) {  
-  echo extlink_($a, $b);
+// create internationalized, internal link to
+// $a.php with description $b 
+function intlink($a, $b) {  
+  echo intlink_($a, $b);
 }
 
 // create internationalized, external link to
@@ -895,46 +677,17 @@
   return $ret;
 }
 
-function P($attr="") {
-  echo "<p $attr>\n";
+// create internationalized, external link to
+// $a with description $b 
+function extlink($a, $b) {  
+  echo extlink_($a, $b);
 }
 
-function BR() {
-  echo "<br />\n";
-}
 
-function HR() {
-  echo "<hr>\n";
-}
-function DTDD($a,$b) {
-  DT($a);
-  DD($b);
-}
-function LILI($a,$b) {
-  echo "<li><a href=\"$a\">" . translateLink_($b) . "</li>";
-}
-function IMG($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
-  echo IMG_($src, $alt, $align, $width, $height, $border, $hspace, $vspace);
-}
+// *************************************************
+// global, call-once helper functions
+// *************************************************
 
-function IMG_($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
-  $ret = "";
-  
-  if ($align == "CENTER") 
-    $ret = $ret . "<p><center>\n";
-  $ret = $ret . "<img src=\"" . $src . "\" alt=\"";
-  $ret = $ret . TRANSLATE_($alt);
-  $ret = $ret . "\" align=\"" . $align . "\" width=$width height=$height 
border=$border hspace=$hspace vspace=$vspace>\n";
-  $ret = $ret . translateLink_($alt);
-  if ($align == "CENTER") 
-    $ret = $ret . "</center><p>\n";
-  return $ret;
-}
-
-function ANCHOR($a) {
-  echo "<a name=\"$a\"></a>";
-}
-
 // outputs appropriate DOCTYPE declaration for the document
 // this should be the 1st line in your php file after including
 // i18nhtml.inc.  Valid types are: HTML for HTML 4 documents,
@@ -944,62 +697,68 @@
 // "Strict", or "Frameset", defaulting to "Transitional".
 // Note for XHTML1.1 $mode is ignored.
 // example:  
-//           -?php 
-//           include("../src/i18nhtml.inc");
+//           include("i18nhtml.inc");
 //           DOCTYPE("XHTML1");
-//           echo "<head><title>Blah</title><body>Blah...</body></html>";
-//           ?-
 function DOCTYPE($type=null, $mode=null) {
   // depending on $mode, use appropriate dtd
   if ($mode == "Strict") {
     $dtd = "strict";
     if ($type != "XHTML1") // Strict not specified except for XHTML1.0
       $mode = "";
-  }
-  elseif ($mode == "Frameset") {
+  } else if ($mode == "Frameset") {
     $dtd = "frameset";
-  }
-  else { // $mode == Transitional, default, or unknown
+  } else { // $mode == Transitional, default, or unknown
     $dtd = "loose";
     $mode = "Transitional";
   }
-
   if ($type == "XHTML1")
     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 " . $mode . "//EN\" 
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-"; . $dtd . ".dtd\">\n";
-  elseif ($type == "XHTML1.1")
+  else if ($type == "XHTML1.1")
     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" 
\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\";>\n";
   else
     echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " . $mode . "//EN\" 
\"http://www.w3.org/TR/html4/"; . $dtd . ".dtd\">\n";
 }
 
+function TITLE($a,$b="") {
+  global $lang;
+  global $languagecodes;
+  echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" 
>";
+  echo "<title>" . TRANSLATE_($a,$b) . "</title>\n";
+  if (isset($languagecodes[$lang])) {
+    echo "<meta name=\"content-language\" content=\"" . 
+         $languagecodes[$lang] . "\">";
+    echo "<meta name=\"language\" content=\"" . 
+         $languagecodes[$lang] . "\">";
+  }
+}
 
 // displays a list of all languages currently available with
 // at least 1 translated string.
 function generateLanguageBar() {
   global $connection;
 
-if ($connection) {
-  echo "<center>[";
-  $query = "SELECT DISTINCT lang FROM map ORDER BY lang";
-  $result = mysql_query($query, $connection);
-  $num = 0;
-  if ($result)   
-    $num = mysql_numrows($result);
-  echo "<a href=\"?xlang=English\">";
-  W("English");
-  echo "</a>";
-  $last = "English";
-  for ($i=0;$i<$num;$i++) {
-    $row = mysql_fetch_array($result);
-    $next = $row["lang"];
-    if ($next == $last)
-      continue;
-    echo " | ";
-    echo "<a href=\"?xlang=$next\">" . W_($next) . "</a>";
-    $last = $next;
+  if ($connection) {
+    echo "<center>[";
+    $query = "SELECT DISTINCT lang FROM map ORDER BY lang";
+    $result = mysql_query($query, $connection);
+    $num = 0;
+    if ($result)   
+      $num = mysql_numrows($result);
+    echo "<a href=\"?xlang=English\">";
+    W("English");
+    echo "</a>";
+    $last = "English";
+    for ($i=0;$i<$num;$i++) {
+      $row = mysql_fetch_array($result);
+      $next = $row["lang"];
+      if ($next == $last)
+        continue;
+      echo " | ";
+      echo "<a href=\"?xlang=$next\">" . W_($next) . "</a>";
+      $last = $next;
+    }
+    echo "]</center>";
   }
-  echo "]</center>";
- }
 }
 
 
@@ -1009,24 +768,97 @@
 function generateFooter() {
   global $xlang;
   global $editor;
-  global $back;
   global $HTTP_SERVER_VARS;
 
   P();
   echo "Translation engine based on <a 
href=\"http://gnunet.org/i18nHTML/\";>i18nHTML</a> (C) 2003, 2004, 2005 
Christian Grothoff.<br />\n";
   if ( ($xlang) && ($xlang != "English") ) {
     $back = "http://"; . $HTTP_SERVER_VARS["HTTP_HOST"] . 
$HTTP_SERVER_VARS["REQUEST_URI"];
-    // echo "<span align=\"center\"><small>";
     echo "<center><small>\n";
     if ($editor != 1)
       echo " <a href=\"$back&amp;editor=1\">" . W_("enter translation mode") . 
"</a>";
     else
       W(" Translation Mode Active (for this page only)");
-    //echo "</small></span>";
     echo "</small></center>\n";
   }
   echo "</p>\n";
 }
 
-   
-?>
+// *************************************************
+// HTML construct helper functions
+// *************************************************
+
+function LI($a,$b="") {
+  echo "<li>" . W_($a,$b) . "</li>\n";
+}
+function TH($a,$b="") {
+  echo "<th>" . W_($a,$b) . "</th>\n";
+}
+function TD($a,$b="") {
+  echo "<td>" . W_($a,$b) . "</td>\n";
+}
+function DT($a,$b="") {
+  echo "<dt>" . W_($a,$b) . "</dt>\n";
+}
+function DD($a,$b="") {
+  echo "<dd>" . W_($a,$b) . "</dd>\n";
+}
+function H1($a,$b="") {
+  echo "<h1>" . W_($a,$b) . "</h1>\n";
+}
+function H2($a,$b="") {
+  echo "<h2>" . W_($a,$b) . "</h2>\n";
+}
+function H3($a,$b="") {
+  echo "<h3>" . W_($a,$b) . "</h3>\n";
+}
+function H4($a,$b="") {
+  echo "<h4>" . W_($a,$b) . "</h4>\n";
+}
+function H5($a,$b="") {
+  echo "<h5>" . W_($a,$b) . "</h5>\n";
+}
+function PRE($a) {
+  echo "<pre>" . $a . "</pre>";
+}
+// 'verbatim' (untranslated) "li"
+function LIV($a) {
+  echo "<li>" . $a . "</li>\n";
+}
+function P($attr="") {
+  echo "<p $attr>\n";
+}
+function BR() {
+  echo "<br />\n";
+}
+function HR() {
+  echo "<hr>\n";
+}
+function DTDD($a,$b) {
+  DT($a);
+  DD($b);
+}
+function LILI($a,$b) {
+  echo "<li>" . extlink_($a,$b) . "</li>\n";
+}
+function ANCHOR($a) {
+  echo "<a name=\"$a\"></a>\n";
+}
+function IMG_($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
+  $ret = "";
+  
+  if ($align == "CENTER") 
+    $ret = $ret . "<p><center>\n";
+  $ret = $ret . "<img src=\"" . $src . "\" alt=\"";
+  $ret = $ret . TRANSLATE_($alt);
+  $ret = $ret . "\" align=\"" . $align . "\" width=$width height=$height 
border=$border hspace=$hspace vspace=$vspace>\n";
+  $ret = $ret . translateLink_($alt);
+  if ($align == "CENTER") 
+    $ret = $ret . "</center><p>\n";
+  return $ret;
+}
+function IMG($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
+  echo IMG_($src, $alt, $align, $width, $height, $border, $hspace, $vspace);
+}
+
+?>
\ No newline at end of file

Modified: GNUnet-docs/WWW/gnu.org/i18nhtml_config.inc
===================================================================
--- GNUnet-docs/WWW/gnu.org/i18nhtml_config.inc 2005-04-11 06:23:40 UTC (rev 
638)
+++ GNUnet-docs/WWW/gnu.org/i18nhtml_config.inc 2005-04-11 06:25:43 UTC (rev 
639)
@@ -29,11 +29,7 @@
 
 $i18nHTMLsqlDB = "translations"; // default is "translation"
 $i18nHTMLbase = "";  // base directory prepended to i18nHTML php pages used in 
links
+$i18nHTMLmarker = "*";  // default value if never changed
 
-if ($_REQUEST['edit'] == "off")
-  $i18nHTMLmarker = "";
-else
- $i18nHTMLmarker = "*";  // default value if never changed
 
-
 ?>

Modified: GNUnet-docs/WWW/gnu.org/index.php
===================================================================
--- GNUnet-docs/WWW/gnu.org/index.php   2005-04-11 06:23:40 UTC (rev 638)
+++ GNUnet-docs/WWW/gnu.org/index.php   2005-04-11 06:25:43 UTC (rev 639)
@@ -1,3 +1,199 @@
 <?php
-include("gnunet.php");
+include("i18nhtml.inc");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>\n";
+if ($title) {
+  echo "<title>";
+  TRANSLATE("Doodle: find information on your computer");
+  echo "</title>";
+ }
+if ($description) {
+  echo "<meta name=\"description\" content=\"";
+  TRANSLATE("A tool to index and search the files on your disk.");
+  echo "\">";
+ }
+echo "<meta name=\"content-language\" content=\"" . 
+     $languagecodes[$lang] . "\">";
+echo "<meta name=\"language\" content=\"" . 
+     $languagecodes[$lang] . "\">";
 ?>
+<meta name="author" content="Christian Grothoff">
+<meta name="keywords" 
content="doodle,desktop,search,suffix,tree,meta,data,libextractor,keywords,fam,index,database,free,Linux,GNU,GPL">
+<meta name="robots" content="index,follow">
+<meta name="revisit-after" content="28 days">
+<meta name="publisher" content="Christian Grothoff">
+<meta name="date" content="2004-12-31">
+<meta name="rights" content="(C) 2004 by Christian Grothoff>";
+<meta http-equiv="expires" content="43200">
+<meta http-equiv="content-type" content="text/html">
+</head>
+<body>
+<?php
+generateLanguageBar();
+
+H1("Doodle");
+ANCHOR("about");
+H2("About");
+
+W("Doodle is a tool to quickly search the documents on a computer.");
+W("Doodle builds an index using meta-data contained in the documents and 
allows fast searches on the resulting database.");
+W("Doodle uses %s to support obtaining meta-data from various file-formats.",
+  extlink_("/libextractor/","libextractor"));
+W("The database used by doodle is a %s, resulting in fast lookups.",
+  extlink_("http://www.nist.gov/dads/HTML/suffixtree.html","suffix tree"));
+W("Doodle supports approximate searches.");
+BR();
+W("Features that Doodle does not have at the moment include:");
+echo "<ul>";
+LI("A web interface");
+LI("Ordering of search results");
+LI("Spidering (indexing the Internet or websites)");
+echo "</ul>";
+W("If you need these features, have a look at the %s section.",
+  extlink_("#links", "links"));
+
+P();
+W("Doodle is licensed under the %s.",
+  extlink_("http://www.gnu.org/licenses/gpl.html","GNU GPL"));
+W("Indexing large volumes can take several hundred MBs of memory (depending on 
the amount of meta-data found).");
+W("Searching should nevertheless require almost no memory.");
+W("Using the latest version of libextractor is recommended.");
+W("Doodle has so far only been tested under %s and %s %s %s.",
+  ARRAY(extlink_("http://www.debian.org/";, "Debian"),
+        extlink_("http://www.redhat.com/";, "RedHat"),
+        extlink_("http://www.gnu.org/";, "GNU"),
+        extlink_("http://www.linux.org/";, "Linux")));
+W("Doodle is expected it to work under any platform supported by %s.",
+  extlink_("/libextractor/", "libextractor"));
+P();
+
+ANCHOR("download");
+H2("Download");
+W("You can find the current release %s.",
+  extlink_("download/doodle-0.6.2.tar.gz", "here"));
+W("Man-pages for %s, %s and %s are also on-line.",
+  ARRAY(extlink_("man/doodle.html", "doodle"),
+        extlink_("man/doodled.html", "doodled"),
+        extlink_("man/libdoodle", "libdoodle")));
+
+W("The latest version can be obtained using");
+PRE("$ svn checkout https://gnunet.org/svn/doodle/";);
+P();    
+W("If you want to be notified about updates, subscribe to %s",
+  extlink_("http://freshmeat.net/projects/doodle/";, "doodle on freshmeat"));
+P();
+W("Debian packages provided by Daniel Baumann can be found %s.",
+  extlink_("http://packages.debian.org/doodle";, "here"));
+W("RedHat/Fedora RPM packages provided by Dag Wieers can be found %s.",
+  extlink_("http://dag.wieers.com/packages/doodle/","here";));
+P();
+
+ANCHOR("using");
+H2("Using doodle");
+W("First the doodle database needs to be created.");
+W("The simplest way to create the database is to run doodle with the 
<tt>-b</tt> option on the directories that are to be indexed.");
+W("For example:");
+PRE("$ doodle -b $HOME");
+W("This will create the doodle database under <tt>~/.doodle</tt>.");
+BR();
+W("After creating the doodle database, you can search it.");
+W("For example:");
+PRE("$ doodle keyword");
+BR();
+H3("Keeping the database up-to-date");
+W("If you want to keep your doodle database up-to-date, you can either 
periodically re-run doodle with the <tt>-b</tt> option, or you can use doodled, 
the doodle daemon.");
+W("doodled uses %s to notice whenever a file is changed and instantly updates 
the doodle database.",
+  "fam");
+W("In order to use doodled, you must have famd running.");
+W("If famd is running, you can start doodled by passing the same arguments 
that you would pass to doodle to construct the database, but without the 
<tt>-b</tt> option:");
+PRE("$ doodled $HOME");
+W("You can also use doodled to construct the initial database.");
+W("While doodled is updating the database, any doodle search will block until 
the update is complete.");
+W("Note that while you may want to index your entire disk (i.e., <tt>doodle -b 
/</tt>), it is typically not a great idea to have doodled monitor your entire 
system for changes -- especially since <tt>/usr</tt> is unlikely to change 
frequently.");
+W("You can address this issue by first indexing <tt>/</tt> and then using 
doodled to monitor only directories that change frequently:");
+PRE("$ doodle -b /\n" .
+    "$ doodled $HOME");
+W("This way, your entire system will be in the index, and your home directory 
will be always up-to-date.");
+P();
+H3("Full-text search");
+W("You can achieve a (limited) form of full-text search with doodle.");
+W("For that, the dictionary-based plaintext extractors from %s are used.",
+  extlink_("/libextractor/","libextractor"));
+W("In order to use them, you need to pass the option <tt>-b LANG</tt> to 
doodle.");
+W("LANG is a two letter language code that selects the dictionary.");
+W("Available languages at the moment are en, es, fr, it and no.");
+W("Words and sentences that are available in the respective dictionaries for 
these languages will then be added to the index.");
+W("While libextractor attempts to avoid full-text extraction for certain kown 
binary formats, it may still find words in non-text files.");
+W("Running with this option will dramatically increase the size of the index 
and the time it takes to build the index.");
+W("Note that if you change the options used to build a database will not (!) 
result in doodle re-indexing files that were processed with other options 
previously.");
+W("The only way to force doodle to re-index files with different options is to 
either touch the files (change modification timestamp) or to delete the old 
database and start from scratch.");
+
+P();
+H3("Hints for system administrators");
+W("If you are the system administrator, you might want to run doodle on the 
entire system periodically (cron job) and have doodled monitor the home 
directories in the background.");
+W("In that case, it is suggested to have the doodle database be group-readable 
for a group doodle.");
+W("Set the permissions for the doodle binary to SGID to allow users to poll 
the database.");
+W("Doodle will ensure that information about files not accessible to the user 
are not leaked by checking if files found in the database are accessible to the 
user.");
+W("doodled has to run as root since otherwise it would be impossible to index 
the personal files of all users.");
+W("If that it too risky, doodled will still work, but only index the files 
readable to the user that runs doodled.");
+
+
+P();
+H3("Using different options for different directories");
+W("You can build a database from multiple doodle runs over distinct sets of 
files with different options.");
+W("For example, the following can make sense:");
+PRE("$ doodle -B en -b /usr/share/doc # full-text index over documentation\n" .
+    "$ doodle -b /usr /opt /bin /lib # normal index over other system files\n" 
.
+    "$ doodled -B en /home # monitor /home, with full-text support\n");
+W("A simple doodle search will then find files in all listed directories.");
+W("You can also build multiple disjoint databases and search all of them in 
one run (see %s for option <tt>-d</tt>).",
+  extlink_("man/doodle.html", "doodle"));
+
+P();
+ANCHOR("mantis");
+H2("Bugtrack");
+W("Doodle uses Mantis for bugtracking.");
+W("Visit %s to report bugs.",
+  extlink_("https://gnunet.org/mantis/","https://gnunet.org/mantis/";));
+W("You need to sign up for a reporter account.");
+W("Please make sure you report bugs under <strong>Doodle</strong> and not 
under any of the other projects.");
+P();
+W("If you dislike Mantis and need to report a bug contact %s via e-mail.",
+  extlink_("mailto:address@hidden","address@hidden";));
+
+
+ANCHOR("links");
+H2("Links");
+echo "<ul>";
+LILI("http://members.cox.net/sinzui/medusa/";, 
+     "Medusa, similar project for Gnome");
+LILI("http://swish-e.org/";, 
+     "Swish-e, indexing tool with focus on the WWW");
+LILI("http://www.gnome.org/~seth/storage/";,
+     "GNOME Storage");
+LILI("http://www.gnome.org/projects/beagle/";,
+     "Beagle");
+LILI("http://sourceforge.net/projects/rlocate/";,
+     "rlocate, version of locate that is always up-to-date");
+LILI("http://www.htdig.org/";,
+     "HTDig");
+LILI("http://jakarta.apache.org/lucene/";,
+     "Lucene");
+LILI("http://homepage.mac.com/pauljlucas/software/swish/";,
+     "Swish++");
+LILI("http://webglimpse.net/";,
+     "Glimpse");
+LILI("http://evidence.sf.net/";,
+     "Evidence, file-manager with support for doodle");
+LILI("http://www.linux-magazin.de/Artikel/ausgabe/2004/09/bgw/bgw.html";,
+     "Article about doodle (and other things) in the German Linux-Magazin");
+echo "</ul>";
+HR();
+echo "<address><a href=\"mailto:address@hidden";>Christian 
Grothoff</a></address>";
+PRE("Copyright (C) 2004 Christian Grothoff.\n" .
+    "Verbatim copying and distribution of this entire article\n" .
+    "is permitted in any medium, provided this notice is preserved.");
+BR();
+generateFooter();
+echo "</body></html>\n";
+?>

Modified: GNUnet-docs/WWW/gnu.org/status.php
===================================================================
--- GNUnet-docs/WWW/gnu.org/status.php  2005-04-11 06:23:40 UTC (rev 638)
+++ GNUnet-docs/WWW/gnu.org/status.php  2005-04-11 06:25:43 UTC (rev 639)
@@ -1,6 +1,6 @@
 <?php
 /*
-     (C) 2003, 2004 Christian Grothoff
+     (C) 2003, 2004, 2005 Christian Grothoff
 
      This code is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -27,7 +27,6 @@
   die();
  }
 $mode = $_REQUEST['mode'];
-
 DOCTYPE("HTML", "Transitional");
 echo "<html><head>\n";
 TITLE("Translation: status");
@@ -35,20 +34,6 @@
 W("Language setting is %s.",
   $lang);
 P();
-if ($mode == 1) {
-  H2("All available translations");
-  echo "<table border=5>\n";
-  echo "<tr><th>";
-  W("Original");
-  echo "</th><th>";
-  W("Language");
-  echo "</th><th>";
-  W("Translation");
-  echo "</th><th>";
-  W("Votes");
-  echo "</th></tr>\n";
- }
-
 $query = "SELECT count FROM pending WHERE lang=\"English\"";
 $result = mysql_query($query, $connection);
 $num = 0;
@@ -57,7 +42,16 @@
 W("Sentences in the original English text: %s",
   $num);
 P();
-
+if ($mode == 1) {
+  H2("All available translations");
+  echo "<table border=5>\n";
+  echo "<tr>";
+  TH("Original");
+  TH("Language");
+  TH("Translation");
+  TH("Votes");
+  echo "</tr>\n";
+}
 $stats = ARRAY();
 $query = "SELECT name,ranking,translation,lang FROM map";
 $result = mysql_query($query, $connection);
@@ -66,29 +60,33 @@
   $num = mysql_numrows($result);
 for ($i=0;$i<$num;$i++) {
   $row = mysql_fetch_array($result);
-  $text = urldecode($row["name"]);
+  $text = stripslashes($row["name"]);
+  $translation = stripslashes($row["translation"]);
   $ranking = $row["ranking"];
   $stats[$row["lang"]]++;
-  if ($mode == 1)
-    printf("<tr><td>%s</td><td>%s</td><td><a 
href=\"vote.php3?lang=%s&text=%s&translation=%s\">%s</a></td><td>%s</td></tr>\n",
-          urldecode($text),
-          $row["lang"],
-          $row["lang"],
+  if ($mode == 1) {
+    printf("<tr><td>%s</td><td>%s</td><td><a href=\"vote.php3?" .
+           "lang=%s&text=%s&translation=%s\">%s</a></td><td>%s</td></tr>\n",
           $text,
-          $row["translation"],
-          urldecode($row["translation"]),
+          $row["lang"],
+          urlencode($row["lang"]),
+          urlencode($text),
+          urlencode($translation),
+          $translation,
           $ranking);
- }
-if ($mode == 1)
-  echo "</table><p><hr><p>\n";
-
-echo "$num ";
-W("translations in database.");
-echo "<p>\n";
+  }
+}
+if ($mode == 1) {
+  echo "</table>";
+  P();
+  HR(); 
+  P();
+}
+W("%s translated sentences in database.", $num);
+P();
 foreach ($stats as $a => $b) {
-  echo "$b ";
-  W("in ");
-  echo "$a<br>";
+  W("%s translations available in %s.", $b, $a);
+  BR();
 }
 generateFooter();
 echo "</body></html>";

Modified: GNUnet-docs/WWW/gnu.org/translate.php
===================================================================
--- GNUnet-docs/WWW/gnu.org/translate.php       2005-04-11 06:23:40 UTC (rev 
638)
+++ GNUnet-docs/WWW/gnu.org/translate.php       2005-04-11 06:25:43 UTC (rev 
639)
@@ -1,6 +1,6 @@
 <?php
 /*
-     (C) 2003, 2004 Christian Grothoff
+     (C) 2003, 2004, 2005 Christian Grothoff
 
      This code is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -22,9 +22,10 @@
   echo "Database is down. Cannot edit translations.";
   die();
 }
-$text = $_REQUEST['text'];
+$text     = fix($_REQUEST['text']);
+$text_sql = mysql_real_escape_string($text);
+$text_url = urlencode($text);
 $back = $_REQUEST['back'];
-
 DOCTYPE("HTML", "Transitional");
 echo "<html><head>\n";
 TITLE("WWW translation");
@@ -37,66 +38,43 @@
   die();
  } 
 H2("Original Text");
-// if (get_magic_quotes_gpc()) $text = stripslashes($text);
 echo $text;
 H2("Translation");
 W("Destination language: ");
 W($lang);
 P();
 echo "<form method=\"POST\" action=\"" . $i18nHTMLbase . 
"commitTranslation.php\">\n";
-echo "<input type=hidden name=\"text\" value=\"" . urlencode($text) . "\">\n";
+echo "<input type=hidden name=\"text\" value=\"$text_url\">\n";
 echo "<input type=hidden name=\"xlang\" value=\"$xlang\">\n";
 echo "<input type=hidden name=\"back\" value=\"$back\">\n";
-/* 
-P();
-W("Character set:");
-<select size="1" name="charset">
-  <option value="UTF-8">Unicode UTF-8 encoding</option>
-  <option selected value="ISO-8859-1">ISO-8859-1 Western European, 
Latin-1</option>
-  <option value="ISO-8859-15">ISO-8859-15 Extended Western European</option>
-  <option value="cp1252">cp1252 Windows Western Europen</option>
-  <option value="cp866">cp866 DOS Cyrillic</option>
-  <option value="cp1251">cp1251 Windows Cyrillic</option>
-  <option value="KOI8-R">koi8-ru Russian</option>
-  <option value="BIG5">BIG5 Traditional Chinese</option>
-  <option value="GB2312">GB2312 Simplified Chinese</option>
-  <option value="Shift-JIS">Shift-JIS Japanese</option>
-  <option value="EUC-JP">EUC-JP Japanese</option>
-</select><br> */
 W("Translated text:");
-?>
-<input size="80" maxlength="65535" name="translation">
-<input type=submit value="I hereby give this translation into the Public 
Domain (commit)">
-</form>
-<?php
+echo "<input size=\"80\" maxlength=\"65535\" name=\"translation\">\n";
+echo "<input type=submit value=\"" . 
+     TRANSLATE_("I hereby give this translation into the Public Domain 
(commit)") . 
+     "\">\n";
+echo "</form>\n";
 P();
 
 H2("All available translations");
-?>
-<table border=5 width=95%>
-<tr><th><?php W("Language"); ?></th><th><?php W("Translation"); ?></th></tr>
-<?php
- $u = urlencode($text);
- $query = "SELECT translation,lang FROM map WHERE name=\"$u\" ORDER BY ranking 
DESC";
- $result = mysql_query($query, $connection);
- $num = 0;
- if ($result) 
-   $num = mysql_num_rows($result);
- for ($i=0;$i<$num;$i++) {
-   $row = mysql_fetch_array($result);
-
-   // we assume strings escaped before adding to DB
-   $translation = stripslashes($row["translation"]);
-
-   printf("<tr><td>%s</td><td><a href=\"" . $i18nHTMLbase . 
"vote.php?xlang=%s&text=%s&translation=%s\">%s</a></td></tr>\n",
-          W_($row["lang"]),
-          urlencode($row["lang"]),
-         $u,
-         urlencode(from_unicode($translation)),
-         fix(from_unicode($translation)));
- }
+echo "<table border=5 width=95%>\n";
+echo "<tr><th>" . W_("Language") . "</th><th>" . W_("Translation") . 
"</th></tr>\n";
+$query = "SELECT translation,lang FROM map WHERE name=\"$text_sql\" ORDER BY 
ranking DESC";
+$result = mysql_query($query, $connection);
+$num = 0;
+if ($result) 
+  $num = mysql_num_rows($result);
+for ($i=0;$i<$num;$i++) {
+  $row = mysql_fetch_array($result);
+  $translation = $row["translation"];
+  printf("<tr><td>%s</td><td><a href=\"" . $i18nHTMLbase . 
+         "vote.php?xlang=%s&text=%s&translation=%s\">%s</a></td></tr>\n",
+         W_($row["lang"]),
+         urlencode($row["lang"]),
+         urlencode($text_url),  // yes, we need urlencode twice!
+         urlencode(urlencode($translation)), // yes, we need urlencode twice!
+         fix($translation));
+}
 echo "</table>";
-
 H2("Remarks");
 H3("The percent sign");
 W("The %% sign is a special character.");
@@ -104,19 +82,15 @@
 W("The sequence %%s is used as a placeholder for links.");
 W("Currently, the translation can only access the links in the same order as 
the original text.");
 P();
-
 H3("Language specific special characters");
 W("Various languages use special characters.");
 W("The code has not been tested with certain character sets, such as 
Chinese.");
 W("If you are trying to translate the page to such a language, please contact 
the developerws if you encounter any problems.");
 P();
-
 H3("Copyright");
 W("The original english text is released under the GNU Free Documentation 
License (FDL).");
 W("Translations submitted to the webpage must be released to the public domain 
to ensure that we will not have any legal trouble.");
 W("If you have concerns or remarks regarding this policy, feel free to bring 
them to our attention.");
-
 generateFooter();
 echo "</body></html>";
-
 ?>

Modified: GNUnet-docs/WWW/gnu.org/vote.php
===================================================================
--- GNUnet-docs/WWW/gnu.org/vote.php    2005-04-11 06:23:40 UTC (rev 638)
+++ GNUnet-docs/WWW/gnu.org/vote.php    2005-04-11 06:25:43 UTC (rev 639)
@@ -17,26 +17,25 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-  // This file records votes from users for translations.
-  // For sentences with multiple translations, the one with the most
-  // votes is displayed.
+// This file records votes from users for translations.
+// For sentences with multiple translations, the one with the most
+// votes is displayed.
 include("i18nhtml.inc");
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
-echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" >";
 TITLE("WWW translation: vote");
 echo "</head><body>";
 if (!$connection) {
   echo "Database is down. Cannot edit translations.";
   die();
  } 
-$text = $_REQUEST['text'];
-$translation = $_REQUEST['translation'];
-$u = mysql_real_escape_string($text);
-$t = mysql_real_escape_string(to_unicode($translation));
-echo "text = " . $text . "<br>\n";
-echo "translation = " . $translation . "<br>\n";
+$text            = fix(urldecode($_REQUEST['text']));
+$translation     = fix(urldecode($_REQUEST['translation']));
+$text_sql        = mysql_real_escape_string($text);
+$translation_sql = mysql_real_escape_string(to_unicode($translation));
 
-$query = "SELECT ranking FROM map WHERE name=\"$u\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+$query = "SELECT ranking FROM map WHERE " .
+         "name=\"$text_sql\" AND lang=\"$lang\" AND 
translation=\"$translation_sql\"";
 $result = mysql_query($query, $connection);
 $num = 0;
 if ($result) 
@@ -44,11 +43,13 @@
 if ($num > 0) {
   $row = mysql_fetch_array($result);
   $ranking = $row["ranking"] + 1;
-  $query = "UPDATE map SET ranking=\"$ranking\" WHERE name=\"$u\" AND 
lang=\"$lang\" AND translation=\"$t\"";
+  $query = "UPDATE map SET ranking=\"$ranking\" WHERE " .
+           "name=\"$text_sql\" AND lang=\"$lang\" AND 
translation=\"$translation_sql\"";
   mysql_query($query, $connection);
   W("Ranking of translation is now: ");
   echo "$ranking";
- } else {
-  W("Translation does not exist (bug?).");
- }
+} else {
+  W("Translation '%s' of '%s' does not exist (bug?).",
+    ARRAY($translation, $text));
+}
 ?>

Modified: GNUnet-docs/WWW/i18nhtml.inc
===================================================================
--- GNUnet-docs/WWW/i18nhtml.inc        2005-04-11 06:23:40 UTC (rev 638)
+++ GNUnet-docs/WWW/i18nhtml.inc        2005-04-11 06:25:43 UTC (rev 639)
@@ -17,7 +17,6 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-
   // This file defines the functions that will be used
   // to build the webpage.  The set may not contain everything
   // you might want, so feel free to define your own extensions.
@@ -35,13 +34,13 @@
   // Most of the code should be straight forward. Look
   // at some of the example files that use it and compare with
   // the generated pages. 
-
-
 // obtain user db specific configuration parameters
 include("i18nhtml_config.inc");
-
 header("Content-type: text/html; charset=utf-8");
 
+if (get_magic_quotes_gpc())
+  die('PHP misconfigured.  Disable get_magic_quotes.');
+
 // establish default connection to database server
 $connection = @mysql_connect($i18nHTMLsqlServer,
                             $i18nHTMLsqlUser,
@@ -57,24 +56,24 @@
   if (!$db_selected) {
      die ('Error selecting db : ' . mysql_error());
   }
- }
+}
 
 // ensure the mapping and pending tables exist, creating them if not
 $query="CREATE TABLE IF NOT EXISTS map" .
        " (name BLOB, lang TINYBLOB, translation BLOB, ranking INT, ip 
TINYTEXT, " .
        "INDEX(name(10)), INDEX(lang(4)), INDEX(ranking), 
INDEX(translation(10)))";
 $result = mysql_query($query, $connection);
-//if (!$result) {
-//   die('Unable to validate mapping table.  Invalid query: ' . mysql_error());
-//}
+if (($i18nHTMLdebug == 1) && (!$result)) {
+  die('Unable to validate map table.  Invalid query: ' . mysql_error());
+}
 
 $query="CREATE TABLE IF NOT EXISTS pending" .
        " (c BLOB, lang TINYBLOB, count INT, " .
        "INDEX(c(10)), INDEX(lang(4)), INDEX(count))";
 $result = mysql_query($query, $connection);
-//if (!$result) {
-//   die('Unable to validate pending table.  Invalid query: ' . mysql_error());
-//}
+if (($i18nHTMLdebug == 1) && (!$result)) {
+  die('Unable to validate pending table.  Invalid query: ' . mysql_error());
+}
 
 /* mapping of real-names to language codes */
 $languagecodes = array("English"=>"en",
@@ -102,7 +101,7 @@
                       "Swedish"=>"sv");
 
 /* try to automagically figure out user preferences */
-$hlang=$_SERVER["HTTP_ACCEPT_LANGUAGE"];
+$hlang = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
 if ($hlang) {
   $tok = strtok($hlang, ";");
   while ($tok) {
@@ -114,7 +113,7 @@
     }
     $tok = strtok(";");
   }
- }
+}
 // If no language is specified, use english.
 if ( (! $lang) || ($lang=="") )
   $lang = "English";
@@ -124,21 +123,23 @@
 $lang = ucfirst(strtolower($lang));
 $lang = mysql_real_escape_string($lang);
 $editor = $_REQUEST['editor'];
+$i18nHTMLhasTranslation = 0; // set by last call to translation_query()
 
-
-$htmlin  = array("&rsquo;", "&gt;", "&quot;", "&prime;", "&amp;");
-$htmlout = array("&#8217;" , "&#62;", "&#34;" , "&#8242" , "&#38;");
-
 /**
  * Replace certain HTML named special characters with their
  * numeric codes (some browsers don't work with the symbolic names).
  */
+$htmlin  = array("&rsquo;", "&gt;",  "&quot;", "&prime;", "&amp;", "\"",    
"'",      "`",       "&lsquo;");
+$htmlout = array("&#8217;", "&#62;", "&#34;" , "&#8242;", "&#38;", "&#34;", 
"&#8242;", "&#8217;", "&#8216;");
 function fix($a) {
   global $htmlin;
   global $htmlout;
   return str_replace($htmlin, $htmlout, $a);
 }
 
+// *************************************************
+// i18nHTML configuration API functions 
+// *************************************************
 
 // change the marker text shown to indicate text
 // is translatable (link to translate page text)
@@ -151,46 +152,18 @@
     $i18nHTMLmarker = $marker;
 }
 
+// ***************************************************
+// i18nHTML _internal_ API functions (don't look here)
+// ***************************************************
 
-// editor = ?         ;      // set by URL parameter, indicates in translation 
mode
-$i18nHTMLhasTranslation = 0; // set by last call to isTranslated() or 
translation_query()
-$i18nHTMLallowedits = 1;
-
-// indicate translate link should only be shown for untranslated items.
-function editOnlyUntranslatedText() {
-  global $i18nHTMLallowedits;
-  $i18nHTMLallowedits = 0;
-}
-
-// indicate translate link should always be shown (or set to indicated value).
-function editAllTranslations($v=null) {
-  global $i18nHTMLallowedits;
-  if ($v == "")
-    $i18nHTMLallowedits = 1;
-  else
-    $i18nHTMLallowedits = $v;
-}
-
-
-// displays a link to the page to enable one to
-// translate the given text ($a)
-// see translateLink_
-function translateLink($a, $hasTranslation=null) {
-  echo translateLink_($a, $hasTranslation);
-}
-
-// returns a HTML string to link to enable one to
-// translate the given text ($a) when
-// $editor has a nonzero value and either
-// $hasTranslation is 0 or $allowedits is nonzero;
-// otherwise and empty string ("") is returned.
-// $hasTranslation may be omitted to use result of
-// last isTranslated() or translation_query() call;
-function translateLink_($a, $hasTranslation=null) {
+// returns a HTML string to link to enable one to translate the given
+// text ($a) when $editor has a nonzero value or
+// $i18nHTMLhasTranslation is 0; otherwise and empty string ("") is
+// returned.
+function translateLink_($a) {
   global $lang;
   global $HTTP_SERVER_VARS;
   global $editor;
-  global $i18nHTMLallowedits;
   global $i18nHTMLhasTranslation;
   global $i18nHTMLmarker;
   global $i18nHTMLbase;
@@ -201,112 +174,21 @@
     $back = "http://"; . $HTTP_SERVER_VARS["HTTP_HOST"] . 
$HTTP_SERVER_VARS["REQUEST_URI"];
     return "<a href=\"" . $i18nHTMLbase . "translate.php?xlang=" 
       . $lang 
-      . "&amp;text=" . urlencode($a)
+      . "&amp;text=" . urlencode(fix($a))
       . "&amp;back=" . urlencode($back) 
       . "\">" . $i18nHTMLmarker . "</a>\n";
   } else
     return "";   
 }
 
-// return 1 if translation is available (or DB down)
-// assumes passed the original text as appears in source
-function isTranslated($a, $charset=null) {
-  global $connection;
-  global $lang;
-  global $editor;
-  global $i18nHTMLhasTranslation;
-
-  $i18nHTMLhasTranslation = 1; // assume translation until failure
-
-  if ( ("English" == $lang) || (!$connection) ) {
-    // Either hard-wired source language (so available) or
-    // database not available.
-    return 1;
-  }
-
-  //  $a = htmlentities($a, ENT_QUOTES, $charset);
-  $u = urlencode($a);
-
-  $query = "SELECT translation FROM map WHERE name=\"$u\" AND lang=\"$lang\" 
ORDER BY ranking DESC";
-  $result = mysql_query($query, $connection);
-  if (!$result) {
-    if ($i18nHTMLdebug != 0)
-      echo 'Unable to execute query $query: ' . mysql_error();
-  }
-
-  $num = 0;
-  if ($result)
-    $num = mysql_numrows($result);
-  if ($num > 0)
-    return 1;
-  else {
-    $i18nHTMLhasTranslation = 0; // no translation was found
-    return 0;   
-  }
+// displays a link to the page to enable one to
+// translate the given text ($a)
+// see translateLink_
+function translateLink($a) {
+  echo translateLink_($a);
 }
 
-
 /**
- * restore UTF-8 from HTML Unicode entities
- *
- * This function is triggered by the YACS handler during page
- * rendering.  It is aiming to transcode HTML Unicode entities
- * (eg, &amp;#8364;) back to actual UTF-8 encoding (eg, �).
- *
- * @param string a string with a mix of UTF-8 and of HTML Unicode entities
- * @return an UTF-8 string
- */
-function from_unicode($text) {
-  // translate extended ISO8859-1 chars, if any
-  $text = utf8_encode($text);
-  
-  // translate Unicode entities
-  $areas = preg_split('/&#(\d+?);/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
-  $text = '';
-  $index = 0;
-  foreach($areas as $area) {
-    switch($index%2) {
-    case 0: // before entity
-      $text .= $area;
-      break;
-    case 1: // the entity itself
-      
-      // get the integer value
-      $unicode = intval($area);
-      
-      // one byte
-      if($unicode < 0x80) {
-       
-       $text .= chr($unicode);
-       
-       // two bytes
-      } elseif($unicode < 0x800) {
-       
-       $text .= chr( 0xC0 +  ( ( $unicode - ( $unicode % 0x40 ) ) / 0x40 ) );
-       $text .= chr( 0x80 + ( $unicode % 0x40 ) );
-       
-       // three bytes
-      } elseif($unicode < 0x10000) {
-       
-       $text .= chr( 0xE0 + ( ( $unicode - ( $unicode % 0x1000 ) ) / 0x1000 ) 
);
-       $text .= chr( 0x80 + ( ( ( $unicode % 0x1000 ) - ( $unicode % 0x40 ) ) 
/ 0x40 ) );
-       $text .= chr( 0x80 + ( $unicode % 0x40 ) );
-       
-       // more bytes, keep it as it is...
-      } else
-         $text .= '&#'.$unicode.';';
-      
-      break;
-    }
-    $index++;
-  }
-  
-  // the updated string
-  return $text;
-}
-
-
-/**
  * transcode unicode entities to/from HTML entities
  *
  * Also, this function transforms HTML entities into their equivalent Unicode 
entities.
@@ -319,8 +201,7 @@
  * @param boolean TRUE to transcode to Unicode, FALSE to transcode to HTML
  * @return a transcoded string
  */
-function transcode($input, $to_unicode=TRUE) {
-  
+function transcode($input, $to_unicode=TRUE) { 
   // initialize tables only once
   static $html_entities, $unicode_entities;
   if(!is_array($html_entities)) {
@@ -583,8 +464,7 @@
       $unicode_entities[] = $unicode_entity;
       $html_entities[] = $html_entity;
     }
-  }
-  
+  }  
   // transcode HTML entities to Unicode
   if($to_unicode)
     return str_replace($html_entities, $unicode_entities, $input);
@@ -594,9 +474,6 @@
     return str_replace($unicode_entities, $html_entities, $input);
 }
 
-
-
-
 /**
  * transcode multi-byte characters to HTML representations for Unicode
  *
@@ -618,119 +495,79 @@
  * @param string the original UTF-8 string
  * @return a string acceptable in an ISO-8859-1 storage system (ie., PHP4 + 
MySQl 3)
  */
-function to_unicode($input) {
-  
+function to_unicode($input) { 
   // transcode HTML entities to Unicode entities
-  $input = transcode($input);
-  
+  $input = transcode($input);  
   // scan the whole string
   $output = '';
   $index = 0;
-  while($index < strlen($input)) {
-    
+  while($index < strlen($input)) {  
     // look at one char
-    $char = ord($input[$index]);
-    
+    $char = ord($input[$index]);    
     // one byte (0xxxxxxx)
-    if($char < 0x80) {
-      
+    if ($char < 0x80) {      
       // some chars may be undefined
       $output .= chr($char);
-      $index += 1;
-      
+      $index += 1;      
       // two bytes (110xxxxx 10xxxxxx)
-    } elseif($char < 0xE0) {
-      
+    } else if ($char < 0xE0) {      
       // strip weird sequences (eg, C0 80 -> NUL)
       if($value = (($char % 0x20) * 0x40) + (ord($input[$index + 1]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 2;
-      
+      $index += 2;      
       // three bytes (1110xxxx 10xxxxxx 10xxxxxx) example: euro sign = 
\xE2\x82\xAC -> &#8364;
-    } elseif($char < 0xF0) {
-      
+    } else if ($char < 0xF0) {      
       // strip weird sequences
       if($value = (($char % 0x10) * 0x1000) + ((ord($input[$index + 1]) % 
0x40) * 0x40) + (ord($input[$index + 2]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 3;
-      
+      $index += 3;      
       // four bytes (11110xxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } elseif($char < 0xF8) {
-      
+    } else if($char < 0xF8) {      
       // strip weird sequences
-      if($value = (($char % 0x08) * 0x40000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000) + ((ord($input[$index + 2]) % 0x40) * 0x40)
+      if ($value = (($char % 0x08) * 0x40000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000) + ((ord($input[$index + 2]) % 0x40) * 0x40)
         + (ord($input[$index + 3]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 4;
-      
+      $index += 4;      
       // five bytes (111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } elseif($char < 0xFC) {
-      
+    } else if($char < 0xFC) {      
       // strip weird sequences
-      if($value = (($char % 0x04) * 0x1000000) + ((ord($input[$index + 1]) % 
0x40) * 0x40000) + ((ord($input[$index + 2]) % 0x40) * 0x1000)
+      if ($value = (($char % 0x04) * 0x1000000) + ((ord($input[$index + 1]) % 
0x40) * 0x40000) + ((ord($input[$index + 2]) % 0x40) * 0x1000)
         + ((ord($input[$index + 3]) % 0x40) * 0x40) + (ord($input[$index + 4]) 
% 0x40))
        $output .= '&#' . $value . ';';
-      $index += 5;
-      
+      $index += 5;      
       // six bytes (1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } else {
-      
+    } else {      
       // strip weird sequences
-      if($value = (($char % 0x02) * 0x40000000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000000) + ((ord($input[$index + 2]) % 0x40) * 0x40000)
+      if ($value = (($char % 0x02) * 0x40000000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000000) + ((ord($input[$index + 2]) % 0x40) * 0x40000)
         + ((ord($input[$index + 3]) % 0x40) * 0x1000) + ((ord($input[$index + 
4]) % 0x40) * 0x40) + (ord($input[$index + 4]) % 0x40))
        $output .= '&#' . $value . ';';
       $index += 6;
-    }
-    
-  }
- 
+    }    
+  } 
   // return the translated string
   return $output;
 }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-// returns either the translated string
-// or the original string.  Assumes we
-// are passed the original string as occurs
-// in text; result will be html tokenized by
-// htmlentities() using default charset or
-// one indicated by $charset, to ensure all
-// required entities are converted for valid html output.
-// Note: it is assumed value in DB have already
-// ran through equivalent of htmlentities().
-// $i18nHTMLhasTranslation is set to nonzero value
-// if a translation is available or failure connecting
-// to database, otherwise it is set to 0.
-function translation_query($a, $charset=null) {
+// returns either the translated string or the original string.
+// Assumes we are passed the original string as occurs in text; result
+// will be html tokenized by htmlentities() using UTF8.
+// $i18nHTMLhasTranslation is set to nonzero value if a translation is
+// available or failure connecting to database, otherwise it is set to
+// 0.
+function translation_query($a) {
   global $connection;
   global $lang;
   global $i18nHTMLrecordMode;
   global $i18nHTMLhasTranslation;
   
   $i18nHTMLhasTranslation = 1; // assume translation until failure
-
   if ($a == "")
     return $a;
-
-  $u = mysql_real_escape_string(urlencode($a));
-  
+  $a = fix($a);
+  $a_sql = mysql_real_escape_string($a);
   if (!$connection) {
     // database not available, just print English
-    return fix($a);
+    return $a;
   }
   if ("English" == $lang) {
     // no need to translate english, that's the
@@ -738,20 +575,20 @@
     if ($i18nHTMLrecordMode == 2) {
       // if not already in pending table (and recordMode set to allow us)
       // then insert this string into it
-      $query = "SELECT count FROM pending WHERE c=\"$u\" AND lang=\"$lang\"";
+      $query = "SELECT count FROM pending WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       $result = mysql_query($query, $connection);
       $num = 0;
       if ($result)
         $num = mysql_num_rows($result);
       if (0 == $num) {
-        $query = "INSERT INTO pending VALUES(\"$u\", \"$lang\", 0)";
+        $query = "INSERT INTO pending VALUES(\"$a_sql\", \"$lang\", 0)";
         mysql_query($query, $connection);
       }
     }
-    return fix($a);
+    return $a;
   }
   // attempt to get translations, ranked for best
-  $query = "SELECT translation FROM map WHERE name=\"$u\" AND lang=\"$lang\" 
ORDER BY ranking DESC";
+  $query = "SELECT translation FROM map WHERE name=\"$a_sql\" AND 
lang=\"$lang\" ORDER BY ranking DESC";
   $result = mysql_query($query, $connection);
   $num = 0;
   if ($result)
@@ -761,7 +598,7 @@
       // either insert untranslated item into pending table or update
       // referenced count; count is used to display more used strings
       // during mass translation before less common ones.
-      $query = "SELECT count FROM pending WHERE c=\"$u\" AND lang=\"$lang\"";
+      $query = "SELECT count FROM pending WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       $result = mysql_query($query, $connection);
       $num = 0;
       if ($result)
@@ -770,20 +607,24 @@
       if ($num > 0) {
         $row = mysql_fetch_array($result);
         $count = $row["count"] + 1;
-        $query = "UPDATE pending SET count=$count WHERE c=\"$u\" AND 
lang=\"$lang\"";
+        $query = "UPDATE pending SET count=$count WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       } else {
-        $query = "INSERT INTO pending VALUES(\"$u\", \"$lang\", 1)";
+        $query = "INSERT INTO pending VALUES(\"$a_sql\", \"$lang\", 1)";
       }
       mysql_query($query, $connection);       
     }
     $i18nHTMLhasTranslation = 0; // no translation was found
-    return fix($a);              // just return English string
+    return $a;              // just return English string
   } else { // translation available
     $row = mysql_fetch_array($result);
     return $row["translation"];
   }
 }
 
+// *************************************************
+// Fundamental i18nHTML API functions 
+// *************************************************
+
 // translate the sentence $a and return the result.
 function TRANSLATE_($a,$args=null) {
   if ($a == "")
@@ -791,6 +632,12 @@
   return vsprintf(translation_query($a), $args);
 }
 
+// translate the sentence $a and output just
+// the translated text (without link to translate.php)
+function TRANSLATE($a,$args=null) {
+  echo TRANSLATE_($a);
+}
+
 // translate the sentence $a adding a link
 // to enable editing translations and return the result.
 function W_($a,$args=null) {
@@ -799,81 +646,16 @@
   return TRANSLATE_($a,$args) . translateLink_($a);
 }
 
-// translate the sentence $a and output just
-// the translated text
-function TRANSLATE($a,$args=null) {
-  echo TRANSLATE_($a);
-}
-
 // translate the sentence $a appending a link
 // to enable edit the translation and output the
-// result. Returns 1 if a translation is needed.
+// result.
 function W($a, $args=NULL) {
-  global $i18nHTMLhasTranslation;
-
-  if ($a == "")
-    return 0;
-  echo W_($a, $args) . "\n";
-  return $i18nHTMLhasTranslation;
+  if ($a != "")
+    echo W_($a, $args) . "\n";
 }
 
-function LI($a,$b="") {
-  echo "<li>" . W_($a,$b) . "</li>\n";
-}
-
-function TITLE($a,$b="") {
-  global $lang;
-  global $languagecodes;
-  echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" 
>";
-  echo "<title>" . TRANSLATE_($a,$b) . "</title>\n";
-  if (isset($languagecodes[$lang])) {
-    echo "<meta name=\"content-language\" content=\"" . 
-         $languagecodes[$lang] . "\">";
-    echo "<meta name=\"language\" content=\"" . 
-         $languagecodes[$lang] . "\">";
-  }
-}
-
-
-function DT($a,$b="") {
-  echo "<dt>" . W_($a,$b) . "</dt>\n";
-}
-function DD($a,$b="") {
-  echo "<dd>" . W_($a,$b) . "</dd>\n";
-}
-function H1($a,$b="") {
-  echo "<h1>" . W_($a,$b) . "</h1>\n";
-}
-function H2($a,$b="") {
-  echo "<h2>" . W_($a,$b) . "</h2>\n";
-}
-function H3($a,$b="") {
-  echo "<h3>" . W_($a,$b) . "</h3>\n";
-}
-function H4($a,$b="") {
-  echo "<h4>" . W_($a,$b) . "</h4>\n";
-}
-function H5($a,$b="") {
-  echo "<h5>" . W_($a,$b) . "</h5>\n";
-}
-// 'verbatim' (untranslated) "pre"
-function PRE($a) {
-  echo "<pre>" . $a . "</pre>";
-}
-// 'verbatim' (untranslated) "li"
-function LIV($a) {
-  echo "<li>" . $a . "</li>\n";
-}
-
-
 // create internationalized, internal link to
 // $a.php with description $b 
-function intlink($a, $b) {  
-  echo intlink_($a, $b);
-}
-
-// create internationalized, internal link to
-// $a.php with description $b 
 function intlink_($a, $b) {  
   global $lang;
   
@@ -882,10 +664,10 @@
   return $ret;
 }
 
-// create internationalized, external link to
-// $a with description $b 
-function extlink($a, $b) {  
-  echo extlink_($a, $b);
+// create internationalized, internal link to
+// $a.php with description $b 
+function intlink($a, $b) {  
+  echo intlink_($a, $b);
 }
 
 // create internationalized, external link to
@@ -895,46 +677,17 @@
   return $ret;
 }
 
-function P($attr="") {
-  echo "<p $attr>\n";
+// create internationalized, external link to
+// $a with description $b 
+function extlink($a, $b) {  
+  echo extlink_($a, $b);
 }
 
-function BR() {
-  echo "<br />\n";
-}
 
-function HR() {
-  echo "<hr>\n";
-}
-function DTDD($a,$b) {
-  DT($a);
-  DD($b);
-}
-function LILI($a,$b) {
-  echo "<li>" . extlink_($a,$b) . "</li>\n";
-}
-function IMG($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
-  echo IMG_($src, $alt, $align, $width, $height, $border, $hspace, $vspace);
-}
+// *************************************************
+// global, call-once helper functions
+// *************************************************
 
-function IMG_($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
-  $ret = "";
-  
-  if ($align == "CENTER") 
-    $ret = $ret . "<p><center>\n";
-  $ret = $ret . "<img src=\"" . $src . "\" alt=\"";
-  $ret = $ret . TRANSLATE_($alt);
-  $ret = $ret . "\" align=\"" . $align . "\" width=$width height=$height 
border=$border hspace=$hspace vspace=$vspace>\n";
-  $ret = $ret . translateLink_($alt);
-  if ($align == "CENTER") 
-    $ret = $ret . "</center><p>\n";
-  return $ret;
-}
-
-function ANCHOR($a) {
-  echo "<a name=\"$a\"></a>\n";
-}
-
 // outputs appropriate DOCTYPE declaration for the document
 // this should be the 1st line in your php file after including
 // i18nhtml.inc.  Valid types are: HTML for HTML 4 documents,
@@ -944,62 +697,68 @@
 // "Strict", or "Frameset", defaulting to "Transitional".
 // Note for XHTML1.1 $mode is ignored.
 // example:  
-//           -?php 
-//           include("../src/i18nhtml.inc");
+//           include("i18nhtml.inc");
 //           DOCTYPE("XHTML1");
-//           echo "<head><title>Blah</title><body>Blah...</body></html>";
-//           ?-
 function DOCTYPE($type=null, $mode=null) {
   // depending on $mode, use appropriate dtd
   if ($mode == "Strict") {
     $dtd = "strict";
     if ($type != "XHTML1") // Strict not specified except for XHTML1.0
       $mode = "";
-  }
-  elseif ($mode == "Frameset") {
+  } else if ($mode == "Frameset") {
     $dtd = "frameset";
-  }
-  else { // $mode == Transitional, default, or unknown
+  } else { // $mode == Transitional, default, or unknown
     $dtd = "loose";
     $mode = "Transitional";
   }
-
   if ($type == "XHTML1")
     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 " . $mode . "//EN\" 
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-"; . $dtd . ".dtd\">\n";
-  elseif ($type == "XHTML1.1")
+  else if ($type == "XHTML1.1")
     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" 
\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\";>\n";
   else
     echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " . $mode . "//EN\" 
\"http://www.w3.org/TR/html4/"; . $dtd . ".dtd\">\n";
 }
 
+function TITLE($a,$b="") {
+  global $lang;
+  global $languagecodes;
+  echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" 
>";
+  echo "<title>" . TRANSLATE_($a,$b) . "</title>\n";
+  if (isset($languagecodes[$lang])) {
+    echo "<meta name=\"content-language\" content=\"" . 
+         $languagecodes[$lang] . "\">";
+    echo "<meta name=\"language\" content=\"" . 
+         $languagecodes[$lang] . "\">";
+  }
+}
 
 // displays a list of all languages currently available with
 // at least 1 translated string.
 function generateLanguageBar() {
   global $connection;
 
-if ($connection) {
-  echo "<center>[";
-  $query = "SELECT DISTINCT lang FROM map ORDER BY lang";
-  $result = mysql_query($query, $connection);
-  $num = 0;
-  if ($result)   
-    $num = mysql_numrows($result);
-  echo "<a href=\"?xlang=English\">";
-  W("English");
-  echo "</a>";
-  $last = "English";
-  for ($i=0;$i<$num;$i++) {
-    $row = mysql_fetch_array($result);
-    $next = $row["lang"];
-    if ($next == $last)
-      continue;
-    echo " | ";
-    echo "<a href=\"?xlang=$next\">" . W_($next) . "</a>";
-    $last = $next;
+  if ($connection) {
+    echo "<center>[";
+    $query = "SELECT DISTINCT lang FROM map ORDER BY lang";
+    $result = mysql_query($query, $connection);
+    $num = 0;
+    if ($result)   
+      $num = mysql_numrows($result);
+    echo "<a href=\"?xlang=English\">";
+    W("English");
+    echo "</a>";
+    $last = "English";
+    for ($i=0;$i<$num;$i++) {
+      $row = mysql_fetch_array($result);
+      $next = $row["lang"];
+      if ($next == $last)
+        continue;
+      echo " | ";
+      echo "<a href=\"?xlang=$next\">" . W_($next) . "</a>";
+      $last = $next;
+    }
+    echo "]</center>";
   }
-  echo "]</center>";
- }
 }
 
 
@@ -1009,24 +768,97 @@
 function generateFooter() {
   global $xlang;
   global $editor;
-  global $back;
   global $HTTP_SERVER_VARS;
 
   P();
   echo "Translation engine based on <a 
href=\"http://gnunet.org/i18nHTML/\";>i18nHTML</a> (C) 2003, 2004, 2005 
Christian Grothoff.<br />\n";
   if ( ($xlang) && ($xlang != "English") ) {
     $back = "http://"; . $HTTP_SERVER_VARS["HTTP_HOST"] . 
$HTTP_SERVER_VARS["REQUEST_URI"];
-    // echo "<span align=\"center\"><small>";
     echo "<center><small>\n";
     if ($editor != 1)
       echo " <a href=\"$back&amp;editor=1\">" . W_("enter translation mode") . 
"</a>";
     else
       W(" Translation Mode Active (for this page only)");
-    //echo "</small></span>";
     echo "</small></center>\n";
   }
   echo "</p>\n";
 }
 
-   
-?>
+// *************************************************
+// HTML construct helper functions
+// *************************************************
+
+function LI($a,$b="") {
+  echo "<li>" . W_($a,$b) . "</li>\n";
+}
+function TH($a,$b="") {
+  echo "<th>" . W_($a,$b) . "</th>\n";
+}
+function TD($a,$b="") {
+  echo "<td>" . W_($a,$b) . "</td>\n";
+}
+function DT($a,$b="") {
+  echo "<dt>" . W_($a,$b) . "</dt>\n";
+}
+function DD($a,$b="") {
+  echo "<dd>" . W_($a,$b) . "</dd>\n";
+}
+function H1($a,$b="") {
+  echo "<h1>" . W_($a,$b) . "</h1>\n";
+}
+function H2($a,$b="") {
+  echo "<h2>" . W_($a,$b) . "</h2>\n";
+}
+function H3($a,$b="") {
+  echo "<h3>" . W_($a,$b) . "</h3>\n";
+}
+function H4($a,$b="") {
+  echo "<h4>" . W_($a,$b) . "</h4>\n";
+}
+function H5($a,$b="") {
+  echo "<h5>" . W_($a,$b) . "</h5>\n";
+}
+function PRE($a) {
+  echo "<pre>" . $a . "</pre>";
+}
+// 'verbatim' (untranslated) "li"
+function LIV($a) {
+  echo "<li>" . $a . "</li>\n";
+}
+function P($attr="") {
+  echo "<p $attr>\n";
+}
+function BR() {
+  echo "<br />\n";
+}
+function HR() {
+  echo "<hr>\n";
+}
+function DTDD($a,$b) {
+  DT($a);
+  DD($b);
+}
+function LILI($a,$b) {
+  echo "<li>" . extlink_($a,$b) . "</li>\n";
+}
+function ANCHOR($a) {
+  echo "<a name=\"$a\"></a>\n";
+}
+function IMG_($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
+  $ret = "";
+  
+  if ($align == "CENTER") 
+    $ret = $ret . "<p><center>\n";
+  $ret = $ret . "<img src=\"" . $src . "\" alt=\"";
+  $ret = $ret . TRANSLATE_($alt);
+  $ret = $ret . "\" align=\"" . $align . "\" width=$width height=$height 
border=$border hspace=$hspace vspace=$vspace>\n";
+  $ret = $ret . translateLink_($alt);
+  if ($align == "CENTER") 
+    $ret = $ret . "</center><p>\n";
+  return $ret;
+}
+function IMG($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
+  echo IMG_($src, $alt, $align, $width, $height, $border, $hspace, $vspace);
+}
+
+?>
\ No newline at end of file

Modified: GNUnet-docs/WWW/index.php
===================================================================
--- GNUnet-docs/WWW/index.php   2005-04-11 06:23:40 UTC (rev 638)
+++ GNUnet-docs/WWW/index.php   2005-04-11 06:25:43 UTC (rev 639)
@@ -1,83 +1,199 @@
 <?php
-include("scripts.php3");
-$title = "GNUnet";
-$description="GNUnet - an anonymous distributed backup system :-)";
-include("html_header.php3");
+include("i18nhtml.inc");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>\n";
+if ($title) {
+  echo "<title>";
+  TRANSLATE("Doodle: find information on your computer");
+  echo "</title>";
+ }
+if ($description) {
+  echo "<meta name=\"description\" content=\"";
+  TRANSLATE("A tool to index and search the files on your disk.");
+  echo "\">";
+ }
+echo "<meta name=\"content-language\" content=\"" . 
+     $languagecodes[$lang] . "\">";
+echo "<meta name=\"language\" content=\"" . 
+     $languagecodes[$lang] . "\">";
+?>
+<meta name="author" content="Christian Grothoff">
+<meta name="keywords" 
content="doodle,desktop,search,suffix,tree,meta,data,libextractor,keywords,fam,index,database,free,Linux,GNU,GPL">
+<meta name="robots" content="index,follow">
+<meta name="revisit-after" content="28 days">
+<meta name="publisher" content="Christian Grothoff">
+<meta name="date" content="2004-12-31">
+<meta name="rights" content="(C) 2004 by Christian Grothoff>";
+<meta http-equiv="expires" content="43200">
+<meta http-equiv="content-type" content="text/html">
+</head>
+<body>
+<?php
+generateLanguageBar();
 
-H2("About GNUnet");
-gnunetlogo();
+H1("Doodle");
+ANCHOR("about");
+H2("About");
 
-W("GNUnet is a framework for secure peer-to-peer networking that does not use 
any centralized or otherwise trusted services.");
-W("A first service implemented on top of the networking layer allows anonymous 
censorship-resistant file-sharing.");
-W("GNUnet uses a simple, excess-based economic model to allocate resources.");
-W("Peers in GNUnet monitor each others behavior with respect to resource 
usage; peers that contribute to the network are rewarded with better service.");
+W("Doodle is a tool to quickly search the documents on a computer.");
+W("Doodle builds an index using meta-data contained in the documents and 
allows fast searches on the resulting database.");
+W("Doodle uses %s to support obtaining meta-data from various file-formats.",
+  extlink_("/libextractor/","libextractor"));
+W("The database used by doodle is a %s, resulting in fast lookups.",
+  extlink_("http://www.nist.gov/dads/HTML/suffixtree.html","suffix tree"));
+W("Doodle supports approximate searches.");
+BR();
+W("Features that Doodle does not have at the moment include:");
+echo "<ul>";
+LI("A web interface");
+LI("Ordering of search results");
+LI("Spidering (indexing the Internet or websites)");
+echo "</ul>";
+W("If you need these features, have a look at the %s section.",
+  extlink_("#links", "links"));
+
 P();
+W("Doodle is licensed under the %s.",
+  extlink_("http://www.gnu.org/licenses/gpl.html","GNU GPL"));
+W("Indexing large volumes can take several hundred MBs of memory (depending on 
the amount of meta-data found).");
+W("Searching should nevertheless require almost no memory.");
+W("Using the latest version of libextractor is recommended.");
+W("Doodle has so far only been tested under %s and %s %s %s.",
+  ARRAY(extlink_("http://www.debian.org/";, "Debian"),
+        extlink_("http://www.redhat.com/";, "RedHat"),
+        extlink_("http://www.gnu.org/";, "GNU"),
+        extlink_("http://www.linux.org/";, "Linux")));
+W("Doodle is expected it to work under any platform supported by %s.",
+  extlink_("/libextractor/", "libextractor"));
+P();
 
-W("GNUnet is part of the %s.",
-  extlink_("http://www.gnu.org/","GNU project"));
-W("Our official GNU website can be found at %s.",
-  
extlink_("http://www.gnu.org/software/gnunet/","http://www.gnu.org/software/gnunet/";));
-W("GNUnet can be downloaded from this site or the %s.",
-  extlink_("http://www.gnu.org/prep/ftp.html","GNU mirrors"));
+ANCHOR("download");
+H2("Download");
+W("You can find the current release %s.",
+  extlink_("download/doodle-0.6.2.tar.gz", "here"));
+W("Man-pages for %s, %s and %s are also on-line.",
+  ARRAY(extlink_("man/doodle.html", "doodle"),
+        extlink_("man/doodled.html", "doodled"),
+        extlink_("man/libdoodle", "libdoodle")));
 
+W("The latest version can be obtained using");
+PRE("$ svn checkout https://gnunet.org/svn/doodle/";);
+P();    
+W("If you want to be notified about updates, subscribe to %s",
+  extlink_("http://freshmeat.net/projects/doodle/";, "doodle on freshmeat"));
 P();
-H2("News");
-W("Older news can be found %s.\n",
-  intlink_("old_news.php3", "here"));
-echo "<dl>\n";
+W("Debian packages provided by Daniel Baumann can be found %s.",
+  extlink_("http://packages.debian.org/doodle";, "here"));
+W("RedHat/Fedora RPM packages provided by Dag Wieers can be found %s.",
+  extlink_("http://dag.wieers.com/packages/doodle/","here";));
+P();
 
-function convert_time($mysql_timestamp){
-if (ereg("^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})" .
-           "([0-9]{2})([0-9]{2})",$mysql_timestamp,$res)):
-  $year=$res[1];
-  $month=$res[2];
-  $day=$res[3];
-  $hour=$res[4];
-  $min=$res[5];
-  $sec=$res[6];
+ANCHOR("using");
+H2("Using doodle");
+W("First the doodle database needs to be created.");
+W("The simplest way to create the database is to run doodle with the 
<tt>-b</tt> option on the directories that are to be indexed.");
+W("For example:");
+PRE("$ doodle -b $HOME");
+W("This will create the doodle database under <tt>~/.doodle</tt>.");
+BR();
+W("After creating the doodle database, you can search it.");
+W("For example:");
+PRE("$ doodle keyword");
+BR();
+H3("Keeping the database up-to-date");
+W("If you want to keep your doodle database up-to-date, you can either 
periodically re-run doodle with the <tt>-b</tt> option, or you can use doodled, 
the doodle daemon.");
+W("doodled uses %s to notice whenever a file is changed and instantly updates 
the doodle database.",
+  "fam");
+W("In order to use doodled, you must have famd running.");
+W("If famd is running, you can start doodled by passing the same arguments 
that you would pass to doodle to construct the database, but without the 
<tt>-b</tt> option:");
+PRE("$ doodled $HOME");
+W("You can also use doodled to construct the initial database.");
+W("While doodled is updating the database, any doodle search will block until 
the update is complete.");
+W("Note that while you may want to index your entire disk (i.e., <tt>doodle -b 
/</tt>), it is typically not a great idea to have doodled monitor your entire 
system for changes -- especially since <tt>/usr</tt> is unlikely to change 
frequently.");
+W("You can address this issue by first indexing <tt>/</tt> and then using 
doodled to monitor only directories that change frequently:");
+PRE("$ doodle -b /\n" .
+    "$ doodled $HOME");
+W("This way, your entire system will be in the index, and your home directory 
will be always up-to-date.");
+P();
+H3("Full-text search");
+W("You can achieve a (limited) form of full-text search with doodle.");
+W("For that, the dictionary-based plaintext extractors from %s are used.",
+  extlink_("/libextractor/","libextractor"));
+W("In order to use them, you need to pass the option <tt>-b LANG</tt> to 
doodle.");
+W("LANG is a two letter language code that selects the dictionary.");
+W("Available languages at the moment are en, es, fr, it and no.");
+W("Words and sentences that are available in the respective dictionaries for 
these languages will then be added to the index.");
+W("While libextractor attempts to avoid full-text extraction for certain kown 
binary formats, it may still find words in non-text files.");
+W("Running with this option will dramatically increase the size of the index 
and the time it takes to build the index.");
+W("Note that if you change the options used to build a database will not (!) 
result in doodle re-indexing files that were processed with other options 
previously.");
+W("The only way to force doodle to re-index files with different options is to 
either touch the files (change modification timestamp) or to delete the old 
database and start from scratch.");
 
- return(array($year,$month,$day,$hour,$min,$sec));
-  else:
-     return(false);
- endif;
-}
+P();
+H3("Hints for system administrators");
+W("If you are the system administrator, you might want to run doodle on the 
entire system periodically (cron job) and have doodled monitor the home 
directories in the background.");
+W("In that case, it is suggested to have the doodle database be group-readable 
for a group doodle.");
+W("Set the permissions for the doodle binary to SGID to allow users to poll 
the database.");
+W("Doodle will ensure that information about files not accessible to the user 
are not leaked by checking if files found in the database are accessible to the 
user.");
+W("doodled has to run as root since otherwise it would be impossible to index 
the personal files of all users.");
+W("If that it too risky, doodled will still work, but only index the files 
readable to the user that runs doodled.");
 
-// definition: news is what is less than 3 months old :-)
-$query = "SELECT title,include,posted FROM news " .
-   "WHERE TO_DAYS(NOW())-TO_DAYS(posted) < 90 " .
-   "ORDER BY posted DESC";
-$result = mysql_query($query, $connection);
-$num = 0;
-if ($result) {
-  $num = mysql_numrows($result);
-}
-for ($i=0;$i<$num;$i++) {
-  $row = mysql_fetch_array($result);
-  $pd = convert_time($row["posted"]);
-  echo "<dt>" . $pd[0] . "-" . $pd[1] . "-" . $pd[2] .  ": " . 
W_($row["title"]) . "</dt>\n";
-  echo "<dd>\n";
-  include($row["include"]);
-  echo "</dd>\n";
-}
-echo "</dl>\n";
+
 P();
-H2("Roadmap");
-W("Here is the current development plan:");
-echo "<ul>\n";
-LI("fix %s",
-   extlink_("https://gnunet.org/mantis/","bugs";));
-LI("improve handling of pseudonyms (manage reputation in namespaces)");
-LI("add testbed harness to allow automated testing and profiling (%s)",
-   extlink_("mailto:address@hidden","contact";));
-LI("extend GTK UI (delete, statistics, configuration, recursive insertion)");
-LI("add download-daemon that manages ongoing/completed/stalled downloads");
-echo "</ul>\n";
+H3("Using different options for different directories");
+W("You can build a database from multiple doodle runs over distinct sets of 
files with different options.");
+W("For example, the following can make sense:");
+PRE("$ doodle -B en -b /usr/share/doc # full-text index over documentation\n" .
+    "$ doodle -b /usr /opt /bin /lib # normal index over other system files\n" 
.
+    "$ doodled -B en /home # monitor /home, with full-text support\n");
+W("A simple doodle search will then find files in all listed directories.");
+W("You can also build multiple disjoint databases and search all of them in 
one run (see %s for option <tt>-d</tt>).",
+  extlink_("man/doodle.html", "doodle"));
+
 P();
-H2("Contact");
-W("GNUnet is developed by %s.",
-  extlink_("http://www.gnu.org/software/gnunet/","the GNUnet developers"));
-W("For questions about GNUnet send E-Mail to %s.",
-  extlink_("mailto:address@hidden","address@hidden";));
+ANCHOR("mantis");
+H2("Bugtrack");
+W("Doodle uses Mantis for bugtracking.");
+W("Visit %s to report bugs.",
+  extlink_("https://gnunet.org/mantis/","https://gnunet.org/mantis/";));
+W("You need to sign up for a reporter account.");
+W("Please make sure you report bugs under <strong>Doodle</strong> and not 
under any of the other projects.");
+P();
+W("If you dislike Mantis and need to report a bug contact %s via e-mail.",
+  extlink_("mailto:address@hidden","address@hidden";));
 
-include("html_footer.php3");
+
+ANCHOR("links");
+H2("Links");
+echo "<ul>";
+LILI("http://members.cox.net/sinzui/medusa/";, 
+     "Medusa, similar project for Gnome");
+LILI("http://swish-e.org/";, 
+     "Swish-e, indexing tool with focus on the WWW");
+LILI("http://www.gnome.org/~seth/storage/";,
+     "GNOME Storage");
+LILI("http://www.gnome.org/projects/beagle/";,
+     "Beagle");
+LILI("http://sourceforge.net/projects/rlocate/";,
+     "rlocate, version of locate that is always up-to-date");
+LILI("http://www.htdig.org/";,
+     "HTDig");
+LILI("http://jakarta.apache.org/lucene/";,
+     "Lucene");
+LILI("http://homepage.mac.com/pauljlucas/software/swish/";,
+     "Swish++");
+LILI("http://webglimpse.net/";,
+     "Glimpse");
+LILI("http://evidence.sf.net/";,
+     "Evidence, file-manager with support for doodle");
+LILI("http://www.linux-magazin.de/Artikel/ausgabe/2004/09/bgw/bgw.html";,
+     "Article about doodle (and other things) in the German Linux-Magazin");
+echo "</ul>";
+HR();
+echo "<address><a href=\"mailto:address@hidden";>Christian 
Grothoff</a></address>";
+PRE("Copyright (C) 2004 Christian Grothoff.\n" .
+    "Verbatim copying and distribution of this entire article\n" .
+    "is permitted in any medium, provided this notice is preserved.");
+BR();
+generateFooter();
+echo "</body></html>\n";
 ?>

Modified: GNUnet-docs/WWW/status.php
===================================================================
--- GNUnet-docs/WWW/status.php  2005-04-11 06:23:40 UTC (rev 638)
+++ GNUnet-docs/WWW/status.php  2005-04-11 06:25:43 UTC (rev 639)
@@ -1,6 +1,6 @@
 <?php
 /*
-     (C) 2003, 2004 Christian Grothoff
+     (C) 2003, 2004, 2005 Christian Grothoff
 
      This code is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -27,7 +27,6 @@
   die();
  }
 $mode = $_REQUEST['mode'];
-
 DOCTYPE("HTML", "Transitional");
 echo "<html><head>\n";
 TITLE("Translation: status");
@@ -35,20 +34,6 @@
 W("Language setting is %s.",
   $lang);
 P();
-if ($mode == 1) {
-  H2("All available translations");
-  echo "<table border=5>\n";
-  echo "<tr><th>";
-  W("Original");
-  echo "</th><th>";
-  W("Language");
-  echo "</th><th>";
-  W("Translation");
-  echo "</th><th>";
-  W("Votes");
-  echo "</th></tr>\n";
- }
-
 $query = "SELECT count FROM pending WHERE lang=\"English\"";
 $result = mysql_query($query, $connection);
 $num = 0;
@@ -57,7 +42,16 @@
 W("Sentences in the original English text: %s",
   $num);
 P();
-
+if ($mode == 1) {
+  H2("All available translations");
+  echo "<table border=5>\n";
+  echo "<tr>";
+  TH("Original");
+  TH("Language");
+  TH("Translation");
+  TH("Votes");
+  echo "</tr>\n";
+}
 $stats = ARRAY();
 $query = "SELECT name,ranking,translation,lang FROM map";
 $result = mysql_query($query, $connection);
@@ -66,29 +60,33 @@
   $num = mysql_numrows($result);
 for ($i=0;$i<$num;$i++) {
   $row = mysql_fetch_array($result);
-  $text = urldecode($row["name"]);
+  $text = stripslashes($row["name"]);
+  $translation = stripslashes($row["translation"]);
   $ranking = $row["ranking"];
   $stats[$row["lang"]]++;
-  if ($mode == 1)
-    printf("<tr><td>%s</td><td>%s</td><td><a 
href=\"vote.php3?lang=%s&text=%s&translation=%s\">%s</a></td><td>%s</td></tr>\n",
-          urldecode($text),
-          $row["lang"],
-          $row["lang"],
+  if ($mode == 1) {
+    printf("<tr><td>%s</td><td>%s</td><td><a href=\"vote.php3?" .
+           "lang=%s&text=%s&translation=%s\">%s</a></td><td>%s</td></tr>\n",
           $text,
-          $row["translation"],
-          urldecode($row["translation"]),
+          $row["lang"],
+          urlencode($row["lang"]),
+          urlencode($text),
+          urlencode($translation),
+          $translation,
           $ranking);
- }
-if ($mode == 1)
-  echo "</table><p><hr><p>\n";
-
-echo "$num ";
-W("translations in database.");
-echo "<p>\n";
+  }
+}
+if ($mode == 1) {
+  echo "</table>";
+  P();
+  HR(); 
+  P();
+}
+W("%s translated sentences in database.", $num);
+P();
 foreach ($stats as $a => $b) {
-  echo "$b ";
-  W("in ");
-  echo "$a<br>";
+  W("%s translations available in %s.", $b, $a);
+  BR();
 }
 generateFooter();
 echo "</body></html>";

Modified: GNUnet-docs/WWW/translate.php
===================================================================
--- GNUnet-docs/WWW/translate.php       2005-04-11 06:23:40 UTC (rev 638)
+++ GNUnet-docs/WWW/translate.php       2005-04-11 06:25:43 UTC (rev 639)
@@ -1,6 +1,6 @@
 <?php
 /*
-     (C) 2003, 2004 Christian Grothoff
+     (C) 2003, 2004, 2005 Christian Grothoff
 
      This code is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -22,9 +22,10 @@
   echo "Database is down. Cannot edit translations.";
   die();
 }
-$text = $_REQUEST['text'];
+$text     = fix($_REQUEST['text']);
+$text_sql = mysql_real_escape_string($text);
+$text_url = urlencode($text);
 $back = $_REQUEST['back'];
-
 DOCTYPE("HTML", "Transitional");
 echo "<html><head>\n";
 TITLE("WWW translation");
@@ -37,66 +38,43 @@
   die();
  } 
 H2("Original Text");
-// if (get_magic_quotes_gpc()) $text = stripslashes($text);
 echo $text;
 H2("Translation");
 W("Destination language: ");
 W($lang);
 P();
 echo "<form method=\"POST\" action=\"" . $i18nHTMLbase . 
"commitTranslation.php\">\n";
-echo "<input type=hidden name=\"text\" value=\"" . urlencode($text) . "\">\n";
+echo "<input type=hidden name=\"text\" value=\"$text_url\">\n";
 echo "<input type=hidden name=\"xlang\" value=\"$xlang\">\n";
 echo "<input type=hidden name=\"back\" value=\"$back\">\n";
-/* 
-P();
-W("Character set:");
-<select size="1" name="charset">
-  <option value="UTF-8">Unicode UTF-8 encoding</option>
-  <option selected value="ISO-8859-1">ISO-8859-1 Western European, 
Latin-1</option>
-  <option value="ISO-8859-15">ISO-8859-15 Extended Western European</option>
-  <option value="cp1252">cp1252 Windows Western Europen</option>
-  <option value="cp866">cp866 DOS Cyrillic</option>
-  <option value="cp1251">cp1251 Windows Cyrillic</option>
-  <option value="KOI8-R">koi8-ru Russian</option>
-  <option value="BIG5">BIG5 Traditional Chinese</option>
-  <option value="GB2312">GB2312 Simplified Chinese</option>
-  <option value="Shift-JIS">Shift-JIS Japanese</option>
-  <option value="EUC-JP">EUC-JP Japanese</option>
-</select><br> */
 W("Translated text:");
-?>
-<input size="80" maxlength="65535" name="translation">
-<input type=submit value="I hereby give this translation into the Public 
Domain (commit)">
-</form>
-<?php
+echo "<input size=\"80\" maxlength=\"65535\" name=\"translation\">\n";
+echo "<input type=submit value=\"" . 
+     TRANSLATE_("I hereby give this translation into the Public Domain 
(commit)") . 
+     "\">\n";
+echo "</form>\n";
 P();
 
 H2("All available translations");
-?>
-<table border=5 width=95%>
-<tr><th><?php W("Language"); ?></th><th><?php W("Translation"); ?></th></tr>
-<?php
- $u = urlencode($text);
- $query = "SELECT translation,lang FROM map WHERE name=\"$u\" ORDER BY ranking 
DESC";
- $result = mysql_query($query, $connection);
- $num = 0;
- if ($result) 
-   $num = mysql_num_rows($result);
- for ($i=0;$i<$num;$i++) {
-   $row = mysql_fetch_array($result);
-
-   // we assume strings escaped before adding to DB
-   $translation = stripslashes($row["translation"]);
-
-   printf("<tr><td>%s</td><td><a href=\"" . $i18nHTMLbase . 
"vote.php?xlang=%s&text=%s&translation=%s\">%s</a></td></tr>\n",
-          W_($row["lang"]),
-          urlencode($row["lang"]),
-         $u,
-         urlencode(from_unicode($translation)),
-         fix(from_unicode($translation)));
- }
+echo "<table border=5 width=95%>\n";
+echo "<tr><th>" . W_("Language") . "</th><th>" . W_("Translation") . 
"</th></tr>\n";
+$query = "SELECT translation,lang FROM map WHERE name=\"$text_sql\" ORDER BY 
ranking DESC";
+$result = mysql_query($query, $connection);
+$num = 0;
+if ($result) 
+  $num = mysql_num_rows($result);
+for ($i=0;$i<$num;$i++) {
+  $row = mysql_fetch_array($result);
+  $translation = $row["translation"];
+  printf("<tr><td>%s</td><td><a href=\"" . $i18nHTMLbase . 
+         "vote.php?xlang=%s&text=%s&translation=%s\">%s</a></td></tr>\n",
+         W_($row["lang"]),
+         urlencode($row["lang"]),
+         urlencode($text_url),  // yes, we need urlencode twice!
+         urlencode(urlencode($translation)), // yes, we need urlencode twice!
+         fix($translation));
+}
 echo "</table>";
-
 H2("Remarks");
 H3("The percent sign");
 W("The %% sign is a special character.");
@@ -104,19 +82,15 @@
 W("The sequence %%s is used as a placeholder for links.");
 W("Currently, the translation can only access the links in the same order as 
the original text.");
 P();
-
 H3("Language specific special characters");
 W("Various languages use special characters.");
 W("The code has not been tested with certain character sets, such as 
Chinese.");
 W("If you are trying to translate the page to such a language, please contact 
the developerws if you encounter any problems.");
 P();
-
 H3("Copyright");
 W("The original english text is released under the GNU Free Documentation 
License (FDL).");
 W("Translations submitted to the webpage must be released to the public domain 
to ensure that we will not have any legal trouble.");
 W("If you have concerns or remarks regarding this policy, feel free to bring 
them to our attention.");
-
 generateFooter();
 echo "</body></html>";
-
 ?>

Modified: GNUnet-docs/WWW/vote.php
===================================================================
--- GNUnet-docs/WWW/vote.php    2005-04-11 06:23:40 UTC (rev 638)
+++ GNUnet-docs/WWW/vote.php    2005-04-11 06:25:43 UTC (rev 639)
@@ -17,26 +17,25 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-  // This file records votes from users for translations.
-  // For sentences with multiple translations, the one with the most
-  // votes is displayed.
+// This file records votes from users for translations.
+// For sentences with multiple translations, the one with the most
+// votes is displayed.
 include("i18nhtml.inc");
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
-echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" >";
 TITLE("WWW translation: vote");
 echo "</head><body>";
 if (!$connection) {
   echo "Database is down. Cannot edit translations.";
   die();
  } 
-$text = $_REQUEST['text'];
-$translation = $_REQUEST['translation'];
-$u = mysql_real_escape_string($text);
-$t = mysql_real_escape_string(to_unicode($translation));
-echo "text = " . $text . "<br>\n";
-echo "translation = " . $translation . "<br>\n";
+$text            = fix(urldecode($_REQUEST['text']));
+$translation     = fix(urldecode($_REQUEST['translation']));
+$text_sql        = mysql_real_escape_string($text);
+$translation_sql = mysql_real_escape_string(to_unicode($translation));
 
-$query = "SELECT ranking FROM map WHERE name=\"$u\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+$query = "SELECT ranking FROM map WHERE " .
+         "name=\"$text_sql\" AND lang=\"$lang\" AND 
translation=\"$translation_sql\"";
 $result = mysql_query($query, $connection);
 $num = 0;
 if ($result) 
@@ -44,11 +43,13 @@
 if ($num > 0) {
   $row = mysql_fetch_array($result);
   $ranking = $row["ranking"] + 1;
-  $query = "UPDATE map SET ranking=\"$ranking\" WHERE name=\"$u\" AND 
lang=\"$lang\" AND translation=\"$t\"";
+  $query = "UPDATE map SET ranking=\"$ranking\" WHERE " .
+           "name=\"$text_sql\" AND lang=\"$lang\" AND 
translation=\"$translation_sql\"";
   mysql_query($query, $connection);
   W("Ranking of translation is now: ");
   echo "$ranking";
- } else {
-  W("Translation does not exist (bug?).");
- }
+} else {
+  W("Translation '%s' of '%s' does not exist (bug?).",
+    ARRAY($translation, $text));
+}
 ?>

Modified: i18nHTML/README
===================================================================
--- i18nHTML/README     2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML/README     2005-04-11 06:25:43 UTC (rev 639)
@@ -17,6 +17,10 @@
 place these files anywhere, then adjust the include path correctly
 and all should still work (ie no need to maintain a copy in each dir).
 
+First, make sure that get_magic_quotes is turned OFF for GET, POST,
+COOKIE and SQL data (php.ini).  Otherwise you will have subtle
+problems.
+
 src/i18nhtml_config.inc must be edited to configure the database
 access method.  You need to configure the MySQL database like this:
 

Modified: i18nHTML/src/commitMassTranslation.php
===================================================================
--- i18nHTML/src/commitMassTranslation.php      2005-04-11 06:23:40 UTC (rev 
638)
+++ i18nHTML/src/commitMassTranslation.php      2005-04-11 06:25:43 UTC (rev 
639)
@@ -26,6 +26,7 @@
   W("Translating to English currently not allowed.\n");
   die();
 }
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
 TITLE("WWW translation: commit");
 echo "</head><body>";
@@ -37,6 +38,7 @@
     continue;
   if ( ($dec == "xlang") || ($dec == "start") )
     continue;
+  $val = fix($val);
   $query = "SELECT c FROM pending WHERE lang=\"$xlang\"";
   $result = mysql_query($query, $connection);
   $num = 0;
@@ -45,8 +47,10 @@
   while ($num > 0) {
     $num--;
     $row = mysql_fetch_array($result);
-    if ($dec == bin2hex(md5(urldecode($row["c"])))) {
-      $enc = mysql_real_escape_string($row["c"]);
+    $cx_plain = fix($row["c"]);
+    $cx_sql = mysql_real_escape_string($cx_plain);
+    if ($dec == bin2hex(md5($cx_plain))) {
+      $enc_sql = $cx_sql;
       break;
     }
   }
@@ -56,30 +60,32 @@
     P();
     continue;
   }  
-  $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$enc\"";
+  $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$enc_sql\"";
   mysql_query($query, $connection); 
-  $t = mysql_real_escape_string(to_unicode($val));
-  $query = "SELECT ranking FROM map WHERE name=\"$enc\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+  $val_sql = mysql_real_escape_string(to_unicode($val));
+  $query = "SELECT ranking FROM map WHERE name=\"$enc_sql\"" .
+           " AND lang=\"$lang\" AND translation=\"$val_sql\"";
   $result = mysql_query($query, $connection);
   $num = 0;
   if ($result) 
     $num = mysql_numrows($result);
   if ($num == 0) {
-    $txtCnt = count_chars(urldecode($enc), 1);
-    $tCnt = count_chars($t, 1);
+    $txtCnt = count_chars(stripslashes($enc_sql), 1);
+    $tCnt = count_chars(stripslashes($val_sql), 1);
     if ($txtCnt[ord('%')] != $tCnt[ord('%')]) {
-      W("Commit '%s->%s' failed.", $enc, $t);
+      W("Commit '%s->%s' failed.", stripslashes($enc_sql), 
stripslashes($val_sql));
       W("The number of percent signs in source text and translation do not 
match.");     
       W("Note that you must preserve all %%s expressions unchanged.");
       W("Also, a single displayed %% sign must be translated into two (%%%%) 
such signs.");
       P();
     } else {
-      $query = "INSERT INTO map VALUES(\"$enc\", \"$lang\", \"$t\", 1, \"" . 
$_SERVER['REMOTE_ADDR'] . "\");";
+      $query = "INSERT INTO map VALUES(\"$enc_sql\", \"$lang\", " .
+               "\"$val_sql\", 1, \"" . $_SERVER['REMOTE_ADDR'] . "\");";
       mysql_query($query, $connection);
       $done++;
       W("Storing translation for &quot;%s&quot = &quot;%s&quot;.",
-        ARRAY(urldecode($enc),
-             urldecode($t)));
+        ARRAY(stripslashes($enc_sql),
+             stripslashes($val_sql)));
       BR();  
     }
   }  

Modified: i18nHTML/src/commitTranslation.php
===================================================================
--- i18nHTML/src/commitTranslation.php  2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML/src/commitTranslation.php  2005-04-11 06:25:43 UTC (rev 639)
@@ -18,9 +18,6 @@
      Boston, MA 02111-1307, USA.
 */
 include("i18nhtml.inc");
-$text = mysql_real_escape_string($_REQUEST['text']);
-$translation = $_REQUEST['translation'];
-$back = $_REQUEST['back'];
 if (!$connection) {
   echo "Database is down. Cannot edit translations.";
   die();
@@ -29,39 +26,47 @@
   W("Translating to English is not allowed.\n");
   die();
 }
+$text            = urldecode($_REQUEST['text']);
+$text_sql        = mysql_real_escape_string($text);
+$translation     = fix($_REQUEST['translation']);
+$translation_sql = mysql_real_escape_string(to_unicode($translation));
 
-$t = mysql_real_escape_string(to_unicode($translation));
+$back            = $_REQUEST['back'];
 // check for identical translation
-$query = "SELECT ranking FROM map WHERE name=\"$text\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+$query = "SELECT ranking FROM map WHERE name=\"$text_sql\"" . 
+         " AND lang=\"$lang\" AND translation=\"$translation_sql\"";
 $result = mysql_query($query, $connection);
 $num = 0;
-if ($result) {
+if ($result) 
   $num = mysql_numrows($result);
-}
 if ($num > 0) {
   echo "<html><head>";
   TITLE("Translation exists.");
   echo "</head><body>";
-  W("Translation exists.");   
+  W("Translation '%s' of sentence '%s' exists.",
+    fix($translation), $text);   
   extlink($back, "Back...");
   generateFooter();
   echo "</body></html>";
 } else {
-  $txtCnt = count_chars(urldecode($text), 1);
-  $tCnt = count_chars($t, 1);
+  $txtCnt = count_chars($text, 1);
+  $tCnt   = count_chars($translation, 1);
   if ($txtCnt[ord('%')] != $tCnt[ord('%')]) {
       echo "<html><head>";
       TITLE("Commit failed.");
       echo "</head><body>";
-      W("Commit failed.");
-      W("The number of percent signs in source text and translation do not 
match.");     
+      W("Commit failed ('%s' and '%s').", ARRAY($text, $translation));
+      W("The number of percent signs in source text and translation does not 
match.");     
       W("Note that you must preserve all %%s expressions unchanged.");
       W("Also, a single displayed %% sign must be translated into two (%%%%) 
such signs.");
       echo "</body></html>";
   } else {
-    $query = "INSERT INTO map VALUES(\"$text\", \"$lang\", \"$t\", 1, \"" . 
$_SERVER['REMOTE_ADDR'] . "\");";
+    $query = "INSERT INTO map VALUES(\"$text_sql\", \"$lang\", " .
+             "\"$translation_sql\", 1, \"" . $_SERVER['REMOTE_ADDR'] . "\");";
     $result = mysql_query($query, $connection);
     if ($result) {
+      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$text_sql\"";
+      mysql_query($query, $connection); 
       header("Location: " . $back); /* Redirect browser */
     } else {
       echo "<html><head>";

Modified: i18nHTML/src/editor.php
===================================================================
--- i18nHTML/src/editor.php     2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML/src/editor.php     2005-04-11 06:25:43 UTC (rev 639)
@@ -22,6 +22,7 @@
   echo "Database is down. Cannot edit translations.";
   die();
 }
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
 TITLE("WWW translation");
 echo "</head><body>";
@@ -51,12 +52,12 @@
   $start = $end - $max;
   if ($start < 0)
     $start = 0;
- }
+}
 
 if ($num == 0) {
   P();
   W("No missing translations for the selected target language were found.");
- } else {
+} else {
   P();
   W("%s translations to %s have been requested and were not available.",
     ARRAY($num,
@@ -71,45 +72,39 @@
   echo "<input type=hidden name=\"start\" value=\"$endp\">";
   
   echo "<table border=5>";
-  echo "<tr><th>";
-  W("Original");
-  echo "</th><th>";
-  W("Translation");
-  echo "</th></tr>";
+  echo "<tr>";
+  TH("Original");
+  TH("Translation");
+  echo "</tr>";
   for ($ii=0;$ii<$end;$ii++) {
     $row = mysql_fetch_array($result);
     if ($ii < $start)
       continue;
-    $cx = $row["c"];
+    $cx_plain = fix($row["c"]);
+    $cx_sql = mysql_real_escape_string($cx_sql);
     
-    $query = "SELECT ranking FROM map WHERE name=\"$cx\" AND lang=\"$lang\"";
+    $query = "SELECT ranking FROM map WHERE name=\"$cx_sql\" AND 
lang=\"$lang\"";
     $result2 = mysql_query($query, $connection);
     $num2 = 0;
     if ($result2) 
       $num2 = mysql_numrows($result2);
+    echo "<tr><td width=\"45%\">";
+    echo "&quot;$cx_plain&quot;";
+    echo "</td>\n\t<td width\"50\%\">";
     if ($num2 > 0) {
-      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$cx\"";
-      mysql_query($query, $connection); 
-      
-      echo "<tr><td width=\"45%\">";
-      $dec = urldecode($cx);
-      echo "&quot;" . $dec . "&quot;";
-      echo "</td>\n\t<td width\"50\%\">";
+      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$cx_sql\"";
+      mysql_query($query, $connection);      
       W("Skipped (already translated).");
+    } else {
+      echo "<input size=\"40\" maxlength=\"65535\" name=\"" . 
bin2hex(md5($cx_plain)) . "\"></td></tr>\n";
     }
-    else {
-      echo "<tr><td width=\"45%\">";
-      $dec = urldecode($cx);
-      echo "&quot;" . $dec . "&quot;";
-      echo "</td>\n\t<td width\"50\%\">";
-      echo "<input size=\"40\" maxlength=\"65535\" name=\"" . 
bin2hex(md5($dec)) . "\"></td></tr>\n";
-    }
   }
   echo "</tr></table>";
-  echo "<input type=submit value=\"I hereby give all these translations into 
the Public Domain (commit)\">";
+  echo "<input type=submit value=\"" . 
+       TRANSLATE_("I hereby give all these translations into the Public Domain 
(commit)") . 
+       "\">";
   echo "</form>";
-  
- }
+}
 if ($end < $num) {
   P();
   echo "<a href=\"" . $i18nHTMLbase . "editor.php?xlang=" . $lang . "&start=" 
. ($end + 1) . "\">";
@@ -117,10 +112,10 @@
   echo "</a>";
   if ($t == 1)
     translateLink($b);
- } else {
+} else {
   W("Statistics about translation progress can be found %s.\n",
     intlink_($i18nHTMLbase . "status.php", "here"));
- }
+}
 P();
 H2("Remarks");
 H3("The percent sign");

Modified: i18nHTML/src/i18nhtml.inc
===================================================================
--- i18nHTML/src/i18nhtml.inc   2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML/src/i18nhtml.inc   2005-04-11 06:25:43 UTC (rev 639)
@@ -17,7 +17,6 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-
   // This file defines the functions that will be used
   // to build the webpage.  The set may not contain everything
   // you might want, so feel free to define your own extensions.
@@ -35,13 +34,13 @@
   // Most of the code should be straight forward. Look
   // at some of the example files that use it and compare with
   // the generated pages. 
-
-
 // obtain user db specific configuration parameters
 include("i18nhtml_config.inc");
-
 header("Content-type: text/html; charset=utf-8");
 
+if (get_magic_quotes_gpc())
+  die('PHP misconfigured.  Disable get_magic_quotes.');
+
 // establish default connection to database server
 $connection = @mysql_connect($i18nHTMLsqlServer,
                             $i18nHTMLsqlUser,
@@ -57,24 +56,24 @@
   if (!$db_selected) {
      die ('Error selecting db : ' . mysql_error());
   }
- }
+}
 
 // ensure the mapping and pending tables exist, creating them if not
 $query="CREATE TABLE IF NOT EXISTS map" .
        " (name BLOB, lang TINYBLOB, translation BLOB, ranking INT, ip 
TINYTEXT, " .
        "INDEX(name(10)), INDEX(lang(4)), INDEX(ranking), 
INDEX(translation(10)))";
 $result = mysql_query($query, $connection);
-//if (!$result) {
-//   die('Unable to validate mapping table.  Invalid query: ' . mysql_error());
-//}
+if (($i18nHTMLdebug == 1) && (!$result)) {
+  die('Unable to validate map table.  Invalid query: ' . mysql_error());
+}
 
 $query="CREATE TABLE IF NOT EXISTS pending" .
        " (c BLOB, lang TINYBLOB, count INT, " .
        "INDEX(c(10)), INDEX(lang(4)), INDEX(count))";
 $result = mysql_query($query, $connection);
-//if (!$result) {
-//   die('Unable to validate pending table.  Invalid query: ' . mysql_error());
-//}
+if (($i18nHTMLdebug == 1) && (!$result)) {
+  die('Unable to validate pending table.  Invalid query: ' . mysql_error());
+}
 
 /* mapping of real-names to language codes */
 $languagecodes = array("English"=>"en",
@@ -102,7 +101,7 @@
                       "Swedish"=>"sv");
 
 /* try to automagically figure out user preferences */
-$hlang=$_SERVER["HTTP_ACCEPT_LANGUAGE"];
+$hlang = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
 if ($hlang) {
   $tok = strtok($hlang, ";");
   while ($tok) {
@@ -114,7 +113,7 @@
     }
     $tok = strtok(";");
   }
- }
+}
 // If no language is specified, use english.
 if ( (! $lang) || ($lang=="") )
   $lang = "English";
@@ -124,21 +123,23 @@
 $lang = ucfirst(strtolower($lang));
 $lang = mysql_real_escape_string($lang);
 $editor = $_REQUEST['editor'];
+$i18nHTMLhasTranslation = 0; // set by last call to translation_query()
 
-
-$htmlin  = array("&rsquo;", "&gt;", "&quot;", "&prime;", "&amp;");
-$htmlout = array("&#8217;" , "&#62;", "&#34;" , "&#8242" , "&#38;");
-
 /**
  * Replace certain HTML named special characters with their
  * numeric codes (some browsers don't work with the symbolic names).
  */
+$htmlin  = array("&rsquo;", "&gt;",  "&quot;", "&prime;", "&amp;", "\"",    
"'",      "`",       "&lsquo;");
+$htmlout = array("&#8217;", "&#62;", "&#34;" , "&#8242;", "&#38;", "&#34;", 
"&#8242;", "&#8217;", "&#8216;");
 function fix($a) {
   global $htmlin;
   global $htmlout;
   return str_replace($htmlin, $htmlout, $a);
 }
 
+// *************************************************
+// i18nHTML configuration API functions 
+// *************************************************
 
 // change the marker text shown to indicate text
 // is translatable (link to translate page text)
@@ -151,46 +152,18 @@
     $i18nHTMLmarker = $marker;
 }
 
+// ***************************************************
+// i18nHTML _internal_ API functions (don't look here)
+// ***************************************************
 
-// editor = ?         ;      // set by URL parameter, indicates in translation 
mode
-$i18nHTMLhasTranslation = 0; // set by last call to isTranslated() or 
translation_query()
-$i18nHTMLallowedits = 1;
-
-// indicate translate link should only be shown for untranslated items.
-function editOnlyUntranslatedText() {
-  global $i18nHTMLallowedits;
-  $i18nHTMLallowedits = 0;
-}
-
-// indicate translate link should always be shown (or set to indicated value).
-function editAllTranslations($v=null) {
-  global $i18nHTMLallowedits;
-  if ($v == "")
-    $i18nHTMLallowedits = 1;
-  else
-    $i18nHTMLallowedits = $v;
-}
-
-
-// displays a link to the page to enable one to
-// translate the given text ($a)
-// see translateLink_
-function translateLink($a, $hasTranslation=null) {
-  echo translateLink_($a, $hasTranslation);
-}
-
-// returns a HTML string to link to enable one to
-// translate the given text ($a) when
-// $editor has a nonzero value and either
-// $hasTranslation is 0 or $allowedits is nonzero;
-// otherwise and empty string ("") is returned.
-// $hasTranslation may be omitted to use result of
-// last isTranslated() or translation_query() call;
-function translateLink_($a, $hasTranslation=null) {
+// returns a HTML string to link to enable one to translate the given
+// text ($a) when $editor has a nonzero value or
+// $i18nHTMLhasTranslation is 0; otherwise and empty string ("") is
+// returned.
+function translateLink_($a) {
   global $lang;
   global $HTTP_SERVER_VARS;
   global $editor;
-  global $i18nHTMLallowedits;
   global $i18nHTMLhasTranslation;
   global $i18nHTMLmarker;
   global $i18nHTMLbase;
@@ -201,112 +174,21 @@
     $back = "http://"; . $HTTP_SERVER_VARS["HTTP_HOST"] . 
$HTTP_SERVER_VARS["REQUEST_URI"];
     return "<a href=\"" . $i18nHTMLbase . "translate.php?xlang=" 
       . $lang 
-      . "&amp;text=" . urlencode($a)
+      . "&amp;text=" . urlencode(fix($a))
       . "&amp;back=" . urlencode($back) 
       . "\">" . $i18nHTMLmarker . "</a>\n";
   } else
     return "";   
 }
 
-// return 1 if translation is available (or DB down)
-// assumes passed the original text as appears in source
-function isTranslated($a, $charset=null) {
-  global $connection;
-  global $lang;
-  global $editor;
-  global $i18nHTMLhasTranslation;
-
-  $i18nHTMLhasTranslation = 1; // assume translation until failure
-
-  if ( ("English" == $lang) || (!$connection) ) {
-    // Either hard-wired source language (so available) or
-    // database not available.
-    return 1;
-  }
-
-  //  $a = htmlentities($a, ENT_QUOTES, $charset);
-  $u = urlencode($a);
-
-  $query = "SELECT translation FROM map WHERE name=\"$u\" AND lang=\"$lang\" 
ORDER BY ranking DESC";
-  $result = mysql_query($query, $connection);
-  if (!$result) {
-    if ($i18nHTMLdebug != 0)
-      echo 'Unable to execute query $query: ' . mysql_error();
-  }
-
-  $num = 0;
-  if ($result)
-    $num = mysql_numrows($result);
-  if ($num > 0)
-    return 1;
-  else {
-    $i18nHTMLhasTranslation = 0; // no translation was found
-    return 0;   
-  }
+// displays a link to the page to enable one to
+// translate the given text ($a)
+// see translateLink_
+function translateLink($a) {
+  echo translateLink_($a);
 }
 
-
 /**
- * restore UTF-8 from HTML Unicode entities
- *
- * This function is triggered by the YACS handler during page
- * rendering.  It is aiming to transcode HTML Unicode entities
- * (eg, &amp;#8364;) back to actual UTF-8 encoding (eg, �).
- *
- * @param string a string with a mix of UTF-8 and of HTML Unicode entities
- * @return an UTF-8 string
- */
-function from_unicode($text) {
-  // translate extended ISO8859-1 chars, if any
-  $text = utf8_encode($text);
-  
-  // translate Unicode entities
-  $areas = preg_split('/&#(\d+?);/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
-  $text = '';
-  $index = 0;
-  foreach($areas as $area) {
-    switch($index%2) {
-    case 0: // before entity
-      $text .= $area;
-      break;
-    case 1: // the entity itself
-      
-      // get the integer value
-      $unicode = intval($area);
-      
-      // one byte
-      if($unicode < 0x80) {
-       
-       $text .= chr($unicode);
-       
-       // two bytes
-      } elseif($unicode < 0x800) {
-       
-       $text .= chr( 0xC0 +  ( ( $unicode - ( $unicode % 0x40 ) ) / 0x40 ) );
-       $text .= chr( 0x80 + ( $unicode % 0x40 ) );
-       
-       // three bytes
-      } elseif($unicode < 0x10000) {
-       
-       $text .= chr( 0xE0 + ( ( $unicode - ( $unicode % 0x1000 ) ) / 0x1000 ) 
);
-       $text .= chr( 0x80 + ( ( ( $unicode % 0x1000 ) - ( $unicode % 0x40 ) ) 
/ 0x40 ) );
-       $text .= chr( 0x80 + ( $unicode % 0x40 ) );
-       
-       // more bytes, keep it as it is...
-      } else
-         $text .= '&#'.$unicode.';';
-      
-      break;
-    }
-    $index++;
-  }
-  
-  // the updated string
-  return $text;
-}
-
-
-/**
  * transcode unicode entities to/from HTML entities
  *
  * Also, this function transforms HTML entities into their equivalent Unicode 
entities.
@@ -319,8 +201,7 @@
  * @param boolean TRUE to transcode to Unicode, FALSE to transcode to HTML
  * @return a transcoded string
  */
-function transcode($input, $to_unicode=TRUE) {
-  
+function transcode($input, $to_unicode=TRUE) { 
   // initialize tables only once
   static $html_entities, $unicode_entities;
   if(!is_array($html_entities)) {
@@ -583,8 +464,7 @@
       $unicode_entities[] = $unicode_entity;
       $html_entities[] = $html_entity;
     }
-  }
-  
+  }  
   // transcode HTML entities to Unicode
   if($to_unicode)
     return str_replace($html_entities, $unicode_entities, $input);
@@ -594,9 +474,6 @@
     return str_replace($unicode_entities, $html_entities, $input);
 }
 
-
-
-
 /**
  * transcode multi-byte characters to HTML representations for Unicode
  *
@@ -618,119 +495,79 @@
  * @param string the original UTF-8 string
  * @return a string acceptable in an ISO-8859-1 storage system (ie., PHP4 + 
MySQl 3)
  */
-function to_unicode($input) {
-  
+function to_unicode($input) { 
   // transcode HTML entities to Unicode entities
-  $input = transcode($input);
-  
+  $input = transcode($input);  
   // scan the whole string
   $output = '';
   $index = 0;
-  while($index < strlen($input)) {
-    
+  while($index < strlen($input)) {  
     // look at one char
-    $char = ord($input[$index]);
-    
+    $char = ord($input[$index]);    
     // one byte (0xxxxxxx)
-    if($char < 0x80) {
-      
+    if ($char < 0x80) {      
       // some chars may be undefined
       $output .= chr($char);
-      $index += 1;
-      
+      $index += 1;      
       // two bytes (110xxxxx 10xxxxxx)
-    } elseif($char < 0xE0) {
-      
+    } else if ($char < 0xE0) {      
       // strip weird sequences (eg, C0 80 -> NUL)
       if($value = (($char % 0x20) * 0x40) + (ord($input[$index + 1]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 2;
-      
+      $index += 2;      
       // three bytes (1110xxxx 10xxxxxx 10xxxxxx) example: euro sign = 
\xE2\x82\xAC -> &#8364;
-    } elseif($char < 0xF0) {
-      
+    } else if ($char < 0xF0) {      
       // strip weird sequences
       if($value = (($char % 0x10) * 0x1000) + ((ord($input[$index + 1]) % 
0x40) * 0x40) + (ord($input[$index + 2]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 3;
-      
+      $index += 3;      
       // four bytes (11110xxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } elseif($char < 0xF8) {
-      
+    } else if($char < 0xF8) {      
       // strip weird sequences
-      if($value = (($char % 0x08) * 0x40000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000) + ((ord($input[$index + 2]) % 0x40) * 0x40)
+      if ($value = (($char % 0x08) * 0x40000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000) + ((ord($input[$index + 2]) % 0x40) * 0x40)
         + (ord($input[$index + 3]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 4;
-      
+      $index += 4;      
       // five bytes (111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } elseif($char < 0xFC) {
-      
+    } else if($char < 0xFC) {      
       // strip weird sequences
-      if($value = (($char % 0x04) * 0x1000000) + ((ord($input[$index + 1]) % 
0x40) * 0x40000) + ((ord($input[$index + 2]) % 0x40) * 0x1000)
+      if ($value = (($char % 0x04) * 0x1000000) + ((ord($input[$index + 1]) % 
0x40) * 0x40000) + ((ord($input[$index + 2]) % 0x40) * 0x1000)
         + ((ord($input[$index + 3]) % 0x40) * 0x40) + (ord($input[$index + 4]) 
% 0x40))
        $output .= '&#' . $value . ';';
-      $index += 5;
-      
+      $index += 5;      
       // six bytes (1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } else {
-      
+    } else {      
       // strip weird sequences
-      if($value = (($char % 0x02) * 0x40000000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000000) + ((ord($input[$index + 2]) % 0x40) * 0x40000)
+      if ($value = (($char % 0x02) * 0x40000000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000000) + ((ord($input[$index + 2]) % 0x40) * 0x40000)
         + ((ord($input[$index + 3]) % 0x40) * 0x1000) + ((ord($input[$index + 
4]) % 0x40) * 0x40) + (ord($input[$index + 4]) % 0x40))
        $output .= '&#' . $value . ';';
       $index += 6;
-    }
-    
-  }
- 
+    }    
+  } 
   // return the translated string
   return $output;
 }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-// returns either the translated string
-// or the original string.  Assumes we
-// are passed the original string as occurs
-// in text; result will be html tokenized by
-// htmlentities() using default charset or
-// one indicated by $charset, to ensure all
-// required entities are converted for valid html output.
-// Note: it is assumed value in DB have already
-// ran through equivalent of htmlentities().
-// $i18nHTMLhasTranslation is set to nonzero value
-// if a translation is available or failure connecting
-// to database, otherwise it is set to 0.
-function translation_query($a, $charset=null) {
+// returns either the translated string or the original string.
+// Assumes we are passed the original string as occurs in text; result
+// will be html tokenized by htmlentities() using UTF8.
+// $i18nHTMLhasTranslation is set to nonzero value if a translation is
+// available or failure connecting to database, otherwise it is set to
+// 0.
+function translation_query($a) {
   global $connection;
   global $lang;
   global $i18nHTMLrecordMode;
   global $i18nHTMLhasTranslation;
   
   $i18nHTMLhasTranslation = 1; // assume translation until failure
-
   if ($a == "")
     return $a;
-
-  $u = mysql_real_escape_string(urlencode($a));
-  
+  $a = fix($a);
+  $a_sql = mysql_real_escape_string($a);
   if (!$connection) {
     // database not available, just print English
-    return fix($a);
+    return $a;
   }
   if ("English" == $lang) {
     // no need to translate english, that's the
@@ -738,20 +575,20 @@
     if ($i18nHTMLrecordMode == 2) {
       // if not already in pending table (and recordMode set to allow us)
       // then insert this string into it
-      $query = "SELECT count FROM pending WHERE c=\"$u\" AND lang=\"$lang\"";
+      $query = "SELECT count FROM pending WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       $result = mysql_query($query, $connection);
       $num = 0;
       if ($result)
         $num = mysql_num_rows($result);
       if (0 == $num) {
-        $query = "INSERT INTO pending VALUES(\"$u\", \"$lang\", 0)";
+        $query = "INSERT INTO pending VALUES(\"$a_sql\", \"$lang\", 0)";
         mysql_query($query, $connection);
       }
     }
-    return fix($a);
+    return $a;
   }
   // attempt to get translations, ranked for best
-  $query = "SELECT translation FROM map WHERE name=\"$u\" AND lang=\"$lang\" 
ORDER BY ranking DESC";
+  $query = "SELECT translation FROM map WHERE name=\"$a_sql\" AND 
lang=\"$lang\" ORDER BY ranking DESC";
   $result = mysql_query($query, $connection);
   $num = 0;
   if ($result)
@@ -761,7 +598,7 @@
       // either insert untranslated item into pending table or update
       // referenced count; count is used to display more used strings
       // during mass translation before less common ones.
-      $query = "SELECT count FROM pending WHERE c=\"$u\" AND lang=\"$lang\"";
+      $query = "SELECT count FROM pending WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       $result = mysql_query($query, $connection);
       $num = 0;
       if ($result)
@@ -770,20 +607,24 @@
       if ($num > 0) {
         $row = mysql_fetch_array($result);
         $count = $row["count"] + 1;
-        $query = "UPDATE pending SET count=$count WHERE c=\"$u\" AND 
lang=\"$lang\"";
+        $query = "UPDATE pending SET count=$count WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       } else {
-        $query = "INSERT INTO pending VALUES(\"$u\", \"$lang\", 1)";
+        $query = "INSERT INTO pending VALUES(\"$a_sql\", \"$lang\", 1)";
       }
       mysql_query($query, $connection);       
     }
     $i18nHTMLhasTranslation = 0; // no translation was found
-    return fix($a);              // just return English string
+    return $a;              // just return English string
   } else { // translation available
     $row = mysql_fetch_array($result);
     return $row["translation"];
   }
 }
 
+// *************************************************
+// Fundamental i18nHTML API functions 
+// *************************************************
+
 // translate the sentence $a and return the result.
 function TRANSLATE_($a,$args=null) {
   if ($a == "")
@@ -791,6 +632,12 @@
   return vsprintf(translation_query($a), $args);
 }
 
+// translate the sentence $a and output just
+// the translated text (without link to translate.php)
+function TRANSLATE($a,$args=null) {
+  echo TRANSLATE_($a);
+}
+
 // translate the sentence $a adding a link
 // to enable editing translations and return the result.
 function W_($a,$args=null) {
@@ -799,81 +646,16 @@
   return TRANSLATE_($a,$args) . translateLink_($a);
 }
 
-// translate the sentence $a and output just
-// the translated text
-function TRANSLATE($a,$args=null) {
-  echo TRANSLATE_($a);
-}
-
 // translate the sentence $a appending a link
 // to enable edit the translation and output the
-// result. Returns 1 if a translation is needed.
+// result.
 function W($a, $args=NULL) {
-  global $i18nHTMLhasTranslation;
-
-  if ($a == "")
-    return 0;
-  echo W_($a, $args) . "\n";
-  return $i18nHTMLhasTranslation;
+  if ($a != "")
+    echo W_($a, $args) . "\n";
 }
 
-function LI($a,$b="") {
-  echo "<li>" . W_($a,$b) . "</li>\n";
-}
-
-function TITLE($a,$b="") {
-  global $lang;
-  global $languagecodes;
-  echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" 
>";
-  echo "<title>" . TRANSLATE_($a,$b) . "</title>\n";
-  if (isset($languagecodes[$lang])) {
-    echo "<meta name=\"content-language\" content=\"" . 
-         $languagecodes[$lang] . "\">";
-    echo "<meta name=\"language\" content=\"" . 
-         $languagecodes[$lang] . "\">";
-  }
-}
-
-
-function DT($a,$b="") {
-  echo "<dt>" . W_($a,$b) . "</dt>\n";
-}
-function DD($a,$b="") {
-  echo "<dd>" . W_($a,$b) . "</dd>\n";
-}
-function H1($a,$b="") {
-  echo "<h1>" . W_($a,$b) . "</h1>\n";
-}
-function H2($a,$b="") {
-  echo "<h2>" . W_($a,$b) . "</h2>\n";
-}
-function H3($a,$b="") {
-  echo "<h3>" . W_($a,$b) . "</h3>\n";
-}
-function H4($a,$b="") {
-  echo "<h4>" . W_($a,$b) . "</h4>\n";
-}
-function H5($a,$b="") {
-  echo "<h5>" . W_($a,$b) . "</h5>\n";
-}
-// 'verbatim' (untranslated) "pre"
-function PRE($a) {
-  echo "<pre>" . $a . "</pre>";
-}
-// 'verbatim' (untranslated) "li"
-function LIV($a) {
-  echo "<li>" . $a . "</li>\n";
-}
-
-
 // create internationalized, internal link to
 // $a.php with description $b 
-function intlink($a, $b) {  
-  echo intlink_($a, $b);
-}
-
-// create internationalized, internal link to
-// $a.php with description $b 
 function intlink_($a, $b) {  
   global $lang;
   
@@ -882,10 +664,10 @@
   return $ret;
 }
 
-// create internationalized, external link to
-// $a with description $b 
-function extlink($a, $b) {  
-  echo extlink_($a, $b);
+// create internationalized, internal link to
+// $a.php with description $b 
+function intlink($a, $b) {  
+  echo intlink_($a, $b);
 }
 
 // create internationalized, external link to
@@ -895,46 +677,17 @@
   return $ret;
 }
 
-function P($attr="") {
-  echo "<p $attr>\n";
+// create internationalized, external link to
+// $a with description $b 
+function extlink($a, $b) {  
+  echo extlink_($a, $b);
 }
 
-function BR() {
-  echo "<br />\n";
-}
 
-function HR() {
-  echo "<hr>\n";
-}
-function DTDD($a,$b) {
-  DT($a);
-  DD($b);
-}
-function LILI($a,$b) {
-  echo "<li>" . extlink_($a,$b) . "</li>\n";
-}
-function IMG($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
-  echo IMG_($src, $alt, $align, $width, $height, $border, $hspace, $vspace);
-}
+// *************************************************
+// global, call-once helper functions
+// *************************************************
 
-function IMG_($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
-  $ret = "";
-  
-  if ($align == "CENTER") 
-    $ret = $ret . "<p><center>\n";
-  $ret = $ret . "<img src=\"" . $src . "\" alt=\"";
-  $ret = $ret . TRANSLATE_($alt);
-  $ret = $ret . "\" align=\"" . $align . "\" width=$width height=$height 
border=$border hspace=$hspace vspace=$vspace>\n";
-  $ret = $ret . translateLink_($alt);
-  if ($align == "CENTER") 
-    $ret = $ret . "</center><p>\n";
-  return $ret;
-}
-
-function ANCHOR($a) {
-  echo "<a name=\"$a\"></a>\n";
-}
-
 // outputs appropriate DOCTYPE declaration for the document
 // this should be the 1st line in your php file after including
 // i18nhtml.inc.  Valid types are: HTML for HTML 4 documents,
@@ -944,62 +697,68 @@
 // "Strict", or "Frameset", defaulting to "Transitional".
 // Note for XHTML1.1 $mode is ignored.
 // example:  
-//           -?php 
-//           include("../src/i18nhtml.inc");
+//           include("i18nhtml.inc");
 //           DOCTYPE("XHTML1");
-//           echo "<head><title>Blah</title><body>Blah...</body></html>";
-//           ?-
 function DOCTYPE($type=null, $mode=null) {
   // depending on $mode, use appropriate dtd
   if ($mode == "Strict") {
     $dtd = "strict";
     if ($type != "XHTML1") // Strict not specified except for XHTML1.0
       $mode = "";
-  }
-  elseif ($mode == "Frameset") {
+  } else if ($mode == "Frameset") {
     $dtd = "frameset";
-  }
-  else { // $mode == Transitional, default, or unknown
+  } else { // $mode == Transitional, default, or unknown
     $dtd = "loose";
     $mode = "Transitional";
   }
-
   if ($type == "XHTML1")
     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 " . $mode . "//EN\" 
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-"; . $dtd . ".dtd\">\n";
-  elseif ($type == "XHTML1.1")
+  else if ($type == "XHTML1.1")
     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" 
\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\";>\n";
   else
     echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " . $mode . "//EN\" 
\"http://www.w3.org/TR/html4/"; . $dtd . ".dtd\">\n";
 }
 
+function TITLE($a,$b="") {
+  global $lang;
+  global $languagecodes;
+  echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" 
>";
+  echo "<title>" . TRANSLATE_($a,$b) . "</title>\n";
+  if (isset($languagecodes[$lang])) {
+    echo "<meta name=\"content-language\" content=\"" . 
+         $languagecodes[$lang] . "\">";
+    echo "<meta name=\"language\" content=\"" . 
+         $languagecodes[$lang] . "\">";
+  }
+}
 
 // displays a list of all languages currently available with
 // at least 1 translated string.
 function generateLanguageBar() {
   global $connection;
 
-if ($connection) {
-  echo "<center>[";
-  $query = "SELECT DISTINCT lang FROM map ORDER BY lang";
-  $result = mysql_query($query, $connection);
-  $num = 0;
-  if ($result)   
-    $num = mysql_numrows($result);
-  echo "<a href=\"?xlang=English\">";
-  W("English");
-  echo "</a>";
-  $last = "English";
-  for ($i=0;$i<$num;$i++) {
-    $row = mysql_fetch_array($result);
-    $next = $row["lang"];
-    if ($next == $last)
-      continue;
-    echo " | ";
-    echo "<a href=\"?xlang=$next\">" . W_($next) . "</a>";
-    $last = $next;
+  if ($connection) {
+    echo "<center>[";
+    $query = "SELECT DISTINCT lang FROM map ORDER BY lang";
+    $result = mysql_query($query, $connection);
+    $num = 0;
+    if ($result)   
+      $num = mysql_numrows($result);
+    echo "<a href=\"?xlang=English\">";
+    W("English");
+    echo "</a>";
+    $last = "English";
+    for ($i=0;$i<$num;$i++) {
+      $row = mysql_fetch_array($result);
+      $next = $row["lang"];
+      if ($next == $last)
+        continue;
+      echo " | ";
+      echo "<a href=\"?xlang=$next\">" . W_($next) . "</a>";
+      $last = $next;
+    }
+    echo "]</center>";
   }
-  echo "]</center>";
- }
 }
 
 
@@ -1009,24 +768,97 @@
 function generateFooter() {
   global $xlang;
   global $editor;
-  global $back;
   global $HTTP_SERVER_VARS;
 
   P();
   echo "Translation engine based on <a 
href=\"http://gnunet.org/i18nHTML/\";>i18nHTML</a> (C) 2003, 2004, 2005 
Christian Grothoff.<br />\n";
   if ( ($xlang) && ($xlang != "English") ) {
     $back = "http://"; . $HTTP_SERVER_VARS["HTTP_HOST"] . 
$HTTP_SERVER_VARS["REQUEST_URI"];
-    // echo "<span align=\"center\"><small>";
     echo "<center><small>\n";
     if ($editor != 1)
       echo " <a href=\"$back&amp;editor=1\">" . W_("enter translation mode") . 
"</a>";
     else
       W(" Translation Mode Active (for this page only)");
-    //echo "</small></span>";
     echo "</small></center>\n";
   }
   echo "</p>\n";
 }
 
-   
-?>
+// *************************************************
+// HTML construct helper functions
+// *************************************************
+
+function LI($a,$b="") {
+  echo "<li>" . W_($a,$b) . "</li>\n";
+}
+function TH($a,$b="") {
+  echo "<th>" . W_($a,$b) . "</th>\n";
+}
+function TD($a,$b="") {
+  echo "<td>" . W_($a,$b) . "</td>\n";
+}
+function DT($a,$b="") {
+  echo "<dt>" . W_($a,$b) . "</dt>\n";
+}
+function DD($a,$b="") {
+  echo "<dd>" . W_($a,$b) . "</dd>\n";
+}
+function H1($a,$b="") {
+  echo "<h1>" . W_($a,$b) . "</h1>\n";
+}
+function H2($a,$b="") {
+  echo "<h2>" . W_($a,$b) . "</h2>\n";
+}
+function H3($a,$b="") {
+  echo "<h3>" . W_($a,$b) . "</h3>\n";
+}
+function H4($a,$b="") {
+  echo "<h4>" . W_($a,$b) . "</h4>\n";
+}
+function H5($a,$b="") {
+  echo "<h5>" . W_($a,$b) . "</h5>\n";
+}
+function PRE($a) {
+  echo "<pre>" . $a . "</pre>";
+}
+// 'verbatim' (untranslated) "li"
+function LIV($a) {
+  echo "<li>" . $a . "</li>\n";
+}
+function P($attr="") {
+  echo "<p $attr>\n";
+}
+function BR() {
+  echo "<br />\n";
+}
+function HR() {
+  echo "<hr>\n";
+}
+function DTDD($a,$b) {
+  DT($a);
+  DD($b);
+}
+function LILI($a,$b) {
+  echo "<li>" . extlink_($a,$b) . "</li>\n";
+}
+function ANCHOR($a) {
+  echo "<a name=\"$a\"></a>\n";
+}
+function IMG_($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
+  $ret = "";
+  
+  if ($align == "CENTER") 
+    $ret = $ret . "<p><center>\n";
+  $ret = $ret . "<img src=\"" . $src . "\" alt=\"";
+  $ret = $ret . TRANSLATE_($alt);
+  $ret = $ret . "\" align=\"" . $align . "\" width=$width height=$height 
border=$border hspace=$hspace vspace=$vspace>\n";
+  $ret = $ret . translateLink_($alt);
+  if ($align == "CENTER") 
+    $ret = $ret . "</center><p>\n";
+  return $ret;
+}
+function IMG($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
+  echo IMG_($src, $alt, $align, $width, $height, $border, $hspace, $vspace);
+}
+
+?>
\ No newline at end of file

Modified: i18nHTML/src/status.php
===================================================================
--- i18nHTML/src/status.php     2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML/src/status.php     2005-04-11 06:25:43 UTC (rev 639)
@@ -1,6 +1,6 @@
 <?php
 /*
-     (C) 2003, 2004 Christian Grothoff
+     (C) 2003, 2004, 2005 Christian Grothoff
 
      This code is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -27,7 +27,6 @@
   die();
  }
 $mode = $_REQUEST['mode'];
-
 DOCTYPE("HTML", "Transitional");
 echo "<html><head>\n";
 TITLE("Translation: status");
@@ -35,20 +34,6 @@
 W("Language setting is %s.",
   $lang);
 P();
-if ($mode == 1) {
-  H2("All available translations");
-  echo "<table border=5>\n";
-  echo "<tr><th>";
-  W("Original");
-  echo "</th><th>";
-  W("Language");
-  echo "</th><th>";
-  W("Translation");
-  echo "</th><th>";
-  W("Votes");
-  echo "</th></tr>\n";
- }
-
 $query = "SELECT count FROM pending WHERE lang=\"English\"";
 $result = mysql_query($query, $connection);
 $num = 0;
@@ -57,7 +42,16 @@
 W("Sentences in the original English text: %s",
   $num);
 P();
-
+if ($mode == 1) {
+  H2("All available translations");
+  echo "<table border=5>\n";
+  echo "<tr>";
+  TH("Original");
+  TH("Language");
+  TH("Translation");
+  TH("Votes");
+  echo "</tr>\n";
+}
 $stats = ARRAY();
 $query = "SELECT name,ranking,translation,lang FROM map";
 $result = mysql_query($query, $connection);
@@ -66,29 +60,33 @@
   $num = mysql_numrows($result);
 for ($i=0;$i<$num;$i++) {
   $row = mysql_fetch_array($result);
-  $text = urldecode($row["name"]);
+  $text = stripslashes($row["name"]);
+  $translation = stripslashes($row["translation"]);
   $ranking = $row["ranking"];
   $stats[$row["lang"]]++;
-  if ($mode == 1)
-    printf("<tr><td>%s</td><td>%s</td><td><a 
href=\"vote.php3?lang=%s&text=%s&translation=%s\">%s</a></td><td>%s</td></tr>\n",
-          urldecode($text),
-          $row["lang"],
-          $row["lang"],
+  if ($mode == 1) {
+    printf("<tr><td>%s</td><td>%s</td><td><a href=\"vote.php3?" .
+           "lang=%s&text=%s&translation=%s\">%s</a></td><td>%s</td></tr>\n",
           $text,
-          $row["translation"],
-          urldecode($row["translation"]),
+          $row["lang"],
+          urlencode($row["lang"]),
+          urlencode($text),
+          urlencode($translation),
+          $translation,
           $ranking);
- }
-if ($mode == 1)
-  echo "</table><p><hr><p>\n";
-
-echo "$num ";
-W("translations in database.");
-echo "<p>\n";
+  }
+}
+if ($mode == 1) {
+  echo "</table>";
+  P();
+  HR(); 
+  P();
+}
+W("%s translated sentences in database.", $num);
+P();
 foreach ($stats as $a => $b) {
-  echo "$b ";
-  W("in ");
-  echo "$a<br>";
+  W("%s translations available in %s.", $b, $a);
+  BR();
 }
 generateFooter();
 echo "</body></html>";

Modified: i18nHTML/src/translate.php
===================================================================
--- i18nHTML/src/translate.php  2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML/src/translate.php  2005-04-11 06:25:43 UTC (rev 639)
@@ -1,6 +1,6 @@
 <?php
 /*
-     (C) 2003, 2004 Christian Grothoff
+     (C) 2003, 2004, 2005 Christian Grothoff
 
      This code is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -22,9 +22,10 @@
   echo "Database is down. Cannot edit translations.";
   die();
 }
-$text = $_REQUEST['text'];
+$text     = fix($_REQUEST['text']);
+$text_sql = mysql_real_escape_string($text);
+$text_url = urlencode($text);
 $back = $_REQUEST['back'];
-
 DOCTYPE("HTML", "Transitional");
 echo "<html><head>\n";
 TITLE("WWW translation");
@@ -37,66 +38,43 @@
   die();
  } 
 H2("Original Text");
-// if (get_magic_quotes_gpc()) $text = stripslashes($text);
 echo $text;
 H2("Translation");
 W("Destination language: ");
 W($lang);
 P();
 echo "<form method=\"POST\" action=\"" . $i18nHTMLbase . 
"commitTranslation.php\">\n";
-echo "<input type=hidden name=\"text\" value=\"" . urlencode($text) . "\">\n";
+echo "<input type=hidden name=\"text\" value=\"$text_url\">\n";
 echo "<input type=hidden name=\"xlang\" value=\"$xlang\">\n";
 echo "<input type=hidden name=\"back\" value=\"$back\">\n";
-/* 
-P();
-W("Character set:");
-<select size="1" name="charset">
-  <option value="UTF-8">Unicode UTF-8 encoding</option>
-  <option selected value="ISO-8859-1">ISO-8859-1 Western European, 
Latin-1</option>
-  <option value="ISO-8859-15">ISO-8859-15 Extended Western European</option>
-  <option value="cp1252">cp1252 Windows Western Europen</option>
-  <option value="cp866">cp866 DOS Cyrillic</option>
-  <option value="cp1251">cp1251 Windows Cyrillic</option>
-  <option value="KOI8-R">koi8-ru Russian</option>
-  <option value="BIG5">BIG5 Traditional Chinese</option>
-  <option value="GB2312">GB2312 Simplified Chinese</option>
-  <option value="Shift-JIS">Shift-JIS Japanese</option>
-  <option value="EUC-JP">EUC-JP Japanese</option>
-</select><br> */
 W("Translated text:");
-?>
-<input size="80" maxlength="65535" name="translation">
-<input type=submit value="I hereby give this translation into the Public 
Domain (commit)">
-</form>
-<?php
+echo "<input size=\"80\" maxlength=\"65535\" name=\"translation\">\n";
+echo "<input type=submit value=\"" . 
+     TRANSLATE_("I hereby give this translation into the Public Domain 
(commit)") . 
+     "\">\n";
+echo "</form>\n";
 P();
 
 H2("All available translations");
-?>
-<table border=5 width=95%>
-<tr><th><?php W("Language"); ?></th><th><?php W("Translation"); ?></th></tr>
-<?php
- $u = urlencode($text);
- $query = "SELECT translation,lang FROM map WHERE name=\"$u\" ORDER BY ranking 
DESC";
- $result = mysql_query($query, $connection);
- $num = 0;
- if ($result) 
-   $num = mysql_num_rows($result);
- for ($i=0;$i<$num;$i++) {
-   $row = mysql_fetch_array($result);
-
-   // we assume strings escaped before adding to DB
-   $translation = stripslashes($row["translation"]);
-
-   printf("<tr><td>%s</td><td><a href=\"" . $i18nHTMLbase . 
"vote.php?xlang=%s&text=%s&translation=%s\">%s</a></td></tr>\n",
-          W_($row["lang"]),
-          urlencode($row["lang"]),
-         $u,
-         urlencode(from_unicode($translation)),
-         fix(from_unicode($translation)));
- }
+echo "<table border=5 width=95%>\n";
+echo "<tr><th>" . W_("Language") . "</th><th>" . W_("Translation") . 
"</th></tr>\n";
+$query = "SELECT translation,lang FROM map WHERE name=\"$text_sql\" ORDER BY 
ranking DESC";
+$result = mysql_query($query, $connection);
+$num = 0;
+if ($result) 
+  $num = mysql_num_rows($result);
+for ($i=0;$i<$num;$i++) {
+  $row = mysql_fetch_array($result);
+  $translation = $row["translation"];
+  printf("<tr><td>%s</td><td><a href=\"" . $i18nHTMLbase . 
+         "vote.php?xlang=%s&text=%s&translation=%s\">%s</a></td></tr>\n",
+         W_($row["lang"]),
+         urlencode($row["lang"]),
+         urlencode($text_url),  // yes, we need urlencode twice!
+         urlencode(urlencode($translation)), // yes, we need urlencode twice!
+         fix($translation));
+}
 echo "</table>";
-
 H2("Remarks");
 H3("The percent sign");
 W("The %% sign is a special character.");
@@ -104,19 +82,15 @@
 W("The sequence %%s is used as a placeholder for links.");
 W("Currently, the translation can only access the links in the same order as 
the original text.");
 P();
-
 H3("Language specific special characters");
 W("Various languages use special characters.");
 W("The code has not been tested with certain character sets, such as 
Chinese.");
 W("If you are trying to translate the page to such a language, please contact 
the developerws if you encounter any problems.");
 P();
-
 H3("Copyright");
 W("The original english text is released under the GNU Free Documentation 
License (FDL).");
 W("Translations submitted to the webpage must be released to the public domain 
to ensure that we will not have any legal trouble.");
 W("If you have concerns or remarks regarding this policy, feel free to bring 
them to our attention.");
-
 generateFooter();
 echo "</body></html>";
-
 ?>

Deleted: i18nHTML/src/update.php
===================================================================
--- i18nHTML/src/update.php     2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML/src/update.php     2005-04-11 06:25:43 UTC (rev 639)
@@ -1,50 +0,0 @@
-<?php
-include("i18nhtml.inc");
-?>
-# This script merely generates the SQL statements<br>
-# to do the update.  You'll have to run the SQL<br>
-# commands yourself to prevent accidental data loss.<br>
-# <pre>
-<?php
-echo "use $i18nHTMLsqlDB;\n";
-$query = "SELECT * FROM map";
-$result = mysql_query($query, $connection);
-$num = 0;
-$loss = 0;
-if ($result) 
-  $num = mysql_numrows($result);
-for ($ii=0;$ii<$num;$ii++) {
-  $row = mysql_fetch_array($result);
-  $la = mysql_real_escape_string($row["lang"]);
-  $src = mysql_real_escape_string($row["name"]); // urlencoded
-  $dst = $row["translation"]; // possibly urlencoded
-  $rank = $row["ranking"];
-  $rtrans = mysql_real_escape_string(to_unicode(urldecode($dst)));
-  // detect "bad" translations (where conversion failed)
-  // if more than 5 values in [0..9] follow => bad conversion
-  $txtCnt = count_chars(urldecode($src), 1);
-  $tCnt = count_chars($rtrans, 1);
-
-  // 3426
-  if (! ( ereg("&#[0-9]{6}", $rtrans) ||
-          ($txtCnt[ord('%')] != $tCnt[ord('%')]) ||
-          ( ( ($la != "Japanese") &&
-              ($la != "Traditional chinese") &&
-              ($la != "Russian") &&
-              ($la != "Ukrainian") &&
-             (ereg("&#[0-9]{4}", $rtrans)) ) ) ) ) {
-    $dst = mysql_real_escape_string($dst);
-    if ($rtrans != $dst) {
-      $subquery = "UPDATE map SET translation=\"$rtrans\" WHERE name=\"$src\" 
AND lang=\"$la\" AND translation=\"$dst\" AND ranking=$rank;\n";
-      echo "$subquery\n";
-    }
-  } else {
-    $subquery = "DELETE FROM map WHERE name=\"$src\" AND lang=\"$la\" AND 
translation=\"$dst\" AND ranking=$rank;\n";
-    echo "$subquery\n";
-    $loss++;
-  }
- }
-echo "# Lost $loss out of $num translations.\n";
-?>
-# </pre>
-# end of conversion

Copied: i18nHTML/src/update0_1_0.php (from rev 587, i18nHTML/src/update.php)

Added: i18nHTML/src/update0_2_0.php
===================================================================
--- i18nHTML/src/update0_2_0.php        2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML/src/update0_2_0.php        2005-04-11 06:25:43 UTC (rev 639)
@@ -0,0 +1,36 @@
+<?php
+include("i18nhtml.inc");
+?>
+# This script merely generates the SQL statements<br>
+# to do the update.  You'll have to run the SQL<br>
+# commands yourself to prevent accidental data loss.<br>
+# <pre>
+<?php
+echo "use $i18nHTMLsqlDB;\n";
+$query = "SELECT * FROM map";
+$result = mysql_query($query, $connection);
+$num = 0;
+$loss = 0;
+if ($result) 
+  $num = mysql_numrows($result);
+for ($ii=0;$ii<$num;$ii++) {
+  $row = mysql_fetch_array($result);
+  $la = mysql_real_escape_string($row["lang"]);
+  $src = $row["name"]; // urlencoded
+  $src_sql = mysql_real_escape_string($src);
+  $dst_sql = mysql_real_escape_string($row["translation"]);
+  $rank = $row["ranking"];
+  $rname = fix(urldecode($src));
+  $rname_sql = mysql_real_escape_string(fix(urldecode($src)));
+  // detect "bad" translations (where conversion failed)
+  // if more than 5 values in [0..9] follow => bad conversion
+  $txtCnt = count_chars(urldecode($src), 1);
+  $tCnt = count_chars($rtrans, 1);
+
+  $dst = mysql_real_escape_string($dst);
+  $subquery = "UPDATE map SET name=\"$rname_sql\" WHERE name=\"$src_sql\" AND 
lang=\"$la\" AND translation=\"$dst_sql\" AND ranking=$rank;\n";
+  echo "$subquery";
+}
+?>
+# </pre>
+# end of conversion

Modified: i18nHTML/src/vote.php
===================================================================
--- i18nHTML/src/vote.php       2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML/src/vote.php       2005-04-11 06:25:43 UTC (rev 639)
@@ -17,26 +17,25 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-  // This file records votes from users for translations.
-  // For sentences with multiple translations, the one with the most
-  // votes is displayed.
+// This file records votes from users for translations.
+// For sentences with multiple translations, the one with the most
+// votes is displayed.
 include("i18nhtml.inc");
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
-echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" >";
 TITLE("WWW translation: vote");
 echo "</head><body>";
 if (!$connection) {
   echo "Database is down. Cannot edit translations.";
   die();
  } 
-$text = $_REQUEST['text'];
-$translation = $_REQUEST['translation'];
-$u = mysql_real_escape_string($text);
-$t = mysql_real_escape_string(to_unicode($translation));
-echo "text = " . $text . "<br>\n";
-echo "translation = " . $translation . "<br>\n";
+$text            = fix(urldecode($_REQUEST['text']));
+$translation     = fix(urldecode($_REQUEST['translation']));
+$text_sql        = mysql_real_escape_string($text);
+$translation_sql = mysql_real_escape_string(to_unicode($translation));
 
-$query = "SELECT ranking FROM map WHERE name=\"$u\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+$query = "SELECT ranking FROM map WHERE " .
+         "name=\"$text_sql\" AND lang=\"$lang\" AND 
translation=\"$translation_sql\"";
 $result = mysql_query($query, $connection);
 $num = 0;
 if ($result) 
@@ -44,11 +43,13 @@
 if ($num > 0) {
   $row = mysql_fetch_array($result);
   $ranking = $row["ranking"] + 1;
-  $query = "UPDATE map SET ranking=\"$ranking\" WHERE name=\"$u\" AND 
lang=\"$lang\" AND translation=\"$t\"";
+  $query = "UPDATE map SET ranking=\"$ranking\" WHERE " .
+           "name=\"$text_sql\" AND lang=\"$lang\" AND 
translation=\"$translation_sql\"";
   mysql_query($query, $connection);
   W("Ranking of translation is now: ");
   echo "$ranking";
- } else {
-  W("Translation does not exist (bug?).");
- }
+} else {
+  W("Translation '%s' of '%s' does not exist (bug?).",
+    ARRAY($translation, $text));
+}
 ?>

Modified: i18nHTML-docs/WWW/commitMassTranslation.php
===================================================================
--- i18nHTML-docs/WWW/commitMassTranslation.php 2005-04-11 06:23:40 UTC (rev 
638)
+++ i18nHTML-docs/WWW/commitMassTranslation.php 2005-04-11 06:25:43 UTC (rev 
639)
@@ -26,6 +26,7 @@
   W("Translating to English currently not allowed.\n");
   die();
 }
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
 TITLE("WWW translation: commit");
 echo "</head><body>";
@@ -37,6 +38,7 @@
     continue;
   if ( ($dec == "xlang") || ($dec == "start") )
     continue;
+  $val = fix($val);
   $query = "SELECT c FROM pending WHERE lang=\"$xlang\"";
   $result = mysql_query($query, $connection);
   $num = 0;
@@ -45,8 +47,10 @@
   while ($num > 0) {
     $num--;
     $row = mysql_fetch_array($result);
-    if ($dec == bin2hex(md5(urldecode($row["c"])))) {
-      $enc = mysql_real_escape_string($row["c"]);
+    $cx_plain = fix($row["c"]);
+    $cx_sql = mysql_real_escape_string($cx_plain);
+    if ($dec == bin2hex(md5($cx_plain))) {
+      $enc_sql = $cx_sql;
       break;
     }
   }
@@ -56,30 +60,32 @@
     P();
     continue;
   }  
-  $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$enc\"";
+  $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$enc_sql\"";
   mysql_query($query, $connection); 
-  $t = mysql_real_escape_string(to_unicode($val));
-  $query = "SELECT ranking FROM map WHERE name=\"$enc\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+  $val_sql = mysql_real_escape_string(to_unicode($val));
+  $query = "SELECT ranking FROM map WHERE name=\"$enc_sql\"" .
+           " AND lang=\"$lang\" AND translation=\"$val_sql\"";
   $result = mysql_query($query, $connection);
   $num = 0;
   if ($result) 
     $num = mysql_numrows($result);
   if ($num == 0) {
-    $txtCnt = count_chars(urldecode($enc), 1);
-    $tCnt = count_chars($t, 1);
+    $txtCnt = count_chars(stripslashes($enc_sql), 1);
+    $tCnt = count_chars(stripslashes($val_sql), 1);
     if ($txtCnt[ord('%')] != $tCnt[ord('%')]) {
-      W("Commit '%s->%s' failed.", $enc, $t);
+      W("Commit '%s->%s' failed.", stripslashes($enc_sql), 
stripslashes($val_sql));
       W("The number of percent signs in source text and translation do not 
match.");     
       W("Note that you must preserve all %%s expressions unchanged.");
       W("Also, a single displayed %% sign must be translated into two (%%%%) 
such signs.");
       P();
     } else {
-      $query = "INSERT INTO map VALUES(\"$enc\", \"$lang\", \"$t\", 1, \"" . 
$_SERVER['REMOTE_ADDR'] . "\");";
+      $query = "INSERT INTO map VALUES(\"$enc_sql\", \"$lang\", " .
+               "\"$val_sql\", 1, \"" . $_SERVER['REMOTE_ADDR'] . "\");";
       mysql_query($query, $connection);
       $done++;
       W("Storing translation for &quot;%s&quot = &quot;%s&quot;.",
-        ARRAY(urldecode($enc),
-             urldecode($t)));
+        ARRAY(stripslashes($enc_sql),
+             stripslashes($val_sql)));
       BR();  
     }
   }  

Modified: i18nHTML-docs/WWW/commitTranslation.php
===================================================================
--- i18nHTML-docs/WWW/commitTranslation.php     2005-04-11 06:23:40 UTC (rev 
638)
+++ i18nHTML-docs/WWW/commitTranslation.php     2005-04-11 06:25:43 UTC (rev 
639)
@@ -18,9 +18,6 @@
      Boston, MA 02111-1307, USA.
 */
 include("i18nhtml.inc");
-$text = mysql_real_escape_string($_REQUEST['text']);
-$translation = $_REQUEST['translation'];
-$back = $_REQUEST['back'];
 if (!$connection) {
   echo "Database is down. Cannot edit translations.";
   die();
@@ -29,39 +26,47 @@
   W("Translating to English is not allowed.\n");
   die();
 }
+$text            = urldecode($_REQUEST['text']);
+$text_sql        = mysql_real_escape_string($text);
+$translation     = fix($_REQUEST['translation']);
+$translation_sql = mysql_real_escape_string(to_unicode($translation));
 
-$t = mysql_real_escape_string(to_unicode($translation));
+$back            = $_REQUEST['back'];
 // check for identical translation
-$query = "SELECT ranking FROM map WHERE name=\"$text\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+$query = "SELECT ranking FROM map WHERE name=\"$text_sql\"" . 
+         " AND lang=\"$lang\" AND translation=\"$translation_sql\"";
 $result = mysql_query($query, $connection);
 $num = 0;
-if ($result) {
+if ($result) 
   $num = mysql_numrows($result);
-}
 if ($num > 0) {
   echo "<html><head>";
   TITLE("Translation exists.");
   echo "</head><body>";
-  W("Translation exists.");   
+  W("Translation '%s' of sentence '%s' exists.",
+    fix($translation), $text);   
   extlink($back, "Back...");
   generateFooter();
   echo "</body></html>";
 } else {
-  $txtCnt = count_chars(urldecode($text), 1);
-  $tCnt = count_chars($t, 1);
+  $txtCnt = count_chars($text, 1);
+  $tCnt   = count_chars($translation, 1);
   if ($txtCnt[ord('%')] != $tCnt[ord('%')]) {
       echo "<html><head>";
       TITLE("Commit failed.");
       echo "</head><body>";
-      W("Commit failed.");
-      W("The number of percent signs in source text and translation do not 
match.");     
+      W("Commit failed ('%s' and '%s').", ARRAY($text, $translation));
+      W("The number of percent signs in source text and translation does not 
match.");     
       W("Note that you must preserve all %%s expressions unchanged.");
       W("Also, a single displayed %% sign must be translated into two (%%%%) 
such signs.");
       echo "</body></html>";
   } else {
-    $query = "INSERT INTO map VALUES(\"$text\", \"$lang\", \"$t\", 1, \"" . 
$_SERVER['REMOTE_ADDR'] . "\");";
+    $query = "INSERT INTO map VALUES(\"$text_sql\", \"$lang\", " .
+             "\"$translation_sql\", 1, \"" . $_SERVER['REMOTE_ADDR'] . "\");";
     $result = mysql_query($query, $connection);
     if ($result) {
+      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$text_sql\"";
+      mysql_query($query, $connection); 
       header("Location: " . $back); /* Redirect browser */
     } else {
       echo "<html><head>";

Modified: i18nHTML-docs/WWW/editor.php
===================================================================
--- i18nHTML-docs/WWW/editor.php        2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML-docs/WWW/editor.php        2005-04-11 06:25:43 UTC (rev 639)
@@ -22,6 +22,7 @@
   echo "Database is down. Cannot edit translations.";
   die();
 }
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
 TITLE("WWW translation");
 echo "</head><body>";
@@ -51,12 +52,12 @@
   $start = $end - $max;
   if ($start < 0)
     $start = 0;
- }
+}
 
 if ($num == 0) {
   P();
   W("No missing translations for the selected target language were found.");
- } else {
+} else {
   P();
   W("%s translations to %s have been requested and were not available.",
     ARRAY($num,
@@ -71,45 +72,39 @@
   echo "<input type=hidden name=\"start\" value=\"$endp\">";
   
   echo "<table border=5>";
-  echo "<tr><th>";
-  W("Original");
-  echo "</th><th>";
-  W("Translation");
-  echo "</th></tr>";
+  echo "<tr>";
+  TH("Original");
+  TH("Translation");
+  echo "</tr>";
   for ($ii=0;$ii<$end;$ii++) {
     $row = mysql_fetch_array($result);
     if ($ii < $start)
       continue;
-    $cx = $row["c"];
+    $cx_plain = fix($row["c"]);
+    $cx_sql = mysql_real_escape_string($cx_sql);
     
-    $query = "SELECT ranking FROM map WHERE name=\"$cx\" AND lang=\"$lang\"";
+    $query = "SELECT ranking FROM map WHERE name=\"$cx_sql\" AND 
lang=\"$lang\"";
     $result2 = mysql_query($query, $connection);
     $num2 = 0;
     if ($result2) 
       $num2 = mysql_numrows($result2);
+    echo "<tr><td width=\"45%\">";
+    echo "&quot;$cx_plain&quot;";
+    echo "</td>\n\t<td width\"50\%\">";
     if ($num2 > 0) {
-      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$cx\"";
-      mysql_query($query, $connection); 
-      
-      echo "<tr><td width=\"45%\">";
-      $dec = urldecode($cx);
-      echo "&quot;" . $dec . "&quot;";
-      echo "</td>\n\t<td width\"50\%\">";
+      $query = "DELETE FROM pending WHERE lang=\"$lang\" AND c=\"$cx_sql\"";
+      mysql_query($query, $connection);      
       W("Skipped (already translated).");
+    } else {
+      echo "<input size=\"40\" maxlength=\"65535\" name=\"" . 
bin2hex(md5($cx_plain)) . "\"></td></tr>\n";
     }
-    else {
-      echo "<tr><td width=\"45%\">";
-      $dec = urldecode($cx);
-      echo "&quot;" . $dec . "&quot;";
-      echo "</td>\n\t<td width\"50\%\">";
-      echo "<input size=\"40\" maxlength=\"65535\" name=\"" . 
bin2hex(md5($dec)) . "\"></td></tr>\n";
-    }
   }
   echo "</tr></table>";
-  echo "<input type=submit value=\"I hereby give all these translations into 
the Public Domain (commit)\">";
+  echo "<input type=submit value=\"" . 
+       TRANSLATE_("I hereby give all these translations into the Public Domain 
(commit)") . 
+       "\">";
   echo "</form>";
-  
- }
+}
 if ($end < $num) {
   P();
   echo "<a href=\"" . $i18nHTMLbase . "editor.php?xlang=" . $lang . "&start=" 
. ($end + 1) . "\">";
@@ -117,10 +112,10 @@
   echo "</a>";
   if ($t == 1)
     translateLink($b);
- } else {
+} else {
   W("Statistics about translation progress can be found %s.\n",
     intlink_($i18nHTMLbase . "status.php", "here"));
- }
+}
 P();
 H2("Remarks");
 H3("The percent sign");

Modified: i18nHTML-docs/WWW/i18nhtml.inc
===================================================================
--- i18nHTML-docs/WWW/i18nhtml.inc      2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML-docs/WWW/i18nhtml.inc      2005-04-11 06:25:43 UTC (rev 639)
@@ -17,7 +17,6 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-
   // This file defines the functions that will be used
   // to build the webpage.  The set may not contain everything
   // you might want, so feel free to define your own extensions.
@@ -35,13 +34,13 @@
   // Most of the code should be straight forward. Look
   // at some of the example files that use it and compare with
   // the generated pages. 
-
-
 // obtain user db specific configuration parameters
 include("i18nhtml_config.inc");
-
 header("Content-type: text/html; charset=utf-8");
 
+if (get_magic_quotes_gpc())
+  die('PHP misconfigured.  Disable get_magic_quotes.');
+
 // establish default connection to database server
 $connection = @mysql_connect($i18nHTMLsqlServer,
                             $i18nHTMLsqlUser,
@@ -57,24 +56,24 @@
   if (!$db_selected) {
      die ('Error selecting db : ' . mysql_error());
   }
- }
+}
 
 // ensure the mapping and pending tables exist, creating them if not
 $query="CREATE TABLE IF NOT EXISTS map" .
        " (name BLOB, lang TINYBLOB, translation BLOB, ranking INT, ip 
TINYTEXT, " .
        "INDEX(name(10)), INDEX(lang(4)), INDEX(ranking), 
INDEX(translation(10)))";
 $result = mysql_query($query, $connection);
-//if (!$result) {
-//   die('Unable to validate mapping table.  Invalid query: ' . mysql_error());
-//}
+if (($i18nHTMLdebug == 1) && (!$result)) {
+  die('Unable to validate map table.  Invalid query: ' . mysql_error());
+}
 
 $query="CREATE TABLE IF NOT EXISTS pending" .
        " (c BLOB, lang TINYBLOB, count INT, " .
        "INDEX(c(10)), INDEX(lang(4)), INDEX(count))";
 $result = mysql_query($query, $connection);
-//if (!$result) {
-//   die('Unable to validate pending table.  Invalid query: ' . mysql_error());
-//}
+if (($i18nHTMLdebug == 1) && (!$result)) {
+  die('Unable to validate pending table.  Invalid query: ' . mysql_error());
+}
 
 /* mapping of real-names to language codes */
 $languagecodes = array("English"=>"en",
@@ -102,7 +101,7 @@
                       "Swedish"=>"sv");
 
 /* try to automagically figure out user preferences */
-$hlang=$_SERVER["HTTP_ACCEPT_LANGUAGE"];
+$hlang = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
 if ($hlang) {
   $tok = strtok($hlang, ";");
   while ($tok) {
@@ -114,7 +113,7 @@
     }
     $tok = strtok(";");
   }
- }
+}
 // If no language is specified, use english.
 if ( (! $lang) || ($lang=="") )
   $lang = "English";
@@ -124,21 +123,23 @@
 $lang = ucfirst(strtolower($lang));
 $lang = mysql_real_escape_string($lang);
 $editor = $_REQUEST['editor'];
+$i18nHTMLhasTranslation = 0; // set by last call to translation_query()
 
-
-$htmlin  = array("&rsquo;", "&gt;", "&quot;", "&prime;", "&amp;");
-$htmlout = array("&#8217;" , "&#62;", "&#34;" , "&#8242" , "&#38;");
-
 /**
  * Replace certain HTML named special characters with their
  * numeric codes (some browsers don't work with the symbolic names).
  */
+$htmlin  = array("&rsquo;", "&gt;",  "&quot;", "&prime;", "&amp;", "\"",    
"'",      "`",       "&lsquo;");
+$htmlout = array("&#8217;", "&#62;", "&#34;" , "&#8242;", "&#38;", "&#34;", 
"&#8242;", "&#8217;", "&#8216;");
 function fix($a) {
   global $htmlin;
   global $htmlout;
   return str_replace($htmlin, $htmlout, $a);
 }
 
+// *************************************************
+// i18nHTML configuration API functions 
+// *************************************************
 
 // change the marker text shown to indicate text
 // is translatable (link to translate page text)
@@ -151,46 +152,18 @@
     $i18nHTMLmarker = $marker;
 }
 
+// ***************************************************
+// i18nHTML _internal_ API functions (don't look here)
+// ***************************************************
 
-// editor = ?         ;      // set by URL parameter, indicates in translation 
mode
-$i18nHTMLhasTranslation = 0; // set by last call to isTranslated() or 
translation_query()
-$i18nHTMLallowedits = 1;
-
-// indicate translate link should only be shown for untranslated items.
-function editOnlyUntranslatedText() {
-  global $i18nHTMLallowedits;
-  $i18nHTMLallowedits = 0;
-}
-
-// indicate translate link should always be shown (or set to indicated value).
-function editAllTranslations($v=null) {
-  global $i18nHTMLallowedits;
-  if ($v == "")
-    $i18nHTMLallowedits = 1;
-  else
-    $i18nHTMLallowedits = $v;
-}
-
-
-// displays a link to the page to enable one to
-// translate the given text ($a)
-// see translateLink_
-function translateLink($a, $hasTranslation=null) {
-  echo translateLink_($a, $hasTranslation);
-}
-
-// returns a HTML string to link to enable one to
-// translate the given text ($a) when
-// $editor has a nonzero value and either
-// $hasTranslation is 0 or $allowedits is nonzero;
-// otherwise and empty string ("") is returned.
-// $hasTranslation may be omitted to use result of
-// last isTranslated() or translation_query() call;
-function translateLink_($a, $hasTranslation=null) {
+// returns a HTML string to link to enable one to translate the given
+// text ($a) when $editor has a nonzero value or
+// $i18nHTMLhasTranslation is 0; otherwise and empty string ("") is
+// returned.
+function translateLink_($a) {
   global $lang;
   global $HTTP_SERVER_VARS;
   global $editor;
-  global $i18nHTMLallowedits;
   global $i18nHTMLhasTranslation;
   global $i18nHTMLmarker;
   global $i18nHTMLbase;
@@ -201,112 +174,21 @@
     $back = "http://"; . $HTTP_SERVER_VARS["HTTP_HOST"] . 
$HTTP_SERVER_VARS["REQUEST_URI"];
     return "<a href=\"" . $i18nHTMLbase . "translate.php?xlang=" 
       . $lang 
-      . "&amp;text=" . urlencode($a)
+      . "&amp;text=" . urlencode(fix($a))
       . "&amp;back=" . urlencode($back) 
       . "\">" . $i18nHTMLmarker . "</a>\n";
   } else
     return "";   
 }
 
-// return 1 if translation is available (or DB down)
-// assumes passed the original text as appears in source
-function isTranslated($a, $charset=null) {
-  global $connection;
-  global $lang;
-  global $editor;
-  global $i18nHTMLhasTranslation;
-
-  $i18nHTMLhasTranslation = 1; // assume translation until failure
-
-  if ( ("English" == $lang) || (!$connection) ) {
-    // Either hard-wired source language (so available) or
-    // database not available.
-    return 1;
-  }
-
-  //  $a = htmlentities($a, ENT_QUOTES, $charset);
-  $u = urlencode($a);
-
-  $query = "SELECT translation FROM map WHERE name=\"$u\" AND lang=\"$lang\" 
ORDER BY ranking DESC";
-  $result = mysql_query($query, $connection);
-  if (!$result) {
-    if ($i18nHTMLdebug != 0)
-      echo 'Unable to execute query $query: ' . mysql_error();
-  }
-
-  $num = 0;
-  if ($result)
-    $num = mysql_numrows($result);
-  if ($num > 0)
-    return 1;
-  else {
-    $i18nHTMLhasTranslation = 0; // no translation was found
-    return 0;   
-  }
+// displays a link to the page to enable one to
+// translate the given text ($a)
+// see translateLink_
+function translateLink($a) {
+  echo translateLink_($a);
 }
 
-
 /**
- * restore UTF-8 from HTML Unicode entities
- *
- * This function is triggered by the YACS handler during page
- * rendering.  It is aiming to transcode HTML Unicode entities
- * (eg, &amp;#8364;) back to actual UTF-8 encoding (eg, �).
- *
- * @param string a string with a mix of UTF-8 and of HTML Unicode entities
- * @return an UTF-8 string
- */
-function from_unicode($text) {
-  // translate extended ISO8859-1 chars, if any
-  $text = utf8_encode($text);
-  
-  // translate Unicode entities
-  $areas = preg_split('/&#(\d+?);/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
-  $text = '';
-  $index = 0;
-  foreach($areas as $area) {
-    switch($index%2) {
-    case 0: // before entity
-      $text .= $area;
-      break;
-    case 1: // the entity itself
-      
-      // get the integer value
-      $unicode = intval($area);
-      
-      // one byte
-      if($unicode < 0x80) {
-       
-       $text .= chr($unicode);
-       
-       // two bytes
-      } elseif($unicode < 0x800) {
-       
-       $text .= chr( 0xC0 +  ( ( $unicode - ( $unicode % 0x40 ) ) / 0x40 ) );
-       $text .= chr( 0x80 + ( $unicode % 0x40 ) );
-       
-       // three bytes
-      } elseif($unicode < 0x10000) {
-       
-       $text .= chr( 0xE0 + ( ( $unicode - ( $unicode % 0x1000 ) ) / 0x1000 ) 
);
-       $text .= chr( 0x80 + ( ( ( $unicode % 0x1000 ) - ( $unicode % 0x40 ) ) 
/ 0x40 ) );
-       $text .= chr( 0x80 + ( $unicode % 0x40 ) );
-       
-       // more bytes, keep it as it is...
-      } else
-         $text .= '&#'.$unicode.';';
-      
-      break;
-    }
-    $index++;
-  }
-  
-  // the updated string
-  return $text;
-}
-
-
-/**
  * transcode unicode entities to/from HTML entities
  *
  * Also, this function transforms HTML entities into their equivalent Unicode 
entities.
@@ -319,8 +201,7 @@
  * @param boolean TRUE to transcode to Unicode, FALSE to transcode to HTML
  * @return a transcoded string
  */
-function transcode($input, $to_unicode=TRUE) {
-  
+function transcode($input, $to_unicode=TRUE) { 
   // initialize tables only once
   static $html_entities, $unicode_entities;
   if(!is_array($html_entities)) {
@@ -583,8 +464,7 @@
       $unicode_entities[] = $unicode_entity;
       $html_entities[] = $html_entity;
     }
-  }
-  
+  }  
   // transcode HTML entities to Unicode
   if($to_unicode)
     return str_replace($html_entities, $unicode_entities, $input);
@@ -594,9 +474,6 @@
     return str_replace($unicode_entities, $html_entities, $input);
 }
 
-
-
-
 /**
  * transcode multi-byte characters to HTML representations for Unicode
  *
@@ -618,119 +495,79 @@
  * @param string the original UTF-8 string
  * @return a string acceptable in an ISO-8859-1 storage system (ie., PHP4 + 
MySQl 3)
  */
-function to_unicode($input) {
-  
+function to_unicode($input) { 
   // transcode HTML entities to Unicode entities
-  $input = transcode($input);
-  
+  $input = transcode($input);  
   // scan the whole string
   $output = '';
   $index = 0;
-  while($index < strlen($input)) {
-    
+  while($index < strlen($input)) {  
     // look at one char
-    $char = ord($input[$index]);
-    
+    $char = ord($input[$index]);    
     // one byte (0xxxxxxx)
-    if($char < 0x80) {
-      
+    if ($char < 0x80) {      
       // some chars may be undefined
       $output .= chr($char);
-      $index += 1;
-      
+      $index += 1;      
       // two bytes (110xxxxx 10xxxxxx)
-    } elseif($char < 0xE0) {
-      
+    } else if ($char < 0xE0) {      
       // strip weird sequences (eg, C0 80 -> NUL)
       if($value = (($char % 0x20) * 0x40) + (ord($input[$index + 1]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 2;
-      
+      $index += 2;      
       // three bytes (1110xxxx 10xxxxxx 10xxxxxx) example: euro sign = 
\xE2\x82\xAC -> &#8364;
-    } elseif($char < 0xF0) {
-      
+    } else if ($char < 0xF0) {      
       // strip weird sequences
       if($value = (($char % 0x10) * 0x1000) + ((ord($input[$index + 1]) % 
0x40) * 0x40) + (ord($input[$index + 2]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 3;
-      
+      $index += 3;      
       // four bytes (11110xxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } elseif($char < 0xF8) {
-      
+    } else if($char < 0xF8) {      
       // strip weird sequences
-      if($value = (($char % 0x08) * 0x40000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000) + ((ord($input[$index + 2]) % 0x40) * 0x40)
+      if ($value = (($char % 0x08) * 0x40000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000) + ((ord($input[$index + 2]) % 0x40) * 0x40)
         + (ord($input[$index + 3]) % 0x40))
        $output .= '&#' . $value . ';';
-      $index += 4;
-      
+      $index += 4;      
       // five bytes (111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } elseif($char < 0xFC) {
-      
+    } else if($char < 0xFC) {      
       // strip weird sequences
-      if($value = (($char % 0x04) * 0x1000000) + ((ord($input[$index + 1]) % 
0x40) * 0x40000) + ((ord($input[$index + 2]) % 0x40) * 0x1000)
+      if ($value = (($char % 0x04) * 0x1000000) + ((ord($input[$index + 1]) % 
0x40) * 0x40000) + ((ord($input[$index + 2]) % 0x40) * 0x1000)
         + ((ord($input[$index + 3]) % 0x40) * 0x40) + (ord($input[$index + 4]) 
% 0x40))
        $output .= '&#' . $value . ';';
-      $index += 5;
-      
+      $index += 5;      
       // six bytes (1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
-    } else {
-      
+    } else {      
       // strip weird sequences
-      if($value = (($char % 0x02) * 0x40000000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000000) + ((ord($input[$index + 2]) % 0x40) * 0x40000)
+      if ($value = (($char % 0x02) * 0x40000000) + ((ord($input[$index + 1]) % 
0x40) * 0x1000000) + ((ord($input[$index + 2]) % 0x40) * 0x40000)
         + ((ord($input[$index + 3]) % 0x40) * 0x1000) + ((ord($input[$index + 
4]) % 0x40) * 0x40) + (ord($input[$index + 4]) % 0x40))
        $output .= '&#' . $value . ';';
       $index += 6;
-    }
-    
-  }
- 
+    }    
+  } 
   // return the translated string
   return $output;
 }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-// returns either the translated string
-// or the original string.  Assumes we
-// are passed the original string as occurs
-// in text; result will be html tokenized by
-// htmlentities() using default charset or
-// one indicated by $charset, to ensure all
-// required entities are converted for valid html output.
-// Note: it is assumed value in DB have already
-// ran through equivalent of htmlentities().
-// $i18nHTMLhasTranslation is set to nonzero value
-// if a translation is available or failure connecting
-// to database, otherwise it is set to 0.
-function translation_query($a, $charset=null) {
+// returns either the translated string or the original string.
+// Assumes we are passed the original string as occurs in text; result
+// will be html tokenized by htmlentities() using UTF8.
+// $i18nHTMLhasTranslation is set to nonzero value if a translation is
+// available or failure connecting to database, otherwise it is set to
+// 0.
+function translation_query($a) {
   global $connection;
   global $lang;
   global $i18nHTMLrecordMode;
   global $i18nHTMLhasTranslation;
   
   $i18nHTMLhasTranslation = 1; // assume translation until failure
-
   if ($a == "")
     return $a;
-
-  $u = mysql_real_escape_string(urlencode($a));
-  
+  $a = fix($a);
+  $a_sql = mysql_real_escape_string($a);
   if (!$connection) {
     // database not available, just print English
-    return fix($a);
+    return $a;
   }
   if ("English" == $lang) {
     // no need to translate english, that's the
@@ -738,20 +575,20 @@
     if ($i18nHTMLrecordMode == 2) {
       // if not already in pending table (and recordMode set to allow us)
       // then insert this string into it
-      $query = "SELECT count FROM pending WHERE c=\"$u\" AND lang=\"$lang\"";
+      $query = "SELECT count FROM pending WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       $result = mysql_query($query, $connection);
       $num = 0;
       if ($result)
         $num = mysql_num_rows($result);
       if (0 == $num) {
-        $query = "INSERT INTO pending VALUES(\"$u\", \"$lang\", 0)";
+        $query = "INSERT INTO pending VALUES(\"$a_sql\", \"$lang\", 0)";
         mysql_query($query, $connection);
       }
     }
-    return fix($a);
+    return $a;
   }
   // attempt to get translations, ranked for best
-  $query = "SELECT translation FROM map WHERE name=\"$u\" AND lang=\"$lang\" 
ORDER BY ranking DESC";
+  $query = "SELECT translation FROM map WHERE name=\"$a_sql\" AND 
lang=\"$lang\" ORDER BY ranking DESC";
   $result = mysql_query($query, $connection);
   $num = 0;
   if ($result)
@@ -761,7 +598,7 @@
       // either insert untranslated item into pending table or update
       // referenced count; count is used to display more used strings
       // during mass translation before less common ones.
-      $query = "SELECT count FROM pending WHERE c=\"$u\" AND lang=\"$lang\"";
+      $query = "SELECT count FROM pending WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       $result = mysql_query($query, $connection);
       $num = 0;
       if ($result)
@@ -770,20 +607,24 @@
       if ($num > 0) {
         $row = mysql_fetch_array($result);
         $count = $row["count"] + 1;
-        $query = "UPDATE pending SET count=$count WHERE c=\"$u\" AND 
lang=\"$lang\"";
+        $query = "UPDATE pending SET count=$count WHERE c=\"$a_sql\" AND 
lang=\"$lang\"";
       } else {
-        $query = "INSERT INTO pending VALUES(\"$u\", \"$lang\", 1)";
+        $query = "INSERT INTO pending VALUES(\"$a_sql\", \"$lang\", 1)";
       }
       mysql_query($query, $connection);       
     }
     $i18nHTMLhasTranslation = 0; // no translation was found
-    return fix($a);              // just return English string
+    return $a;              // just return English string
   } else { // translation available
     $row = mysql_fetch_array($result);
     return $row["translation"];
   }
 }
 
+// *************************************************
+// Fundamental i18nHTML API functions 
+// *************************************************
+
 // translate the sentence $a and return the result.
 function TRANSLATE_($a,$args=null) {
   if ($a == "")
@@ -791,6 +632,12 @@
   return vsprintf(translation_query($a), $args);
 }
 
+// translate the sentence $a and output just
+// the translated text (without link to translate.php)
+function TRANSLATE($a,$args=null) {
+  echo TRANSLATE_($a);
+}
+
 // translate the sentence $a adding a link
 // to enable editing translations and return the result.
 function W_($a,$args=null) {
@@ -799,81 +646,16 @@
   return TRANSLATE_($a,$args) . translateLink_($a);
 }
 
-// translate the sentence $a and output just
-// the translated text
-function TRANSLATE($a,$args=null) {
-  echo TRANSLATE_($a);
-}
-
 // translate the sentence $a appending a link
 // to enable edit the translation and output the
-// result. Returns 1 if a translation is needed.
+// result.
 function W($a, $args=NULL) {
-  global $i18nHTMLhasTranslation;
-
-  if ($a == "")
-    return 0;
-  echo W_($a, $args) . "\n";
-  return $i18nHTMLhasTranslation;
+  if ($a != "")
+    echo W_($a, $args) . "\n";
 }
 
-function LI($a,$b="") {
-  echo "<li>" . W_($a,$b) . "</li>\n";
-}
-
-function TITLE($a,$b="") {
-  global $lang;
-  global $languagecodes;
-  echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" 
>";
-  echo "<title>" . TRANSLATE_($a,$b) . "</title>\n";
-  if (isset($languagecodes[$lang])) {
-    echo "<meta name=\"content-language\" content=\"" . 
-         $languagecodes[$lang] . "\">";
-    echo "<meta name=\"language\" content=\"" . 
-         $languagecodes[$lang] . "\">";
-  }
-}
-
-
-function DT($a,$b="") {
-  echo "<dt>" . W_($a,$b) . "</dt>\n";
-}
-function DD($a,$b="") {
-  echo "<dd>" . W_($a,$b) . "</dd>\n";
-}
-function H1($a,$b="") {
-  echo "<h1>" . W_($a,$b) . "</h1>\n";
-}
-function H2($a,$b="") {
-  echo "<h2>" . W_($a,$b) . "</h2>\n";
-}
-function H3($a,$b="") {
-  echo "<h3>" . W_($a,$b) . "</h3>\n";
-}
-function H4($a,$b="") {
-  echo "<h4>" . W_($a,$b) . "</h4>\n";
-}
-function H5($a,$b="") {
-  echo "<h5>" . W_($a,$b) . "</h5>\n";
-}
-// 'verbatim' (untranslated) "pre"
-function PRE($a) {
-  echo "<pre>" . $a . "</pre>";
-}
-// 'verbatim' (untranslated) "li"
-function LIV($a) {
-  echo "<li>" . $a . "</li>\n";
-}
-
-
 // create internationalized, internal link to
 // $a.php with description $b 
-function intlink($a, $b) {  
-  echo intlink_($a, $b);
-}
-
-// create internationalized, internal link to
-// $a.php with description $b 
 function intlink_($a, $b) {  
   global $lang;
   
@@ -882,10 +664,10 @@
   return $ret;
 }
 
-// create internationalized, external link to
-// $a with description $b 
-function extlink($a, $b) {  
-  echo extlink_($a, $b);
+// create internationalized, internal link to
+// $a.php with description $b 
+function intlink($a, $b) {  
+  echo intlink_($a, $b);
 }
 
 // create internationalized, external link to
@@ -895,46 +677,17 @@
   return $ret;
 }
 
-function P($attr="") {
-  echo "<p $attr>\n";
+// create internationalized, external link to
+// $a with description $b 
+function extlink($a, $b) {  
+  echo extlink_($a, $b);
 }
 
-function BR() {
-  echo "<br />\n";
-}
 
-function HR() {
-  echo "<hr>\n";
-}
-function DTDD($a,$b) {
-  DT($a);
-  DD($b);
-}
-function LILI($a,$b) {
-  echo "<li>" . extlink_($a,$b) . "</li>\n";
-}
-function IMG($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
-  echo IMG_($src, $alt, $align, $width, $height, $border, $hspace, $vspace);
-}
+// *************************************************
+// global, call-once helper functions
+// *************************************************
 
-function IMG_($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
-  $ret = "";
-  
-  if ($align == "CENTER") 
-    $ret = $ret . "<p><center>\n";
-  $ret = $ret . "<img src=\"" . $src . "\" alt=\"";
-  $ret = $ret . TRANSLATE_($alt);
-  $ret = $ret . "\" align=\"" . $align . "\" width=$width height=$height 
border=$border hspace=$hspace vspace=$vspace>\n";
-  $ret = $ret . translateLink_($alt);
-  if ($align == "CENTER") 
-    $ret = $ret . "</center><p>\n";
-  return $ret;
-}
-
-function ANCHOR($a) {
-  echo "<a name=\"$a\"></a>\n";
-}
-
 // outputs appropriate DOCTYPE declaration for the document
 // this should be the 1st line in your php file after including
 // i18nhtml.inc.  Valid types are: HTML for HTML 4 documents,
@@ -944,62 +697,68 @@
 // "Strict", or "Frameset", defaulting to "Transitional".
 // Note for XHTML1.1 $mode is ignored.
 // example:  
-//           -?php 
-//           include("../src/i18nhtml.inc");
+//           include("i18nhtml.inc");
 //           DOCTYPE("XHTML1");
-//           echo "<head><title>Blah</title><body>Blah...</body></html>";
-//           ?-
 function DOCTYPE($type=null, $mode=null) {
   // depending on $mode, use appropriate dtd
   if ($mode == "Strict") {
     $dtd = "strict";
     if ($type != "XHTML1") // Strict not specified except for XHTML1.0
       $mode = "";
-  }
-  elseif ($mode == "Frameset") {
+  } else if ($mode == "Frameset") {
     $dtd = "frameset";
-  }
-  else { // $mode == Transitional, default, or unknown
+  } else { // $mode == Transitional, default, or unknown
     $dtd = "loose";
     $mode = "Transitional";
   }
-
   if ($type == "XHTML1")
     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 " . $mode . "//EN\" 
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-"; . $dtd . ".dtd\">\n";
-  elseif ($type == "XHTML1.1")
+  else if ($type == "XHTML1.1")
     echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" 
\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\";>\n";
   else
     echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " . $mode . "//EN\" 
\"http://www.w3.org/TR/html4/"; . $dtd . ".dtd\">\n";
 }
 
+function TITLE($a,$b="") {
+  global $lang;
+  global $languagecodes;
+  echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" 
>";
+  echo "<title>" . TRANSLATE_($a,$b) . "</title>\n";
+  if (isset($languagecodes[$lang])) {
+    echo "<meta name=\"content-language\" content=\"" . 
+         $languagecodes[$lang] . "\">";
+    echo "<meta name=\"language\" content=\"" . 
+         $languagecodes[$lang] . "\">";
+  }
+}
 
 // displays a list of all languages currently available with
 // at least 1 translated string.
 function generateLanguageBar() {
   global $connection;
 
-if ($connection) {
-  echo "<center>[";
-  $query = "SELECT DISTINCT lang FROM map ORDER BY lang";
-  $result = mysql_query($query, $connection);
-  $num = 0;
-  if ($result)   
-    $num = mysql_numrows($result);
-  echo "<a href=\"?xlang=English\">";
-  W("English");
-  echo "</a>";
-  $last = "English";
-  for ($i=0;$i<$num;$i++) {
-    $row = mysql_fetch_array($result);
-    $next = $row["lang"];
-    if ($next == $last)
-      continue;
-    echo " | ";
-    echo "<a href=\"?xlang=$next\">" . W_($next) . "</a>";
-    $last = $next;
+  if ($connection) {
+    echo "<center>[";
+    $query = "SELECT DISTINCT lang FROM map ORDER BY lang";
+    $result = mysql_query($query, $connection);
+    $num = 0;
+    if ($result)   
+      $num = mysql_numrows($result);
+    echo "<a href=\"?xlang=English\">";
+    W("English");
+    echo "</a>";
+    $last = "English";
+    for ($i=0;$i<$num;$i++) {
+      $row = mysql_fetch_array($result);
+      $next = $row["lang"];
+      if ($next == $last)
+        continue;
+      echo " | ";
+      echo "<a href=\"?xlang=$next\">" . W_($next) . "</a>";
+      $last = $next;
+    }
+    echo "]</center>";
   }
-  echo "]</center>";
- }
 }
 
 
@@ -1009,24 +768,97 @@
 function generateFooter() {
   global $xlang;
   global $editor;
-  global $back;
   global $HTTP_SERVER_VARS;
 
   P();
   echo "Translation engine based on <a 
href=\"http://gnunet.org/i18nHTML/\";>i18nHTML</a> (C) 2003, 2004, 2005 
Christian Grothoff.<br />\n";
   if ( ($xlang) && ($xlang != "English") ) {
     $back = "http://"; . $HTTP_SERVER_VARS["HTTP_HOST"] . 
$HTTP_SERVER_VARS["REQUEST_URI"];
-    // echo "<span align=\"center\"><small>";
     echo "<center><small>\n";
     if ($editor != 1)
       echo " <a href=\"$back&amp;editor=1\">" . W_("enter translation mode") . 
"</a>";
     else
       W(" Translation Mode Active (for this page only)");
-    //echo "</small></span>";
     echo "</small></center>\n";
   }
   echo "</p>\n";
 }
 
-   
-?>
+// *************************************************
+// HTML construct helper functions
+// *************************************************
+
+function LI($a,$b="") {
+  echo "<li>" . W_($a,$b) . "</li>\n";
+}
+function TH($a,$b="") {
+  echo "<th>" . W_($a,$b) . "</th>\n";
+}
+function TD($a,$b="") {
+  echo "<td>" . W_($a,$b) . "</td>\n";
+}
+function DT($a,$b="") {
+  echo "<dt>" . W_($a,$b) . "</dt>\n";
+}
+function DD($a,$b="") {
+  echo "<dd>" . W_($a,$b) . "</dd>\n";
+}
+function H1($a,$b="") {
+  echo "<h1>" . W_($a,$b) . "</h1>\n";
+}
+function H2($a,$b="") {
+  echo "<h2>" . W_($a,$b) . "</h2>\n";
+}
+function H3($a,$b="") {
+  echo "<h3>" . W_($a,$b) . "</h3>\n";
+}
+function H4($a,$b="") {
+  echo "<h4>" . W_($a,$b) . "</h4>\n";
+}
+function H5($a,$b="") {
+  echo "<h5>" . W_($a,$b) . "</h5>\n";
+}
+function PRE($a) {
+  echo "<pre>" . $a . "</pre>";
+}
+// 'verbatim' (untranslated) "li"
+function LIV($a) {
+  echo "<li>" . $a . "</li>\n";
+}
+function P($attr="") {
+  echo "<p $attr>\n";
+}
+function BR() {
+  echo "<br />\n";
+}
+function HR() {
+  echo "<hr>\n";
+}
+function DTDD($a,$b) {
+  DT($a);
+  DD($b);
+}
+function LILI($a,$b) {
+  echo "<li>" . extlink_($a,$b) . "</li>\n";
+}
+function ANCHOR($a) {
+  echo "<a name=\"$a\"></a>\n";
+}
+function IMG_($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
+  $ret = "";
+  
+  if ($align == "CENTER") 
+    $ret = $ret . "<p><center>\n";
+  $ret = $ret . "<img src=\"" . $src . "\" alt=\"";
+  $ret = $ret . TRANSLATE_($alt);
+  $ret = $ret . "\" align=\"" . $align . "\" width=$width height=$height 
border=$border hspace=$hspace vspace=$vspace>\n";
+  $ret = $ret . translateLink_($alt);
+  if ($align == "CENTER") 
+    $ret = $ret . "</center><p>\n";
+  return $ret;
+}
+function IMG($src, $alt, $align="CENTER", $width, $height, $border=0, 
$hspace=0, $vspace=0) {
+  echo IMG_($src, $alt, $align, $width, $height, $border, $hspace, $vspace);
+}
+
+?>
\ No newline at end of file

Modified: i18nHTML-docs/WWW/index.php
===================================================================
--- i18nHTML-docs/WWW/index.php 2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML-docs/WWW/index.php 2005-04-11 06:25:43 UTC (rev 639)
@@ -2,84 +2,198 @@
 include("i18nhtml.inc");
 DOCTYPE("HTML", "Transitional");
 echo "<html><head>\n";
-TITLE("i18nHTML - enabling collaborative webpage translation");
-echo "<meta name=\"description\" content=\"";
-TRANSLATE("i18nHTML is a collection of PHP scripts that allow visitors of a 
webpage to help translating it.");
-echo "\">";
+if ($title) {
+  echo "<title>";
+  TRANSLATE("Doodle: find information on your computer");
+  echo "</title>";
+ }
+if ($description) {
+  echo "<meta name=\"description\" content=\"";
+  TRANSLATE("A tool to index and search the files on your disk.");
+  echo "\">";
+ }
+echo "<meta name=\"content-language\" content=\"" . 
+     $languagecodes[$lang] . "\">";
+echo "<meta name=\"language\" content=\"" . 
+     $languagecodes[$lang] . "\">";
 ?>
 <meta name="author" content="Christian Grothoff">
-<meta name="keywords" 
content="i18n,HTML,PHP,translation,languages,mysql,database,internationalization,www,free,GNU,GPL">
+<meta name="keywords" 
content="doodle,desktop,search,suffix,tree,meta,data,libextractor,keywords,fam,index,database,free,Linux,GNU,GPL">
 <meta name="robots" content="index,follow">
 <meta name="revisit-after" content="28 days">
 <meta name="publisher" content="Christian Grothoff">
-<meta name="date" content="2005-01-03">
-<meta name="rights" content="(C) 2004,2005 by Christian Grothoff>";
+<meta name="date" content="2004-12-31">
+<meta name="rights" content="(C) 2004 by Christian Grothoff>";
 <meta http-equiv="expires" content="43200">
 <meta http-equiv="content-type" content="text/html">
 </head>
 <body>
 <?php
 generateLanguageBar();
-H1("i18nHTML");
+
+H1("Doodle");
+ANCHOR("about");
 H2("About");
-W("i18nHTML is a collection of PHP files that can be used to write webpages 
that visitors can translate into their respective native languages.");
-W("i18nHTML uses a database to match sentences from the webpage against 
translations.");
-W("i18nHTML defines a set of PHP functions that generate either the translated 
HTML sentences or the original (typically English) text with decorations that 
allow users to provide translations.");
-W("i18nHTML requires the internationalized webpages to be written using the 
provided PHP functions but does not constrain the page design in any way.");
-W("Webpages internationalized with i18nHTML can be updated without loosing 
existing translations for sentences that were not changed.");
-W("Note that it is important that you use the i18nHTML <tt>TITLE</tt> command 
in your documents in order to ensure that the character set and other meta-data 
is set properly.");
+
+W("Doodle is a tool to quickly search the documents on a computer.");
+W("Doodle builds an index using meta-data contained in the documents and 
allows fast searches on the resulting database.");
+W("Doodle uses %s to support obtaining meta-data from various file-formats.",
+  extlink_("/libextractor/","libextractor"));
+W("The database used by doodle is a %s, resulting in fast lookups.",
+  extlink_("http://www.nist.gov/dads/HTML/suffixtree.html","suffix tree"));
+W("Doodle supports approximate searches.");
+BR();
+W("Features that Doodle does not have at the moment include:");
+echo "<ul>";
+LI("A web interface");
+LI("Ordering of search results");
+LI("Spidering (indexing the Internet or websites)");
+echo "</ul>";
+W("If you need these features, have a look at the %s section.",
+  extlink_("#links", "links"));
+
 P();
-H2("News");
-H3("i18nHTML 0.1.0 released");
-W("i18nHTML 0.1.0 is expected to solve various character set encoding 
issues.");
-W("It also ensures that all entered translations match the original sentence 
in the number of escape sequences.");
-W("The new version also resolves various minor bugs (such as editor mode only 
working with php-register-globals enabled).");
+W("Doodle is licensed under the %s.",
+  extlink_("http://www.gnu.org/licenses/gpl.html","GNU GPL"));
+W("Indexing large volumes can take several hundred MBs of memory (depending on 
the amount of meta-data found).");
+W("Searching should nevertheless require almost no memory.");
+W("Using the latest version of libextractor is recommended.");
+W("Doodle has so far only been tested under %s and %s %s %s.",
+  ARRAY(extlink_("http://www.debian.org/";, "Debian"),
+        extlink_("http://www.redhat.com/";, "RedHat"),
+        extlink_("http://www.gnu.org/";, "GNU"),
+        extlink_("http://www.linux.org/";, "Linux")));
+W("Doodle is expected it to work under any platform supported by %s.",
+  extlink_("/libextractor/", "libextractor"));
 P();
-W("Upgrading from i18nHTML 0.0.2 to 0.1.0 requires changes to the encoding of 
strings in the database (which is now hopefully properly based on unicode).");
-W("This can be done by running the update.php script and feeding the SQL 
statements that update.php generates into MySQL.");
-W("Running <tt>update.php</tt> by itself will not do the data conversion (for 
security reasons).");
-W("You should backup your old translation database first.");
-W("mysqldump should be useful here.");
-W("Note that <tt>update.php</tt> may discard translations that it believes 
have serious character set (or other) problems.");
-W("The total number of discarded translations can be found at the end of the 
output (in a generated comment).");
-P();
-W("Another important step in upgrading from 0.0.2 to 0.1.0 is to use the new 
<tt>TITLE</tt> function to generate the title of all webpages.");
-W("The reason is that the <tt>TITLE</tt> function will generate other HTML 
tags that should be placed in the HTML header to help ensure that the browser 
picks up the character encodings correctly.");
-P();
+
+ANCHOR("download");
 H2("Download");
-W("You can find the latest version %s.",
-  extlink_("https://gnunet.org/i18nHTML/download/";, "here"));
-W("The latest SVN version can be obtained using");
-PRE("$ svn checkout https://gnunet.org/svn/i18nHTML/";);
+W("You can find the current release %s.",
+  extlink_("download/doodle-0.6.2.tar.gz", "here"));
+W("Man-pages for %s, %s and %s are also on-line.",
+  ARRAY(extlink_("man/doodle.html", "doodle"),
+        extlink_("man/doodled.html", "doodled"),
+        extlink_("man/libdoodle", "libdoodle")));
+
+W("The latest version can be obtained using");
+PRE("$ svn checkout https://gnunet.org/svn/doodle/";);
 P();    
 W("If you want to be notified about updates, subscribe to %s",
-  extlink_("http://freshmeat.net/projects/i18nHTML/";, "i18nHTML on 
freshmeat"));
+  extlink_("http://freshmeat.net/projects/doodle/";, "doodle on freshmeat"));
 P();
+W("Debian packages provided by Daniel Baumann can be found %s.",
+  extlink_("http://packages.debian.org/doodle";, "here"));
+W("RedHat/Fedora RPM packages provided by Dag Wieers can be found %s.",
+  extlink_("http://dag.wieers.com/packages/doodle/","here";));
+P();
 
+ANCHOR("using");
+H2("Using doodle");
+W("First the doodle database needs to be created.");
+W("The simplest way to create the database is to run doodle with the 
<tt>-b</tt> option on the directories that are to be indexed.");
+W("For example:");
+PRE("$ doodle -b $HOME");
+W("This will create the doodle database under <tt>~/.doodle</tt>.");
+BR();
+W("After creating the doodle database, you can search it.");
+W("For example:");
+PRE("$ doodle keyword");
+BR();
+H3("Keeping the database up-to-date");
+W("If you want to keep your doodle database up-to-date, you can either 
periodically re-run doodle with the <tt>-b</tt> option, or you can use doodled, 
the doodle daemon.");
+W("doodled uses %s to notice whenever a file is changed and instantly updates 
the doodle database.",
+  "fam");
+W("In order to use doodled, you must have famd running.");
+W("If famd is running, you can start doodled by passing the same arguments 
that you would pass to doodle to construct the database, but without the 
<tt>-b</tt> option:");
+PRE("$ doodled $HOME");
+W("You can also use doodled to construct the initial database.");
+W("While doodled is updating the database, any doodle search will block until 
the update is complete.");
+W("Note that while you may want to index your entire disk (i.e., <tt>doodle -b 
/</tt>), it is typically not a great idea to have doodled monitor your entire 
system for changes -- especially since <tt>/usr</tt> is unlikely to change 
frequently.");
+W("You can address this issue by first indexing <tt>/</tt> and then using 
doodled to monitor only directories that change frequently:");
+PRE("$ doodle -b /\n" .
+    "$ doodled $HOME");
+W("This way, your entire system will be in the index, and your home directory 
will be always up-to-date.");
+P();
+H3("Full-text search");
+W("You can achieve a (limited) form of full-text search with doodle.");
+W("For that, the dictionary-based plaintext extractors from %s are used.",
+  extlink_("/libextractor/","libextractor"));
+W("In order to use them, you need to pass the option <tt>-b LANG</tt> to 
doodle.");
+W("LANG is a two letter language code that selects the dictionary.");
+W("Available languages at the moment are en, es, fr, it and no.");
+W("Words and sentences that are available in the respective dictionaries for 
these languages will then be added to the index.");
+W("While libextractor attempts to avoid full-text extraction for certain kown 
binary formats, it may still find words in non-text files.");
+W("Running with this option will dramatically increase the size of the index 
and the time it takes to build the index.");
+W("Note that if you change the options used to build a database will not (!) 
result in doodle re-indexing files that were processed with other options 
previously.");
+W("The only way to force doodle to re-index files with different options is to 
either touch the files (change modification timestamp) or to delete the old 
database and start from scratch.");
 
+P();
+H3("Hints for system administrators");
+W("If you are the system administrator, you might want to run doodle on the 
entire system periodically (cron job) and have doodled monitor the home 
directories in the background.");
+W("In that case, it is suggested to have the doodle database be group-readable 
for a group doodle.");
+W("Set the permissions for the doodle binary to SGID to allow users to poll 
the database.");
+W("Doodle will ensure that information about files not accessible to the user 
are not leaked by checking if files found in the database are accessible to the 
user.");
+W("doodled has to run as root since otherwise it would be impossible to index 
the personal files of all users.");
+W("If that it too risky, doodled will still work, but only index the files 
readable to the user that runs doodled.");
 
+
 P();
-if ( ($xlang) && ($xlang != "English")) {
-  H2("Mass translation");
-  W("The mass-translation page for translating many sentences at once is %s.",
-    intlink_("editor.php", "here"));
-  W("Note that the sentence database is shared with the %s, %s and %s 
projects.",
-    ARRAY(extlink_("http://gnunet.org/";, "GNUnet"),
-         extlink_("http://gnunet.org/doodle/";, "doodle"),
-         extlink_("http://gnunet.org/libextractor/";, "libExtractor")));  
- }
+H3("Using different options for different directories");
+W("You can build a database from multiple doodle runs over distinct sets of 
files with different options.");
+W("For example, the following can make sense:");
+PRE("$ doodle -B en -b /usr/share/doc # full-text index over documentation\n" .
+    "$ doodle -b /usr /opt /bin /lib # normal index over other system files\n" 
.
+    "$ doodled -B en /home # monitor /home, with full-text support\n");
+W("A simple doodle search will then find files in all listed directories.");
+W("You can also build multiple disjoint databases and search all of them in 
one run (see %s for option <tt>-d</tt>).",
+  extlink_("man/doodle.html", "doodle"));
 
+P();
+ANCHOR("mantis");
 H2("Bugtrack");
-W("i18nHTML uses Mantis for bugtracking.");
+W("Doodle uses Mantis for bugtracking.");
 W("Visit %s to report bugs.",
   extlink_("https://gnunet.org/mantis/","https://gnunet.org/mantis/";));
 W("You need to sign up for a reporter account.");
-W("Please make sure you report bugs under <strong>I18nHTML</strong> and not 
under any of the other projects.");
+W("Please make sure you report bugs under <strong>Doodle</strong> and not 
under any of the other projects.");
 P();
-W("If you dislike Mantis and need to report a bug contact %s via e-mail (good 
luck getting by the spam-filter).",
+W("If you dislike Mantis and need to report a bug contact %s via e-mail.",
   extlink_("mailto:address@hidden","address@hidden";));
 
+
+ANCHOR("links");
+H2("Links");
+echo "<ul>";
+LILI("http://members.cox.net/sinzui/medusa/";, 
+     "Medusa, similar project for Gnome");
+LILI("http://swish-e.org/";, 
+     "Swish-e, indexing tool with focus on the WWW");
+LILI("http://www.gnome.org/~seth/storage/";,
+     "GNOME Storage");
+LILI("http://www.gnome.org/projects/beagle/";,
+     "Beagle");
+LILI("http://sourceforge.net/projects/rlocate/";,
+     "rlocate, version of locate that is always up-to-date");
+LILI("http://www.htdig.org/";,
+     "HTDig");
+LILI("http://jakarta.apache.org/lucene/";,
+     "Lucene");
+LILI("http://homepage.mac.com/pauljlucas/software/swish/";,
+     "Swish++");
+LILI("http://webglimpse.net/";,
+     "Glimpse");
+LILI("http://evidence.sf.net/";,
+     "Evidence, file-manager with support for doodle");
+LILI("http://www.linux-magazin.de/Artikel/ausgabe/2004/09/bgw/bgw.html";,
+     "Article about doodle (and other things) in the German Linux-Magazin");
+echo "</ul>";
 HR();
+echo "<address><a href=\"mailto:address@hidden";>Christian 
Grothoff</a></address>";
+PRE("Copyright (C) 2004 Christian Grothoff.\n" .
+    "Verbatim copying and distribution of this entire article\n" .
+    "is permitted in any medium, provided this notice is preserved.");
+BR();
 generateFooter();
 echo "</body></html>\n";
 ?>

Modified: i18nHTML-docs/WWW/status.php
===================================================================
--- i18nHTML-docs/WWW/status.php        2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML-docs/WWW/status.php        2005-04-11 06:25:43 UTC (rev 639)
@@ -1,6 +1,6 @@
 <?php
 /*
-     (C) 2003, 2004 Christian Grothoff
+     (C) 2003, 2004, 2005 Christian Grothoff
 
      This code is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -27,7 +27,6 @@
   die();
  }
 $mode = $_REQUEST['mode'];
-
 DOCTYPE("HTML", "Transitional");
 echo "<html><head>\n";
 TITLE("Translation: status");
@@ -35,20 +34,6 @@
 W("Language setting is %s.",
   $lang);
 P();
-if ($mode == 1) {
-  H2("All available translations");
-  echo "<table border=5>\n";
-  echo "<tr><th>";
-  W("Original");
-  echo "</th><th>";
-  W("Language");
-  echo "</th><th>";
-  W("Translation");
-  echo "</th><th>";
-  W("Votes");
-  echo "</th></tr>\n";
- }
-
 $query = "SELECT count FROM pending WHERE lang=\"English\"";
 $result = mysql_query($query, $connection);
 $num = 0;
@@ -57,7 +42,16 @@
 W("Sentences in the original English text: %s",
   $num);
 P();
-
+if ($mode == 1) {
+  H2("All available translations");
+  echo "<table border=5>\n";
+  echo "<tr>";
+  TH("Original");
+  TH("Language");
+  TH("Translation");
+  TH("Votes");
+  echo "</tr>\n";
+}
 $stats = ARRAY();
 $query = "SELECT name,ranking,translation,lang FROM map";
 $result = mysql_query($query, $connection);
@@ -66,29 +60,33 @@
   $num = mysql_numrows($result);
 for ($i=0;$i<$num;$i++) {
   $row = mysql_fetch_array($result);
-  $text = urldecode($row["name"]);
+  $text = stripslashes($row["name"]);
+  $translation = stripslashes($row["translation"]);
   $ranking = $row["ranking"];
   $stats[$row["lang"]]++;
-  if ($mode == 1)
-    printf("<tr><td>%s</td><td>%s</td><td><a 
href=\"vote.php3?lang=%s&text=%s&translation=%s\">%s</a></td><td>%s</td></tr>\n",
-          urldecode($text),
-          $row["lang"],
-          $row["lang"],
+  if ($mode == 1) {
+    printf("<tr><td>%s</td><td>%s</td><td><a href=\"vote.php3?" .
+           "lang=%s&text=%s&translation=%s\">%s</a></td><td>%s</td></tr>\n",
           $text,
-          $row["translation"],
-          urldecode($row["translation"]),
+          $row["lang"],
+          urlencode($row["lang"]),
+          urlencode($text),
+          urlencode($translation),
+          $translation,
           $ranking);
- }
-if ($mode == 1)
-  echo "</table><p><hr><p>\n";
-
-echo "$num ";
-W("translations in database.");
-echo "<p>\n";
+  }
+}
+if ($mode == 1) {
+  echo "</table>";
+  P();
+  HR(); 
+  P();
+}
+W("%s translated sentences in database.", $num);
+P();
 foreach ($stats as $a => $b) {
-  echo "$b ";
-  W("in ");
-  echo "$a<br>";
+  W("%s translations available in %s.", $b, $a);
+  BR();
 }
 generateFooter();
 echo "</body></html>";

Modified: i18nHTML-docs/WWW/translate.php
===================================================================
--- i18nHTML-docs/WWW/translate.php     2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML-docs/WWW/translate.php     2005-04-11 06:25:43 UTC (rev 639)
@@ -1,6 +1,6 @@
 <?php
 /*
-     (C) 2003, 2004 Christian Grothoff
+     (C) 2003, 2004, 2005 Christian Grothoff
 
      This code is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -22,9 +22,10 @@
   echo "Database is down. Cannot edit translations.";
   die();
 }
-$text = $_REQUEST['text'];
+$text     = fix($_REQUEST['text']);
+$text_sql = mysql_real_escape_string($text);
+$text_url = urlencode($text);
 $back = $_REQUEST['back'];
-
 DOCTYPE("HTML", "Transitional");
 echo "<html><head>\n";
 TITLE("WWW translation");
@@ -37,66 +38,43 @@
   die();
  } 
 H2("Original Text");
-// if (get_magic_quotes_gpc()) $text = stripslashes($text);
 echo $text;
 H2("Translation");
 W("Destination language: ");
 W($lang);
 P();
 echo "<form method=\"POST\" action=\"" . $i18nHTMLbase . 
"commitTranslation.php\">\n";
-echo "<input type=hidden name=\"text\" value=\"" . urlencode($text) . "\">\n";
+echo "<input type=hidden name=\"text\" value=\"$text_url\">\n";
 echo "<input type=hidden name=\"xlang\" value=\"$xlang\">\n";
 echo "<input type=hidden name=\"back\" value=\"$back\">\n";
-/* 
-P();
-W("Character set:");
-<select size="1" name="charset">
-  <option value="UTF-8">Unicode UTF-8 encoding</option>
-  <option selected value="ISO-8859-1">ISO-8859-1 Western European, 
Latin-1</option>
-  <option value="ISO-8859-15">ISO-8859-15 Extended Western European</option>
-  <option value="cp1252">cp1252 Windows Western Europen</option>
-  <option value="cp866">cp866 DOS Cyrillic</option>
-  <option value="cp1251">cp1251 Windows Cyrillic</option>
-  <option value="KOI8-R">koi8-ru Russian</option>
-  <option value="BIG5">BIG5 Traditional Chinese</option>
-  <option value="GB2312">GB2312 Simplified Chinese</option>
-  <option value="Shift-JIS">Shift-JIS Japanese</option>
-  <option value="EUC-JP">EUC-JP Japanese</option>
-</select><br> */
 W("Translated text:");
-?>
-<input size="80" maxlength="65535" name="translation">
-<input type=submit value="I hereby give this translation into the Public 
Domain (commit)">
-</form>
-<?php
+echo "<input size=\"80\" maxlength=\"65535\" name=\"translation\">\n";
+echo "<input type=submit value=\"" . 
+     TRANSLATE_("I hereby give this translation into the Public Domain 
(commit)") . 
+     "\">\n";
+echo "</form>\n";
 P();
 
 H2("All available translations");
-?>
-<table border=5 width=95%>
-<tr><th><?php W("Language"); ?></th><th><?php W("Translation"); ?></th></tr>
-<?php
- $u = urlencode($text);
- $query = "SELECT translation,lang FROM map WHERE name=\"$u\" ORDER BY ranking 
DESC";
- $result = mysql_query($query, $connection);
- $num = 0;
- if ($result) 
-   $num = mysql_num_rows($result);
- for ($i=0;$i<$num;$i++) {
-   $row = mysql_fetch_array($result);
-
-   // we assume strings escaped before adding to DB
-   $translation = stripslashes($row["translation"]);
-
-   printf("<tr><td>%s</td><td><a href=\"" . $i18nHTMLbase . 
"vote.php?xlang=%s&text=%s&translation=%s\">%s</a></td></tr>\n",
-          W_($row["lang"]),
-          urlencode($row["lang"]),
-         $u,
-         urlencode(from_unicode($translation)),
-         fix(from_unicode($translation)));
- }
+echo "<table border=5 width=95%>\n";
+echo "<tr><th>" . W_("Language") . "</th><th>" . W_("Translation") . 
"</th></tr>\n";
+$query = "SELECT translation,lang FROM map WHERE name=\"$text_sql\" ORDER BY 
ranking DESC";
+$result = mysql_query($query, $connection);
+$num = 0;
+if ($result) 
+  $num = mysql_num_rows($result);
+for ($i=0;$i<$num;$i++) {
+  $row = mysql_fetch_array($result);
+  $translation = $row["translation"];
+  printf("<tr><td>%s</td><td><a href=\"" . $i18nHTMLbase . 
+         "vote.php?xlang=%s&text=%s&translation=%s\">%s</a></td></tr>\n",
+         W_($row["lang"]),
+         urlencode($row["lang"]),
+         urlencode($text_url),  // yes, we need urlencode twice!
+         urlencode(urlencode($translation)), // yes, we need urlencode twice!
+         fix($translation));
+}
 echo "</table>";
-
 H2("Remarks");
 H3("The percent sign");
 W("The %% sign is a special character.");
@@ -104,19 +82,15 @@
 W("The sequence %%s is used as a placeholder for links.");
 W("Currently, the translation can only access the links in the same order as 
the original text.");
 P();
-
 H3("Language specific special characters");
 W("Various languages use special characters.");
 W("The code has not been tested with certain character sets, such as 
Chinese.");
 W("If you are trying to translate the page to such a language, please contact 
the developerws if you encounter any problems.");
 P();
-
 H3("Copyright");
 W("The original english text is released under the GNU Free Documentation 
License (FDL).");
 W("Translations submitted to the webpage must be released to the public domain 
to ensure that we will not have any legal trouble.");
 W("If you have concerns or remarks regarding this policy, feel free to bring 
them to our attention.");
-
 generateFooter();
 echo "</body></html>";
-
 ?>

Modified: i18nHTML-docs/WWW/vote.php
===================================================================
--- i18nHTML-docs/WWW/vote.php  2005-04-11 06:23:40 UTC (rev 638)
+++ i18nHTML-docs/WWW/vote.php  2005-04-11 06:25:43 UTC (rev 639)
@@ -17,26 +17,25 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-  // This file records votes from users for translations.
-  // For sentences with multiple translations, the one with the most
-  // votes is displayed.
+// This file records votes from users for translations.
+// For sentences with multiple translations, the one with the most
+// votes is displayed.
 include("i18nhtml.inc");
+DOCTYPE("HTML", "Transitional");
 echo "<html><head>";
-echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" >";
 TITLE("WWW translation: vote");
 echo "</head><body>";
 if (!$connection) {
   echo "Database is down. Cannot edit translations.";
   die();
  } 
-$text = $_REQUEST['text'];
-$translation = $_REQUEST['translation'];
-$u = mysql_real_escape_string($text);
-$t = mysql_real_escape_string(to_unicode($translation));
-echo "text = " . $text . "<br>\n";
-echo "translation = " . $translation . "<br>\n";
+$text            = fix(urldecode($_REQUEST['text']));
+$translation     = fix(urldecode($_REQUEST['translation']));
+$text_sql        = mysql_real_escape_string($text);
+$translation_sql = mysql_real_escape_string(to_unicode($translation));
 
-$query = "SELECT ranking FROM map WHERE name=\"$u\" AND lang=\"$lang\" AND 
translation=\"$t\"";
+$query = "SELECT ranking FROM map WHERE " .
+         "name=\"$text_sql\" AND lang=\"$lang\" AND 
translation=\"$translation_sql\"";
 $result = mysql_query($query, $connection);
 $num = 0;
 if ($result) 
@@ -44,11 +43,13 @@
 if ($num > 0) {
   $row = mysql_fetch_array($result);
   $ranking = $row["ranking"] + 1;
-  $query = "UPDATE map SET ranking=\"$ranking\" WHERE name=\"$u\" AND 
lang=\"$lang\" AND translation=\"$t\"";
+  $query = "UPDATE map SET ranking=\"$ranking\" WHERE " .
+           "name=\"$text_sql\" AND lang=\"$lang\" AND 
translation=\"$translation_sql\"";
   mysql_query($query, $connection);
   W("Ranking of translation is now: ");
   echo "$ranking";
- } else {
-  W("Translation does not exist (bug?).");
- }
+} else {
+  W("Translation '%s' of '%s' does not exist (bug?).",
+    ARRAY($translation, $text));
+}
 ?>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]