diff --git a/simpleid/www/lib/gettext/gettext.inc.php b/simpleid/www/lib/gettext/gettext.inc.php
new file mode 100644
index 0000000..00b9666
--- /dev/null
+++ b/simpleid/www/lib/gettext/gettext.inc.php
@@ -0,0 +1,536 @@
+<?php
+/*
+   Copyright (c) 2005 Steven Armstrong <sa at c-area dot ch>
+   Copyright (c) 2009 Danilo Segan <danilo@kvota.net>
+
+   Drop in replacement for native gettext.
+
+   This file is part of PHP-gettext.
+
+   PHP-gettext 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.
+
+   PHP-gettext is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with PHP-gettext; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+*/
+/*
+LC_CTYPE        0
+LC_NUMERIC      1
+LC_TIME         2
+LC_COLLATE      3
+LC_MONETARY     4
+LC_MESSAGES     5
+LC_ALL          6
+*/
+
+// LC_MESSAGES is not available if php-gettext is not loaded
+// while the other constants are already available from session extension.
+if (!defined('LC_MESSAGES')) {
+  define('LC_MESSAGES',	5);
+}
+
+require('streams.php');
+require('gettext.php');
+
+
+// Variables
+
+global $text_domains, $default_domain, $LC_CATEGORIES, $EMULATEGETTEXT, $CURRENTLOCALE;
+$text_domains = array();
+$default_domain = 'messages';
+$LC_CATEGORIES = array('LC_CTYPE', 'LC_NUMERIC', 'LC_TIME', 'LC_COLLATE', 'LC_MONETARY', 'LC_MESSAGES', 'LC_ALL');
+$EMULATEGETTEXT = 0;
+$CURRENTLOCALE = '';
+
+/* Class to hold a single domain included in $text_domains. */
+class domain {
+  var $l10n;
+  var $path;
+  var $codeset;
+}
+
+// Utility functions
+
+/**
+ * Return a list of locales to try for any POSIX-style locale specification.
+ */
+function get_list_of_locales($locale) {
+  /* Figure out all possible locale names and start with the most
+   * specific ones.  I.e. for sr_CS.UTF-8@latin, look through all of
+   * sr_CS.UTF-8@latin, sr_CS@latin, sr@latin, sr_CS.UTF-8, sr_CS, sr.
+   */
+  $locale_names = array();
+  $lang = NULL;
+  $country = NULL;
+  $charset = NULL;
+  $modifier = NULL;
+  if ($locale) {
+    if (preg_match("/^(?P<lang>[a-z]{2,3})"              // language code
+                   ."(?:_(?P<country>[A-Z]{2}))?"           // country code
+                   ."(?:\.(?P<charset>[-A-Za-z0-9_]+))?"    // charset
+                   ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/",  // @ modifier
+                   $locale, $matches)) {
+
+      if (isset($matches["lang"])) $lang = $matches["lang"];
+      if (isset($matches["country"])) $country = $matches["country"];
+      if (isset($matches["charset"])) $charset = $matches["charset"];
+      if (isset($matches["modifier"])) $modifier = $matches["modifier"];
+
+      if ($modifier) {
+        if ($country) {
+          if ($charset)
+            array_push($locale_names, "${lang}_$country.$charset@$modifier");
+          array_push($locale_names, "${lang}_$country@$modifier");
+        } elseif ($charset)
+            array_push($locale_names, "${lang}.$charset@$modifier");
+        array_push($locale_names, "$lang@$modifier");
+      }
+      if ($country) {
+        if ($charset)
+          array_push($locale_names, "${lang}_$country.$charset");
+        array_push($locale_names, "${lang}_$country");
+      } elseif ($charset)
+          array_push($locale_names, "${lang}.$charset");
+      array_push($locale_names, $lang);
+    }
+
+    // If the locale name doesn't match POSIX style, just include it as-is.
+    if (!in_array($locale, $locale_names))
+      array_push($locale_names, $locale);
+  }
+  return $locale_names;
+}
+
+/**
+ * Utility function to get a StreamReader for the given text domain.
+ */
+function _get_reader($domain=null, $category=5, $enable_cache=true) {
+    global $text_domains, $default_domain, $LC_CATEGORIES;
+    if (!isset($domain)) $domain = $default_domain;
+    if (!isset($text_domains[$domain]->l10n)) {
+        // get the current locale
+        $locale = _setlocale(LC_MESSAGES, 0);
+        $bound_path = isset($text_domains[$domain]->path) ?
+          $text_domains[$domain]->path : './';
+        $subpath = $LC_CATEGORIES[$category] ."/$domain.mo";
+
+        $locale_names = get_list_of_locales($locale);
+        $input = null;
+        foreach ($locale_names as $locale) {
+          $full_path = $bound_path . $locale . "/" . $subpath;
+          if (file_exists($full_path)) {
+            $input = new FileReader($full_path);
+            break;
+          }
+        }
+
+        if (!array_key_exists($domain, $text_domains)) {
+          // Initialize an empty domain object.
+          $text_domains[$domain] = new domain();
+        }
+        $text_domains[$domain]->l10n = new gettext_reader($input,
+                                                          $enable_cache);
+    }
+    return $text_domains[$domain]->l10n;
+}
+
+/**
+ * Returns whether we are using our emulated gettext API or PHP built-in one.
+ */
+function locale_emulation() {
+    global $EMULATEGETTEXT;
+    return $EMULATEGETTEXT;
+}
+
+/**
+ * Checks if the current locale is supported on this system.
+ */
+function _check_locale_and_function($function=false) {
+    global $EMULATEGETTEXT;
+    if ($function and !function_exists($function))
+        return false;
+    return !$EMULATEGETTEXT;
+}
+
+/**
+ * Get the codeset for the given domain.
+ */
+function _get_codeset($domain=null) {
+    global $text_domains, $default_domain, $LC_CATEGORIES;
+    if (!isset($domain)) $domain = $default_domain;
+    return (isset($text_domains[$domain]->codeset))? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding');
+}
+
+/**
+ * Convert the given string to the encoding set by bind_textdomain_codeset.
+ */
+function _encode($text) {
+    $source_encoding = mb_detect_encoding($text);
+    $target_encoding = _get_codeset();
+    if ($source_encoding != $target_encoding) {
+        return mb_convert_encoding($text, $target_encoding, $source_encoding);
+    }
+    else {
+        return $text;
+    }
+}
+
+
+// Custom implementation of the standard gettext related functions
+
+/**
+ * Returns passed in $locale, or environment variable $LANG if $locale == ''.
+ */
+function _get_default_locale($locale) {
+  if ($locale == '') // emulate variable support
+    return getenv('LANG');
+  else
+    return $locale;
+}
+
+/**
+ * Sets a requested locale, if needed emulates it.
+ */
+function _setlocale($category, $locale) {
+    global $CURRENTLOCALE, $EMULATEGETTEXT;
+    if ($locale === 0) { // use === to differentiate between string "0"
+        if ($CURRENTLOCALE != '')
+            return $CURRENTLOCALE;
+        else
+            // obey LANG variable, maybe extend to support all of LC_* vars
+            // even if we tried to read locale without setting it first
+            return _setlocale($category, $CURRENTLOCALE);
+    } else {
+        if (function_exists('setlocale')) {
+          $ret = setlocale($category, $locale);
+          if (($locale == '' and !$ret) or // failed setting it by env
+              ($locale != '' and $ret != $locale)) { // failed setting it
+            // Failed setting it according to environment.
+            $CURRENTLOCALE = _get_default_locale($locale);
+            $EMULATEGETTEXT = 1;
+          } else {
+            $CURRENTLOCALE = $ret;
+            $EMULATEGETTEXT = 0;
+          }
+        } else {
+          // No function setlocale(), emulate it all.
+          $CURRENTLOCALE = _get_default_locale($locale);
+          $EMULATEGETTEXT = 1;
+        }
+        // Allow locale to be changed on the go for one translation domain.
+        global $text_domains, $default_domain;
+        if (array_key_exists($default_domain, $text_domains)) {
+            unset($text_domains[$default_domain]->l10n);
+        }
+        return $CURRENTLOCALE;
+    }
+}
+
+/**
+ * Sets the path for a domain.
+ */
+function _bindtextdomain($domain, $path) {
+    global $text_domains;
+    // ensure $path ends with a slash ('/' should work for both, but lets still play nice)
+    if (substr(php_uname(), 0, 7) == "Windows") {
+      if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/')
+        $path .= '\\';
+    } else {
+      if ($path[strlen($path)-1] != '/')
+        $path .= '/';
+    }
+    if (!array_key_exists($domain, $text_domains)) {
+      // Initialize an empty domain object.
+      $text_domains[$domain] = new domain();
+    }
+    $text_domains[$domain]->path = $path;
+}
+
+/**
+ * Specify the character encoding in which the messages from the DOMAIN message catalog will be returned.
+ */
+function _bind_textdomain_codeset($domain, $codeset) {
+    global $text_domains;
+    $text_domains[$domain]->codeset = $codeset;
+}
+
+/**
+ * Sets the default domain.
+ */
+function _textdomain($domain) {
+    global $default_domain;
+    $default_domain = $domain;
+}
+
+/**
+ * Lookup a message in the current domain.
+ */
+function _gettext($msgid) {
+    $l10n = _get_reader();
+    return _encode($l10n->translate($msgid));
+}
+
+/**
+ * Alias for gettext.
+ */
+function __($msgid) {
+    return _gettext($msgid);
+}
+
+/**
+ * Plural version of gettext.
+ */
+function _ngettext($singular, $plural, $number) {
+    $l10n = _get_reader();
+    return _encode($l10n->ngettext($singular, $plural, $number));
+}
+
+/**
+ * Override the current domain.
+ */
+function _dgettext($domain, $msgid) {
+    $l10n = _get_reader($domain);
+    return _encode($l10n->translate($msgid));
+}
+
+/**
+ * Plural version of dgettext.
+ */
+function _dngettext($domain, $singular, $plural, $number) {
+    $l10n = _get_reader($domain);
+    return _encode($l10n->ngettext($singular, $plural, $number));
+}
+
+/**
+ * Overrides the domain and category for a single lookup.
+ */
+function _dcgettext($domain, $msgid, $category) {
+    $l10n = _get_reader($domain, $category);
+    return _encode($l10n->translate($msgid));
+}
+/**
+ * Plural version of dcgettext.
+ */
+function _dcngettext($domain, $singular, $plural, $number, $category) {
+    $l10n = _get_reader($domain, $category);
+    return _encode($l10n->ngettext($singular, $plural, $number));
+}
+
+/**
+ * Context version of gettext.
+ */
+function _pgettext($context, $msgid) {
+    $l10n = _get_reader();
+    return _encode($l10n->pgettext($context, $msgid));
+}
+
+/**
+ * Override the current domain in a context gettext call.
+ */
+function _dpgettext($domain, $context, $msgid) {
+    $l10n = _get_reader($domain);
+    return _encode($l10n->pgettext($context, $msgid));
+}
+
+/**
+ * Overrides the domain and category for a single context-based lookup.
+ */
+function _dcpgettext($domain, $context, $msgid, $category) {
+    $l10n = _get_reader($domain, $category);
+    return _encode($l10n->pgettext($context, $msgid));
+}
+
+/**
+ * Context version of ngettext.
+ */
+function _npgettext($context, $singular, $plural) {
+    $l10n = _get_reader();
+    return _encode($l10n->npgettext($context, $singular, $plural));
+}
+
+/**
+ * Override the current domain in a context ngettext call.
+ */
+function _dnpgettext($domain, $context, $singular, $plural) {
+    $l10n = _get_reader($domain);
+    return _encode($l10n->npgettext($context, $singular, $plural));
+}
+
+/**
+ * Overrides the domain and category for a plural context-based lookup.
+ */
+function _dcnpgettext($domain, $context, $singular, $plural, $category) {
+    $l10n = _get_reader($domain, $category);
+    return _encode($l10n->npgettext($context, $singular, $plural));
+}
+
+
+
+// Wrappers to use if the standard gettext functions are available,
+// but the current locale is not supported by the system.
+// Use the standard impl if the current locale is supported, use the
+// custom impl otherwise.
+
+function T_setlocale($category, $locale) {
+    return _setlocale($category, $locale);
+}
+
+function T_bindtextdomain($domain, $path) {
+    if (_check_locale_and_function()) return bindtextdomain($domain, $path);
+    else return _bindtextdomain($domain, $path);
+}
+function T_bind_textdomain_codeset($domain, $codeset) {
+    // bind_textdomain_codeset is available only in PHP 4.2.0+
+    if (_check_locale_and_function('bind_textdomain_codeset'))
+        return bind_textdomain_codeset($domain, $codeset);
+    else return _bind_textdomain_codeset($domain, $codeset);
+}
+function T_textdomain($domain) {
+    if (_check_locale_and_function()) return textdomain($domain);
+    else return _textdomain($domain);
+}
+function T_gettext($msgid) {
+    if (_check_locale_and_function()) return gettext($msgid);
+    else return _gettext($msgid);
+}
+function T_($msgid) {
+    if (_check_locale_and_function()) return _($msgid);
+    return __($msgid);
+}
+function T_ngettext($singular, $plural, $number) {
+    if (_check_locale_and_function())
+        return ngettext($singular, $plural, $number);
+    else return _ngettext($singular, $plural, $number);
+}
+function T_dgettext($domain, $msgid) {
+    if (_check_locale_and_function()) return dgettext($domain, $msgid);
+    else return _dgettext($domain, $msgid);
+}
+function T_dngettext($domain, $singular, $plural, $number) {
+    if (_check_locale_and_function())
+        return dngettext($domain, $singular, $plural, $number);
+    else return _dngettext($domain, $singular, $plural, $number);
+}
+function T_dcgettext($domain, $msgid, $category) {
+    if (_check_locale_and_function())
+        return dcgettext($domain, $msgid, $category);
+    else return _dcgettext($domain, $msgid, $category);
+}
+function T_dcngettext($domain, $singular, $plural, $number, $category) {
+    if (_check_locale_and_function())
+      return dcngettext($domain, $singular, $plural, $number, $category);
+    else return _dcngettext($domain, $singular, $plural, $number, $category);
+}
+
+function T_pgettext($context, $msgid) {
+  if (_check_locale_and_function('pgettext'))
+      return pgettext($context, $msgid);
+  else
+      return _pgettext($context, $msgid);
+}
+
+function T_dpgettext($domain, $context, $msgid) {
+  if (_check_locale_and_function('dpgettext'))
+      return dpgettext($domain, $context, $msgid);
+  else
+      return _dpgettext($domain, $context, $msgid);
+}
+
+function T_dcpgettext($domain, $context, $msgid, $category) {
+  if (_check_locale_and_function('dcpgettext'))
+      return dcpgettext($domain, $context, $msgid, $category);
+  else
+      return _dcpgettext($domain, $context, $msgid, $category);
+}
+
+function T_npgettext($context, $singular, $plural, $number) {
+    if (_check_locale_and_function('npgettext'))
+        return npgettext($context, $singular, $plural, $number);
+    else
+        return _npgettext($context, $singular, $plural, $number);
+}
+
+function T_dnpgettext($domain, $context, $singular, $plural, $number) {
+  if (_check_locale_and_function('dnpgettext'))
+      return dnpgettext($domain, $context, $singular, $plural, $number);
+  else
+      return _dnpgettext($domain, $context, $singular, $plural, $number);
+}
+
+function T_dcnpgettext($domain, $context, $singular, $plural,
+                       $number, $category) {
+    if (_check_locale_and_function('dcnpgettext'))
+        return dcnpgettext($domain, $context, $singular,
+                           $plural, $number, $category);
+    else
+        return _dcnpgettext($domain, $context, $singular,
+                            $plural, $number, $category);
+}
+
+
+
+// Wrappers used as a drop in replacement for the standard gettext functions
+
+if (!function_exists('gettext')) {
+    function bindtextdomain($domain, $path) {
+        return _bindtextdomain($domain, $path);
+    }
+    function bind_textdomain_codeset($domain, $codeset) {
+        return _bind_textdomain_codeset($domain, $codeset);
+    }
+    function textdomain($domain) {
+        return _textdomain($domain);
+    }
+    function gettext($msgid) {
+        return _gettext($msgid);
+    }
+    function _($msgid) {
+        return __($msgid);
+    }
+    function ngettext($singular, $plural, $number) {
+        return _ngettext($singular, $plural, $number);
+    }
+    function dgettext($domain, $msgid) {
+        return _dgettext($domain, $msgid);
+    }
+    function dngettext($domain, $singular, $plural, $number) {
+        return _dngettext($domain, $singular, $plural, $number);
+    }
+    function dcgettext($domain, $msgid, $category) {
+        return _dcgettext($domain, $msgid, $category);
+    }
+    function dcngettext($domain, $singular, $plural, $number, $category) {
+        return _dcngettext($domain, $singular, $plural, $number, $category);
+    }
+    function pgettext($context, $msgid) {
+        return _pgettext($context, $msgid);
+    }
+    function npgettext($context, $singular, $plural, $number) {
+        return _npgettext($context, $singular, $plural, $number);
+    }
+    function dpgettext($domain, $context, $msgid) {
+        return _dpgettext($domain, $context, $msgid);
+    }
+    function dnpgettext($domain, $context, $singular, $plural, $number) {
+        return _dnpgettext($domain, $context, $singular, $plural, $number);
+    }
+    function dcpgettext($domain, $context, $msgid, $category) {
+        return _dcpgettext($domain, $context, $msgid, $category);
+    }
+    function dcnpgettext($domain, $context, $singular, $plural,
+                         $number, $category) {
+      return _dcnpgettext($domain, $context, $singular, $plural,
+                          $number, $category);
+    }
+}
+
+?>
diff --git a/simpleid/www/lib/gettext/gettext.php b/simpleid/www/lib/gettext/gettext.php
new file mode 100644
index 0000000..5064047
--- /dev/null
+++ b/simpleid/www/lib/gettext/gettext.php
@@ -0,0 +1,432 @@
+<?php
+/*
+   Copyright (c) 2003, 2009 Danilo Segan <danilo@kvota.net>.
+   Copyright (c) 2005 Nico Kaiser <nico@siriux.net>
+
+   This file is part of PHP-gettext.
+
+   PHP-gettext 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.
+
+   PHP-gettext is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with PHP-gettext; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+*/
+
+/**
+ * Provides a simple gettext replacement that works independently from
+ * the system's gettext abilities.
+ * It can read MO files and use them for translating strings.
+ * The files are passed to gettext_reader as a Stream (see streams.php)
+ *
+ * This version has the ability to cache all strings and translations to
+ * speed up the string lookup.
+ * While the cache is enabled by default, it can be switched off with the
+ * second parameter in the constructor (e.g. whenusing very large MO files
+ * that you don't want to keep in memory)
+ */
+class gettext_reader {
+  //public:
+   var $error = 0; // public variable that holds error code (0 if no error)
+
+   //private:
+  var $BYTEORDER = 0;        // 0: low endian, 1: big endian
+  var $STREAM = NULL;
+  var $short_circuit = false;
+  var $enable_cache = false;
+  var $originals = NULL;      // offset of original table
+  var $translations = NULL;    // offset of translation table
+  var $pluralheader = NULL;    // cache header field for plural forms
+  var $total = 0;          // total string count
+  var $table_originals = NULL;  // table for original strings (offsets)
+  var $table_translations = NULL;  // table for translated strings (offsets)
+  var $cache_translations = NULL;  // original -> translation mapping
+
+
+  /* Methods */
+
+
+  /**
+   * Reads a 32bit Integer from the Stream
+   *
+   * @access private
+   * @return Integer from the Stream
+   */
+  function readint() {
+      if ($this->BYTEORDER == 0) {
+        // low endian
+        $input=unpack('V', $this->STREAM->read(4));
+        return array_shift($input);
+      } else {
+        // big endian
+        $input=unpack('N', $this->STREAM->read(4));
+        return array_shift($input);
+      }
+    }
+
+  function read($bytes) {
+    return $this->STREAM->read($bytes);
+  }
+
+  /**
+   * Reads an array of Integers from the Stream
+   *
+   * @param int count How many elements should be read
+   * @return Array of Integers
+   */
+  function readintarray($count) {
+    if ($this->BYTEORDER == 0) {
+        // low endian
+        return unpack('V'.$count, $this->STREAM->read(4 * $count));
+      } else {
+        // big endian
+        return unpack('N'.$count, $this->STREAM->read(4 * $count));
+      }
+  }
+
+  /**
+   * Constructor
+   *
+   * @param object Reader the StreamReader object
+   * @param boolean enable_cache Enable or disable caching of strings (default on)
+   */
+  function gettext_reader($Reader, $enable_cache = true) {
+    // If there isn't a StreamReader, turn on short circuit mode.
+    if (! $Reader || isset($Reader->error) ) {
+      $this->short_circuit = true;
+      return;
+    }
+
+    // Caching can be turned off
+    $this->enable_cache = $enable_cache;
+
+    $MAGIC1 = "\x95\x04\x12\xde";
+    $MAGIC2 = "\xde\x12\x04\x95";
+
+    $this->STREAM = $Reader;
+    $magic = $this->read(4);
+    if ($magic == $MAGIC1) {
+      $this->BYTEORDER = 1;
+    } elseif ($magic == $MAGIC2) {
+      $this->BYTEORDER = 0;
+    } else {
+      $this->error = 1; // not MO file
+      return false;
+    }
+
+    // FIXME: Do we care about revision? We should.
+    $revision = $this->readint();
+
+    $this->total = $this->readint();
+    $this->originals = $this->readint();
+    $this->translations = $this->readint();
+  }
+
+  /**
+   * Loads the translation tables from the MO file into the cache
+   * If caching is enabled, also loads all strings into a cache
+   * to speed up translation lookups
+   *
+   * @access private
+   */
+  function load_tables() {
+    if (is_array($this->cache_translations) &&
+      is_array($this->table_originals) &&
+      is_array($this->table_translations))
+      return;
+
+    /* get original and translations tables */
+    if (!is_array($this->table_originals)) {
+      $this->STREAM->seekto($this->originals);
+      $this->table_originals = $this->readintarray($this->total * 2);
+    }
+    if (!is_array($this->table_translations)) {
+      $this->STREAM->seekto($this->translations);
+      $this->table_translations = $this->readintarray($this->total * 2);
+    }
+
+    if ($this->enable_cache) {
+      $this->cache_translations = array ();
+      /* read all strings in the cache */
+      for ($i = 0; $i < $this->total; $i++) {
+        $this->STREAM->seekto($this->table_originals[$i * 2 + 2]);
+        $original = $this->STREAM->read($this->table_originals[$i * 2 + 1]);
+        $this->STREAM->seekto($this->table_translations[$i * 2 + 2]);
+        $translation = $this->STREAM->read($this->table_translations[$i * 2 + 1]);
+        $this->cache_translations[$original] = $translation;
+      }
+    }
+  }
+
+  /**
+   * Returns a string from the "originals" table
+   *
+   * @access private
+   * @param int num Offset number of original string
+   * @return string Requested string if found, otherwise ''
+   */
+  function get_original_string($num) {
+    $length = $this->table_originals[$num * 2 + 1];
+    $offset = $this->table_originals[$num * 2 + 2];
+    if (! $length)
+      return '';
+    $this->STREAM->seekto($offset);
+    $data = $this->STREAM->read($length);
+    return (string)$data;
+  }
+
+  /**
+   * Returns a string from the "translations" table
+   *
+   * @access private
+   * @param int num Offset number of original string
+   * @return string Requested string if found, otherwise ''
+   */
+  function get_translation_string($num) {
+    $length = $this->table_translations[$num * 2 + 1];
+    $offset = $this->table_translations[$num * 2 + 2];
+    if (! $length)
+      return '';
+    $this->STREAM->seekto($offset);
+    $data = $this->STREAM->read($length);
+    return (string)$data;
+  }
+
+  /**
+   * Binary search for string
+   *
+   * @access private
+   * @param string string
+   * @param int start (internally used in recursive function)
+   * @param int end (internally used in recursive function)
+   * @return int string number (offset in originals table)
+   */
+  function find_string($string, $start = -1, $end = -1) {
+    if (($start == -1) or ($end == -1)) {
+      // find_string is called with only one parameter, set start end end
+      $start = 0;
+      $end = $this->total;
+    }
+    if (abs($start - $end) <= 1) {
+      // We're done, now we either found the string, or it doesn't exist
+      $txt = $this->get_original_string($start);
+      if ($string == $txt)
+        return $start;
+      else
+        return -1;
+    } else if ($start > $end) {
+      // start > end -> turn around and start over
+      return $this->find_string($string, $end, $start);
+    } else {
+      // Divide table in two parts
+      $half = (int)(($start + $end) / 2);
+      $cmp = strcmp($string, $this->get_original_string($half));
+      if ($cmp == 0)
+        // string is exactly in the middle => return it
+        return $half;
+      else if ($cmp < 0)
+        // The string is in the upper half
+        return $this->find_string($string, $start, $half);
+      else
+        // The string is in the lower half
+        return $this->find_string($string, $half, $end);
+    }
+  }
+
+  /**
+   * Translates a string
+   *
+   * @access public
+   * @param string string to be translated
+   * @return string translated string (or original, if not found)
+   */
+  function translate($string) {
+    if ($this->short_circuit)
+      return $string;
+    $this->load_tables();
+
+    if ($this->enable_cache) {
+      // Caching enabled, get translated string from cache
+      if (array_key_exists($string, $this->cache_translations))
+        return $this->cache_translations[$string];
+      else
+        return $string;
+    } else {
+      // Caching not enabled, try to find string
+      $num = $this->find_string($string);
+      if ($num == -1)
+        return $string;
+      else
+        return $this->get_translation_string($num);
+    }
+  }
+
+  /**
+   * Sanitize plural form expression for use in PHP eval call.
+   *
+   * @access private
+   * @return string sanitized plural form expression
+   */
+  function sanitize_plural_expression($expr) {
+    // Get rid of disallowed characters.
+    $expr = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $expr);
+
+    // Add parenthesis for tertiary '?' operator.
+    $expr .= ';';
+    $res = '';
+    $p = 0;
+    for ($i = 0; $i < strlen($expr); $i++) {
+      $ch = $expr[$i];
+      switch ($ch) {
+      case '?':
+        $res .= ' ? (';
+        $p++;
+        break;
+      case ':':
+        $res .= ') : (';
+        break;
+      case ';':
+        $res .= str_repeat( ')', $p) . ';';
+        $p = 0;
+        break;
+      default:
+        $res .= $ch;
+      }
+    }
+    return $res;
+  }
+
+  /**
+   * Parse full PO header and extract only plural forms line.
+   *
+   * @access private
+   * @return string verbatim plural form header field
+   */
+  function extract_plural_forms_header_from_po_header($header) {
+    if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs))
+      $expr = $regs[2];
+    else
+      $expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
+    return $expr;
+  }
+
+  /**
+   * Get possible plural forms from MO header
+   *
+   * @access private
+   * @return string plural form header
+   */
+  function get_plural_forms() {
+    // lets assume message number 0 is header
+    // this is true, right?
+    $this->load_tables();
+
+    // cache header field for plural forms
+    if (! is_string($this->pluralheader)) {
+      if ($this->enable_cache) {
+        $header = $this->cache_translations[""];
+      } else {
+        $header = $this->get_translation_string(0);
+      }
+      $expr = $this->extract_plural_forms_header_from_po_header($header);
+      $this->pluralheader = $this->sanitize_plural_expression($expr);
+    }
+    return $this->pluralheader;
+  }
+
+  /**
+   * Detects which plural form to take
+   *
+   * @access private
+   * @param n count
+   * @return int array index of the right plural form
+   */
+  function select_string($n) {
+    $string = $this->get_plural_forms();
+    $string = str_replace('nplurals',"\$total",$string);
+    $string = str_replace("n",$n,$string);
+    $string = str_replace('plural',"\$plural",$string);
+
+    $total = 0;
+    $plural = 0;
+
+    eval("$string");
+    if ($plural >= $total) $plural = $total - 1;
+    return $plural;
+  }
+
+  /**
+   * Plural version of gettext
+   *
+   * @access public
+   * @param string single
+   * @param string plural
+   * @param string number
+   * @return translated plural form
+   */
+  function ngettext($single, $plural, $number) {
+    if ($this->short_circuit) {
+      if ($number != 1)
+        return $plural;
+      else
+        return $single;
+    }
+
+    // find out the appropriate form
+    $select = $this->select_string($number);
+
+    // this should contains all strings separated by NULLs
+    $key = $single . chr(0) . $plural;
+
+
+    if ($this->enable_cache) {
+      if (! array_key_exists($key, $this->cache_translations)) {
+        return ($number != 1) ? $plural : $single;
+      } else {
+        $result = $this->cache_translations[$key];
+        $list = explode(chr(0), $result);
+        return $list[$select];
+      }
+    } else {
+      $num = $this->find_string($key);
+      if ($num == -1) {
+        return ($number != 1) ? $plural : $single;
+      } else {
+        $result = $this->get_translation_string($num);
+        $list = explode(chr(0), $result);
+        return $list[$select];
+      }
+    }
+  }
+
+  function pgettext($context, $msgid) {
+    $key = $context . chr(4) . $msgid;
+    $ret = $this->translate($key);
+    if (strpos($ret, "\004") !== FALSE) {
+      return $msgid;
+    } else {
+      return $ret;
+    }
+  }
+
+  function npgettext($context, $singular, $plural, $number) {
+    $key = $context . chr(4) . $singular;
+    $ret = $this->ngettext($key, $plural, $number);
+    if (strpos($ret, "\004") !== FALSE) {
+      return $singular;
+    } else {
+      return $ret;
+    }
+
+  }
+}
+
+?>
diff --git a/simpleid/www/lib/gettext/streams.php b/simpleid/www/lib/gettext/streams.php
new file mode 100644
index 0000000..3cdc158
--- /dev/null
+++ b/simpleid/www/lib/gettext/streams.php
@@ -0,0 +1,167 @@
+<?php
+/*
+   Copyright (c) 2003, 2005, 2006, 2009 Danilo Segan <danilo@kvota.net>.
+
+   This file is part of PHP-gettext.
+
+   PHP-gettext 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.
+
+   PHP-gettext is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with PHP-gettext; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+*/
+
+
+  // Simple class to wrap file streams, string streams, etc.
+  // seek is essential, and it should be byte stream
+class StreamReader {
+  // should return a string [FIXME: perhaps return array of bytes?]
+  function read($bytes) {
+    return false;
+  }
+
+  // should return new position
+  function seekto($position) {
+    return false;
+  }
+
+  // returns current position
+  function currentpos() {
+    return false;
+  }
+
+  // returns length of entire stream (limit for seekto()s)
+  function length() {
+    return false;
+  }
+};
+
+class StringReader {
+  var $_pos;
+  var $_str;
+
+  function StringReader($str='') {
+    $this->_str = $str;
+    $this->_pos = 0;
+  }
+
+  function read($bytes) {
+    $data = substr($this->_str, $this->_pos, $bytes);
+    $this->_pos += $bytes;
+    if (strlen($this->_str)<$this->_pos)
+      $this->_pos = strlen($this->_str);
+
+    return $data;
+  }
+
+  function seekto($pos) {
+    $this->_pos = $pos;
+    if (strlen($this->_str)<$this->_pos)
+      $this->_pos = strlen($this->_str);
+    return $this->_pos;
+  }
+
+  function currentpos() {
+    return $this->_pos;
+  }
+
+  function length() {
+    return strlen($this->_str);
+  }
+
+};
+
+
+class FileReader {
+  var $_pos;
+  var $_fd;
+  var $_length;
+
+  function FileReader($filename) {
+    if (file_exists($filename)) {
+
+      $this->_length=filesize($filename);
+      $this->_pos = 0;
+      $this->_fd = fopen($filename,'rb');
+      if (!$this->_fd) {
+        $this->error = 3; // Cannot read file, probably permissions
+        return false;
+      }
+    } else {
+      $this->error = 2; // File doesn't exist
+      return false;
+    }
+  }
+
+  function read($bytes) {
+    if ($bytes) {
+      fseek($this->_fd, $this->_pos);
+
+      // PHP 5.1.1 does not read more than 8192 bytes in one fread()
+      // the discussions at PHP Bugs suggest it's the intended behaviour
+      $data = '';
+      while ($bytes > 0) {
+        $chunk  = fread($this->_fd, $bytes);
+        $data  .= $chunk;
+        $bytes -= strlen($chunk);
+      }
+      $this->_pos = ftell($this->_fd);
+
+      return $data;
+    } else return '';
+  }
+
+  function seekto($pos) {
+    fseek($this->_fd, $pos);
+    $this->_pos = ftell($this->_fd);
+    return $this->_pos;
+  }
+
+  function currentpos() {
+    return $this->_pos;
+  }
+
+  function length() {
+    return $this->_length;
+  }
+
+  function close() {
+    fclose($this->_fd);
+  }
+
+};
+
+// Preloads entire file in memory first, then creates a StringReader
+// over it (it assumes knowledge of StringReader internals)
+class CachedFileReader extends StringReader {
+  function CachedFileReader($filename) {
+    if (file_exists($filename)) {
+
+      $length=filesize($filename);
+      $fd = fopen($filename,'rb');
+
+      if (!$fd) {
+        $this->error = 3; // Cannot read file, probably permissions
+        return false;
+      }
+      $this->_str = fread($fd, $length);
+      fclose($fd);
+
+    } else {
+      $this->error = 2; // File doesn't exist
+      return false;
+    }
+  }
+};
+
+
+?>
diff --git a/simpleid/www/lib/xtemplate.class.php b/simpleid/www/lib/xtemplate.class.php
new file mode 100644
index 0000000..84713c6
--- /dev/null
+++ b/simpleid/www/lib/xtemplate.class.php
@@ -0,0 +1,1301 @@
+<?php
+
+// When developing uncomment the line below, re-comment before making public
+//error_reporting(E_ALL);
+
+/**
+ * XTemplate PHP templating engine
+ *
+ * @package XTemplate
+ * @author Barnabas Debreceni [cranx@users.sourceforge.net]
+ * @copyright Barnabas Debreceni 2000-2001
+ * @author Jeremy Coates [cocomp@users.sourceforge.net]
+ * @copyright Jeremy Coates 2002-2007
+ * @see license.txt LGPL / BSD license
+ * @since PHP 5
+ * @link $HeadURL: https://xtpl.svn.sourceforge.net/svnroot/xtpl/trunk/xtemplate.class.php $
+ * @version $Id$
+ *
+ *
+ * XTemplate class - http://www.phpxtemplate.org/ (x)html / xml generation with templates - fast & easy
+ * Latest stable & Subversion versions available @ http://sourceforge.net/projects/xtpl/
+ * License: LGPL / BSD - see license.txt
+ * Changelog: see changelog.txt
+ */
+class XTemplate {
+
+	/**
+	 * Properties
+	 */
+
+	/**
+	 * Raw contents of the template file
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $filecontents = '';
+
+	/**
+	 * Unparsed blocks
+	 *
+	 * @access public
+	 * @var array
+	 */
+	public $blocks = array();
+
+	/**
+	 * Parsed blocks
+	 *
+	 * @var unknown_type
+	 */
+	public $parsed_blocks = array();
+
+	/**
+	 * Preparsed blocks (for file includes)
+	 *
+	 * @access public
+	 * @var array
+	 */
+	public $preparsed_blocks = array();
+
+	/**
+	 * Block parsing order for recursive parsing
+	 * (Sometimes reverse :)
+	 *
+	 * @access public
+	 * @var array
+	 */
+	public $block_parse_order = array();
+
+	/**
+	 * Store sub-block names
+	 * (For fast resetting)
+	 *
+	 * @access public
+	 * @var array
+	 */
+	public $sub_blocks = array();
+
+	/**
+	 * Variables array
+	 *
+	 * @access public
+	 * @var array
+	 */
+	public $vars = array();
+
+	/**
+	 * File variables array
+	 *
+	 * @access public
+	 * @var array
+	 */
+	public $filevars = array();
+
+	/**
+	 * Filevars' parent block
+	 *
+	 * @access public
+	 * @var array
+	 */
+	public $filevar_parent = array();
+
+	/**
+	 * File caching during duration of script
+	 * e.g. files only cached to speed {FILE "filename"} repeats
+	 *
+	 * @access public
+	 * @var array
+	 */
+	public $filecache = array();
+
+	/**
+	 * Location of template files
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $tpldir = '';
+
+	/**
+	 * Filenames lookup table
+	 *
+	 * @access public
+	 * @var null
+	 */
+	public $files = null;
+
+	/**
+	 * Template filename
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $filename = '';
+
+	// moved to setup method so uses the tag_start & end_delims
+	/**
+	 * RegEx for file includes
+	 *
+	 * "/\{FILE\s*\"([^\"]+)\"\s*\}/m";
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $file_delim = '';
+
+	/**
+	 * RegEx for file include variable
+	 *
+	 * "/\{FILE\s*\{([A-Za-z0-9\._]+?)\}\s*\}/m";
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $filevar_delim = '';
+
+	/**
+	 * RegEx for file includes with newlines
+	 *
+	 * "/^\s*\{FILE\s*\{([A-Za-z0-9\._]+?)\}\s*\}\s*\n/m";
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $filevar_delim_nl = '';
+
+	/**
+	 * Template block start delimiter
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $block_start_delim = '<!-- ';
+
+	/**
+	 * Template block end delimiter
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $block_end_delim = '-->';
+
+	/**
+	 * Template block start word
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $block_start_word = 'BEGIN:';
+
+	/**
+	 * Template block end word
+	 *
+	 * The last 3 properties and this make the delimiters look like:
+	 * @example <!-- BEGIN: block_name -->
+	 * if you use the default syntax.
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $block_end_word = 'END:';
+
+	/**
+	 * Template tag start delimiter
+	 *
+	 * This makes the delimiters look like:
+	 * @example {tagname}
+	 * if you use the default syntax.
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $tag_start_delim = '{';
+
+	/**
+	 * Template tag end delimiter
+	 *
+	 * This makes the delimiters look like:
+	 * @example {tagname}
+	 * if you use the default syntax.
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $tag_end_delim = '}';
+	/* this makes the delimiters look like: {tagname} if you use my syntax. */
+
+	/**
+	 * Regular expression element for comments within tags and blocks
+	 *
+	 * @example {tagname#My Comment}
+	 * @example {tagname #My Comment}
+	 * @example <!-- BEGIN: blockname#My Comment -->
+	 * @example <!-- BEGIN: blockname #My Comment -->
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $comment_preg = '( ?#.*?)?';
+
+	/**
+	 * Default main template block name
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $mainblock = 'main';
+
+	/**
+	 * Script output type
+	 *
+	 * @access public
+	 * @var string
+	 */
+	public $output_type = 'HTML';
+
+	/**
+	 * Debug mode
+	 *
+	 * @access public
+	 * @var boolean
+	 */
+	public $debug = false;
+
+	/**
+	 * Null string for unassigned vars
+	 *
+	 * @access protected
+	 * @var array
+	 */
+	protected $_null_string = array('' => '');
+
+	/**
+	 * Null string for unassigned blocks
+	 *
+	 * @access protected
+	 * @var array
+	 */
+	protected $_null_block = array('' => '');
+
+	/**
+	 * Errors
+	 *
+	 * @access protected
+	 * @var string
+	 */
+	protected $_error = '';
+
+	/**
+	 * Auto-reset sub blocks
+	 *
+	 * @access protected
+	 * @var boolean
+	 */
+	protected $_autoreset = true;
+
+	/**
+	 * Set to FALSE to generate errors if a non-existant blocks is referenced
+	 *
+	 * @author NW
+	 * @since 2002/10/17
+	 * @access protected
+	 * @var boolean
+	 */
+	protected $_ignore_missing_blocks = true;
+
+	/**
+     * PHP 5 Constructor - Instantiate the object
+     *
+     * @param string $file Template file to work on
+     * @param string/array $tpldir Location of template files (useful for keeping files outside web server root)
+     * @param array $files Filenames lookup
+     * @param string $mainblock Name of main block in the template
+     * @param boolean $autosetup If true, run setup() as part of constuctor
+     * @return XTemplate
+     */
+	public function __construct($file, $tpldir = '', $files = null, $mainblock = 'main', $autosetup = true) {
+
+		$this->restart($file, $tpldir, $files, $mainblock, $autosetup, $this->tag_start_delim, $this->tag_end_delim);
+	}
+
+	/*
+     * PHP 4 Constructor - Instantiate the object
+     *
+     * @deprecated Use PHP 5 constructor instead
+     * @param string $file Template file to work on
+     * @param string/array $tpldir Location of template files (useful for keeping files outside web server root)
+     * @param array $files Filenames lookup
+     * @param string $mainblock Name of main block in the template
+     * @param boolean $autosetup If true, run setup() as part of constuctor
+     * @return XTemplate
+     *
+	public function XTemplate ($file, $tpldir = '', $files = null, $mainblock = 'main', $autosetup = true) {
+
+		assert('Deprecated - use PHP 5 constructor');
+	}*/
+
+
+	/***************************************************************************/
+	/***[ public stuff ]********************************************************/
+	/***************************************************************************/
+
+	/**
+	 * Restart the class - allows one instantiation with several files processed by restarting
+	 * e.g. $xtpl = new XTemplate('file1.xtpl');
+	 * $xtpl->parse('main');
+	 * $xtpl->out('main');
+	 * $xtpl->restart('file2.xtpl');
+	 * $xtpl->parse('main');
+	 * $xtpl->out('main');
+	 * (Added in response to sf:641407 feature request)
+	 *
+	 * @param string $file Template file to work on
+	 * @param string/array $tpldir Location of template files
+	 * @param array $files Filenames lookup
+	 * @param string $mainblock Name of main block in the template
+	 * @param boolean $autosetup If true, run setup() as part of restarting
+	 * @param string $tag_start {
+	 * @param string $tag_end }
+	 */
+	public function restart ($file, $tpldir = '', $files = null, $mainblock = 'main', $autosetup = true, $tag_start = '{', $tag_end = '}') {
+
+		$this->filename = $file;
+
+		// From SF Feature request 1202027
+		// Kenneth Kalmer
+		$this->tpldir = $tpldir;
+		if (defined('XTPL_DIR') && empty($this->tpldir)) {
+			$this->tpldir = XTPL_DIR;
+		}
+
+		if (is_array($files)) {
+			$this->files = $files;
+		}
+
+		$this->mainblock = $mainblock;
+
+		$this->tag_start_delim = $tag_start;
+		$this->tag_end_delim = $tag_end;
+
+		// Start with fresh file contents
+		$this->filecontents = '';
+
+		// Reset the template arrays
+		$this->blocks = array();
+		$this->parsed_blocks = array();
+		$this->preparsed_blocks = array();
+		$this->block_parse_order = array();
+		$this->sub_blocks = array();
+		$this->vars = array();
+		$this->filevars = array();
+		$this->filevar_parent = array();
+		$this->filecache = array();
+
+		if ($autosetup) {
+			$this->setup();
+		}
+	}
+
+	/**
+     * setup - the elements that were previously in the constructor
+     *
+     * @access public
+     * @param boolean $add_outer If true is passed when called, it adds an outer main block to the file
+     */
+	public function setup ($add_outer = false) {
+
+		$this->tag_start_delim = preg_quote($this->tag_start_delim);
+		$this->tag_end_delim = preg_quote($this->tag_end_delim);
+
+		// Setup the file delimiters
+
+		// regexp for file includes
+		$this->file_delim = "/" . $this->tag_start_delim . "FILE\s*\"([^\"]+)\"" . $this->comment_preg . $this->tag_end_delim . "/m";
+
+		// regexp for file includes
+		$this->filevar_delim = "/" . $this->tag_start_delim . "FILE\s*" . $this->tag_start_delim . "([A-Za-z0-9\._]+?)" . $this->comment_preg . $this->tag_end_delim . $this->comment_preg . $this->tag_end_delim . "/m";
+
+		// regexp for file includes w/ newlines
+		$this->filevar_delim_nl = "/^\s*" . $this->tag_start_delim . "FILE\s*" . $this->tag_start_delim . "([A-Za-z0-9\._]+?)" . $this->comment_preg . $this->tag_end_delim . $this->comment_preg . $this->tag_end_delim . "\s*\n/m";
+
+		if (empty($this->filecontents)) {
+			// read in template file
+			$this->filecontents = $this->_r_getfile($this->filename);
+		}
+
+		if ($add_outer) {
+			$this->_add_outer_block();
+		}
+
+		// preprocess some stuff
+		$this->blocks = $this->_maketree($this->filecontents, '');
+		$this->filevar_parent = $this->_store_filevar_parents($this->blocks);
+		$this->scan_globals();
+	}
+
+	/**
+     * assign a variable
+     *
+     * @example Simplest case:
+     * @example $xtpl->assign('name', 'value');
+     * @example {name} in template
+     *
+     * @example Array assign:
+     * @example $xtpl->assign(array('name' => 'value', 'name2' => 'value2'));
+     * @example {name} {name2} in template
+     *
+     * @example Value as array assign:
+     * @example $xtpl->assign('name', array('key' => 'value', 'key2' => 'value2'));
+     * @example {name.key} {name.key2} in template
+     *
+     * @example Reset array:
+     * @example $xtpl->assign('name', array('key' => 'value', 'key2' => 'value2'));
+     * @example // Other code then:
+     * @example $xtpl->assign('name', array('key3' => 'value3'), false);
+     * @example {name.key} {name.key2} {name.key3} in template
+     *
+     * @access public
+     * @param string $name Variable to assign $val to
+     * @param string / array $val Value to assign to $name
+	 * @param boolean $reset_array Reset the variable array if $val is an array
+     */
+	public function assign ($name, $val = '', $reset_array = true) {
+
+		if (is_array($name)) {
+
+			foreach ($name as $k => $v) {
+
+				$this->vars[$k] = $v;
+			}
+		} elseif (is_array($val)) {
+
+			// Clear the existing values
+    		if ($reset_array) {
+    			$this->vars[$name] = array();
+    		}
+
+        	foreach ($val as $k => $v) {
+
+        		$this->vars[$name][$k] = $v;
+        	}
+
+		} else {
+
+			$this->vars[$name] = $val;
+		}
+	}
+
+	/**
+     * assign a file variable
+     *
+     * @access public
+     * @param string $name Variable to assign $val to
+     * @param string / array $val Values to assign to $name
+     */
+	public function assign_file ($name, $val = '') {
+
+		if (is_array($name)) {
+
+			foreach ($name as $k => $v) {
+
+				$this->_assign_file_sub($k, $v);
+			}
+		} else {
+
+			$this->_assign_file_sub($name, $val);
+		}
+	}
+
+	/**
+     * parse a block
+     *
+     * @access public
+     * @param string $bname Block name to parse
+     */
+	public function parse ($bname) {
+
+		if (isset($this->preparsed_blocks[$bname])) {
+
+			$copy = $this->preparsed_blocks[$bname];
+
+		} elseif (isset($this->blocks[$bname])) {
+
+			$copy = $this->blocks[$bname];
+
+		} elseif ($this->_ignore_missing_blocks) {
+			// ------------------------------------------------------
+			// NW : 17 Oct 2002. Added default of ignore_missing_blocks
+			//      to allow for generalised processing where some
+			//      blocks may be removed from the HTML without the
+			//      processing code needing to be altered.
+			// ------------------------------------------------------
+			// JRC: 3/1/2003 added set error to ignore missing functionality
+			$this->_set_error("parse: blockname [$bname] does not exist");
+			return;
+
+		} else {
+
+			$this->_set_error("parse: blockname [$bname] does not exist");
+		}
+
+		/* from there we should have no more {FILE } directives */
+		if (!isset($copy)) {
+			die('Block: ' . $bname);
+		}
+
+		$copy = preg_replace($this->filevar_delim_nl, '', $copy);
+
+		$var_array = array();
+
+		/* find & replace variables+blocks */
+		preg_match_all("|" . $this->tag_start_delim . "([A-Za-z0-9\._]+?" . $this->comment_preg . ")" . $this->tag_end_delim. "|", $copy, $var_array);
+
+		$var_array = $var_array[1];
+
+		foreach ($var_array as $k => $v) {
+
+			// Are there any comments in the tags {tag#a comment for documenting the template}
+			$any_comments = explode('#', $v);
+			$v = rtrim($any_comments[0]);
+
+			if (sizeof($any_comments) > 1) {
+
+				$comments = $any_comments[1];
+			} else {
+
+				$comments = '';
+			}
+
+			$sub = explode('.', $v);
+
+			if ($sub[0] == '_BLOCK_') {
+
+				unset($sub[0]);
+
+				$bname2 = implode('.', $sub);
+
+				// trinary operator eliminates assign error in E_ALL reporting
+				$var = isset($this->parsed_blocks[$bname2]) ? $this->parsed_blocks[$bname2] : null;
+				$nul = (!isset($this->_null_block[$bname2])) ? $this->_null_block[''] : $this->_null_block[$bname2];
+
+				if ($var === '') {
+
+					if ($nul == '') {
+						// -----------------------------------------------------------
+						// Removed requirement for blocks to be at the start of string
+						// -----------------------------------------------------------
+						//                      $copy=preg_replace("/^\s*\{".$v."\}\s*\n*/m","",$copy);
+						// Now blocks don't need to be at the beginning of a line,
+						//$copy=preg_replace("/\s*" . $this->tag_start_delim . $v . $this->tag_end_delim . "\s*\n*/m","",$copy);
+						$copy = preg_replace("|" . $this->tag_start_delim . $v . $this->tag_end_delim . "|m", '', $copy);
+
+					} else {
+
+						$copy = preg_replace("|" . $this->tag_start_delim . $v . $this->tag_end_delim . "|m", "$nul", $copy);
+					}
+				} else {
+
+					//$var = trim($var);
+					switch (true) {
+						case preg_match('/^\n/', $var) && preg_match('/\n$/', $var):
+							$var = substr($var, 1, -1);
+							break;
+
+						case preg_match('/^\n/', $var):
+							$var = substr($var, 1);
+							break;
+
+						case preg_match('/\n$/', $var):
+							$var = substr($var, 0, -1);
+							break;
+					}
+
+					// SF Bug no. 810773 - thanks anonymous
+					$var = str_replace('\\', '\\\\', $var);
+					// Ensure dollars in strings are not evaluated reported by SadGeezer 31/3/04
+					$var = str_replace('$', '\\$', $var);
+					// Replaced str_replaces with preg_quote
+					//$var = preg_quote($var);
+					$var = str_replace('\\|', '|', $var);
+					$copy = preg_replace("|" . $this->tag_start_delim . $v . $this->tag_end_delim . "|m", "$var", $copy);
+
+					if (preg_match('/^\n/', $copy) && preg_match('/\n$/', $copy)) {
+						$copy = substr($copy, 1, -1);
+					}
+				}
+			} else {
+
+				$var = $this->vars;
+
+				foreach ($sub as $v1) {
+
+					// NW 4 Oct 2002 - Added isset and is_array check to avoid NOTICE messages
+					// JC 17 Oct 2002 - Changed EMPTY to stlen=0
+					//                if (empty($var[$v1])) { // this line would think that zeros(0) were empty - which is not true
+					if (!isset($var[$v1]) || (!is_array($var[$v1]) && strlen($var[$v1]) == 0)) {
+
+						// Check for constant, when variable not assigned
+						if (defined($v1)) {
+
+							$var[$v1] = constant($v1);
+
+						} else {
+
+							$var[$v1] = null;
+						}
+					}
+
+					$var = $var[$v1];
+				}
+
+				$nul = (!isset($this->_null_string[$v])) ? ($this->_null_string[""]) : ($this->_null_string[$v]);
+				$var = (!isset($var)) ? $nul : $var;
+
+				if ($var === '') {
+					// -----------------------------------------------------------
+					// Removed requriement for blocks to be at the start of string
+					// -----------------------------------------------------------
+					//                    $copy=preg_replace("|^\s*\{".$v." ?#?".$comments."\}\s*\n|m","",$copy);
+					$copy = preg_replace("|" . $this->tag_start_delim . $v . "( ?#" . $comments . ")?" . $this->tag_end_delim . "|m", '', $copy);
+				}
+
+				$var = trim($var);
+				// SF Bug no. 810773 - thanks anonymous
+				$var = str_replace('\\', '\\\\', $var);
+				// Ensure dollars in strings are not evaluated reported by SadGeezer 31/3/04
+				$var = str_replace('$', '\\$', $var);
+				// Replace str_replaces with preg_quote
+				//$var = preg_quote($var);
+				$var = str_replace('\\|', '|', $var);
+				$copy = preg_replace("|" . $this->tag_start_delim . $v . "( ?#" . $comments . ")?" . $this->tag_end_delim . "|m", "$var", $copy);
+
+				if (preg_match('/^\n/', $copy) && preg_match('/\n$/', $copy)) {
+					$copy = substr($copy, 1);
+				}
+			}
+		}
+
+		if (isset($this->parsed_blocks[$bname])) {
+			$this->parsed_blocks[$bname] .= $copy;
+		} else {
+			$this->parsed_blocks[$bname] = $copy;
+		}
+
+		/* reset sub-blocks */
+		if ($this->_autoreset && (!empty($this->sub_blocks[$bname]))) {
+
+			reset($this->sub_blocks[$bname]);
+
+			foreach ($this->sub_blocks[$bname] as $k => $v) {
+				$this->reset($v);
+			}
+		}
+	}
+
+	/**
+     * returns the parsed text for a block, including all sub-blocks.
+     *
+     * @access public
+     * @param string $bname Block name to parse
+     */
+	public function rparse ($bname) {
+
+		if (!empty($this->sub_blocks[$bname])) {
+
+			reset($this->sub_blocks[$bname]);
+
+			foreach ($this->sub_blocks[$bname] as $k => $v) {
+
+				if (!empty($v)) {
+					$this->rparse($v);
+				}
+			}
+		}
+
+		$this->parse($bname);
+	}
+
+	/**
+     * inserts a loop ( call assign & parse )
+     *
+     * @access public
+     * @param string $bname Block name to assign
+     * @param string $var Variable to assign values to
+     * @param string / array $value Value to assign to $var
+    */
+	public function insert_loop ($bname, $var, $value = '') {
+
+		$this->assign($var, $value);
+		$this->parse($bname);
+	}
+
+	/**
+     * parses a block for every set of data in the values array
+     *
+     * @access public
+     * @param string $bname Block name to loop
+     * @param string $var Variable to assign values to
+     * @param array $values Values to assign to $var
+    */
+	public function array_loop ($bname, $var, &$values) {
+
+		if (is_array($values)) {
+
+			foreach($values as $v) {
+
+				$this->insert_loop($bname, $var, $v);
+			}
+		}
+	}
+
+	/**
+     * returns the parsed text for a block
+     *
+     * @access public
+     * @param string $bname Block name to return
+     * @return string
+     */
+	public function text ($bname = '') {
+
+		$text = '';
+
+		if ($this->debug && $this->output_type == 'HTML') {
+			// JC 20/11/02 echo the template filename if in development as
+			// html comment
+			$text .= '<!-- XTemplate: ' . realpath($this->filename) . " -->\n";
+		}
+
+		$bname = !empty($bname) ? $bname : $this->mainblock;
+
+		$text .= isset($this->parsed_blocks[$bname]) ? $this->parsed_blocks[$bname] : $this->get_error();
+
+		return $text;
+	}
+
+	/**
+     * prints the parsed text
+     *
+     * @access public
+     * @param string $bname Block name to echo out
+     */
+	public function out ($bname) {
+
+		$out = $this->text($bname);
+		//        $length=strlen($out);
+		//header("Content-Length: ".$length); // TODO: Comment this back in later
+
+		echo $out;
+	}
+
+	/**
+     * prints the parsed text to a specified file
+     *
+     * @access public
+     * @param string $bname Block name to write out
+     * @param string $fname File name to write to
+     */
+	public function out_file ($bname, $fname) {
+
+		if (!empty($bname) && !empty($fname) && is_writeable($fname)) {
+
+			$fp = fopen($fname, 'w');
+			fwrite($fp, $this->text($bname));
+			fclose($fp);
+		}
+	}
+
+	/**
+     * resets the parsed text
+     *
+     * @access public
+     * @param string $bname Block to reset
+     */
+	public function reset ($bname) {
+
+		$this->parsed_blocks[$bname] = '';
+	}
+
+	/**
+     * returns true if block was parsed, false if not
+     *
+     * @access public
+     * @param string $bname Block name to test
+     * @return boolean
+     */
+	public function parsed ($bname) {
+
+		return (!empty($this->parsed_blocks[$bname]));
+	}
+
+	/**
+     * sets the string to replace in case the var was not assigned
+     *
+     * @access public
+     * @param string $str Display string for null block
+     * @param string $varname Variable name to apply $str to
+     */
+	public function set_null_string($str, $varname = '') {
+
+		$this->_null_string[$varname] = $str;
+	}
+
+	/**
+	 * Backwards compatibility only
+	 *
+	 * @param string $str
+	 * @param string $varname
+	 * @deprecated Change to set_null_string to keep in with rest of naming convention
+	 */
+	public function SetNullString ($str, $varname = '') {
+		$this->set_null_string($str, $varname);
+	}
+
+	/**
+     * sets the string to replace in case the block was not parsed
+     *
+     * @access public
+     * @param string $str Display string for null block
+     * @param string $bname Block name to apply $str to
+     */
+	public function set_null_block ($str, $bname = '') {
+
+		$this->_null_block[$bname] = $str;
+	}
+
+	/**
+	 * Backwards compatibility only
+	 *
+	 * @param string $str
+	 * @param string $bname
+	 * @deprecated Change to set_null_block to keep in with rest of naming convention
+	 */
+	public function SetNullBlock ($str, $bname = '') {
+		$this->set_null_block($str, $bname);
+	}
+
+	/**
+     * sets AUTORESET to 1. (default is 1)
+     * if set to 1, parse() automatically resets the parsed blocks' sub blocks
+     * (for multiple level blocks)
+     *
+     * @access public
+     */
+	public function set_autoreset () {
+
+		$this->_autoreset = true;
+	}
+
+	/**
+     * sets AUTORESET to 0. (default is 1)
+     * if set to 1, parse() automatically resets the parsed blocks' sub blocks
+     * (for multiple level blocks)
+     *
+     * @access public
+     */
+	public function clear_autoreset () {
+
+		$this->_autoreset = false;
+	}
+
+	/**
+     * scans global variables and assigns to PHP array
+     *
+     * @access public
+     */
+	public function scan_globals () {
+
+		foreach ($GLOBALS as $k => $v) {
+			$GLOB[$k] = $v;
+		}
+
+		/**
+		 * Access global variables as:
+		 * @example {PHP._SERVER.HTTP_HOST}
+		 * in your template!
+		 */
+		$this->assign('PHP', $GLOB);
+	}
+
+	/**
+     * gets error condition / string
+     *
+     * @access public
+     * @return boolean / string
+     */
+	public function get_error () {
+
+		// JRC: 3/1/2003 Added ouptut wrapper and detection of output type for error message output
+		$retval = false;
+
+		if ($this->_error != '') {
+
+			switch ($this->output_type) {
+				case 'HTML':
+				case 'html':
+					$retval = '<b>[XTemplate]</b><ul>' . nl2br(str_replace('* ', '<li>', str_replace(" *\n", "</li>\n", $this->_error))) . '</ul>';
+					break;
+
+				default:
+					$retval = '[XTemplate] ' . str_replace(' *\n', "\n", $this->_error);
+					break;
+			}
+		}
+
+		return $retval;
+	}
+
+	/***************************************************************************/
+	/***[ private stuff ]*******************************************************/
+	/***************************************************************************/
+
+	/**
+     * generates the array containing to-be-parsed stuff:
+     * $blocks["main"],$blocks["main.table"],$blocks["main.table.row"], etc.
+     * also builds the reverse parse order.
+     *
+     * @access public - aiming for private
+     * @param string $con content to be processed
+     * @param string $parentblock name of the parent block in the block hierarchy
+     */
+	public function _maketree ($con, $parentblock='') {
+
+		$blocks = array();
+
+		$con2 = explode($this->block_start_delim, $con);
+
+		if (!empty($parentblock)) {
+
+			$block_names = explode('.', $parentblock);
+			$level = sizeof($block_names);
+
+		} else {
+
+			$block_names = array();
+			$level = 0;
+		}
+
+		// JRC 06/04/2005 Added block comments (on BEGIN or END) <!-- BEGIN: block_name#Comments placed here -->
+		//$patt = "($this->block_start_word|$this->block_end_word)\s*(\w+)\s*$this->block_end_delim(.*)";
+		$patt = "(" . $this->block_start_word . "|" . $this->block_end_word . ")\s*(\w+)" . $this->comment_preg . "\s*" . $this->block_end_delim . "(.*)";
+
+		foreach($con2 as $k => $v) {
+
+			$res = array();
+
+			if (preg_match_all("/$patt/ims", $v, $res, PREG_SET_ORDER)) {
+				// $res[0][1] = BEGIN or END
+				// $res[0][2] = block name
+				// $res[0][3] = comment
+				// $res[0][4] = kinda content
+				$block_word	= $res[0][1];
+				$block_name	= $res[0][2];
+				$comment	= $res[0][3];
+				$content	= $res[0][4];
+
+				if (strtoupper($block_word) == $this->block_start_word) {
+
+					$parent_name = implode('.', $block_names);
+
+					// add one level - array("main","table","row")
+					$block_names[++$level] = $block_name;
+
+					// make block name (main.table.row)
+					$cur_block_name=implode('.', $block_names);
+
+					// build block parsing order (reverse)
+					$this->block_parse_order[] = $cur_block_name;
+
+					//add contents. trinary operator eliminates assign error in E_ALL reporting
+					$blocks[$cur_block_name] = isset($blocks[$cur_block_name]) ? $blocks[$cur_block_name] . $content : $content;
+
+					// add {_BLOCK_.blockname} string to parent block
+					$blocks[$parent_name] .= str_replace('\\', '', $this->tag_start_delim) . '_BLOCK_.' . $cur_block_name . str_replace('\\', '', $this->tag_end_delim);
+
+					// store sub block names for autoresetting and recursive parsing
+					$this->sub_blocks[$parent_name][] = $cur_block_name;
+
+					// store sub block names for autoresetting
+					$this->sub_blocks[$cur_block_name][] = '';
+
+				} else if (strtoupper($block_word) == $this->block_end_word) {
+
+					unset($block_names[$level--]);
+
+					$parent_name = implode('.', $block_names);
+
+					// add rest of block to parent block
+					$blocks[$parent_name] .= $content;
+				}
+			} else {
+
+				// no block delimiters found
+				// Saves doing multiple implodes - less overhead
+				$tmp = implode('.', $block_names);
+
+				if ($k) {
+					$blocks[$tmp] .= $this->block_start_delim;
+				}
+
+				// trinary operator eliminates assign error in E_ALL reporting
+				$blocks[$tmp] = isset($blocks[$tmp]) ? $blocks[$tmp] . $v : $v;
+			}
+		}
+
+		return $blocks;
+	}
+
+	/**
+     * Sub processing for assign_file method
+     *
+     * @access private
+     * @param string $name
+     * @param string $val
+     */
+	private function _assign_file_sub ($name, $val) {
+
+		if (isset($this->filevar_parent[$name])) {
+
+			if ($val != '') {
+
+				$val = $this->_r_getfile($val);
+
+				foreach($this->filevar_parent[$name] as $parent) {
+
+					if (isset($this->preparsed_blocks[$parent]) && !isset($this->filevars[$name])) {
+
+						$copy = $this->preparsed_blocks[$parent];
+
+					} elseif (isset($this->blocks[$parent])) {
+
+						$copy = $this->blocks[$parent];
+					}
+
+					$res = array();
+
+					preg_match_all($this->filevar_delim, $copy, $res, PREG_SET_ORDER);
+
+					if (is_array($res) && isset($res[0])) {
+
+						// Changed as per solution in SF bug ID #1261828
+						foreach ($res as $v) {
+
+							// Changed as per solution in SF bug ID #1261828
+							if ($v[1] == $name) {
+
+								// Changed as per solution in SF bug ID #1261828
+								$copy = preg_replace("/" . preg_quote($v[0]) . "/", "$val", $copy);
+								$this->preparsed_blocks = array_merge($this->preparsed_blocks, $this->_maketree($copy, $parent));
+								$this->filevar_parent = array_merge($this->filevar_parent, $this->_store_filevar_parents($this->preparsed_blocks));
+							}
+						}
+					}
+				}
+			}
+		}
+
+		$this->filevars[$name] = $val;
+	}
+
+	/**
+     * store container block's name for file variables
+     *
+     * @access public - aiming for private
+     * @param array $blocks
+     * @return array
+     */
+	public function _store_filevar_parents ($blocks){
+
+		$parents = array();
+
+		foreach ($blocks as $bname => $con) {
+
+			$res = array();
+
+			preg_match_all($this->filevar_delim, $con, $res);
+
+			foreach ($res[1] as $k => $v) {
+
+				$parents[$v][] = $bname;
+			}
+		}
+		return $parents;
+	}
+
+	/**
+     * Set the error string
+     *
+     * @access private
+     * @param string $str
+     */
+	private function _set_error ($str)    {
+
+		// JRC: 3/1/2003 Made to append the error messages
+		$this->_error .= '* ' . $str . " *\n";
+		// JRC: 3/1/2003 Removed trigger error, use this externally if you want it eg. trigger_error($xtpl->get_error())
+		//trigger_error($this->get_error());
+	}
+
+	/**
+     * returns the contents of a file
+     *
+     * @access protected
+     * @param string $file
+     * @return string
+     */
+	protected function _getfile ($file) {
+
+		if (!isset($file)) {
+			// JC 19/12/02 added $file to error message
+			$this->_set_error('!isset file name!' . $file);
+
+			return '';
+		}
+
+		// check if filename is mapped to other filename
+		if (isset($this->files)) {
+
+			if (isset($this->files[$file])) {
+
+				$file = $this->files[$file];
+			}
+		}
+
+		// prepend template dir
+		if (!empty($this->tpldir)) {
+
+			/**
+			 * Support hierarchy of file locations to search
+			 *
+			 * @example Supply array of filepaths when instantiating
+			 * 			First path supplied that has the named file is prioritised
+			 * 			$xtpl = new XTemplate('myfile.xtpl', array('.','/mypath', '/mypath2'));
+			 * @since 29/05/2007
+			 */
+			if (is_array($this->tpldir)) {
+
+				foreach ($this->tpldir as $dir) {
+
+					if (is_readable($dir . DIRECTORY_SEPARATOR . $file)) {
+						$file = $dir . DIRECTORY_SEPARATOR . $file;
+						break;
+					}
+				}
+			} else {
+
+				$file = $this->tpldir. DIRECTORY_SEPARATOR . $file;
+			}
+		}
+
+		$file_text = '';
+
+		if (isset($this->filecache[$file])) {
+
+			$file_text .= $this->filecache[$file];
+
+			if ($this->debug) {
+				$file_text = '<!-- XTemplate debug cached: ' . realpath($file) . ' -->' . "\n" . $file_text;
+			}
+
+		} else {
+
+			if (is_file($file) && is_readable($file)) {
+
+				if (filesize($file)) {
+
+					if (!($fh = fopen($file, 'r'))) {
+
+						$this->_set_error('Cannot open file: ' . realpath($file));
+						return '';
+					}
+
+					$file_text .= fread($fh,filesize($file));
+					fclose($fh);
+
+				}
+
+				if ($this->debug) {
+					$file_text = '<!-- XTemplate debug: ' . realpath($file) . ' -->' . "\n" . $file_text;
+				}
+
+			} elseif (str_replace('.', '', phpversion()) >= '430' && $file_text = @file_get_contents($file, true)) {
+				// Enable use of include path by using file_get_contents
+				// Implemented at suggestion of SF Feature Request ID #1529478 michaelgroh
+				if ($file_text === false) {
+					$this->_set_error("[" . realpath($file) . "] ($file) does not exist");
+					$file_text = "<b>__XTemplate fatal error: file [$file] does not exist in the include path__</b>";
+				} elseif ($this->debug) {
+					$file_text = '<!-- XTemplate debug: ' . realpath($file) . ' (via include path) -->' . "\n" . $file_text;
+				}
+			} elseif (!is_file($file)) {
+
+				// NW 17 Oct 2002 : Added realpath around the file name to identify where the code is searching.
+				$this->_set_error("[" . realpath($file) . "] ($file) does not exist");
+				$file_text .= "<b>__XTemplate fatal error: file [$file] does not exist__</b>";
+
+			} elseif (!is_readable($file)) {
+
+				$this->_set_error("[" . realpath($file) . "] ($file) is not readable");
+				$file_text .= "<b>__XTemplate fatal error: file [$file] is not readable__</b>";
+			}
+
+			$this->filecache[$file] = $file_text;
+		}
+
+		return $file_text;
+	}
+
+	/**
+     * recursively gets the content of a file with {FILE "filename.tpl"} directives
+     *
+     * @access public - aiming for private
+     * @param string $file
+     * @return string
+     */
+	public function _r_getfile ($file) {
+
+		$text = $this->_getfile($file);
+
+		$res = array();
+
+		while (preg_match($this->file_delim,$text,$res)) {
+
+			$text2 = $this->_getfile($res[1]);
+			$text = preg_replace("'".preg_quote($res[0])."'",$text2,$text);
+		}
+
+		return $text;
+	}
+
+
+	/**
+     * add an outer block delimiter set useful for rtfs etc - keeps them editable in word
+     *
+     * @access private
+     */
+	private function _add_outer_block () {
+
+		$before = $this->block_start_delim . $this->block_start_word . ' ' . $this->mainblock . ' ' . $this->block_end_delim;
+		$after = $this->block_start_delim . $this->block_end_word . ' ' . $this->mainblock . ' ' . $this->block_end_delim;
+
+		$this->filecontents = $before . "\n" . $this->filecontents . "\n" . $after;
+	}
+
+	/**
+     * Debug function - var_dump wrapped in '<pre></pre>' tags
+     *
+     * @access private
+     * @param multiple var_dumps all the supplied arguments
+     */
+	private function _pre_var_dump ($args) {
+
+		if ($this->debug) {
+			echo '<pre>';
+			var_dump(func_get_args());
+			echo '</pre>';
+		}
+	}
+} /* end of XTemplate class. */
+
+?>
