Exemple #1
0
 /**
  * Writes current values for user back to the database.
  * This method does nothing in the base class and is supposed to
  * be overridden in subclasses according to the supported backend.
  *
  * @return boolean true on success or false on failure
  *
  * @access private
  */
 function _updateUserData()
 {
     $index = 0;
     foreach ($this->userObj->children as $value) {
         if ($value->name == $this->alias['lastlogin']) {
             $el =& $this->userObj->getElement(array($index));
             $el->setContent($this->currentLogin);
         }
         $index++;
     }
     $success = false;
     do {
         $fp = fopen($this->file, 'wb');
         if (!$fp) {
             $errorMsg = "Auth freeze failure. Failed to open the xml file.";
             break;
         }
         if (!flock($fp, LOCK_EX)) {
             $errorMsg = "Auth freeze failure. Couldn't get an exclusive lock on the file.";
             break;
         }
         if (!fwrite($fp, $this->tree->get())) {
             $errorMsg = "Auth freeze failure. Write error when writing back the file.";
             break;
         }
         @fflush($fp);
         $success = true;
     } while (false);
     @flock($fp, LOCK_UN);
     @fclose($fp);
     if (!$success) {
         $this->_stack->push(LIVEUSER_ERROR, 'exception', array(), 'Cannot read XML Auth file: ' . $errorMsg);
     }
     return $success;
 }
Exemple #2
0
function update_shopinfo_xml()
{
    global $spalten;
    if (!file_exists(DIR_FS_SHOPINFO_XML) || filesize(DIR_FS_SHOPINFO_XML) == 0) {
        echo '<p class="ok">OK, die Shopdatei wurde noch nicht angelegt und muss folglich auch nicht angepasst werden.</p>' . "\n";
        return true;
    }
    echo '<p>Lade Shopdatei: <code>' . DIR_FS_SHOPINFO_XML . '</code>' . "\n";
    $tree = new XML_Tree(DIR_FS_SHOPINFO_XML, '1.0" encoding="ISO-8859-1');
    #$tree->useCdataSections();
    $root =& $tree->getTreeFromFile();
    if (PEAR::isError($root)) {
        echo '<p class="error">Fehler beim Parsen der Shopdatei:<br>' . "\n";
        echo $root->toString() . "</p>\n";
        return false;
    }
    $name_parts = explode(':', $root->name);
    if (sizeof($name_parts) > 1) {
        $namespace = $name_parts[0] . ':';
    } else {
        $namespace = '';
    }
    $requests =& $tree->getNodeAt($namespace . 'Shop/Requests');
    if (PEAR::isError($requests)) {
        #echo '<p>Warnung: Zugriff auf Produktdaten in der Shopdatei nicht gefunden.</p>'."\n";
        // Request-Tag nach dem Url-Tag einfügen
        $pos = -1;
        for ($i = 0; $i < count($root->children); ++$i) {
            if ($root->children[$i]->name == 'Url') {
                $pos = $i + 1;
            }
        }
        $requests = new XML_Tree_Node('Requests');
        $res =& $root->insertChild(null, $pos, $requests);
        if (PEAR::isError($res)) {
            echo '<p class="error">Das Requests-Tag konnte nicht in die shopinfo.xml eingef&uuml;gt werden:<br>' . "\n";
            echo $res->toString() . "</p>\n";
            return false;
        }
    }
    $offlineRequest =& $tree->getNodeAt($namespace . 'Shop/Requests/OfflineRequest');
    if (PEAR::isError($offlineRequest)) {
        #echo '<p>Warnung: Produktdatei-Angaben in der Shopdatei nicht gefunden.</p>'."\n";
        $offlineRequest =& offlineRequest($requests);
        echo '<p class="ok">OK, Produktdatei-Angaben erg&auml;nzt.</p>' . "\n";
    } else {
        $header =& $tree->getNodeAt($namespace . 'Shop/Requests/OfflineRequest/Format/Tabular/CSV/Header');
        if (PEAR::isError($header)) {
            echo '<p class="error">Das Kopfzeilen-Tag in der Shopdatei nicht gefunden:<br>' . "\n";
            echo $header->toString() . "</p>\n";
            return false;
        }
        $old_titel = $header->content;
        // Funktion getContent gibt es nicht.
        #echo 'old_titel: '.htmlspecialchars($old_titel)."\n\n";
        $corrected = false;
        if ($header->getAttribute('columns') != count($spalten)) {
            $header->setAttribute('columns', count($spalten));
            $corrected = true;
        }
        $mappings =& $tree->getNodeAt($namespace . 'Shop/Requests/OfflineRequest/Format/Tabular/Mappings');
        if (PEAR::isError($mappings)) {
            echo '<p class="error">Das Mappings-Tag in der Shopdatei nicht gefunden:<br>' . "\n";
            echo $mappings->toString() . "</p>\n";
            return false;
        }
        foreach ($mappings->children as $idx => $child) {
            if (count($child->attributes) > 0) {
                if ($child->getAttribute('columnName') != $spalten[$child->getAttribute('column') - 1]) {
                    #echo $idx.': '.$child->getAttribute('columnName').' =&gt; ';
                    $mappings->children[$idx]->setAttribute('columnName', $spalten[$child->getAttribute('column') - 1]);
                    #echo $mappings->children[$idx]->getAttribute('columnName')."<br>\n";
                    $corrected = true;
                }
            }
        }
        if (defined('DEFAULT_QUOTE')) {
            $titel = DEFAULT_QUOTE . implode(DEFAULT_QUOTE . DEFAULT_DELIMITER . DEFAULT_QUOTE, $spalten) . DEFAULT_QUOTE;
        } else {
            $titel = implode(DEFAULT_DELIMITER, $spalten);
        }
        #echo 'titel: '.htmlspecialchars($titel)."\n\n";
        if ($old_titel != $titel) {
            $header->setContent($titel);
        }
        $special =& $tree->getNodeAt($namespace . 'Shop/Requests/OfflineRequest/Format/Tabular/CSV/SpecialCharacters');
        if (PEAR::isError($special)) {
            echo '<p class="error">Das Sonderzeichen-Tag in der Shopdatei nicht gefunden:<br>' . "\n";
            echo $special->toString() . "</p>\n";
            return false;
        }
        $old_escape = $special->getAttribute('escaped');
        $old_quote = $special->getAttribute('quoted');
        $old_lineend = $special->getAttribute('lineend');
        $old_delimiter = $special->getAttribute('delimiter');
        if (defined('DEFAULT_ESCAPE')) {
            $special->setAttribute('escaped', DEFAULT_ESCAPE);
        } else {
            $special->unsetAttribute('escaped');
        }
        if (defined('DEFAULT_QUOTE')) {
            $special->setAttribute('quoted', DEFAULT_QUOTE);
        } else {
            $special->unsetAttribute('quoted');
        }
        if (defined('DEFAULT_LINEEND')) {
            $special->setAttribute('lineend', DEFAULT_LINEEND == "\n" ? '\\n' : (DEFAULT_LINEEND == "\r" ? '\\r' : '\\r\\n'));
        } else {
            $special->unsetAttribute('lineend');
        }
        if (defined('DEFAULT_DELIMITER')) {
            $special->setAttribute('delimiter', DEFAULT_DELIMITER == "\t" ? '[tab]' : DEFAULT_DELIMITER);
        } else {
            $special->unsetAttribute('delimiter');
        }
        $new_escape = $special->getAttribute('escaped');
        $new_quote = $special->getAttribute('quoted');
        $new_lineend = $special->getAttribute('lineend');
        $new_delimiter = $special->getAttribute('delimiter');
        if (!$corrected && $old_titel == $titel && $new_escape == $old_escape && $new_quote == $old_quote && $new_lineend == $old_lineend && $new_delimiter == $old_delimiter) {
            echo '<p class="ok">OK, die Shopdatei wurde bereits aktualisiert.</p>' . "\n";
            return true;
        }
        if ($old_titel != $titel) {
            echo '<p class="ok">OK, Kopfzeile aktualisiert.</p>' . "\n";
        }
        if ($corrected) {
            echo '<p class="ok">OK, Spaltennamen aktualisiert.</p>' . "\n";
        }
        if ($new_escape != $old_escape) {
            echo '<p class="ok">OK, Escape-Zeichen aktualisiert.</p>' . "\n";
        }
        if ($new_quote != $old_quote) {
            echo '<p class="ok">OK, Zeichenkettenbegrenzer aktualisiert.</p>' . "\n";
        }
        if ($new_lineend != $old_lineend) {
            echo '<p class="ok">OK, Zeilenendezeichen aktualisiert.</p>' . "\n";
        }
        if ($new_delimiter != $old_delimiter) {
            echo '<p class="ok">OK, Trennzeichenzeichen aktualisiert.</p>' . "\n";
        }
    }
    #echo '<pre>'.(htmlspecialchars($tree->get())).'</pre>'."\n";
    if (!is_writable(DIR_FS_SHOPINFO_XML)) {
        echo '<p class="error">Die Shopdatei kann nicht geschrieben werden:<br>' . DIR_FS_SHOPINFO_XML . "</p>\n";
        return false;
    }
    if (!($handle = @fopen(DIR_FS_SHOPINFO_XML, 'wb'))) {
        echo '<p class="error">Die Shopdatei kann nicht zum Schreiben ge&ouml;ffnet werden:<br>' . DIR_FS_SHOPINFO_XML . "</p>\n";
        return false;
    }
    flock($handle, LOCK_EX);
    if (!@fwrite($handle, $tree->get())) {
        echo '<p class="error">Fehler beim Schreiben der Shopdatei:<br>' . DIR_FS_SHOPINFO_XML . "</p>\n";
        return false;
    }
    flock($handle, LOCK_UN);
    @fclose($handle);
    // wenn hier etwas schief geht, ignorieren
    #$tree->free();
    echo '<p class="ok">OK, die Shopdatei wurde aktualisiert.<br>' . DIR_FS_SHOPINFO_XML . '</p>' . "\n";
    return true;
}
Exemple #3
0
 /**
  * @brief Build a DiGIR search query.
  *
  * Given an institutional code (such as a museum abbreviation) and a specimen 
  * number we construct a DiGIR query to retrieve the corresponding record.
  * 
  * This is a bit of an undertaking as there is not an easy means to discover the
  * DiGIR provider corresponding to a given specimen code, and the DiGIR providers
  * themselves vary in what version of the DarwinCore schema they support. 
  * See The Big Dig (http://bigdig.ecoforge.net/wiki) for details.
  * Here I use the value of  <b>Revision</b> in the &lt;version&gt; tag in the header field of
  * the DiGIR provider response as a flag to use different code to make the query.
  *
  * By default I assume we have an original specimen code such as <b>FMNH 14734</b>,
  * and this has been parsed into the institution code (FMNH), a namespace (where needed),
  * and the specimen number
  * (14734). Namespaces are needed for two reasons:
  *    - Different taxon collections may have different providers (e.g., FMNH)
  *    - The same institution and specimen code may occur in different collections
  *      served by the same provider (e.g., MVZ)
  *
  * An example of an identifier is <b>FMNH:Mammals:14734</b>. 
  * In some cases, we need some further fussing. For example, the KU and Calacademy DiGIR
  * providers expects specimen numbers to include the institutional or collection prefix.
  *
  * I hard code the mapping between museum codes and DiGIR providers. 
  * If I was clever we'd do this via GBIF's UDDI interface, but that 
  * looks like a world of pain. Typically the DiGIR provider's URL is found by browsing
  * GBIF's web site. 
  *
  * The DiGIR query is a XML tree, which is then encoded as a URL. The tree varies depending
  * on whether the provider is serving schema 1.2 or 1.4.
  *
  * @param institution Institutional code
  * @param id Specimen number
  */
 function buildDIGIRQuery($institution, $id)
 {
     //echo $institution, "<br/>";
     // Kansas expects specimen codes to have KU at the start
     //		if (strcasecmp($institution,'KU-Herps') == 0) { $id = 'KU' . $id; }
     // Calacademy is similar to KU
     if (strcasecmp($institution, 'CASENT') == 0) {
         $id = strtolower($institution) . $id;
         $institution = 'CASENT';
     }
     if (strcasecmp($institution, 'inbiocri') == 0) {
         $id = strtolower($institution) . $id;
         $institution = 'CASENT';
     }
     if (strcasecmp($institution, 'lacment') == 0) {
         $id = 'lacm ent ' . $id;
         $institution = 'CASENT';
     }
     if (strcasecmp($institution, 'jtlc') == 0) {
         $id = strtolower($institution) . $id;
         $institution = 'CASENT';
     }
     $server = $this->serverURL[$institution];
     $resource = $this->resourceCode[$institution];
     // Build request message
     $tree = new XML_Tree();
     $root =& $tree->addRoot("request", '', array("xmlns" => 'http://digir.net/schema/protocol/2003/1.0', "xmlns:xsd" => 'http://www.w3.org/2001/XMLSchema', "xmlns:xsi" => 'http://www.w3.org/2001/XMLSchema-instance', "xmlns:digir" => 'http://digir.net/schema/protocol/2003/1.0', "xmlns:dwc" => 'http://digir.net/schema/conceptual/darwin/2003/1.0', "xmlns:darwin" => 'http://digir.net/schema/conceptual/darwin/2003/1.0', "xsi:schemaLocation" => 'http://digir.net/schema/protocol/2003/1.0', "xsi:schemaLocation" => 'http://digir.net/schema/protocol/2003/1.0 http://digir.sourceforge.net/schema/protocol/2003/1.0/digir.xsd http://digir.net/schema/conceptual/darwin/2003/1.0 http://digir.sourceforge.net/schema/conceptual/darwin/2003/1.0/darwin2.xsd'));
     $header =& $root->addChild("header");
     $header->addChild("version", "1.0.0");
     $header->addChild("sendTime", date("Ymd \\TG:i:s"));
     $header->addChild("source", $_SERVER['SERVER_ADDR']);
     $header->addChild("destination", $server, array("resource" => $resource));
     $header->addChild("type", "search");
     $search =& $root->addChild("search");
     $filter =& $search->addChild("filter");
     // Australian stuff served by Ozcam may have more than one provider
     switch ($institution) {
         case 'SAMA':
         case 'ANWC':
         case 'AMS':
         case 'WAM':
         case 'NT':
             $and =& $filter->addChild("and");
             $equals =& $and->addChild("equals");
             $equals->addChild("darwin:CatalogNumberText", $id);
             $equals2 =& $and->addChild("equals");
             $equals2->addChild("darwin:InstitutionCode", $institution);
             break;
         default:
             if (preg_match('/^MVZ/', $institution)) {
                 //echo $institution;
                 list($inst, $coll) = explode("-", $institution);
                 //echo $coll;
                 $and =& $filter->addChild("and");
                 $equals =& $and->addChild("equals");
                 $equals->addChild("darwin:CatalogNumberText", $id);
                 $equals2 =& $and->addChild("equals");
                 switch ($coll) {
                     case 'Herps':
                         $equals2->addChild("darwin:CollectionCode", 'Herp');
                         break;
                     case 'Mammals':
                         $equals2->addChild("darwin:CollectionCode", 'Mamm');
                         break;
                     case 'Birds':
                         $equals2->addChild("darwin:CollectionCode", 'Bird');
                         break;
                     default:
                         $equals2->addChild("darwin:CollectionCode", $coll);
                         break;
                 }
             } else {
                 $equals =& $filter->addChild("equals");
                 switch ($this->schema[$institution]) {
                     case "1.14":
                         $equals->addChild("darwin:CatalogNumber", $id);
                         break;
                     default:
                         $equals->addChild("darwin:CatalogNumberText", $id);
                         break;
                 }
             }
             break;
     }
     $records =& $search->addChild("records", "", array("limit" => 10, "start" => 0));
     if ($this->schema[$institution] == '1.12') {
         $records->addChild("structure", "", array("schemaLocation" => "http://digir.sourceforge.net/schema/conceptual/darwin/result/full/2003/darwin2resultfull.xsd"));
     } else {
         $structure =& $records->addChild("structure", "");
         $element =& $structure->addChild("xsd:element", "", array("name" => "record"));
         $complexType =& $element->addChild("xsd:complexType", "");
         $sequence =& $complexType->addChild("xsd:sequence", "");
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:InstitutionCode"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:CollectionCode"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:CatalogNumber"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:ScientificName"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:VerbatimCollectingDate"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:DateLastModified"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:YearCollected"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:MonthCollected"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:DayCollected"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:TimeCollected"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Kingdom"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Phylum"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Class"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Order"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Family"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Genus"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Species"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Subspecies"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Country"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:StateProvince"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:County"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Island"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:IslandGroup"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:ContinentOcean"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Locality"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:HorizontalDatum"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Collector"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Remarks"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:TypeStatus"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:OtherCatalogNumbers"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:CollectorNumber"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:FieldNumber"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:GenBankNum"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Latitude"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Longitude"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Sex"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:Notes"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:IdentifiedBy"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:YearIdentified"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:MonthIdentified"));
         $sequence->addChild("xsd:element", "", array("ref" => "darwin:DayIdentified"));
     }
     $xml = $tree->get();
     //echo $xml;
     // Strip XML header
     $xml = str_replace('<?xml version="1.0"?>', '', $xml);
     // Remove line breaks
     $xml = str_replace("\n", '', $xml);
     // Replace spaces with HEX code
     $xml = str_replace(" ", '%20', $xml);
     //echo $xml;
     $url = "http://{$server}?doc=";
     $url .= $xml;
     //echo $url;
     /*	$url = "http://$server?doc=<request%20xmlns='http://digir.net/schema/protocol/2003/1.0'%20xmlns:xsd='http://www.w3.org/2001/XMLSchema'%20xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'%20xmlns:digir='http://digir.net/schema/protocol/2003/1.0'%20xmlns:dwc='http://digir.net/schema/conceptual/darwin/2003/1.0'%20xmlns:darwin='http://digir.net/schema/conceptual/darwin/2003/1.0'%20xsi:schemaLocation='http://digir.net/schema/protocol/2003/1.0%20http://digir.sourceforge.net/schema/protocol/2003/1.0/digir.xsd%20http://digir.net/schema/conceptual/darwin/2003/1.0%20http://digir.sourceforge.net/schema/conceptual/darwin/2003/1.0/darwin2.xsd'><header><version>1.0.0</version><sendTime>20040324T094003+0100</sendTime><source>192.168.1.101</source><destination%20resource='$resource'>$server</destination><type>search</type></header><search><filter><equals><darwin:CatalogNumberText>$id</darwin:CatalogNumberText></equals></filter><records%20limit=\"10\"%20start=\"0\"><structure%20schemaLocation=\"http://bnhm.berkeley.museum/manis/DwC/darwin2resultfull.xsd\"%20/></records></search></request>";
      */
     return $url;
 }
        if (defined('AFFILIATES_CONTACT_EMAIL')) {
            $email =& $root->addChild('email', AFFILIATES_CONTACT_EMAIL);
        }
        if (defined('AFFILIATES_CONTACT_URL')) {
            $url =& $root->addChild('url', htmlentities(AFFILIATES_CONTACT_URL));
        }
        $description_de =& $root->addChild('description', 'Ihr Domainname ist bei uns noch nicht registriert. Bitte kontaktieren Sie uns.', array('lang' => 'de'));
        $description_en =& $root->addChild('description', 'We have not registered your domain name, yet. Please contact us.', array('lang' => 'en'));
    }
}
if (isset($_REQUEST['debug']) && $_REQUEST['debug'] == 'on') {
    $debug =& $root->addChild('debug');
    if (isset($name)) {
        $debug->addChild('name', $name);
    }
    if (isset($_SERVER['HTTP_USER_AGENT'])) {
        $debug->addChild('user-agent', $_SERVER['HTTP_USER_AGENT']);
    }
    if (isset($_SERVER['REMOTE_ADDR'])) {
        $debug->addChild('ip', $_SERVER['REMOTE_ADDR']);
        $debug->addChild('host', gethostbyaddr($_SERVER['REMOTE_ADDR']));
    }
    $ob_contents = trim(ob_get_contents());
    if (strlen($ob_contents) > 0) {
        $debug->addChild('text', $ob_contents);
    }
}
ob_end_clean();
// Falls schon Zeichen geschrieben wurden, diese verwerfen, damit nur das XML-Dokument geschrieben wird.
echo $tree->get();
<?php

require_once 'XML/Tree.php';
$tree = new XML_Tree();
$root =& $tree->addRoot('slide', '', array('title' => 'A simple slide'));
$root->addChild('blurb', 'A blurb element', array('align' => 'center'));
$root->addChild('example', '', array('type' => 'xml', 'filename' => 'data/sdphp_talks.xml'));
$list =& $root->addChild('list', '', array('type' => 'arrow'));
$list->addChild('bullet', 'first bullet');
$list->addChild('bullet', 'second bullet');
$out = $tree->get();
echo nl2br(htmlspecialchars($out));
Exemple #6
0
function generate_shopinfo()
{
    global $languages_id, $language_code, $currency, $currency_rate;
    // Alle Includes hier, wegen der Pfadangabe. Reihenfolge ist relevant!
    require ELMAR_PATH . 'tools/pear.php';
    require ELMAR_PATH . 'tools/node.php';
    require ELMAR_PATH . 'tools/parser.php';
    require ELMAR_PATH . 'tools/tree.php';
    $attributes = '1.0" encoding="ISO-8859-1';
    $tree = new XML_Tree(NULL, $attributes);
    if (ELMAR_NEW_SHOPINFO_XML) {
        $XMLarray = array('xmlns' => 'http://elektronischer-markt.de/schema/shopinfo-2.0', 'xmlns:c' => 'http://elektronischer-markt.de/schema/categories-2.0', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'http://elektronischer-markt.de/schema/shopinfo-2.0 ' . ELMAR_SCHEMA_BASE_URL . 'shopinfo-2.0.xsd', 'version' => '2.0');
        $root =& $tree->addRoot('Shop', NULL, $XMLarray);
    } else {
        $XMLarray = array('xmlns:osp' => 'http://elektronischer-markt.de/schema', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'http://elektronischer-markt.de/schema ' . ELMAR_SCHEMA_BASE_URL . 'shop.xsd');
        $root =& $tree->addRoot('osp:Shop', NULL, $XMLarray);
    }
    $common =& $root->addChild("Common");
    $xml_version =& $common->addChild("Version", ELMAR_NEW_SHOPINFO_XML ? '2.0' : '1.1');
    $xml_language =& $common->addChild("Language", $language_code);
    $xml_currency =& $common->addChild("Currency", $currency);
    if (ELMAR_NEW_SHOPINFO_XML) {
        $xml_generator =& $common->addChild('Generator', 'Elm@r-Modul osCommerce/' . MODUL_VERSION . '.' . MODUL_SUBVERSION . ' (http://projekt.wifo.uni-mannheim.de/elmar/nav/osCommerce)');
    }
    $name =& $root->addChild("Name", shopNameOrHost());
    $shopUrl = ELMAR_SHOP_ROOT_DIR;
    //tep_href_link('index.php', '', 'NONSSL', false);
    $url =& $root->addChild("Url", $shopUrl);
    $requests =& $root->addChild("Requests");
    // Die Parameter fuer die Echtzeitanfrage, siehe elmar_request.php
    $requestUrl = ELMAR_SHOP_ROOT_DIR . 'elmar_request.php';
    // Url zur Echtzeitabfrage
    $onlineRequest =& $requests->addChild("OnlineRequest", Null, array("method" => "GET POST TRACE"));
    $processor =& $onlineRequest->addChild("Processor", $requestUrl);
    $paramBrand =& $onlineRequest->addChild("ParamBrand", 'p_brand');
    $paramProduct =& $onlineRequest->addChild("ParamProduct", 'p_product');
    $paramDescription =& $onlineRequest->addChild("ParamDescription", 'p_desc');
    if (defined('ELMAR_PRODUCTS_EAN_FIELD')) {
        $paramEan =& $onlineRequest->addChild("ParamID", 'p_ean', array("type" => "EAN"));
    }
    if (defined('ELMAR_PRODUCTS_ISBN_FIELD')) {
        $paramIsbn =& $onlineRequest->addChild("ParamID", 'p_isbn', array("type" => "ISBN"));
    }
    if (ELMAR_NEW_SHOPINFO_XML) {
        $paramId =& $onlineRequest->addChild("ParamID", 'p_id', array("type" => "ID"));
    }
    $paramQuickSearch =& $onlineRequest->addChild("ParamQuickSearch", 'p_qs');
    $paramPriceBounds =& $onlineRequest->addChild("ParamPriceBounds");
    $lowerPrice =& $paramPriceBounds->addChild("LowerPrice", 'p_low');
    $upperPrice =& $paramPriceBounds->addChild("UpperPrice", 'p_high');
    $paramSize =& $onlineRequest->addChild("ParamSize", 'p_size');
    $paramIP =& $onlineRequest->addChild("ParamIP", 'p_ip');
    $offlineRequest =& offlineRequest($requests);
    if (ELMAR_NEW_SHOPINFO_XML) {
        $affiliateRequest =& $requests->addChild('AffiliateRequest', NULL, array('method' => 'GET POST TRACE'));
        $processor =& $affiliateRequest->addChild('Processor', ELMAR_SHOP_ROOT_DIR . 'elmar_affiliate.php');
        $paramName =& $affiliateRequest->addChild('ParamName', 'name');
    }
    /*
    $interface = & $root->addChild("Interface");
        $positionLimit = & $interface->addChild("PositionLimit");
    */
    if (defined('STORE_LOGO') && file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . STORE_LOGO)) {
        $logo =& $root->addChild("Logo", IMAGE_PATH . STORE_LOGO);
    }
    /*
    $address = & $root->addChild("Adress");
        $company= & $address->addChild("Company");
        $street = & $address->addChild("Street");
        $city = & $address->addChild("City");
    */
    if (emailOk()) {
        $contact =& $root->addChild("Contact");
        $publicMailAddress =& $contact->addChild("PublicMailAddress", STORE_OWNER_EMAIL_ADDRESS);
        $privateMailAddress =& $contact->addChild("PrivateMailAddress", STORE_OWNER_EMAIL_ADDRESS);
    }
    /*
    $orderPhone = & $contact->addChild("OrderPhone");
        $number= & $orderPhone->addChild("Number");
        $costPerMinute= & $orderPhone->addChild("CostPerMinute");
    $orderFax= & $contact->addChild("OrderFax");
        $number = & $orderFax->addChild("Number");
        $costPerMinute= & $orderFax->addChild("CostPerMinute");
    $hotline = & $contact->addChild("Hotline");
    */
    $prodSum = productAnz();
    $categories =& $root->addChild("Categories");
    if ($prodSum > 0) {
        $totalProductCount =& $categories->addChild("TotalProductCount", $prodSum);
    }
    $ns = ELMAR_NEW_SHOPINFO_XML ? 'c:' : '';
    $attrib = ELMAR_NEW_SHOPINFO_XML ? array('lang' => $language_code) : NULL;
    $mapOther = $language_code == 'de' ? 'Sonstiges' : 'Other';
    // Die Produktkategorien der ersten Ebene schreiben. Durch "group by" Doppelte herauswerfen.
    $categories_query = tep_db_query('select c.categories_id, cd.categories_name from ' . TABLE_CATEGORIES . ' c left join ' . TABLE_CATEGORIES_DESCRIPTION . ' cd using(categories_id) where c.parent_id=0 and cd.language_id=' . (int) $languages_id . ' group by cd.categories_name');
    if (tep_db_num_rows($categories_query)) {
        while ($category = tep_db_fetch_array($categories_query)) {
            $categories_name = trim($category['categories_name']);
            if ($categories_name != '') {
                $item =& $categories->addChild("Item", NULL, $attrib);
                $name =& $item->addChild($ns . "Name", $categories_name);
                if (function_exists('tep_count_products_in_category') && ($cpic = tep_count_products_in_category($category['categories_id']))) {
                    $productCount =& $item->addChild($ns . "ProductCount", $cpic);
                }
                $mapping =& $item->addChild($ns . "Mapping", KategorieAnpassen($category['categories_name'], $mapOther));
            }
        }
    } else {
        $item =& $categories->addChild("Item", NULL, $attrib);
        $name =& $item->addChild($ns . "Name", $mapOther);
        if ($prodSum > 0) {
            $productCount =& $item->addChild($ns . "ProductCount", $prodSum);
        }
        $mapping =& $item->addChild($ns . "Mapping", $mapOther);
    }
    $lastschriftverfahren = defined('MODULE_PAYMENT_BANKTRANSFER_STATUS') && MODULE_PAYMENT_BANKTRANSFER_STATUS == 'True' ? true : false;
    $nachnahme = defined('MODULE_PAYMENT_COD_STATUS') && MODULE_PAYMENT_COD_STATUS == 'True' ? true : false;
    $paypal = defined('MODULE_PAYMENT_PAYPAL_STATUS') && MODULE_PAYMENT_PAYPAL_STATUS == 'True' ? true : false;
    $rechnung = defined('MODULE_PAYMENT_INVOICE_STATUS') && MODULE_PAYMENT_INVOICE_STATUS == 'True' ? true : false;
    $vorkasse = defined('MODULE_PAYMENT_MONEYORDER_STATUS') && MODULE_PAYMENT_MONEYORDER_STATUS == 'True' ? true : false;
    #$barzahlung = (defined('MODULE_PAYMENT_CASH_STATUS') && (MODULE_PAYMENT_CASH_STATUS == 'True')) ? true : false;
    #e-cash (elektronisches Zahlungsmittel); money transfer (Ueberweisung); cheque (Scheck)
    if ($nachnahme || $paypal || $lastschriftverfahren || $rechnung || $vorkasse) {
        $payment =& $root->addChild("Payment");
        if ($nachnahme) {
            $item =& $payment->addChild("Item");
            $name =& $item->addChild("Name", 'on delivery');
            // Nachnahme
            //$surcharge = & $item->addChild("Surcharge");
            //$maxSurcharge = & $item->addChild("MaxSurcharge");
            //$relativeSurcharge = & $item->addChild("RelativeSurcharge");
        }
        if ($paypal) {
            $item =& $payment->addChild("Item");
            $name =& $item->addChild("Name", 'paypal');
            // PayPal
        }
        if ($lastschriftverfahren) {
            $item =& $payment->addChild("Item");
            $name =& $item->addChild("Name", 'debit');
            // Bankeinzug/Lastschrift
        }
        if ($rechnung) {
            $item =& $payment->addChild("Item");
            $name =& $item->addChild("Name", 'invoice');
            // Rechnung
        }
        if ($vorkasse) {
            $item =& $payment->addChild("Item");
            $name =& $item->addChild("Name", 'pre-payment');
            // Vorauszahlung
        }
    }
    $free_shipping = defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true' ? true : false;
    $shipping_flat_status = defined('MODULE_SHIPPING_FLAT_STATUS') && MODULE_SHIPPING_FLAT_STATUS == 'True' ? true : false;
    if ($free_shipping || $shipping_flat_status) {
        $forwardExpenses =& $root->addChild("ForwardExpenses");
        if ($shipping_flat_status) {
            if (DISPLAY_PRICE_WITH_TAX == 'true') {
                $shipping_flat_cost = tep_add_tax(MODULE_SHIPPING_FLAT_COST, tep_get_tax_rate(MODULE_SHIPPING_FLAT_TAX_CLASS, STORE_COUNTRY, MODULE_SHIPPING_FLAT_ZONE));
            } else {
                $shipping_flat_cost = MODULE_SHIPPING_FLAT_COST;
            }
            $flatRate =& $forwardExpenses->addChild("FlatRate", number_format($shipping_flat_cost * $currency_rate, 2));
        }
        if ($free_shipping) {
            $upperBound =& $forwardExpenses->addChild("UpperBound", number_format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER * $currency_rate, 2));
        }
    }
    /*
    $features = & $root->addChild("Features");
        $installment = & $features->addChild("Installment");
        $orderTracking = & $features->addChild("OrderTracking");
        $deliverTracking = & $features->addChild("DeliverTRacking");
        $installationAssistance = & $features->addChild("InstallationAssistance");
        $repairService = & $features->addChild("RepairService");
        $careAfterPurchase = & $features->addChild("CareAfterPurchase");
        $giftService = & $features->addChild("GiftService");
    */
    $technology =& $root->addChild("Technology");
    if (ENABLE_SSL) {
        $ssl =& $technology->addChild("SSL");
    }
    $search =& $technology->addChild("Search");
    // $set = & $technology->addChild("SET");
    if (defined('FILENAME_CONDITIONS')) {
        $termAndConditions =& $root->addChild("TermsAndConditions");
        $url =& $termAndConditions->addChild("Url", tep_href_link(FILENAME_CONDITIONS, '', 'NONSSL', false));
        // $return = & $termAndConditions->addChild("Return");
    }
    /*
    $specialDiscount = & $root->addChild("SpecialDiscount");
        $description = & $specialDiscount->addChild("Description");
        $url = & $specialDiscount->addChild("Url");
    $certifications= & $root->addChild("Certifications");
        $item = & $certifications->addChild("Item");
    $self_Discription = & $root->addChild("Self-Discription");
    */
    $content = $tree->get();
    $content = str_replace('&apos;', '\'', $content);
    // ersetzen von &apos;
    $content = str_replace('&#124;', '|', $content);
    // ersetzen von &#124;
    return $content;
}