Ejemplo n.º 1
0
function outputXmlFile($sessionid, $filenr, $bXmlDecl, $bOcXmlTag, $bDocType, $ziptype)
{
    global $zip_basedir, $zip_wwwdir, $sDateformat, $sDateshort, $t1, $t2, $t3, $safemode_zip, $safemode_zip, $sCharset, $bAttrlist;
    global $absolute_server_URI, $bLicense, $sLanguage;
    global $ocxmlversion;
    // alle records aus tmpxml_* übertragen
    if (!mb_ereg_match('^[0-9]{1,11}', $sessionid)) {
        die('sessionid invalid');
    }
    if (!mb_ereg_match('^[0-9]{1,11}', $filenr)) {
        die('filenr invalid');
    }
    /* begin now a few dynamically loaded constants */
    $logtypes = array();
    $rs = sql('SELECT `id`, `de` FROM log_types');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $r = sql_fetch_array($rs);
        $logtypes[$r['id']] = $r['de'];
    }
    mysql_free_result($rs);
    $cachetypes = array();
    $rs = sql('SELECT `id`, `short`, `de` FROM cache_type');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $r = sql_fetch_array($rs);
        $cachetypes[$r['id']]['de'] = $r['de'];
        $cachetypes[$r['id']]['short'] = $r['short'];
    }
    mysql_free_result($rs);
    $cachestatus = array();
    $rs = sql('SELECT `id`, `de` FROM cache_status');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $r = sql_fetch_array($rs);
        $cachestatus[$r['id']]['de'] = $r['de'];
    }
    mysql_free_result($rs);
    $counties = array();
    $rs = sql('SELECT `short`, `de` FROM countries');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $r = sql_fetch_array($rs);
        $counties[$r['short']]['de'] = $r['de'];
    }
    mysql_free_result($rs);
    $cachesizes = array();
    $rs = sql('SELECT `id`, `de` FROM cache_size');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $r = sql_fetch_array($rs);
        $cachesizes[$r['id']]['de'] = $r['de'];
    }
    mysql_free_result($rs);
    $languages = array();
    $rs = sql('SELECT `short`, `de` FROM languages');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $r = sql_fetch_array($rs);
        $languages[$r['short']]['de'] = $r['de'];
    }
    mysql_free_result($rs);
    $objecttypes['4'] = 'user';
    $objecttypes['2'] = 'cache';
    $objecttypes['3'] = 'cachedesc';
    $objecttypes['1'] = 'cachelog';
    $objecttypes['6'] = 'picture';
    $objecttypes['8'] = 'cachelist';
    // not implemented yet
    /* end now a few dynamically loaded constants */
    // temporäre Datei erstellen
    if (!is_dir($zip_basedir . 'ocxml11/' . $sessionid)) {
        mkdir($zip_basedir . 'ocxml11/' . $sessionid);
    }
    $fileid = 1;
    while (file_exists($zip_basedir . 'ocxml11/' . $sessionid . '/' . $sessionid . '-' . $filenr . '-' . $fileid . '.xml')) {
        $fileid++;
    }
    $xmlfilename = $zip_basedir . 'ocxml11/' . $sessionid . '/' . $sessionid . '-' . $filenr . '-' . $fileid . '.xml';
    $f = fopen($xmlfilename, 'w');
    if ($bXmlDecl == '1') {
        if ($sCharset == 'iso-8859-1') {
            fwrite($f, '<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>' . "\n");
        } else {
            if ($sCharset == 'utf-8') {
                fwrite($f, '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' . "\n");
            }
        }
    }
    if ($bDocType == '1') {
        fwrite($f, '<!DOCTYPE oc11xml PUBLIC "-//Opencaching Network//DTD OCXml V 1.' . $ocxmlversion % 10 . '//EN" "http://www.opencaching.de/xml/ocxml' . $ocxmlversion . '.dtd">' . "\n");
    }
    if ($bOcXmlTag == '1') {
        $rs = sql('SELECT `date_created`, `modified_since` FROM `xmlsession` WHERE `id`=&1', $sessionid);
        $r = sql_fetch_array($rs);
        fwrite($f, '<oc11xml version="1.' . $ocxmlversion % 10 . '" date="' . date($sDateformat, strtotime($r['date_created'])) . '" since="' . date($sDateformat, strtotime($r['modified_since'])) . '">' . "\n");
        mysql_free_result($rs);
    }
    if ($bAttrlist == '1') {
        $rs = sql("SELECT SQL_BUFFER_RESULT `id`, `name`, `icon_large`, `icon_no`, `icon_undef` FROM `cache_attrib`");
        fwrite($f, $t1 . '<attrlist>' . "\n");
        while ($r = sql_fetch_assoc($rs)) {
            fwrite($f, $t2 . '<attr id="' . $r['id'] . '" icon_large="' . xmlentities($absolute_server_URI . $r['icon_large']) . '" icon_no="' . xmlentities($absolute_server_URI . $r['icon_no']) . '" icon_undef="' . xmlentities($absolute_server_URI . $r['icon_undef']) . '">' . xmlcdata($r['name']) . '</attr>' . "\n");
        }
        fwrite($f, $t1 . '</attrlist>' . "\n");
        sql_free_result($rs);
    }
    $rs = sql('SELECT SQL_BUFFER_RESULT `user`.`user_id` `id`, `user`.`node` `node`, `user`.`uuid` `uuid`, `user`.`username` `username`, `user`.`pmr_flag` `pmr_flag`, `user`.`date_created` `date_created`, `user`.`last_modified` `last_modified` FROM `tmpxml_users`, `user` WHERE `tmpxml_users`.`id`=`user`.`user_id`');
    while ($r = sql_fetch_array($rs)) {
        fwrite($f, $t1 . '<user>' . "\n");
        fwrite($f, $t2 . '<id id="' . $r['id'] . '" node="' . $r['node'] . '">' . $r['uuid'] . '</id>' . "\n");
        fwrite($f, $t2 . '<username>' . xmlcdata($r['username']) . '</username>' . "\n");
        fwrite($f, $t2 . '<pmr>' . ($r['pmr_flag'] == 0 ? '0' : '1') . '</pmr>' . "\n");
        fwrite($f, $t2 . '<datecreated>' . date($sDateformat, strtotime($r['date_created'])) . '</datecreated>' . "\n");
        fwrite($f, $t2 . '<lastmodified>' . date($sDateformat, strtotime($r['last_modified'])) . '</lastmodified>' . "\n");
        fwrite($f, $t1 . '</user>' . "\n");
    }
    mysql_free_result($rs);
    $rs = sql('SELECT SQL_BUFFER_RESULT `caches`.`cache_id` `id`, `caches`.`uuid` `uuid`, `caches`.`user_id` `user_id`, 
	                                    `user`.`uuid` `useruuid`, `user`.`username` `username`, `caches`.`name` `name`, 
	                                    `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`type` `type`, 
	                                    `caches`.`country` `country`, `caches`.`size` `size`, `caches`.`desc_languages` `desclanguages`,
	                                    `caches`.`difficulty` `difficulty`, `caches`.`terrain` `terrain`, `caches`.`way_length` `way_length`, 
	                                    `caches`.`search_time` `search_time`, `caches`.`wp_gc` `wp_gc`, `caches`.`wp_nc` `wp_nc`,
	                                    /* we deliberatly do not use gc_wp_maintained here */
	                                    `caches`.`wp_oc` `wp_oc`, `caches`.`date_hidden` `date_hidden`, `caches`.`date_created` `date_created`, `caches`.`is_publishdate` `is_publishdate`, 
	                                    `caches`.`last_modified` `last_modified`, `caches`.`status` `status`, `caches`.`node` `node`,
	                                    `caches`.`listing_last_modified` `listing_last_modified`, `cache_status`.`allow_user_view`
	                               FROM `tmpxml_caches`
	                         INNER JOIN `caches` ON `tmpxml_caches`.`id`=`caches`.`cache_id`
	                         INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id`
	                         INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id`');
    while ($r = sql_fetch_array($rs)) {
        $bAllowView = $r['allow_user_view'] == 1;
        if ($r['size'] == 8 && $ocxmlversion < 12) {
            $r['size'] = 2;
        }
        // return as micro in old interface version
        fwrite($f, $t1 . '<cache>' . "\n");
        fwrite($f, $t2 . '<id id="' . $r['id'] . '" node="' . $r['node'] . '">' . $r['uuid'] . '</id>' . "\n");
        fwrite($f, $t2 . '<userid id="' . $r['user_id'] . '" uuid="' . $r['useruuid'] . '">' . xmlcdata($r['username']) . '</userid>' . "\n");
        fwrite($f, $t2 . '<name>' . xmlcdata($bAllowView ? $r['name'] : '') . '</name>' . "\n");
        fwrite($f, $t2 . '<longitude>' . sprintf('%01.5f', $bAllowView ? $r['longitude'] : 0) . '</longitude>' . "\n");
        fwrite($f, $t2 . '<latitude>' . sprintf('%01.5f', $bAllowView ? $r['latitude'] : 0) . '</latitude>' . "\n");
        fwrite($f, $t2 . '<type id="' . $r['type'] . '" short="' . xmlentities($cachetypes[$r['type']]['short']) . '">' . xmlcdata($cachetypes[$r['type']]['de']) . '</type>' . "\n");
        fwrite($f, $t2 . '<status id="' . $r['status'] . '">' . xmlcdata($cachestatus[$r['status']]['de']) . '</status>' . "\n");
        fwrite($f, $t2 . '<country id="' . $r['country'] . '">' . xmlcdata($counties[$r['country']]['de']) . '</country>' . "\n");
        fwrite($f, $t2 . '<size id="' . $r['size'] . '">' . xmlcdata($cachesizes[$r['size']]['de']) . '</size>' . "\n");
        fwrite($f, $t2 . '<desclanguages>' . $r['desclanguages'] . '</desclanguages>' . "\n");
        fwrite($f, $t2 . '<difficulty>' . sprintf('%01.1f', $r['difficulty'] / 2) . '</difficulty>' . "\n");
        fwrite($f, $t2 . '<terrain>' . sprintf('%01.1f', $r['terrain'] / 2) . '</terrain>' . "\n");
        fwrite($f, $t2 . '<rating waylength="' . $r['way_length'] . '" needtime="' . $r['search_time'] . '" />' . "\n");
        fwrite($f, $t2 . '<waypoints gccom="' . xmlentities($r['wp_gc']) . '" nccom="' . xmlentities($r['wp_nc']) . '" oc="' . xmlentities($r['wp_oc']) . '" />' . "\n");
        fwrite($f, $t2 . '<datehidden>' . date($sDateformat, strtotime($r['date_hidden'])) . '</datehidden>' . "\n");
        if ($ocxmlversion >= 12) {
            $pd = ' ispublishdate="' . $r['is_publishdate'] . '"';
        } else {
            $pd = "";
        }
        fwrite($f, $t2 . '<datecreated' . $pd . '>' . date($sDateformat, strtotime($r['date_created'])) . '</datecreated>' . "\n");
        fwrite($f, $t2 . '<lastmodified>' . date($sDateformat, strtotime($r['last_modified'])) . '</lastmodified>' . "\n");
        if ($ocxmlversion >= 14) {
            fwrite($f, $t2 . '<listing_lastmodified>' . date($sDateformat, strtotime($r['listing_last_modified'])) . '</listing_lastmodified>' . "\n");
        }
        $rsAttributes = sql("SELECT `cache_attrib`.`id`, `cache_attrib`.`name`\n\t\t                       FROM `caches_attributes`\n\t\t                 INNER JOIN `cache_attrib` ON `caches_attributes`.`attrib_id`=`cache_attrib`.`id`\n\t\t                      WHERE `caches_attributes`.`cache_id`='&1'", $r['id']);
        fwrite($f, $t2 . '<attributes>' . "\n");
        while ($rAttribute = sql_fetch_assoc($rsAttributes)) {
            fwrite($f, $t3 . '<attribute id="' . ($rAttribute['id'] + 0) . '">' . xmlcdata($rAttribute['name']) . '</attribute>' . "\n");
        }
        fwrite($f, $t2 . '</attributes>' . "\n");
        sql_free_result($rsAttributes);
        if ($ocxmlversion >= 13) {
            $rsWaypoints = sql("SELECT `coordinates`.`id`, `coordinates`.`subtype` AS `type`,\n\t\t\t                           `coordinates`.`latitude`, `coordinates`.`longitude`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t `coordinates`.`description`,\n\t\t\t                           `coordinates_type`.`name` AS `type_name`\n\t\t\t                      FROM `coordinates`\n\t\t\t                INNER JOIN `coordinates_type` ON `coordinates_type`.`id`=`coordinates`.`subtype`\n\t\t\t                     WHERE `cache_id`='&1' AND `type`=1\n\t\t\t                  ORDER BY `coordinates`.`id` ASC", $r['id']);
            fwrite($f, $t2 . '<wpts>' . "\n");
            while ($rWaypoint = sql_fetch_assoc($rsWaypoints)) {
                fwrite($f, $t3 . '<wpt id="' . ($rWaypoint['id'] + 0) . '" type="' . ($rWaypoint['type'] + 0) . '" typename="' . xmlentities($rWaypoint['type_name']) . '" longitude="' . sprintf('%01.5f', $rWaypoint['longitude']) . '" latitude="' . sprintf('%01.5f', $rWaypoint['latitude']) . '">' . xmlcdata($rWaypoint['description']) . '</wpt>' . "\n");
            }
            fwrite($f, $t2 . '</wpts>' . "\n");
            sql_free_result($rsAttributes);
        }
        fwrite($f, $t1 . '</cache>' . "\n");
    }
    mysql_free_result($rs);
    $rs = sql('SELECT SQL_BUFFER_RESULT `cache_desc`.`id` `id`, `cache_desc`.`uuid` `uuid`, `cache_desc`.`cache_id` `cache_id`, 
	                                    `cache_desc`.`language` `language`, `cache_desc`.`short_desc` `short_desc`,
	                                    `cache_desc`.`desc` `desc`, `cache_desc`.`desc_html` `desc_html`, `cache_desc`.`hint` `hint`, 
	                                    `cache_desc`.`last_modified` `last_modified`, `caches`.`uuid` `cacheuuid`, `cache_desc`.`node` `node`,
	                                    `cache_status`.`allow_user_view`,
	                                    `caches`.`user_id`, `user`.`username`, `user`.`data_license`
	                               FROM `tmpxml_cachedescs`
	                         INNER JOIN `cache_desc` ON `tmpxml_cachedescs`.`id`=`cache_desc`.`id`
	                         INNER JOIN `caches` ON `caches`.`cache_id`=`cache_desc`.`cache_id`
	                         INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id`
													 INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`');
    while ($r = sql_fetch_array($rs)) {
        $bAllowView = $r['allow_user_view'] == 1;
        fwrite($f, $t1 . '<cachedesc>' . "\n");
        fwrite($f, $t2 . '<id id="' . $r['id'] . '" node="' . $r['node'] . '">' . $r['uuid'] . '</id>' . "\n");
        fwrite($f, $t2 . '<cacheid id="' . $r['cache_id'] . '">' . $r['cacheuuid'] . '</cacheid>' . "\n");
        fwrite($f, $t2 . '<language id="' . $r['language'] . '">' . xmlcdata($languages[$r['language']]['de']) . '</language>' . "\n");
        fwrite($f, $t2 . '<shortdesc>' . xmlcdata($bAllowView ? $r['short_desc'] : '') . '</shortdesc>' . "\n");
        $desc = $r['desc'];
        if ($r['desc_html'] == 0) {
            $desc = mb_ereg_replace('<br />', '', $desc);
            $desc = html_entity_decode($desc, ENT_COMPAT, 'UTF-8');
        }
        $lang = $sLanguage != "" ? $sLanguage : $r['language'];
        $disclaimer = getLicenseDisclaimer($r['user_id'], $r['username'], $r['data_license'], $r['cache_id'], $lang, true, true);
        if ($bLicense) {
            fwrite($f, $t2 . '<license>' . xmlcdata($disclaimer) . '</license>' . "\n");
        } else {
            if ($disclaimer != "") {
                $desc .= "<p><em>" . $disclaimer . "</em></p>";
            }
        }
        $desc .= get_desc_npas($r['cache_id']);
        fwrite($f, $t2 . '<desc html="' . ($r['desc_html'] == 1 ? '1' : '0') . '">' . xmlcdata($bAllowView ? $desc : '') . '</desc>' . "\n");
        $r['hint'] = mb_ereg_replace('<br />', '', $r['hint']);
        $r['hint'] = html_entity_decode($r['hint'], ENT_COMPAT, 'UTF-8');
        fwrite($f, $t2 . '<hint>' . xmlcdata($bAllowView ? $r['hint'] : '') . '</hint>' . "\n");
        fwrite($f, $t2 . '<lastmodified>' . date($sDateformat, strtotime($r['last_modified'])) . '</lastmodified>' . "\n");
        fwrite($f, $t1 . '</cachedesc>' . "\n");
    }
    mysql_free_result($rs);
    if ($ocxmlversion >= 14) {
        $rating_condition = "AND `cache_logs`.`date`=`cache_rating`.`rating_date`";
    } else {
        $rating_condition = "";
    }
    $rs = sql('SELECT SQL_BUFFER_RESULT `cache_logs`.`id` `id`, `cache_logs`.`cache_id` `cache_id`, `cache_logs`.`user_id` `user_id`, 
	                                    `cache_logs`.`type` `type`, `cache_logs`.`date` `date`, `cache_logs`.`text` `text`, `cache_logs`.`text_html` `text_html`,
	                                    `cache_logs`.`oc_team_comment`,
	                                    `cache_logs`.`date_created` `date_created`, `cache_logs`.`last_modified` `last_modified`,
	                                    `cache_logs`.`log_last_modified` `log_last_modified`, 
	                                    `cache_logs`.`uuid` `uuid`, `user`.`username` `username`, `caches`.`uuid` `cacheuuid`, 
	                                    `user`.`uuid` `useruuid`, `cache_logs`.`node` `node`, IF(NOT ISNULL(`cache_rating`.`cache_id`) AND `cache_logs`.`type` IN (1,7), 1, 0) AS `recommended`,
	                                    `cache_status`.`allow_user_view`,
	                                    `user`.`data_license`,
	                                    `caches`.`country` AS `language`  /* hack */
	                               FROM `cache_logs` 
	                         INNER JOIN `tmpxml_cachelogs` ON `cache_logs`.`id`=`tmpxml_cachelogs`.`id`
	                         INNER JOIN `user` ON `cache_logs`.`user_id`=`user`.`user_id`
	                         INNER JOIN `caches` ON `caches`.`cache_id`=`cache_logs`.`cache_id`
	                         INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id`
	                          LEFT JOIN `cache_rating` ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id` AND `cache_logs`.`user_id`=`cache_rating`.`user_id` ' . $rating_condition);
    while ($r = sql_fetch_array($rs)) {
        $bAllowView = $r['allow_user_view'] == 1;
        $r['text'] = mb_ereg_replace('<br />', '', $r['text']);
        $r['text'] = html_entity_decode($r['text'], ENT_COMPAT, 'UTF-8');
        // locked/invisible should never be returned here - these logs are deleted before
        // reactivating the cache. Just for the case ... it is safe to return them as 'locked'.
        if ($r['type'] == 14) {
            $r['type'] = 13;
        }
        if ($ocxmlversion >= 13) {
            $teamcomment = ' teamcomment="' . $r['oc_team_comment'] . '"';
        } else {
            $teamcomment = '';
            if ($r['type'] > 8) {
                $r['type'] = 3;
            }
        }
        fwrite($f, $t1 . '<cachelog>' . "\n");
        fwrite($f, $t2 . '<id id="' . $r['id'] . '" node="' . $r['node'] . '">' . $r['uuid'] . '</id>' . "\n");
        fwrite($f, $t2 . '<cacheid id="' . $r['cache_id'] . '">' . $r['cacheuuid'] . '</cacheid>' . "\n");
        fwrite($f, $t2 . '<userid id="' . $r['user_id'] . '" uuid="' . $r['useruuid'] . '">' . xmlcdata($r['username']) . '</userid>' . "\n");
        fwrite($f, $t2 . '<logtype id="' . $r['type'] . '" recommended="' . $r['recommended'] . '"' . $teamcomment . '>' . xmlcdata($logtypes[$r['type']]) . '</logtype>' . "\n");
        fwrite($f, $t2 . '<date>' . date($ocxmlversion >= 13 ? $sDateformat : $sDateshort, strtotime($r['date'])) . '</date>' . "\n");
        fwrite($f, $t2 . '<text html="' . $r['text_html'] . '">' . xmlcdata($bAllowView ? $r['text'] : '') . '</text>' . "\n");
        fwrite($f, $t2 . '<datecreated>' . date($sDateformat, strtotime($r['date_created'])) . '</datecreated>' . "\n");
        fwrite($f, $t2 . '<lastmodified>' . date($sDateformat, strtotime($r['last_modified'])) . '</lastmodified>' . "\n");
        if ($ocxmlversion >= 14) {
            fwrite($f, $t2 . '<log_lastmodified>' . date($sDateformat, strtotime($r['log_last_modified'])) . '</log_lastmodified>' . "\n");
        }
        if ($bLicense) {
            $lang = $sLanguage != "" ? $sLanguage : $r['language'];
            $disclaimer = getLicenseDisclaimer($r['user_id'], $r['username'], $r['data_license'], $r['cache_id'], $lang, false, true);
            fwrite($f, $t2 . '<license>' . xmlcdata($disclaimer) . '</license>' . "\n");
        }
        fwrite($f, $t1 . '</cachelog>' . "\n");
    }
    mysql_free_result($rs);
    $rs = sql('SELECT SQL_BUFFER_RESULT `pictures`.`id` `id`, `pictures`.`url` `url`, `pictures`.`title` `title`, 
	                                    `pictures`.`object_id` `object_id`, `pictures`.`object_type` `object_type`, 
	                                    `pictures`.`date_created` `date_created`, `pictures`.`uuid` `uuid`, 
	                                    `pictures`.`last_modified` `last_modified`, `pictures`.`display` `display`, 
	                                    `pictures`.`spoiler` `spoiler`, `pictures`.`node` `node`,
	                                    `pictures`.`mappreview`,
	                                    IFNULL(`c1`.`cache_id`,`c2`.`cache_id`) AS `cache_id`,
	                                    IFNULL(`c1`.`country`,`c2`.`country`) AS `language`,  /* hack */
	                                    IFNULL(`cs1`.`allow_user_view`, `cs2`.`allow_user_view`) AS `auv`,
	                                    IFNULL(`u1`.`user_id`,`u2`.`user_id`) AS `user_id`,
	                                    IFNULL(`u1`.`username`,`u2`.`username`) AS `username`,
	                                    IFNULL(`u1`.`data_license`,`u2`.`data_license`) AS `data_license`
	                               FROM `tmpxml_pictures` 
	                         INNER JOIN `pictures` ON `tmpxml_pictures`.`id`=`pictures`.`id` 
	                          LEFT JOIN `caches` AS `c1` ON `pictures`.`object_type`=2 AND `pictures`.`object_id`=`c1`.`cache_id` 
	                          LEFT JOIN `cache_logs` ON `pictures`.`object_type`=1 AND `pictures`.`object_id`=`cache_logs`.`id` 
	                          LEFT JOIN `caches` AS `c2` ON `cache_logs`.`cache_id`=`c2`.`cache_id` 
	                          LEFT JOIN `cache_status` AS `cs1` ON `c1`.`status`=`cs1`.`id` 
	                          LEFT JOIN `cache_status` AS `cs2` ON `c2`.`status`=`cs2`.`id`
	                          LEFT JOIN `user` `u1` ON `u1`.`user_id`=`cache_logs`.`user_id`
	                          LEFT JOIN `user` `u2` ON `u2`.`user_id`=`c1`.`user_id`');
    while ($r = sql_fetch_array($rs)) {
        $bAllowView = $r['auv'] == 1;
        fwrite($f, $t1 . '<picture>' . "\n");
        fwrite($f, $t2 . '<id id="' . $r['id'] . '" node="' . $r['node'] . '">' . $r['uuid'] . '</id>' . "\n");
        fwrite($f, $t2 . '<url>' . xmlcdata($bAllowView ? $r['url'] : '') . '</url>' . "\n");
        fwrite($f, $t2 . '<title>' . xmlcdata($bAllowView ? $r['title'] : '') . '</title>' . "\n");
        fwrite($f, $t2 . '<object id="' . $r['object_id'] . '" type="' . $r['object_type'] . '" typename="' . xmlentities($objecttypes[$r['object_type']]) . '">' . object_id2uuid($r['object_id'], $r['object_type']) . '</object>' . "\n");
        if ($ocxmlversion >= 13) {
            fwrite($f, $t2 . '<picattr spoiler="' . $r['spoiler'] . '" display="' . $r['display'] . '" preview="' . $r['mappreview'] . '" />' . "\n");
        } else {
            fwrite($f, $t2 . '<attributes spoiler="' . $r['spoiler'] . '" display="' . $r['display'] . '" />' . "\n");
        }
        fwrite($f, $t2 . '<datecreated>' . date($sDateformat, strtotime($r['date_created'])) . '</datecreated>' . "\n");
        fwrite($f, $t2 . '<lastmodified>' . date($sDateformat, strtotime($r['last_modified'])) . '</lastmodified>' . "\n");
        if ($bLicense) {
            $lang = $sLanguage != "" ? $sLanguage : $r['language'];
            $disclaimer = getLicenseDisclaimer($r['user_id'], $r['username'], $r['data_license'], $r['cache_id'], $lang, false, true);
            fwrite($f, $t2 . '<license>' . xmlcdata($disclaimer) . '</license>' . "\n");
        }
        fwrite($f, $t1 . '</picture>' . "\n");
    }
    mysql_free_result($rs);
    $rs = sql('SELECT SQL_BUFFER_RESULT `removed_objects`.`id` `id`, `removed_objects`.`localid` `localid`, `removed_objects`.`uuid` `uuid`, 
	                                    `removed_objects`.`type` `type`, `removed_objects`.`removed_date` `removed_date`, `removed_objects`.`node` `node` 
	                               FROM `tmpxml_removedobjects`, `removed_objects` WHERE `removed_objects`.`id`=`tmpxml_removedobjects`.`id`');
    while ($r = sql_fetch_array($rs)) {
        fwrite($f, $t1 . '<removedobject>' . "\n");
        fwrite($f, $t2 . '<id id="' . $r['id'] . '" node="' . $r['node'] . '" />' . "\n");
        fwrite($f, $t2 . '<object id="' . $r['localid'] . '" type="' . $r['type'] . '" typename="' . xmlentities($objecttypes[$r['type']]) . '">' . $r['uuid'] . '</object>' . "\n");
        fwrite($f, $t2 . '<removeddate>' . date($sDateformat, strtotime($r['removed_date'])) . '</removeddate>' . "\n");
        fwrite($f, $t1 . '</removedobject>' . "\n");
    }
    mysql_free_result($rs);
    if ($bOcXmlTag == '1') {
        fwrite($f, '</oc11xml>' . "\n");
    }
    fclose($f);
    $rel_xmlfile = 'ocxml11/' . $sessionid . '/' . $sessionid . '-' . $filenr . '-' . $fileid . '.xml';
    $rel_zipfile = 'ocxml11/' . $sessionid . '/' . $sessionid . '-' . $filenr . '-' . $fileid;
    // zippen und url-redirect
    if ($ziptype == '0') {
        tpl_redirect($zip_wwwdir . $rel_xmlfile);
        exit;
    } else {
        if ($ziptype == 'zip') {
            $rel_zipfile .= '.zip';
        } else {
            if ($ziptype == 'bzip2') {
                $rel_zipfile .= '.bz2';
            } else {
                if ($ziptype == 'gzip') {
                    $rel_zipfile .= '.gz';
                } else {
                    die('unknown zip type');
                }
            }
        }
    }
    $call = $safemode_zip . ' --type=' . escapeshellcmd($ziptype) . ' --src=' . escapeshellcmd($rel_xmlfile) . ' --dst=' . escapeshellcmd($rel_zipfile);
    system($call);
    // datei vorhanden?
    if (!file_exists($zip_basedir . $rel_zipfile)) {
        die('all ok, but zip failed - internal server error');
    }
    tpl_redirect($zip_wwwdir . $rel_zipfile);
    exit;
}
Ejemplo n.º 2
0
function outputXmlFile($sessionid, $filenr, $bXmlDecl, $bOcXmlTag, $bDocType, $ziptype)
{
    global $zip_basedir, $zip_wwwdir, $sDateformat, $sDateshort, $t1, $t2, $safemode_zip, $safemode_zip, $sCharset;
    // alle records aus tmpxml_* übertragen
    if (!mb_ereg_match('^[0-9]{1,11}', $sessionid)) {
        die('sessionid invalid');
    }
    if (!mb_ereg_match('^[0-9]{1,11}', $filenr)) {
        die('filenr invalid');
    }
    /* begin now a few dynamically loaded constants */
    $logtypes = array();
    $rs = sql('SELECT `id`, `pl` FROM log_types');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $r = sql_fetch_array($rs);
        $logtypes[$r['id']] = $r['pl'];
    }
    mysql_free_result($rs);
    $cachetypes = array();
    $rs = sql('SELECT `id`, `short`, `pl` FROM cache_type');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $r = sql_fetch_array($rs);
        $cachetypes[$r['id']]['pl'] = $r['pl'];
        $cachetypes[$r['id']]['short'] = $r['short'];
    }
    mysql_free_result($rs);
    $cachestatus = array();
    $rs = sql('SELECT `id`, `pl` FROM cache_status');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $r = sql_fetch_array($rs);
        $cachestatus[$r['id']]['pl'] = $r['pl'];
    }
    mysql_free_result($rs);
    $counties = array();
    $rs = sql('SELECT `short`, `pl` FROM countries');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $r = sql_fetch_array($rs);
        $counties[$r['short']]['pl'] = $r['pl'];
    }
    mysql_free_result($rs);
    $cachesizes = array();
    $rs = sql('SELECT `id`, `pl` FROM cache_size');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $r = sql_fetch_array($rs);
        $cachesizes[$r['id']]['pl'] = $r['pl'];
    }
    mysql_free_result($rs);
    $languages = array();
    $rs = sql('SELECT `short`, `pl` FROM languages');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $r = sql_fetch_array($rs);
        $languages[$r['short']]['pl'] = $r['pl'];
    }
    mysql_free_result($rs);
    $objecttypes['4'] = 'user';
    $objecttypes['2'] = 'cache';
    $objecttypes['3'] = 'cachedesc';
    $objecttypes['1'] = 'cachelog';
    $objecttypes['6'] = 'picture';
    /* end now a few dynamically loaded constants */
    // temporäre Datei erstellen
    if (!is_dir($zip_basedir . 'ocxml11/' . $sessionid)) {
        mkdir($zip_basedir . 'ocxml11/' . $sessionid);
    }
    $fileid = 1;
    while (file_exists($zip_basedir . 'ocxml11/' . $sessionid . '/' . $sessionid . '-' . $filenr . '-' . $fileid . '.xml')) {
        $fileid++;
    }
    $xmlfilename = $zip_basedir . 'ocxml11/' . $sessionid . '/' . $sessionid . '-' . $filenr . '-' . $fileid . '.xml';
    $f = fopen($xmlfilename, 'w');
    if ($bXmlDecl == '1') {
        if ($sCharset == 'iso-8859-2') {
            fwrite($f, '<?xml version="1.0" encoding="iso-8859-2" standalone="no" ?>' . "\n");
        } else {
            if ($sCharset == 'utf-8') {
                fwrite($f, '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' . "\n");
            }
        }
    }
    if ($bDocType == '1') {
        fwrite($f, '<!DOCTYPE oc11xml PUBLIC "-//Opencaching Network//DTD OCXml V 1.1//EN" "http://www.opencaching.pl/xml/ocxml11.dtd">' . "\n");
    }
    if ($bOcXmlTag == '1') {
        $rs = sql('SELECT `date_created`, `modified_since` FROM `xmlsession` WHERE `id`=&1', $sessionid);
        $r = sql_fetch_array($rs);
        fwrite($f, '<oc11xml version="1.1" date="' . date($sDateformat, strtotime($r['date_created'])) . '" since="' . date($sDateformat, strtotime($r['modified_since'])) . '">' . "\n");
        mysql_free_result($rs);
    }
    $rs = sql('SELECT `user`.`user_id` `id`, `user`.`node` `node`, `user`.`uuid` `uuid`, `user`.`username` `username`, `user`.`pmr_flag` `pmr_flag`, `user`.`date_created` `date_created`, `user`.`last_modified` `last_modified` FROM `tmpxml_users`, `user` WHERE `tmpxml_users`.`id`=`user`.`user_id`');
    while ($r = sql_fetch_array($rs)) {
        fwrite($f, $t1 . '<user>' . "\n");
        fwrite($f, $t2 . '<id id="' . $r['id'] . '" node="' . $r['node'] . '">' . $r['uuid'] . '</id>' . "\n");
        fwrite($f, $t2 . '<username>' . xmlcdata($r['username']) . '</username>' . "\n");
        fwrite($f, $t2 . '<pmr>' . ($r['pmr_flag'] == 0 ? '0' : '1') . '</pmr>' . "\n");
        fwrite($f, $t2 . '<datecreated>' . date($sDateformat, strtotime($r['date_created'])) . '</datecreated>' . "\n");
        fwrite($f, $t2 . '<lastmodified>' . date($sDateformat, strtotime($r['last_modified'])) . '</lastmodified>' . "\n");
        fwrite($f, $t1 . '</user>' . "\n");
    }
    mysql_free_result($rs);
    $rs = sql('SELECT `caches`.`cache_id` `id`, `caches`.`uuid` `uuid`, `caches`.`user_id` `user_id`,
                      `user`.`uuid` `useruuid`, `user`.`username` `username`, `caches`.`name` `name`,
                      `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`type` `type`,
                      `caches`.`country` `country`, `caches`.`size` `size`, `caches`.`desc_languages` `desclanguages`,
                      `caches`.`difficulty` `difficulty`, `caches`.`terrain` `terrain`, `caches`.`way_length` `way_length`,
                      `caches`.`search_time` `search_time`, `caches`.`wp_gc` `wp_gc`, `caches`.`wp_nc` `wp_nc`,
                      `caches`.`wp_oc` `wp_oc`, `caches`.`date_hidden` `date_hidden`, `caches`.`date_created` `date_created`,
                      `caches`.`last_modified` `last_modified`, `caches`.`status` `status`, `caches`.`node` `node`
                 FROM `tmpxml_caches`, `caches`, `user` WHERE `tmpxml_caches`.`id`=`caches`.`cache_id` AND `caches`.`user_id`=`user`.`user_id`');
    while ($r = sql_fetch_array($rs)) {
        fwrite($f, $t1 . '<cache>' . "\n");
        fwrite($f, $t2 . '<id id="' . $r['id'] . '" node="' . $r['node'] . '">' . $r['uuid'] . '</id>' . "\n");
        fwrite($f, $t2 . '<userid id="' . $r['user_id'] . '" uuid="' . $r['useruuid'] . '">' . xmlcdata($r['username']) . '</userid>' . "\n");
        fwrite($f, $t2 . '<name>' . xmlcdata($r['name']) . '</name>' . "\n");
        fwrite($f, $t2 . '<longitude>' . sprintf('%01.5f', $r['longitude']) . '</longitude>' . "\n");
        fwrite($f, $t2 . '<latitude>' . sprintf('%01.5f', $r['latitude']) . '</latitude>' . "\n");
        fwrite($f, $t2 . '<type id="' . $r['type'] . '" short="' . xmlentities($cachetypes[$r['type']]['short']) . '">' . xmlcdata($cachetypes[$r['type']]['pl']) . '</type>' . "\n");
        fwrite($f, $t2 . '<status id="' . $r['status'] . '">' . xmlcdata($cachestatus[$r['status']]['pl']) . '</status>' . "\n");
        fwrite($f, $t2 . '<country id="' . $r['country'] . '">' . xmlcdata($counties[$r['country']]['pl']) . '</country>' . "\n");
        fwrite($f, $t2 . '<size id="' . $r['size'] . '">' . xmlcdata($cachesizes[$r['size']]['pl']) . '</size>' . "\n");
        fwrite($f, $t2 . '<desclanguages>' . $r['desclanguages'] . '</desclanguages>' . "\n");
        fwrite($f, $t2 . '<difficulty>' . sprintf('%01.1f', $r['difficulty'] / 2) . '</difficulty>' . "\n");
        fwrite($f, $t2 . '<terrain>' . sprintf('%01.1f', $r['terrain'] / 2) . '</terrain>' . "\n");
        fwrite($f, $t2 . '<rating waylength="' . $r['way_length'] . '" needtime="' . $r['search_time'] . '" />' . "\n");
        fwrite($f, $t2 . '<waypoints gccom="' . xmlentities($r['wp_gc']) . '" gpsgames="' . xmlentities($r['wp_nc']) . '" oc="' . xmlentities($r['wp_oc']) . '" />' . "\n");
        fwrite($f, $t2 . '<datehidden>' . date($sDateformat, strtotime($r['date_hidden'])) . '</datehidden>' . "\n");
        fwrite($f, $t2 . '<datecreated>' . date($sDateformat, strtotime($r['date_created'])) . '</datecreated>' . "\n");
        fwrite($f, $t2 . '<lastmodified>' . date($sDateformat, strtotime($r['last_modified'])) . '</lastmodified>' . "\n");
        fwrite($f, $t1 . '</cache>' . "\n");
    }
    mysql_free_result($rs);
    $rs = sql('SELECT `cache_desc`.`id` `id`, `cache_desc`.`uuid` `uuid`, `cache_desc`.`cache_id` `cache_id`,
                      `cache_desc`.`language` `language`, `cache_desc`.`short_desc` `short_desc`,
                      `cache_desc`.`desc` `desc`, `cache_desc`.`desc_html` `desc_html`, `cache_desc`.`hint` `hint`,
                      `cache_desc`.`last_modified` `last_modified`, `caches`.`uuid` `cacheuuid`, `cache_desc`.`node` `node`
                 FROM `tmpxml_cachedescs`, `cache_desc`, `caches` WHERE `tmpxml_cachedescs`.`id`=`cache_desc`.`id` AND
                 `caches`.`cache_id`=`cache_desc`.`cache_id`');
    while ($r = sql_fetch_array($rs)) {
        fwrite($f, $t1 . '<cachedesc>' . "\n");
        fwrite($f, $t2 . '<id id="' . $r['id'] . '" node="' . $r['node'] . '">' . $r['uuid'] . '</id>' . "\n");
        fwrite($f, $t2 . '<cacheid id="' . $r['cache_id'] . '">' . $r['cacheuuid'] . '</cacheid>' . "\n");
        fwrite($f, $t2 . '<language id="' . $r['language'] . '">' . xmlcdata($languages[$r['language']]['pl']) . '</language>' . "\n");
        fwrite($f, $t2 . '<shortdesc>' . xmlcdata($r['short_desc']) . '</shortdesc>' . "\n");
        if ($r['desc_html'] == 0) {
            $r['desc'] = mb_ereg_replace('<br />', '', $r['desc']);
            $r['desc'] = html_entity_decode($r['desc'], ENT_COMPAT, 'UTF-8');
        }
        fwrite($f, $t2 . '<desc html="' . ($r['desc_html'] == 1 ? '1' : '0') . '">' . xmlcdata($r['desc']) . '</desc>' . "\n");
        $r['hint'] = mb_ereg_replace('<br />', '', $r['hint']);
        $r['hint'] = html_entity_decode($r['hint'], ENT_COMPAT, 'UTF-8');
        fwrite($f, $t2 . '<hint>' . xmlcdata($r['hint']) . '</hint>' . "\n");
        fwrite($f, $t2 . '<lastmodified>' . date($sDateformat, strtotime($r['last_modified'])) . '</lastmodified>' . "\n");
        fwrite($f, $t1 . '</cachedesc>' . "\n");
    }
    mysql_free_result($rs);
    $rs = sql('SELECT `cache_logs`.`id` `id`, `cache_logs`.`cache_id` `cache_id`, `cache_logs`.`user_id` `user_id`,
                      `cache_logs`.`type` `type`, `cache_logs`.`date` `date`, `cache_logs`.`text` `text`,
                      `cache_logs`.`date_created` `date_created`, `cache_logs`.`last_modified` `last_modified`,
                      `cache_logs`.`uuid` `uuid`, `user`.`username` `username`, `caches`.`uuid` `cacheuuid`,
                      `user`.`uuid` `useruuid`, `cache_logs`.`node` `node`, IF(NOT ISNULL(`cache_rating`.`cache_id`) AND `cache_logs`.`type`=1, 1, 0) AS `recommended`
                 FROM `cache_logs`
           INNER JOIN `tmpxml_cachelogs` ON `cache_logs`.`id`=`tmpxml_cachelogs`.`id`
           INNER JOIN `user` ON `cache_logs`.`user_id`=`user`.`user_id`
           INNER JOIN `caches` ON `caches`.`cache_id`=`cache_logs`.`cache_id`
            LEFT JOIN `cache_rating` ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id` AND `cache_logs`.`user_id`=`cache_rating`.`user_id` AND   `cache_logs`.`deleted`=0
                    ');
    while ($r = sql_fetch_array($rs)) {
        $r['text'] = mb_ereg_replace('<br />', '', $r['text']);
        $r['text'] = html_entity_decode($r['text'], ENT_COMPAT, 'UTF-8');
        fwrite($f, $t1 . '<cachelog>' . "\n");
        fwrite($f, $t2 . '<id id="' . $r['id'] . '" node="' . $r['node'] . '">' . $r['uuid'] . '</id>' . "\n");
        fwrite($f, $t2 . '<cacheid id="' . $r['cache_id'] . '">' . $r['cacheuuid'] . '</cacheid>' . "\n");
        fwrite($f, $t2 . '<userid id="' . $r['user_id'] . '" uuid="' . $r['useruuid'] . '">' . xmlcdata($r['username']) . '</userid>' . "\n");
        fwrite($f, $t2 . '<logtype id="' . $r['type'] . '" recommended="' . $r['recommended'] . '">' . xmlcdata($logtypes[$r['type']]) . '</logtype>' . "\n");
        fwrite($f, $t2 . '<date>' . date($sDateshort, strtotime($r['date'])) . '</date>' . "\n");
        fwrite($f, $t2 . '<text>' . xmlcdata($r['text']) . '</text>' . "\n");
        fwrite($f, $t2 . '<datecreated>' . date($sDateformat, strtotime($r['date_created'])) . '</datecreated>' . "\n");
        fwrite($f, $t2 . '<lastmodified>' . date($sDateformat, strtotime($r['last_modified'])) . '</lastmodified>' . "\n");
        fwrite($f, $t1 . '</cachelog>' . "\n");
    }
    mysql_free_result($rs);
    $rs = sql('SELECT `pictures`.`id` `id`, `pictures`.`url` `url`, `pictures`.`title` `title`,
                      `pictures`.`object_id` `object_id`, `pictures`.`object_type` `object_type`,
                      `pictures`.`date_created` `date_created`, `pictures`.`uuid` `uuid`,
                      `pictures`.`last_modified` `last_modified`, `pictures`.`display` `display`,
                      `pictures`.`spoiler` `spoiler`, `pictures`.`node` `node`
                 FROM `tmpxml_pictures`, `pictures` WHERE `tmpxml_pictures`.`id`=`pictures`.id');
    while ($r = sql_fetch_array($rs)) {
        fwrite($f, $t1 . '<picture>' . "\n");
        fwrite($f, $t2 . '<id id="' . $r['id'] . '" node="' . $r['node'] . '">' . $r['uuid'] . '</id>' . "\n");
        fwrite($f, $t2 . '<url>' . xmlcdata($r['url']) . '</url>' . "\n");
        fwrite($f, $t2 . '<title>' . xmlcdata($r['title']) . '</title>' . "\n");
        fwrite($f, $t2 . '<object id="' . $r['object_id'] . '" type="' . $r['object_type'] . '" typename="' . xmlentities($objecttypes[$r['object_type']]) . '">' . object_id2uuid($r['object_id'], $r['object_type']) . '</object>' . "\n");
        fwrite($f, $t2 . '<attributes spoiler="' . $r['spoiler'] . '" display="' . $r['display'] . '" />' . "\n");
        fwrite($f, $t2 . '<datecreated>' . date($sDateformat, strtotime($r['date_created'])) . '</datecreated>' . "\n");
        fwrite($f, $t2 . '<lastmodified>' . date($sDateformat, strtotime($r['last_modified'])) . '</lastmodified>' . "\n");
        fwrite($f, $t1 . '</picture>' . "\n");
    }
    mysql_free_result($rs);
    $rs = sql('SELECT `removed_objects`.`id` `id`, `removed_objects`.`localid` `localid`, `removed_objects`.`uuid` `uuid`,
                      `removed_objects`.`type` `type`, `removed_objects`.`removed_date` `removed_date`, `removed_objects`.`node` `node`
                 FROM `tmpxml_removedobjects`, `removed_objects` WHERE `removed_objects`.`id`=`tmpxml_removedobjects`.`id`');
    while ($r = sql_fetch_array($rs)) {
        fwrite($f, $t1 . '<removedobject>' . "\n");
        fwrite($f, $t2 . '<id id="' . $r['id'] . '" node="' . $r['node'] . '" />' . "\n");
        fwrite($f, $t2 . '<object id="' . $r['localid'] . '" type="' . $r['type'] . '" typename="' . xmlentities($objecttypes[$r['type']]) . '">' . $r['uuid'] . '</object>' . "\n");
        fwrite($f, $t2 . '<removeddate>' . date($sDateformat, strtotime($r['removed_date'])) . '</removeddate>' . "\n");
        fwrite($f, $t1 . '</removedobject>' . "\n");
    }
    mysql_free_result($rs);
    if ($bOcXmlTag == '1') {
        fwrite($f, '</oc11xml>' . "\n");
    }
    fclose($f);
    $rel_xmlfile = 'ocxml11/' . $sessionid . '/' . $sessionid . '-' . $filenr . '-' . $fileid . '.xml';
    $rel_zipfile = 'ocxml11/' . $sessionid . '/' . $sessionid . '-' . $filenr . '-' . $fileid;
    // zippen und url-redirect
    if ($ziptype == '0') {
        tpl_redirect($zip_wwwdir . 'ocxml11/' . $sessionid . '/' . $sessionid . '-' . $filenr . '-' . $fileid . '.xml');
        exit;
    } else {
        if ($ziptype == 'zip') {
            $rel_zipfile .= '.zip';
        } else {
            if ($ziptype == 'bzip2') {
                $rel_zipfile .= '.bz2';
            } else {
                if ($ziptype == 'gzip') {
                    $rel_zipfile .= '.gz';
                } else {
                    die('unknown zip type');
                }
            }
        }
    }
    $call = $safemode_zip . ' --type=' . escapeshellcmd($ziptype) . ' --src=' . escapeshellcmd($rel_xmlfile) . ' --dst=' . escapeshellcmd($rel_zipfile);
    system($call);
    // datei vorhanden?
    if (!file_exists($zip_basedir . $rel_zipfile)) {
        die('all ok, but zip failed - internal server error');
    }
    tpl_redirect($zip_wwwdir . $rel_zipfile);
    exit;
}
Ejemplo n.º 3
0
// Pictures
if (count($naPictures) > 0) {
    $sIds = '';
    foreach ($naPictures as $id) {
        $sIds .= ', ' . $id;
    }
    $sIds = substr($sIds, 2);
    $rs = sql('SELECT `id`, `url`, `title`, `description`, `desc_html`, `object_id`, `object_type`, `date_created`, `uuid`, `last_modified` FROM `pictures` WHERE `id` IN (' . $sIds . ')');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $r = this_sql_fetch_array($rs);
        $sHTML = $r['desc_html'] == '1' ? '1' : '0';
        echo $t1 . '<picture>' . "\n";
        echo $t2 . '<id id="' . $r['id'] . '">' . $r['uuid'] . '</id>' . "\n";
        echo $t2 . '<url>' . htmlentities(filterevilchars($r['url'])) . '</url>' . "\n";
        echo $t2 . '<title>' . htmlentities_iso88592(filterevilchars($r['title'])) . '</title>' . "\n";
        echo $t2 . '<object id="' . $r['object_id'] . '" type="' . $r['object_type'] . '" typename="' . $objecttypes[$r['object_type']] . '">' . object_id2uuid($r['object_id'], $r['object_type']) . '</object>' . "\n";
        echo $t2 . '<datecreated>' . date($sDateformat, strtotime($r['date_created'])) . '</datecreated>' . "\n";
        echo $t2 . '<lastmodified>' . date($sDateformat, strtotime($r['last_modified'])) . '</lastmodified>' . "\n";
        echo $t1 . '</picture>' . "\n";
    }
    mysql_free_result($rs);
}
// removed_objects
if (count($naRemovedObjects) > 0) {
    $sIds = '';
    foreach ($naRemovedObjects as $id) {
        $sIds .= ', ' . $id;
    }
    $sIds = substr($sIds, 2);
    $rs = sql('SELECT `id`, `localid`, `uuid`, `type`, `removed_date` FROM `removed_objects` WHERE `id` IN (' . $sIds . ')');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {