function search_output() { global $sqldebug; /* cacheid name latitude longitude type size difficulty terrain username waypoint */ $sql = ' SELECT &searchtmp.`cache_id` `cacheid`, &searchtmp.`longitude`, &searchtmp.`latitude`, `caches`.`name`, `caches`.`wp_oc`, `caches`.`terrain`, `caches`.`difficulty`, `cache_type`.`short` `typedesc`, `cache_size`.`name` `sizedesc`, `user`.`username` FROM &searchtmp, `caches`, `cache_type`, `cache_size`, `user` WHERE &searchtmp.`cache_id`=`caches`.`cache_id` AND &searchtmp.`type`=`cache_type`.`id` AND &searchtmp.`size`=`cache_size`.`id` AND &searchtmp.`user_id`=`user`.`user_id`'; $rs = sql_slave($sql, $sqldebug); while ($r = sql_fetch_array($rs)) { $lat = sprintf('%07d', $r['latitude'] * 100000); $lon = sprintf('%07d', $r['longitude'] * 100000); $name = convert_string($r['name']); $username = convert_string($r['username']); $type = convert_string($r['typedesc']); $size = convert_string($r['sizedesc']); $difficulty = sprintf('%01.1f', $r['difficulty'] / 2); $terrain = sprintf('%01.1f', $r['terrain'] / 2); $cacheid = convert_string($r['wp_oc']); $line = "{$name} by {$username}, {$type}, {$size}, {$cacheid}"; $record = pack("CLllA*x", 2, 1 + 4 + 4 + 4 + strlen($line) + 1, (int) $lon, (int) $lat, $line); append_output($record); } mysql_free_result($rs); }
function search_output() { $ovlLine = "[Symbol {symbolnr1}]\r\nTyp=6\r\nGroup=1\r\nWidth=20\r\nHeight=20\r\nDir=100\r\nArt=1\r\nCol=3\r\nZoom=1\r\nSize=103\r\nArea=2\r\nXKoord={lon}\r\nYKoord={lat}\r\n[Symbol {symbolnr2}]\r\nTyp=2\r\nGroup=1\r\nCol=3\r\nArea=1\r\nZoom=1\r\nSize=130\r\nFont=1\r\nDir=100\r\nXKoord={lonname}\r\nYKoord={latname}\r\nText={cachename}\r\n"; $ovlFoot = "[Overlay]\r\nSymbols={symbolscount}\r\n"; /* {symbolnr1} {lon} {lat} {symbolnr2} {lonname} {latname} {cachename} {symbolscount} */ $nr = 1; $rs = sql_slave(' SELECT SQL_BUFFER_RESULT &searchtmp.`cache_id` `cacheid`, &searchtmp.`longitude`, &searchtmp.`latitude`, `caches`.`name` FROM &searchtmp, `caches` WHERE &searchtmp.`cache_id`=`caches`.`cache_id`'); while ($r = sql_fetch_array($rs)) { $thisline = $ovlLine; $lat = sprintf('%01.5f', $r['latitude']); $thisline = mb_ereg_replace('{lat}', $lat, $thisline); $thisline = mb_ereg_replace('{latname}', $lat, $thisline); $lon = sprintf('%01.5f', $r['longitude']); $thisline = mb_ereg_replace('{lon}', $lon, $thisline); $thisline = mb_ereg_replace('{lonname}', $lon, $thisline); $thisline = mb_ereg_replace('{cachename}', utf8ToIso88591($r['name']), $thisline); $thisline = mb_ereg_replace('{symbolnr1}', $nr, $thisline); $thisline = mb_ereg_replace('{symbolnr2}', $nr + 1, $thisline); append_output($thisline); $nr += 2; } mysql_free_result($rs); $ovlFoot = mb_ereg_replace('{symbolscount}', $nr - 1, $ovlFoot); append_output($ovlFoot); }
*/ $sql = 'SELECT `ov2content`.`cache_id` `cacheid`, `ov2content`.`longitude` `longitude`, `ov2content`.`latitude` `latitude`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`, `caches`.`wp_oc` `wp_oc`, `cache_type`.`short` `typedesc`, `cache_size`.`de` `sizedesc`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `user`.`username` `username` FROM `ov2content`, `caches`, `cache_type`, `cache_size`, `user` WHERE `ov2content`.`cache_id`=`caches`.`cache_id` AND `ov2content`.`type`=`cache_type`.`id` AND `ov2content`.`size`=`cache_size`.`id` AND `ov2content`.`user_id`=`user`.`user_id`'; $rs = sql_slave($sql, $sqldebug); while ($r = sql_fetch_array($rs)) { $lat = sprintf('%07d', $r['latitude'] * 100000); $lon = sprintf('%07d', $r['longitude'] * 100000); $name = convert_string($r['name']); $username = convert_string($r['username']); $type = convert_string($r['typedesc']); $size = convert_string($r['sizedesc']); $difficulty = sprintf('%01.1f', $r['difficulty'] / 2); $terrain = sprintf('%01.1f', $r['terrain'] / 2); $cacheid = convert_string($r['wp_oc']); $line = "{$name} by {$username}, {$type}, {$size}, {$cacheid}"; $record = pack("CLllA*x", 2, 1 + 4 + 4 + 4 + strlen($line) + 1, (int) $lon, (int) $lat, $line); append_output($record); } mysql_free_result($rs); if ($sqldebug == true) { sqldbg_end(); } // phpzip versenden if ($bUseZip == true) { $phpzip->add_data($sFilebasename . '.ov2', $content); echo $phpzip->save($sFilebasename . '.zip', 'b'); } exit; function convert_string($str) { $newstr = iconv("UTF-8", "ISO-8859-1", $str); if ($newstr == false) {
//check if we have user coords $thisline = str_replace('{mod_suffix}', '<F>', $thisline); } else { $thisline = str_replace('{mod_suffix}', '', $thisline); } $thisline = mb_ereg_replace('{cachename}', convert_string($r['name']), $thisline); $thisline = mb_ereg_replace('{symbolnr1}', $nr, $thisline); $thisline = mb_ereg_replace('{symbolnr2}', $nr + 1, $thisline); append_output($thisline); ob_flush(); $nr += 2; } $dbcSearch->reset(); unset($dbc); $ovlFoot = mb_ereg_replace('{symbolscount}', $nr - 1, $ovlFoot); append_output($ovlFoot); if ($sqldebug == true) { sqldbg_end(); } // phpzip versenden if ($bUseZip == true) { $phpzip->add_data($sFilebasename . '.ovl', $content); echo $phpzip->save($sFilebasename . '.zip', 'b'); } } exit; function convert_string($str) { $newstr = iconv("UTF-8", "utf-8", $str); if ($newstr == false) { return $str;
function search_output() { global $opt; global $state_temporarily_na, $state_archived, $state_locked; $server_domain = $opt['page']['domain']; $server_address = $opt['page']['default_absolute_url']; $locHead = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><loc version="1.0" src="' . $server_domain . '">' . "\n"; $locLine = ' <waypoint> <name id="{waypoint}"><![CDATA[{archivedflag}{name} by {username}]]></name> <coord lat="{lat}" lon="{lon}"/> <type>Geocache</type> <link text="Beschreibung">' . $server_address . 'viewcache.php?cacheid={cacheid}</link> </waypoint> '; $locFoot = '</loc>'; append_output($locHead); /* {waypoint} status -> {archivedflag} {name} {username} {lon} {lat} {cacheid} */ $rs = sql_slave(' SELECT SQL_BUFFER_RESULT &searchtmp.`cache_id` `cacheid`, &searchtmp.`longitude`, &searchtmp.`latitude`, `caches`.`name`, `caches`.`status`, `caches`.`wp_oc` `waypoint`, `user`.`username` `username` FROM &searchtmp, `caches`, `user` WHERE &searchtmp.`cache_id`=`caches`.`cache_id` AND &searchtmp.`user_id`=`user`.`user_id`'); while ($r = sql_fetch_array($rs)) { $thisline = $locLine; $lat = sprintf('%01.5f', $r['latitude']); $thisline = mb_ereg_replace('{lat}', $lat, $thisline); $lon = sprintf('%01.5f', $r['longitude']); $thisline = mb_ereg_replace('{lon}', $lon, $thisline); $thisline = mb_ereg_replace('{waypoint}', $r['waypoint'], $thisline); $thisline = mb_ereg_replace('{name}', $r['name'], $thisline); if ($r['status'] == 2 || $r['status'] == 3 || $r['status'] == 6) { if ($r['status'] == 2) { $thisline = mb_ereg_replace('{archivedflag}', $state_temporarily_na . '!, ', $thisline); } elseif ($r['status'] == 3) { $thisline = mb_ereg_replace('{archivedflag}', $state_archived . '!, ', $thisline); } else { $thisline = mb_ereg_replace('{archivedflag}', $state_locked . '!, ', $thisline); } } else { $thisline = mb_ereg_replace('{archivedflag}', '', $thisline); } $thisline = mb_ereg_replace('{username}', $r['username'], $thisline); $thisline = mb_ereg_replace('{cacheid}', $r['cacheid'], $thisline); append_output($thisline); } mysql_free_result($rs); append_output($locFoot); }
} } else { $thisline = mb_ereg_replace('{archivedflag}', '', $thisline); } $thisline = mb_ereg_replace('{type}', xmlentities($r['typedesc']), $thisline); $thisline = mb_ereg_replace('{size}', xmlentities($r['sizedesc']), $thisline); $difficulty = sprintf('%01.1f', $r['difficulty'] / 2); $thisline = mb_ereg_replace('{difficulty}', $difficulty, $thisline); $terrain = sprintf('%01.1f', $r['terrain'] / 2); $thisline = mb_ereg_replace('{terrain}', $terrain, $thisline); $thisline = mb_ereg_replace('{username}', xmlentities($r['username']), $thisline); $thisline = mb_ereg_replace('{cacheid}', $r['cacheid'], $thisline); append_output($thisline); } mysql_free_result($rs); append_output($locFoot); if ($sqldebug == true) { sqldbg_end(); } // phpzip versenden if ($bUseZip == true) { $phpzip->add_data($sFilebasename . '.loc', $content); echo $phpzip->save($sFilebasename . '.zip', 'b'); } exit; function xmlentities($str) { $from[0] = '&'; $to[0] = '&'; $from[1] = '<'; $to[1] = '<';
$sDiffDecimals = '.5'; } $r['difficulty'] -= $r['difficulty'] % 2; $thisline = mb_ereg_replace('{difficulty}', $r['difficulty'] / 2 . $sDiffDecimals, $thisline); $sTerrDecimals = ''; if ($r['terrain'] % 2) { $sTerrDecimals = '.5'; } $r['terrain'] -= $r['terrain'] % 2; $thisline = mb_ereg_replace('{terrain}', $r['terrain'] / 2 . $sTerrDecimals, $thisline); $thisline = mb_ereg_replace('{owner}', xmlentities($r['username']), $thisline); $thisline = mb_ereg_replace('{userid}', xmlentities($r['userid']), $thisline); append_output($thisline); } mysql_free_result($rs); append_output($gpxFoot); if ($sqldebug == true) { sqldbg_end(); } // phpzip versenden if ($bUseZip == true) { $phpzip->add_data($sFilebasename . '.gpx', $content); echo $phpzip->save($sFilebasename . '.zip', 'b'); } exit; function xmlentities($str) { $from[0] = '&'; $to[0] = '&'; $from[1] = '<'; $to[1] = '<';
function search_output() { global $opt; global $state_temporarily_na, $state_archived, $state_locked; global $t_showdesc, $t_by, $t_type, $t_size, $t_difficulty, $t_terrain; // see also util2/google-earth/caches.php $kmlLine = ' <Placemark> <description><![CDATA[' . $t_by . ' {username}<br><br><a href="' . $opt['page']['absolute_url'] . 'viewcache.php?cacheid={cacheid}">' . $t_showdesc . '</a><br> <br><table cellspacing="0" cellpadding="0" border="0"><tr><td>{typeimgurl} </td><td>' . $t_type . ' {type}<br>' . $t_size . ' {size}</td></tr><tr><td colspan="2">' . $t_difficulty . '<br>' . $t_terrain . '</td></tr></table>]]></description> <name>{name}{archivedflag}</name> <LookAt> <longitude>{lon}</longitude> <latitude>{lat}</latitude> <range>5000</range> <tilt>0</tilt> <heading>3</heading> </LookAt> <styleUrl>#{icon}</styleUrl> <Point> <coordinates>{lon},{lat},0</coordinates> </Point> <Snippet>D: {difficulty}/T: {terrain} {size} ' . $t_by . ' {username}</Snippet> </Placemark> '; $kmlFoot = '</Folder></Document></kml>'; $kmlTimeFormat = 'Y-m-d\\TH:i:s\\Z'; $style = $opt['template']['style']; $kmlDetailHead = file_get_contents("resource2/misc/google-earth/search.result.caches.kml.head.xml"); $rsMinMax = sql_slave(' SELECT MIN(`longitude`) `minlon`, MAX(`longitude`) `maxlon`, MIN(`latitude`) `minlat`, MAX(`latitude`) `maxlat` FROM &searchtmp'); $rMinMax = sql_fetch_array($rsMinMax); mysql_free_result($rsMinMax); $kmlDetailHead = mb_ereg_replace('{minlat}', $rMinMax['minlat'], $kmlDetailHead); $kmlDetailHead = mb_ereg_replace('{minlon}', $rMinMax['minlon'], $kmlDetailHead); $kmlDetailHead = mb_ereg_replace('{maxlat}', $rMinMax['maxlat'], $kmlDetailHead); $kmlDetailHead = mb_ereg_replace('{maxlon}', $rMinMax['maxlon'], $kmlDetailHead); $kmlDetailHead = mb_ereg_replace('{time}', date($kmlTimeFormat), $kmlDetailHead); append_output($kmlDetailHead); $rs = sql_slave("\n\t\tSELECT SQL_BUFFER_RESULT\n\t\t\t&searchtmp.`cache_id` `cacheid`,\n\t\t\t&searchtmp.`longitude`,\n\t\t\t&searchtmp.`latitude`,\n\t\t\t`caches`.`date_hidden`,\n\t\t\t`caches`.`name`,\n\t\t\t`caches`.`status`,\n\t\t\tIFNULL(`stt_type`.`text`, `cache_type`.`en`) `typedesc`,\n\t\t\t`cache_type`.`kml_name`,\n\t\t\t`cache_type`.`icon_large`,\n\t\t\tIFNULL(`stt_size`.`text`, `cache_size`.`en`) `sizedesc`,\n\t\t\t`caches`.`terrain`,\n\t\t\t`caches`.`difficulty`,\n\t\t\t`user`.`username`\n\t\tFROM &searchtmp\n\t\tJOIN `caches` ON &searchtmp.`cache_id`=`caches`.`cache_id`\n\t\tJOIN `cache_type` ON `caches`.`type`=`cache_type`.`id`\n\t\tJOIN `cache_size` ON `caches`.`size`=`cache_size`.`id`\n\t\tLEFT JOIN `user` ON &searchtmp.`user_id`=`user`.`user_id`\n\t\tLEFT JOIN `sys_trans_text` `stt_type` ON `stt_type`.`trans_id`=`cache_type`.`trans_id` AND `stt_type`.`lang`='&1'\n\t\tLEFT JOIN `sys_trans_text` `stt_size` ON `stt_size`.`trans_id`=`cache_size`.`trans_id` AND `stt_size`.`lang`='&1'\n\t\t", $opt['template']['locale']); while ($r = sql_fetch_array($rs)) { $thisline = $kmlLine; $typeimgurl = '<img src="{urlbase}resource2/' . $style . '/images/cacheicon/' . $r['icon_large'] . '" alt="' . $r['typedesc'] . '" title="' . $r['typedesc'] . '" />'; $thisline = mb_ereg_replace('{icon}', $r['kml_name'], $thisline); $thisline = mb_ereg_replace('{typeimgurl}', $typeimgurl, $thisline); $lat = sprintf('%01.5f', $r['latitude']); $thisline = mb_ereg_replace('{lat}', $lat, $thisline); $lon = sprintf('%01.5f', $r['longitude']); $thisline = mb_ereg_replace('{lon}', $lon, $thisline); $time = date($kmlTimeFormat, strtotime($r['date_hidden'])); $thisline = mb_ereg_replace('{time}', $time, $thisline); $thisline = mb_ereg_replace('{name}', xmlentities($r['name']), $thisline); if ($r['status'] == 2 || $r['status'] == 3 || $r['status'] == 6) { if ($r['status'] == 2) { $thisline = mb_ereg_replace('{archivedflag}', ' (' . $state_temporarily_na . ')', $thisline); } elseif ($r['status'] == 3) { $thisline = mb_ereg_replace('{archivedflag}', ' (' . $state_archived . ')', $thisline); } else { $thisline = mb_ereg_replace('{archivedflag}', ' (' . $state_locked . ')', $thisline); } } else { $thisline = mb_ereg_replace('{archivedflag}', '', $thisline); } $thisline = mb_ereg_replace('{type}', xmlentities($r['typedesc']), $thisline); $thisline = mb_ereg_replace('{size}', xmlentities($r['sizedesc']), $thisline); $difficulty = sprintf('%01.1f', $r['difficulty'] / 2); $thisline = mb_ereg_replace('{difficulty}', $difficulty, $thisline); $terrain = sprintf('%01.1f', $r['terrain'] / 2); $thisline = mb_ereg_replace('{terrain}', $terrain, $thisline); $time = date($kmlTimeFormat, strtotime($r['date_hidden'])); $thisline = mb_ereg_replace('{time}', $time, $thisline); $thisline = mb_ereg_replace('{username}', xmlentities($r['username']), $thisline); $thisline = mb_ereg_replace('{cacheid}', xmlentities($r['cacheid']), $thisline); $thisline = mb_ereg_replace('{urlbase}', xmlentities($opt['page']['absolute_url']), $thisline); append_output($thisline); } mysql_free_result($rs); append_output($kmlFoot); }
function search_output() { global $opt, $login; global $cache_note_text; $server_address = $opt['page']['absolute_url']; $server_domain = parse_url($server_address, PHP_URL_HOST); $gpxHead = '<?xml version="1.0" encoding="utf-8"?> <gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0" creator="Opencaching.de - http://www.opencaching.de" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.groundspeak.com/cache/1/0/1 http://www.groundspeak.com/cache/1/0/1/cache.xsd" xmlns="http://www.topografix.com/GPX/1/0"> <name>Cache listing generated from Opencaching.de</name> <desc>This is a waypoint file generated from Opencaching.de{wpchildren}</desc> <author>Opencaching.de</author> <email>contact@opencaching.de</email> <url>http://' . $server_domain . '</url> <urlname>Opencaching.de - Geocaching in Deutschland, Oesterreich und der Schweiz</urlname> <time>{time}</time> <keywords>cache, geocache, opencaching, waypoint</keywords> '; $gpxLine = ' <wpt lat="{lat}" lon="{lon}"> <time>{time}</time> <name>{waypoint}</name> <desc>{cachename}</desc> <src>' . $server_domain . '</src> <url>' . $server_address . 'viewcache.php?cacheid={cacheid}</url> <urlname>{cachename}</urlname> <sym>{sym}</sym> <type>Geocache|{type}</type> <groundspeak:cache id="{cacheid}" {status} xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1"> <groundspeak:name>{cachename}</groundspeak:name> <groundspeak:placed_by>{owner}</groundspeak:placed_by> <groundspeak:owner id="{userid}">{owner}</groundspeak:owner> <groundspeak:type>{type}</groundspeak:type> <groundspeak:container>{container}</groundspeak:container> <groundspeak:attributes> {attributes} </groundspeak:attributes> <groundspeak:difficulty>{difficulty}</groundspeak:difficulty> <groundspeak:terrain>{terrain}</groundspeak:terrain> <groundspeak:country>{country}</groundspeak:country> <groundspeak:state>{state}</groundspeak:state> <groundspeak:short_description html="True">{shortdesc}</groundspeak:short_description> <groundspeak:long_description html="True">{desc}<br />{images}</groundspeak:long_description> {hints} <groundspeak:logs> {logs} </groundspeak:logs> <groundspeak:travelbugs> {geokrety} </groundspeak:travelbugs> </groundspeak:cache> </wpt> {cache_waypoints}'; /* Ocprop: * <wpt\s+lat=\"([0-9\-\+\.]+)\"\s+lon=\"([0-9\-\+\.]+)\"> * <time>(.*?)<\/time> * (Date: ^([0-9]{4})\-([0-9]{2})\-([0-9]{2})T[0-9\:\-\.]+(Z)?$/s) * <name>(.*?)<\/name> * <url>http:\/\/www\.opencaching\.de\/viewcache\.php\?cacheid=([0-9]+)<\/url> * <sym>(.*?)<\/sym> * <groundspeak:cache\s+id=\"[0-9]+\"\s+available=\"(True|False)\"\s+archived=\"(True|False)\" * <groundspeak:name>(.*?)<\/groundspeak:name> * <groundspeak:placed_by>(.*?)<\/groundspeak:placed_by> * <groundspeak:owner id="([0-9])+">(.*?)<\/groundspeak:owner> * <groundspeak:type>(.*?)<\/groundspeak:type> * <groundspeak:container>(.*?)<\/groundspeak:container> * <groundspeak:difficulty>(.*?)<\/groundspeak:difficulty> * <groundspeak:terrain>(.*?)<\/groundspeak:terrain> * <groundspeak:country>(.*?)<\/groundspeak:country> * <groundspeak:state>(.*?)<\/groundspeak:state> * <groundspeak:short_description html="(.*?)".*?>(.*?)<\/groundspeak:short_description> * <groundspeak:long_description html="(.*?)".*?>(.*?)<\/groundspeak:long_description> * <groundspeak:encoded_hints>(.*?)<\/groundspeak:encoded_hints> */ $gpxAttributes = ' <groundspeak:attribute id="{attrib_id}" inc="{attrib_inc}">{attrib_name}</groundspeak:attribute>'; $gpxLog = ' <groundspeak:log id="{id}"> <groundspeak:date>{date}</groundspeak:date> <groundspeak:type>{type}</groundspeak:type> <groundspeak:finder id="{userid}">{username}</groundspeak:finder> <groundspeak:text encoded="False">{text}</groundspeak:text> </groundspeak:log>'; $gpxGeokrety = ' <groundspeak:travelbug id="{gkid}" ref="{gkref}"> <groundspeak:name>{gkname}</groundspeak:name> </groundspeak:travelbug>'; $gpxWaypoints = ' <wpt lat="{wp_lat}" lon="{wp_lon}"> <time>{time}</time> <name>{name}</name> <cmt>{comment}</cmt> <desc>{desc}</desc> <url>' . $server_address . 'viewcache.php?cacheid={cacheid}</url> <urlname>{parent} {cachename}</urlname> <sym>{type}</sym> <type>Waypoint|{type}</type> <gsak:wptExtension xmlns:gsak="http://www.gsak.net/xmlv1/4"> <gsak:Parent>{parent}</gsak:Parent> </gsak:wptExtension> </wpt> '; $gpxFoot = '</gpx>'; $gpxTimeFormat = 'Y-m-d\\TH:i:s\\Z'; $gpxStatus[0] = 'available="False" archived="False"'; // other (unavailable, not archived) $gpxStatus[1] = 'available="True" archived="False"'; //available, not archived $gpxStatus[2] = 'available="False" archived="False"'; //unavailable, not archived $gpxStatus[3] = 'available="False" archived="True"'; //unavailable, archived $gpxStatus[6] = 'available="False" archived="True"'; //locked, visible $gpxContainer[0] = 'Other'; $gpxContainer[2] = 'Micro'; $gpxContainer[3] = 'Small'; $gpxContainer[4] = 'Regular'; $gpxContainer[5] = 'Large'; $gpxContainer[6] = 'Large'; $gpxContainer[7] = 'Virtual'; $gpxContainer[8] = 'Micro'; // cache types known by gpx $gpxType[0] = 'Unknown Cache'; $gpxType[2] = 'Traditional Cache'; $gpxType[3] = 'Multi-cache'; $gpxType[4] = 'Virtual Cache'; $gpxType[5] = 'Webcam Cache'; $gpxType[6] = 'Event Cache'; // unknown ... converted $gpxType[7] = 'Unknown Cache'; $gpxType[8] = 'Unknown Cache'; $gpxType[10] = 'Traditional Cache'; $gpxLogType[0] = 'Other'; $gpxLogType[1] = 'Found it'; $gpxLogType[2] = 'Didn\'t find it'; $gpxLogType[3] = 'Write note'; $gpxLogType[7] = 'Attended'; $gpxLogType[8] = 'Will attend'; $gpxLogType[9] = 'Archive'; $gpxLogType[10] = 'Owner Maintenance'; $gpxLogType[11] = 'Temporarily Disable Listing'; $gpxLogType[13] = 'Archive'; $gpxLogType[14] = 'Archive'; $gpxSymNormal = 'Geocache'; $gpxSymFound = 'Geocache Found'; $childwphandler = new ChildWp_Handler(); $children = ''; $rs = sql('SELECT &searchtmp.`cache_id` `cacheid` FROM &searchtmp'); while ($r = sql_fetch_array($rs) && $children == '') { if (count($childwphandler->getChildWps($r['cacheid']))) { $children = ' (HasChildren)'; } } mysql_free_result($rs); $gpxHead = mb_ereg_replace('{wpchildren}', $children, $gpxHead); $gpxHead = mb_ereg_replace('{time}', date($gpxTimeFormat, time()), $gpxHead); append_output($gpxHead); $user_id = $login->userid; $rs = sql_slave("SELECT SQL_BUFFER_RESULT &searchtmp.`cache_id` `cacheid`, &searchtmp.`longitude` `longitude`, &searchtmp.`latitude` `latitude`,\n\t\t\t\t\t\t\t`cache_location`.`adm2` `state`, `caches`.`wp_oc` `waypoint`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`,\n\t\t\t\t\t\t\t`caches`.`country` `country`, `countries`.`name` AS `country_name`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `caches`.`desc_languages` `desc_languages`,\n\t\t\t\t\t\t\t`caches`.`size` `size`, `caches`.`type` `type`, `caches`.`status` `status`, `user`.`username` `username`, `caches`.`user_id` `userid`, `user`.`data_license`,\n\t\t\t\t\t\t\t`cache_desc`.`desc` `desc`, `cache_desc`.`short_desc` `short_desc`, `cache_desc`.`hint` `hint`,\n\t\t\t\t\t\t\tIFNULL(`stat_cache_logs`.`found`, 0) AS `found`\n\t\t\t\t\t\tFROM &searchtmp\n\t\t\t\t\t\t\tINNER JOIN `caches` ON &searchtmp.`cache_id`=`caches`.`cache_id`\n\t\t\t\t\t\t\tINNER JOIN `countries` ON `caches`.`country`=`countries`.`short`\n\t\t\t\t\t\t\tINNER JOIN `user` ON &searchtmp.`user_id`=`user`.`user_id`\n\t\t\t\t\t\t\tINNER JOIN `cache_desc` ON `caches`.`cache_id`=`cache_desc`.`cache_id`AND `caches`.`default_desclang`=`cache_desc`.`language`\n\t\t\t\t\t\t\tLEFT JOIN `cache_location` ON &searchtmp.`cache_id`=`cache_location`.`cache_id`\n\t\t\t\t\t\t\tLEFT JOIN `stat_cache_logs` ON &searchtmp.`cache_id`=`stat_cache_logs`.`cache_id` AND `stat_cache_logs`.`user_id`='&1'", $user_id); while ($r = sql_fetch_array($rs)) { $thisline = $gpxLine; $lat = sprintf('%01.5f', $r['latitude']); $thisline = mb_ereg_replace('{lat}', $lat, $thisline); $lon = sprintf('%01.5f', $r['longitude']); $thisline = mb_ereg_replace('{lon}', $lon, $thisline); $time = date($gpxTimeFormat, strtotime($r['date_hidden'])); $thisline = mb_ereg_replace('{time}', $time, $thisline); $thisline = mb_ereg_replace('{waypoint}', $r['waypoint'], $thisline); $thisline = mb_ereg_replace('{cacheid}', $r['cacheid'], $thisline); $thisline = mb_ereg_replace('{cachename}', text_xmlentities($r['name']), $thisline); $thisline = mb_ereg_replace('{country}', text_xmlentities($r['country_name']), $thisline); $thisline = mb_ereg_replace('{state}', text_xmlentities($r['state']), $thisline); if ($r['hint'] == '') { $thisline = mb_ereg_replace('{hints}', '', $thisline); } else { // Ocprop: <groundspeak:encoded_hints>(.*?)<\/groundspeak:encoded_hints> $hint = html_entity_decode(strip_tags($r['hint']), ENT_COMPAT, "UTF-8"); } $thisline = mb_ereg_replace('{hints}', ' <groundspeak:encoded_hints>' . text_xmlentities($hint) . '</groundspeak:encoded_hints> ', $thisline); $thisline = mb_ereg_replace('{shortdesc}', text_xmlentities($r['short_desc']), $thisline); $desc = str_replace(' src="images/uploads/', ' src="' . $server_address . 'images/uploads/', $r['desc']); $license = getLicenseDisclaimer($r['userid'], $r['username'], $r['data_license'], $r['cacheid'], $opt['template']['locale'], true, true); if ($license != "") { $desc .= "<p><em>{$license}</em></p>\n"; } $desc .= get_desc_npas($r['cacheid']); $thisline = mb_ereg_replace('{desc}', text_xmlentities(decodeEntities($desc)), $thisline); $thisline = mb_ereg_replace('{images}', text_xmlentities(getPictures($r['cacheid'], $server_address)), $thisline); if (isset($gpxType[$r['type']])) { $thisline = mb_ereg_replace('{type}', $gpxType[$r['type']], $thisline); } else { $thisline = mb_ereg_replace('{type}', $gpxType[0], $thisline); } if (isset($gpxContainer[$r['size']])) { $thisline = mb_ereg_replace('{container}', $gpxContainer[$r['size']], $thisline); } else { $thisline = mb_ereg_replace('{container}', $gpxContainer[0], $thisline); } if (isset($gpxStatus[$r['status']])) { $thisline = mb_ereg_replace('{status}', $gpxStatus[$r['status']], $thisline); } else { $thisline = mb_ereg_replace('{status}', $gpxStatus[0], $thisline); } $sDiffDecimals = ''; if ($r['difficulty'] % 2) { $sDiffDecimals = '.5'; } $r['difficulty'] -= $r['difficulty'] % 2; $thisline = mb_ereg_replace('{difficulty}', $r['difficulty'] / 2 . $sDiffDecimals, $thisline); $sTerrDecimals = ''; if ($r['terrain'] % 2) { $sTerrDecimals = '.5'; } $r['terrain'] -= $r['terrain'] % 2; $thisline = mb_ereg_replace('{terrain}', $r['terrain'] / 2 . $sTerrDecimals, $thisline); $thisline = mb_ereg_replace('{owner}', text_xmlentities($r['username']), $thisline); $thisline = mb_ereg_replace('{userid}', $r['userid'], $thisline); if ($r['found'] > 0) { $thisline = mb_ereg_replace('{sym}', text_xmlentities($gpxSymFound), $thisline); } else { $thisline = mb_ereg_replace('{sym}', text_xmlentities($gpxSymNormal), $thisline); } // clear cache specific data $logentries = ''; $cache_note = false; $attribentries = ''; $waypoints = ''; $gkentries = ''; // fetch logs if ($user_id != 0) { // insert personal note $cacheNote = getCacheNote($user_id, $r['cacheid']); if ($cacheNote) { $thislog = $gpxLog; $thislog = mb_ereg_replace('{id}', 0, $thislog); $thislog = mb_ereg_replace('{date}', date($gpxTimeFormat), $thislog); $thislog = mb_ereg_replace('{userid}', $user_id, $thislog); $thislog = mb_ereg_replace('{username}', text_xmlentities($login->username), $thislog); $thislog = mb_ereg_replace('{type}', $gpxLogType[3], $thislog); $thislog = mb_ereg_replace('{text}', text_xmlentities($cacheNote['note']), $thislog); $logentries .= $thislog . "\n"; } // current users logs $rsLogs = sql_slave("SELECT `cache_logs`.`id`, `cache_logs`.`type`, `cache_logs`.`date`, `cache_logs`.`text`, `user`.`username`, `user`.`user_id` FROM `cache_logs`, `user` WHERE `cache_logs`.`user_id`=`user`.`user_id` AND `cache_logs`.`cache_id`=&1 AND `user`.`user_id`=&2 ORDER BY `cache_logs`.`date` DESC, `cache_logs`.`date_created` DESC", $r['cacheid'], $user_id); while ($rLog = sql_fetch_array($rsLogs)) { $thislog = $gpxLog; $thislog = mb_ereg_replace('{id}', $rLog['id'], $thislog); $thislog = mb_ereg_replace('{date}', date($gpxTimeFormat, strtotime($rLog['date'])), $thislog); $thislog = mb_ereg_replace('{userid}', $rLog['user_id'], $thislog); $thislog = mb_ereg_replace('{username}', text_xmlentities($rLog['username']), $thislog); if (isset($gpxLogType[$rLog['type']])) { $logtype = $gpxLogType[$rLog['type']]; } else { $logtype = $gpxLogType[0]; } $thislog = mb_ereg_replace('{type}', $logtype, $thislog); $thislog = mb_ereg_replace('{text}', text_xmlentities(decodeEntities($rLog['text'])), $thislog); $logentries .= $thislog . "\n"; } mysql_free_result($rsLogs); } // newest 20 logs (except current users) $rsLogs = sql_slave("SELECT `cache_logs`.`id`, `cache_logs`.`type`, `cache_logs`.`date`, `cache_logs`.`text`, `user`.`username`, `user`.`user_id` FROM `cache_logs`, `user` WHERE `cache_logs`.`user_id`=`user`.`user_id` AND `cache_logs`.`cache_id`=&1 AND `user`.`user_id`!=&2 ORDER BY `cache_logs`.`date` DESC, `cache_logs`.`date_created` DESC LIMIT 20", $r['cacheid'], $user_id); while ($rLog = sql_fetch_array($rsLogs)) { $thislog = $gpxLog; $thislog = mb_ereg_replace('{id}', $rLog['id'], $thislog); $thislog = mb_ereg_replace('{date}', date($gpxTimeFormat, strtotime($rLog['date'])), $thislog); $thislog = mb_ereg_replace('{userid}', $rLog['user_id'], $thislog); $thislog = mb_ereg_replace('{username}', text_xmlentities($rLog['username']), $thislog); if (isset($gpxLogType[$rLog['type']])) { $logtype = $gpxLogType[$rLog['type']]; } else { $logtype = $gpxLogType[0]; } $thislog = mb_ereg_replace('{type}', $logtype, $thislog); $thislog = mb_ereg_replace('{text}', text_xmlentities(decodeEntities($rLog['text'])), $thislog); $logentries .= $thislog . "\n"; } mysql_free_result($rsLogs); $thisline = mb_ereg_replace('{logs}', $logentries, $thisline); // attributes $rsAttributes = sql_slave("SELECT `gc_id`, `gc_inc`, `gc_name`\n\t\t FROM `caches_attributes`\n\t\t INNER JOIN `cache_attrib` ON `cache_attrib`.`id`=`caches_attributes`.`attrib_id`\n\t\t WHERE `caches_attributes`.`cache_id`=&1", $r['cacheid']); $gc_ids = array(); while ($rAttrib = sql_fetch_array($rsAttributes)) { // Multiple OC attributes can be mapped to one GC attribute, either with // the same "inc"s or with different. Both may disturb applications, so we // output each GC ID only once. if (!isset($gc_ids[$rAttrib['gc_id']])) { $thisattribute = mb_ereg_replace('{attrib_id}', $rAttrib['gc_id'], $gpxAttributes); $thisattribute = mb_ereg_replace('{attrib_inc}', $rAttrib['gc_inc'], $thisattribute); $thisattribute = mb_ereg_replace('{attrib_name}', text_xmlentities($rAttrib['gc_name']), $thisattribute); $attribentries .= $thisattribute . "\n"; $gc_ids[$rAttrib['gc_id']] = true; } } mysql_free_result($rsAttributes); $thisline = mb_ereg_replace('{attributes}', $attribentries, $thisline); // geokrety $rsGeokrety = sql_slave("SELECT `gk_item`.`id`, `gk_item`.`name`, `caches`.`wp_oc` FROM `gk_item` INNER JOIN `gk_item_waypoint` ON `gk_item`.`id`=`gk_item_waypoint`.`id` INNER JOIN `caches` ON `gk_item_waypoint`.`wp`=`caches`.`wp_oc` WHERE `caches`.`cache_id`=&1", $r['cacheid']); while ($rGK = sql_fetch_array($rsGeokrety)) { $thiskrety = $gpxGeokrety; $thiskrety = mb_ereg_replace('{gkid}', $rGK['id'], $thiskrety); $thiskrety = mb_ereg_replace('{gkref}', sprintf("GK%04X", $rGK['id']), $thiskrety); $thiskrety = mb_ereg_replace('{gkname}', text_xmlentities($rGK['name']), $thiskrety); $gkentries .= $thiskrety . "\n"; } mysql_free_result($rsGeokrety); $thisline = mb_ereg_replace('{geokrety}', $gkentries, $thisline); // additional waypoints, including personal cache note $childWaypoints = $childwphandler->getChildWps($r['cacheid']); $n = 1; $digits = "%0" . strlen(count($childWaypoints)) . "d"; foreach ($childWaypoints as $childWaypoint) { $thiswp = $gpxWaypoints; $thiswp = mb_ereg_replace('{wp_lat}', sprintf('%01.5f', $childWaypoint['latitude']), $thiswp); $thiswp = mb_ereg_replace('{wp_lon}', sprintf('%01.5f', $childWaypoint['longitude']), $thiswp); $thiswp = mb_ereg_replace('{time}', $time, $thiswp); $thiswp = mb_ereg_replace('{name}', $r['waypoint'] . '-' . sprintf($digits, $n), $thiswp); $thiswp = mb_ereg_replace('{cachename}', text_xmlentities($r['name']), $thiswp); $thiswp = mb_ereg_replace('{comment}', text_xmlentities($childWaypoint['description']), $thiswp); $thiswp = mb_ereg_replace('{desc}', text_xmlentities($childWaypoint['name']), $thiswp); switch ($childWaypoint['type']) { case 1: $wp_typename = "Parking Area"; break; // well-known garmin symbols // well-known garmin symbols case 2: $wp_typename = "Flag, Green"; break; // stage / ref point // stage / ref point case 3: $wp_typename = "Flag, Blue"; break; // path // path case 4: $wp_typename = "Circle with X"; break; // final // final case 5: $wp_typename = "Diamond, Green"; break; // point of interest // point of interest default: $wp_typename = "Flag, Blue"; break; // for the case new types are forgotten here .. } $thiswp = mb_ereg_replace('{type}', text_xmlentities($wp_typename), $thiswp); $thiswp = mb_ereg_replace('{parent}', $r['waypoint'], $thiswp); $thiswp = mb_ereg_replace('{cacheid}', $r['cacheid'], $thiswp); $waypoints .= $thiswp; ++$n; } if ($cacheNote && !empty($cacheNote['latitude']) && !empty($cacheNote['longitude'])) { $thiswp = $gpxWaypoints; $thiswp = mb_ereg_replace('{wp_lat}', sprintf('%01.5f', $cacheNote['latitude']), $thiswp); $thiswp = mb_ereg_replace('{wp_lon}', sprintf('%01.5f', $cacheNote['longitude']), $thiswp); $thiswp = mb_ereg_replace('{time}', $time, $thiswp); $thiswp = mb_ereg_replace('{name}', $r['waypoint'] . 'NOTE', $thiswp); $thiswp = mb_ereg_replace('{cachename}', text_xmlentities($r['name']), $thiswp); $thiswp = mb_ereg_replace('{comment}', text_xmlentities($cacheNote['note']), $thiswp); $thiswp = mb_ereg_replace('{desc}', text_xmlentities($cache_note_text), $thiswp); $thiswp = mb_ereg_replace('{type}', "Reference Point", $thiswp); $thiswp = mb_ereg_replace('{parent}', $r['waypoint'], $thiswp); $thiswp = mb_ereg_replace('{cacheid}', $r['cacheid'], $thiswp); $waypoints .= $thiswp; } $thisline = mb_ereg_replace('{cache_waypoints}', $waypoints, $thisline); append_output($thisline); } mysql_free_result($rs); append_output($gpxFoot); }
function search_output() { global $opt; global $state_temporarily_na, $state_archived, $state_locked; $kmlLine = ' <Placemark> <description><![CDATA[<a href="' . $opt['page']['absolute_url'] . 'viewcache.php?cacheid={cacheid}">Beschreibung ansehen</a><br>Von {username}<br> <br><table cellspacing="0" cellpadding="0" border="0"><tr><td>{typeimgurl} </td><td>Art: {type}<br>Größe: {size}</td></tr><tr><td colspan="2">Schwierigkeit: {difficulty} von 5.0<br>Gelände: {terrain} von 5.0</td></tr></table>]]></description> <name>{name}{archivedflag}</name> <LookAt> <longitude>{lon}</longitude> <latitude>{lat}</latitude> <range>5000</range> <tilt>0</tilt> <heading>3</heading> </LookAt> <styleUrl>#{icon}</styleUrl> <Point> <coordinates>{lon},{lat},0</coordinates> </Point> <Snippet>D: {difficulty}/T: {terrain} {size} von {username}</Snippet> </Placemark> '; $kmlFoot = '</Folder></Document></kml>'; $kmlTimeFormat = 'Y-m-d\\TH:i:s\\Z'; $style = $opt['template']['style']; $kmlDetailHead = file_get_contents("resource2/misc/google-earth/search.result.caches.kml.head.xml"); $rsMinMax = sql_slave(' SELECT MIN(`longitude`) `minlon`, MAX(`longitude`) `maxlon`, MIN(`latitude`) `minlat`, MAX(`latitude`) `maxlat` FROM &searchtmp'); $rMinMax = sql_fetch_array($rsMinMax); mysql_free_result($rsMinMax); $kmlDetailHead = mb_ereg_replace('{minlat}', $rMinMax['minlat'], $kmlDetailHead); $kmlDetailHead = mb_ereg_replace('{minlon}', $rMinMax['minlon'], $kmlDetailHead); $kmlDetailHead = mb_ereg_replace('{maxlat}', $rMinMax['maxlat'], $kmlDetailHead); $kmlDetailHead = mb_ereg_replace('{maxlon}', $rMinMax['maxlon'], $kmlDetailHead); $kmlDetailHead = mb_ereg_replace('{time}', date($kmlTimeFormat), $kmlDetailHead); append_output($kmlDetailHead); /* wp name username type size lon lat icon */ $rs = sql_slave(' SELECT SQL_BUFFER_RESULT &searchtmp.`cache_id` `cacheid`, &searchtmp.`longitude`, &searchtmp.`latitude`, &searchtmp.`type`, `caches`.`date_hidden`, `caches`.`name`, `caches`.`status`, `cache_type`.`de` `typedesc`, `cache_size`.`de` `sizedesc`, `caches`.`terrain`, `caches`.`difficulty`, `user`.`username` FROM &searchtmp, `caches`, `cache_type`, `cache_size`, `user` WHERE &searchtmp.`cache_id`=`caches`.`cache_id` AND &searchtmp.`type`=`cache_type`.`id` AND &searchtmp.`size`=`cache_size`.`id` AND &searchtmp.`user_id`=`user`.`user_id`'); while ($r = sql_fetch_array($rs)) { $thisline = $kmlLine; // icon suchen switch ($r['type']) { case 2: $icon = 'tradi'; $typeimgurl = '<img src="http://www.opencaching.de/resource2/' . $style . '/images/cacheicon/traditional.gif" alt="Normaler Cache" title="Normaler Cache" />'; break; case 3: $icon = 'multi'; $typeimgurl = '<img src="http://www.opencaching.de/resource2/' . $style . '/images/cacheicon/multi.gif" alt="Multicache" title="Multicache" />'; break; case 4: $icon = 'virtual'; $typeimgurl = '<img src="http://www.opencaching.de/resource2/' . $style . '/images/cacheicon/virtual.gif" alt="virtueller Cache" title="virtueller Cache" />'; break; case 5: $icon = 'webcam'; $typeimgurl = '<img src="http://www.opencaching.de/resource2/' . $style . '/images/cacheicon/webcam.gif" alt="Webcam Cache" title="Webcam Cache" />'; break; case 6: $icon = 'event'; $typeimgurl = '<img src="http://www.opencaching.de/resource2/' . $style . '/images/cacheicon/event.gif" alt="Event Cache" title="Event Cache" />'; break; case 7: $icon = 'mystery'; $typeimgurl = '<img src="http://www.opencaching.de/resource2/' . $style . '/images/cacheicon/mystery.gif" alt="Rätselcache" title="Event Cache" />'; break; case 8: $icon = 'mathe'; $typeimgurl = '<img src="http://www.opencaching.de/resource2/' . $style . '/images/cacheicon/mathe.gif" alt="Mathe-/Physik-Cache" title="Event Cache" />'; break; case 9: $icon = 'moving'; $typeimgurl = '<img src="http://www.opencaching.de/resource2/' . $style . '/images/cacheicon/moving.gif" alt="Moving Cache" title="Event Cache" />'; break; case 10: $icon = 'drivein'; $typeimgurl = '<img src="http://www.opencaching.de/resource2/' . $style . '/images/cacheicon/drivein.gif" alt="Drive-In Cache" title="Event Cache" />'; break; default: $icon = 'other'; $typeimgurl = '<img src="http://www.opencaching.de/resource2/' . $style . '/images/cacheicon/unknown.gif" alt="unbekannter Cachetyp" title="unbekannter Cachetyp" />'; break; } $thisline = mb_ereg_replace('{icon}', $icon, $thisline); $thisline = mb_ereg_replace('{typeimgurl}', $typeimgurl, $thisline); $lat = sprintf('%01.5f', $r['latitude']); $thisline = mb_ereg_replace('{lat}', $lat, $thisline); $lon = sprintf('%01.5f', $r['longitude']); $thisline = mb_ereg_replace('{lon}', $lon, $thisline); $time = date($kmlTimeFormat, strtotime($r['date_hidden'])); $thisline = mb_ereg_replace('{time}', $time, $thisline); $thisline = mb_ereg_replace('{name}', xmlentities($r['name']), $thisline); if ($r['status'] == 2 || $r['status'] == 3 || $r['status'] == 6) { if ($r['status'] == 2) { $thisline = mb_ereg_replace('{archivedflag}', ' (' . $state_temporarily_na . ')', $thisline); } elseif ($r['status'] == 3) { $thisline = mb_ereg_replace('{archivedflag}', ' (' . $state_archived . ')', $thisline); } else { $thisline = mb_ereg_replace('{archivedflag}', ' (' . $state_locked . ')', $thisline); } } else { $thisline = mb_ereg_replace('{archivedflag}', '', $thisline); } $thisline = mb_ereg_replace('{type}', xmlentities($r['typedesc']), $thisline); $thisline = mb_ereg_replace('{size}', xmlentities($r['sizedesc']), $thisline); $difficulty = sprintf('%01.1f', $r['difficulty'] / 2); $thisline = mb_ereg_replace('{difficulty}', $difficulty, $thisline); $terrain = sprintf('%01.1f', $r['terrain'] / 2); $thisline = mb_ereg_replace('{terrain}', $terrain, $thisline); $time = date($kmlTimeFormat, strtotime($r['date_hidden'])); $thisline = mb_ereg_replace('{time}', $time, $thisline); $thisline = mb_ereg_replace('{username}', xmlentities($r['username']), $thisline); $thisline = mb_ereg_replace('{cacheid}', xmlentities($r['cacheid']), $thisline); append_output($thisline); } mysql_free_result($rs); append_output($kmlFoot); }
$opis1 = "Zalozona przez {$username} - Opis - "; //if ($r['html'] == 0) // { $opis2 = strip_tags($r['desc']); // } // else // { // $opis2 = html2txt($r['desc']); // } $opis12 = "{$opis1}{$opis2}"; $opiss = substr($opis12, 0, 255); $length = strlen($opiss); if ($length < 255) { $diff = 255 - $length; $thisline3 = mb_ereg_replace('{opis}', $opiss, $thisline3); append_output($thisline3); for ($i = 1; $i <= $diff; $i++) { $tmp = sprintf('%c', 0); fwrite($file, $tmp); } } else { $thisline3 = mb_ereg_replace('{opis}', $opiss, $thisline3); fwrite($file, $thisline3); } fwrite($file, $uamB); } mysql_free_result($rs); // if ($sqldebug == true) sqldbg_end(); // phpzip versenden // if ($bUseZip == true) // {
$thisline = mb_ereg_replace('{archivedflag}', '', $thisline); } $thisline = mb_ereg_replace('{type}', xmlentities($r['typedesc']), $thisline); $thisline = mb_ereg_replace('{size}', xmlentities($r['sizedesc']), $thisline); $difficulty = sprintf('%01.1f', $r['difficulty'] / 2); $thisline = mb_ereg_replace('{difficulty}', $difficulty, $thisline); $terrain = sprintf('%01.1f', $r['terrain'] / 2); $thisline = mb_ereg_replace('{terrain}', $terrain, $thisline); $time = date($kmlTimeFormat, strtotime($r['date_hidden'])); $thisline = mb_ereg_replace('{time}', $time, $thisline); $thisline = mb_ereg_replace('{username}', xmlentities($r['username']), $thisline); $thisline = mb_ereg_replace('{cacheid}', xmlentities($r['cacheid']), $thisline); append_output($thisline); } mysql_free_result($rs); append_output($kmlFoot); if ($sqldebug == true) { sqldbg_end(); } // phpzip versenden if ($bUseZip == true) { $phpzip->add_data($sFilebasename . '.kml', $content); // use 'r'=raw instead of 'b'=browser: don't generate new header information! echo $phpzip->save($sFilebasename . '.kmz', 'r'); } exit; function xmlentities($str) { $from[0] = '&'; $to[0] = '&'; $from[1] = '<';