moved lib1 search code to lib2 or away
This commit is contained in:
@@ -0,0 +1,329 @@
|
||||
<?php
|
||||
/****************************************************************************
|
||||
./lib/ftsearch.inc.php
|
||||
--------------------
|
||||
begin : January 10 2007
|
||||
|
||||
For license information see doc/license.txt
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
functions for the full text search-engine
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
/* begin conversion rules */
|
||||
|
||||
$ftsearch_simplerules[] = array('qu', 'k');
|
||||
$ftsearch_simplerules[] = array('ts', 'z');
|
||||
$ftsearch_simplerules[] = array('tz', 'z');
|
||||
$ftsearch_simplerules[] = array('alp', 'alb');
|
||||
$ftsearch_simplerules[] = array('y', 'i');
|
||||
$ftsearch_simplerules[] = array('ai', 'ei');
|
||||
$ftsearch_simplerules[] = array('ou', 'u');
|
||||
$ftsearch_simplerules[] = array('th', 't');
|
||||
$ftsearch_simplerules[] = array('ph', 'f');
|
||||
$ftsearch_simplerules[] = array('oh', 'o');
|
||||
$ftsearch_simplerules[] = array('ah', 'a');
|
||||
$ftsearch_simplerules[] = array('eh', 'e');
|
||||
$ftsearch_simplerules[] = array('aux', 'o');
|
||||
$ftsearch_simplerules[] = array('eau', 'o');
|
||||
$ftsearch_simplerules[] = array('eux', 'oe');
|
||||
$ftsearch_simplerules[] = array('^ch', 'sch');
|
||||
$ftsearch_simplerules[] = array('ck', 'k');
|
||||
$ftsearch_simplerules[] = array('ie', 'i');
|
||||
$ftsearch_simplerules[] = array('ih', 'i');
|
||||
$ftsearch_simplerules[] = array('ent', 'end');
|
||||
$ftsearch_simplerules[] = array('uh', 'u');
|
||||
$ftsearch_simplerules[] = array('sh', 'sch');
|
||||
$ftsearch_simplerules[] = array('ver', 'wer');
|
||||
$ftsearch_simplerules[] = array('dt', 't');
|
||||
$ftsearch_simplerules[] = array('hard', 'hart');
|
||||
$ftsearch_simplerules[] = array('egg', 'ek');
|
||||
$ftsearch_simplerules[] = array('eg', 'ek');
|
||||
$ftsearch_simplerules[] = array('cr', 'kr');
|
||||
$ftsearch_simplerules[] = array('ca', 'ka');
|
||||
$ftsearch_simplerules[] = array('ce', 'ze');
|
||||
$ftsearch_simplerules[] = array('x', 'ks');
|
||||
$ftsearch_simplerules[] = array('ve', 'we');
|
||||
$ftsearch_simplerules[] = array('va', 'wa');
|
||||
|
||||
/* end conversion rules */
|
||||
|
||||
function ftsearch_hash(&$str)
|
||||
{
|
||||
$astr = ftsearch_split($str, true);
|
||||
foreach ($astr AS $k => $s)
|
||||
{
|
||||
if (strlen($s) > 2)
|
||||
$astr[$k] = sprintf("%u", crc32($s));
|
||||
else
|
||||
unset($astr[$k]);
|
||||
}
|
||||
return $astr;
|
||||
}
|
||||
|
||||
// str = long text
|
||||
function ftsearch_split(&$str, $simple)
|
||||
{
|
||||
global $ftsearch_ignores;
|
||||
|
||||
// interpunktion
|
||||
$str = mb_ereg_replace('\\?', ' ', $str);
|
||||
$str = mb_ereg_replace('\\)', ' ', $str);
|
||||
$str = mb_ereg_replace('\\(', ' ', $str);
|
||||
$str = mb_ereg_replace('\\.', ' ', $str);
|
||||
$str = mb_ereg_replace('´', ' ', $str);
|
||||
$str = mb_ereg_replace('`', ' ', $str);
|
||||
$str = mb_ereg_replace('\'', ' ', $str);
|
||||
$str = mb_ereg_replace('/', ' ', $str);
|
||||
$str = mb_ereg_replace(':', ' ', $str);
|
||||
$str = mb_ereg_replace(',', ' ', $str);
|
||||
$str = mb_ereg_replace("\r\n", ' ', $str);
|
||||
$str = mb_ereg_replace("\n", ' ', $str);
|
||||
$str = mb_ereg_replace("\r", ' ', $str);
|
||||
|
||||
$ostr = '';
|
||||
while ($ostr != $str)
|
||||
{
|
||||
$ostr = $str;
|
||||
$str = mb_ereg_replace(' ', ' ', $str);
|
||||
}
|
||||
|
||||
$astr = mb_split(' ', $str);
|
||||
$str = '';
|
||||
|
||||
ftsearch_load_ignores();
|
||||
for ($i = count($astr) - 1; $i >= 0; $i--)
|
||||
{
|
||||
// ignore?
|
||||
if (array_search(mb_strtolower($astr[$i]), $ftsearch_ignores) !== false)
|
||||
unset($astr[$i]);
|
||||
else
|
||||
{
|
||||
if ($simple)
|
||||
$astr[$i] = ftsearch_text2simple($astr[$i]);
|
||||
|
||||
if ($astr[$i] == '')
|
||||
unset($astr[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
return $astr;
|
||||
}
|
||||
|
||||
function ftsearch_load_ignores()
|
||||
{
|
||||
global $ftsearch_ignores;
|
||||
global $ftsearch_ignores_loaded;
|
||||
|
||||
if ($ftsearch_ignores_loaded != true)
|
||||
{
|
||||
$ftsearch_ignores = array();
|
||||
|
||||
$rs = sql('SELECT `word` FROM `search_ignore`');
|
||||
while ($r = sql_fetch_assoc($rs))
|
||||
$ftsearch_ignores[] = $r['word'];
|
||||
sql_free_result($rs);
|
||||
|
||||
$ftsearch_ignores_loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
// str = single word
|
||||
function ftsearch_text2simple($str)
|
||||
{
|
||||
global $ftsearch_simplerules;
|
||||
|
||||
$str = ftsearch_text2sort($str);
|
||||
|
||||
// regeln anwenden
|
||||
foreach ($ftsearch_simplerules AS $rule)
|
||||
{
|
||||
$str = mb_ereg_replace($rule[0], $rule[1], $str);
|
||||
}
|
||||
|
||||
// doppelte chars ersetzen
|
||||
for ($c = ord('a'); $c <= ord('z'); $c++)
|
||||
{
|
||||
$old_str = '';
|
||||
while ($old_str != $str)
|
||||
{
|
||||
$old_str = $str;
|
||||
$str = mb_ereg_replace(chr($c) . chr($c), chr($c), $str);
|
||||
}
|
||||
$old_str = '';
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// str = single word
|
||||
function ftsearch_text2sort($str)
|
||||
{
|
||||
$str = mb_strtolower($str);
|
||||
|
||||
// deutsches
|
||||
$str = mb_ereg_replace('ä', 'ae', $str);
|
||||
$str = mb_ereg_replace('ö', 'oe', $str);
|
||||
$str = mb_ereg_replace('ü', 'ue', $str);
|
||||
$str = mb_ereg_replace('Ä', 'ae', $str);
|
||||
$str = mb_ereg_replace('Ö', 'oe', $str);
|
||||
$str = mb_ereg_replace('Ü', 'ue', $str);
|
||||
$str = mb_ereg_replace('ß', 'ss', $str);
|
||||
|
||||
// akzente usw.
|
||||
$str = mb_ereg_replace('à', 'a', $str);
|
||||
$str = mb_ereg_replace('á', 'a', $str);
|
||||
$str = mb_ereg_replace('â', 'a', $str);
|
||||
$str = mb_ereg_replace('è', 'e', $str);
|
||||
$str = mb_ereg_replace('é', 'e', $str);
|
||||
$str = mb_ereg_replace('ë', 'e', $str);
|
||||
$str = mb_ereg_replace('É', 'e', $str);
|
||||
$str = mb_ereg_replace('ô', 'o', $str);
|
||||
$str = mb_ereg_replace('ó', 'o', $str);
|
||||
$str = mb_ereg_replace('ò', 'o', $str);
|
||||
$str = mb_ereg_replace('ê', 'e', $str);
|
||||
$str = mb_ereg_replace('ě', 'e', $str);
|
||||
$str = mb_ereg_replace('û', 'u', $str);
|
||||
$str = mb_ereg_replace('ç', 'c', $str);
|
||||
$str = mb_ereg_replace('c', 'c', $str);
|
||||
$str = mb_ereg_replace('ć', 'c', $str);
|
||||
$str = mb_ereg_replace('î', 'i', $str);
|
||||
$str = mb_ereg_replace('ï', 'i', $str);
|
||||
$str = mb_ereg_replace('ì', 'i', $str);
|
||||
$str = mb_ereg_replace('í', 'i', $str);
|
||||
$str = mb_ereg_replace('ł', 'l', $str);
|
||||
$str = mb_ereg_replace('š', 's', $str);
|
||||
$str = mb_ereg_replace('Š', 's', $str);
|
||||
$str = mb_ereg_replace('u', 'u', $str);
|
||||
$str = mb_ereg_replace('ý', 'y', $str);
|
||||
$str = mb_ereg_replace('ž', 'z', $str);
|
||||
$str = mb_ereg_replace('Ž', 'Z', $str);
|
||||
|
||||
$str = mb_ereg_replace('Æ', 'ae', $str);
|
||||
$str = mb_ereg_replace('æ', 'ae', $str);
|
||||
$str = mb_ereg_replace('œ', 'oe', $str);
|
||||
|
||||
// sonstiges
|
||||
$str = mb_ereg_replace('[^A-Za-z ]', '', $str);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
function ftsearch_refresh()
|
||||
{
|
||||
ftsearch_refresh_all_caches();
|
||||
ftsearch_refresh_all_cache_desc();
|
||||
ftsearch_refresh_all_pictures();
|
||||
ftsearch_refresh_all_cache_logs();
|
||||
}
|
||||
|
||||
function ftsearch_refresh_all_caches()
|
||||
{
|
||||
$rs = sql('SELECT `caches`.`cache_id` FROM `caches` LEFT JOIN `search_index_times` ON `caches`.`cache_id`=`search_index_times`.`object_id` AND 2=`search_index_times`.`object_type` WHERE `caches`.`status`!=5 AND ISNULL(`search_index_times`.`object_id`) UNION DISTINCT SELECT `caches`.`cache_id` FROM `caches` INNER JOIN `search_index_times` ON `search_index_times`.`object_type`=2 AND `caches`.`cache_id`=`search_index_times`.`object_id` WHERE `caches`.`last_modified`>`search_index_times`.`last_refresh` AND `caches`.`status`!=5');
|
||||
while ($r = sql_fetch_assoc($rs))
|
||||
ftsearch_refresh_cache($r['cache_id']);
|
||||
sql_free_result($rs);
|
||||
}
|
||||
|
||||
function ftsearch_refresh_cache($cache_id)
|
||||
{
|
||||
$rs = sql("SELECT `name`, `last_modified` FROM `caches` WHERE `cache_id`='&1'", $cache_id);
|
||||
if ($r = sql_fetch_assoc($rs))
|
||||
{
|
||||
ftsearch_set_entries(2, $cache_id, $cache_id, $r['name'], $r['last_modified']);
|
||||
}
|
||||
sql_free_result($rs);
|
||||
}
|
||||
|
||||
function ftsearch_refresh_all_cache_desc()
|
||||
{
|
||||
$rs = sql('SELECT `cache_desc`.`id` FROM `cache_desc` INNER JOIN `caches` ON `caches`.`cache_id`=`cache_desc`.`cache_id` LEFT JOIN `search_index_times` ON `cache_desc`.`id`=`search_index_times`.`object_id` AND 3=`search_index_times`.`object_type` WHERE `caches`.`status`!=5 AND ISNULL(`search_index_times`.`object_id`) UNION DISTINCT SELECT `cache_desc`.`id` FROM `cache_desc` INNER JOIN `caches` ON `caches`.`cache_id`=`cache_desc`.`cache_id` INNER JOIN `search_index_times` ON `search_index_times`.`object_type`=3 AND `cache_desc`.`id`=`search_index_times`.`object_id` WHERE `cache_desc`.`last_modified`>`search_index_times`.`last_refresh` AND `caches`.`status`!=5');
|
||||
while ($r = sql_fetch_assoc($rs))
|
||||
ftsearch_refresh_cache_desc($r['id']);
|
||||
sql_free_result($rs);
|
||||
}
|
||||
|
||||
function ftsearch_refresh_cache_desc($id)
|
||||
{
|
||||
$rs = sql("SELECT `cache_id`, `desc`, `last_modified` FROM `cache_desc` WHERE `id`='&1'", $id);
|
||||
if ($r = sql_fetch_assoc($rs))
|
||||
{
|
||||
$r['desc'] = ftsearch_strip_html($r['desc']);
|
||||
ftsearch_set_entries(3, $id, $r['cache_id'], $r['desc'], $r['last_modified']);
|
||||
}
|
||||
sql_free_result($rs);
|
||||
}
|
||||
|
||||
function ftsearch_refresh_all_pictures()
|
||||
{
|
||||
$rs = sql('SELECT `pictures`.`id` FROM `pictures` LEFT JOIN `search_index_times` ON `pictures`.`id`=`search_index_times`.`object_id` AND 6=`search_index_times`.`object_type` WHERE ISNULL(`search_index_times`.`object_id`) UNION DISTINCT SELECT `pictures`.`id` FROM `pictures` INNER JOIN `search_index_times` ON `search_index_times`.`object_type`=6 AND `pictures`.`id`=`search_index_times`.`object_id` WHERE `pictures`.`last_modified`>`search_index_times`.`last_refresh`');
|
||||
while ($r = sql_fetch_assoc($rs))
|
||||
ftsearch_refresh_picture($r['id']);
|
||||
sql_free_result($rs);
|
||||
}
|
||||
|
||||
function ftsearch_refresh_picture($id)
|
||||
{
|
||||
$rs = sql("SELECT `caches`.`cache_id`, `pictures`.`title`, `pictures`.`last_modified` FROM `pictures` INNER JOIN `caches` ON `pictures`.`object_type`=2 AND `caches`.`cache_id`=`pictures`.`object_id` WHERE `pictures`.`id`='&1' UNION DISTINCT SELECT `cache_logs`.`cache_id` , `pictures`.`title`, `pictures`.`last_modified` FROM `pictures` INNER JOIN `cache_logs` ON `pictures`.`object_type`=1 AND `cache_logs`.`id`=`pictures`.`object_id` WHERE `pictures`.`id`='&1' LIMIT 1", $id);
|
||||
if ($r = sql_fetch_assoc($rs))
|
||||
{
|
||||
ftsearch_set_entries(6, $id, $r['cache_id'], $r['title'], $r['last_modified']);
|
||||
}
|
||||
sql_free_result($rs);
|
||||
}
|
||||
|
||||
function ftsearch_refresh_all_cache_logs()
|
||||
{
|
||||
$rs = sql('SELECT `cache_logs`.`id` FROM `cache_logs` LEFT JOIN `search_index_times` ON `cache_logs`.`id`=`search_index_times`.`object_id` AND 1=`search_index_times`.`object_type` WHERE ISNULL(`search_index_times`.`object_id`) UNION DISTINCT SELECT `cache_logs`.`id` FROM `cache_logs` INNER JOIN `search_index_times` ON `search_index_times`.`object_type`=1 AND `cache_logs`.`id`=`search_index_times`.`object_id` WHERE `cache_logs`.`last_modified`>`search_index_times`.`last_refresh`');
|
||||
while ($r = sql_fetch_assoc($rs))
|
||||
ftsearch_refresh_cache_logs($r['id']);
|
||||
sql_free_result($rs);
|
||||
}
|
||||
|
||||
function ftsearch_refresh_cache_logs($id)
|
||||
{
|
||||
$rs = sql("SELECT `cache_id`, `text`, `last_modified` FROM `cache_logs` WHERE `id`='&1'", $id);
|
||||
if ($r = sql_fetch_assoc($rs))
|
||||
{
|
||||
$r['text'] = ftsearch_strip_html($r['text']);
|
||||
ftsearch_set_entries(1, $id, $r['cache_id'], $r['text'], $r['last_modified']);
|
||||
}
|
||||
sql_free_result($rs);
|
||||
}
|
||||
|
||||
function ftsearch_delete_entries($object_type, $object_id, $cache_id)
|
||||
{
|
||||
sql("DELETE FROM `search_index` WHERE `object_type`='&1' AND `cache_id`='&2'", $object_type, $cache_id);
|
||||
sql("DELETE FROM `search_index_times` WHERE `object_type`='&1' AND `object_id`='&2'", $object_type, $object_id);
|
||||
}
|
||||
|
||||
function ftsearch_set_entries($object_type, $object_id, $cache_id, &$text, $last_modified)
|
||||
{
|
||||
ftsearch_delete_entries($object_type, $object_id, $cache_id);
|
||||
|
||||
$ahash = ftsearch_hash($text);
|
||||
foreach ($ahash AS $k => $h)
|
||||
{
|
||||
sql("INSERT INTO `search_index` (`object_type`, `cache_id`, `hash`, `count`) VALUES ('&1', '&2', '&3', '&4') ON DUPLICATE KEY UPDATE `count`=`count`+1", $object_type, $cache_id, $h, 1);
|
||||
}
|
||||
sql("INSERT INTO `search_index_times` (`object_id`, `object_type`, `last_refresh`) VALUES ('&1', '&2', '&3') ON DUPLICATE KEY UPDATE `last_refresh`='&3'", $object_id, $object_type, $last_modified);
|
||||
}
|
||||
|
||||
function ftsearch_strip_html($text)
|
||||
{
|
||||
$text = str_replace("\n", ' ', $text);
|
||||
$text = str_replace("\r", ' ', $text);
|
||||
$text = str_replace('<br />', ' ', $text);
|
||||
$text = str_replace('<br/>', ' ', $text);
|
||||
$text = str_replace('<br>', ' ', $text);
|
||||
$text = strip_tags($text);
|
||||
$text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');
|
||||
|
||||
return $text;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,514 @@
|
||||
<?php
|
||||
/****************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
GPX search output (GC compatible)
|
||||
used by Ocprop
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
require_once('lib/npas.inc.php');
|
||||
|
||||
$search_output_file_download = true;
|
||||
$content_type_plain = 'application/gpx';
|
||||
|
||||
|
||||
function search_output()
|
||||
{
|
||||
global $absolute_server_URI, $locale, $usr, $login;
|
||||
global $cache_note_text;
|
||||
|
||||
$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://www.opencaching.de</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>www.opencaching.de</src>
|
||||
<url>' . $absolute_server_URI . '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>' . $absolute_server_URI . '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))
|
||||
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);
|
||||
|
||||
if ($usr === false)
|
||||
$user_id = 0;
|
||||
else
|
||||
$user_id = $usr['userid'];
|
||||
|
||||
$rs = sql_slave("SELECT SQL_BUFFER_RESULT `searchtmp`.`cache_id` `cacheid`, `searchtmp`.`longitude` `longitude`, `searchtmp`.`latitude` `latitude`,
|
||||
`cache_location`.`adm2` `state`, `caches`.`wp_oc` `waypoint`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`,
|
||||
`caches`.`country` `country`, `countries`.`name` AS `country_name`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `caches`.`desc_languages` `desc_languages`,
|
||||
`caches`.`size` `size`, `caches`.`type` `type`, `caches`.`status` `status`, `user`.`username` `username`, `caches`.`user_id` `userid`, `user`.`data_license`,
|
||||
`cache_desc`.`desc` `desc`, `cache_desc`.`short_desc` `short_desc`, `cache_desc`.`hint` `hint`,
|
||||
IFNULL(`stat_cache_logs`.`found`, 0) AS `found`
|
||||
FROM `searchtmp`
|
||||
INNER JOIN `caches` ON `searchtmp`.`cache_id`=`caches`.`cache_id`
|
||||
INNER JOIN `countries` ON `caches`.`country`=`countries`.`short`
|
||||
INNER JOIN `user` ON `searchtmp`.`user_id`=`user`.`user_id`
|
||||
INNER JOIN `cache_desc` ON `caches`.`cache_id`=`cache_desc`.`cache_id`AND `caches`.`default_desclang`=`cache_desc`.`language`
|
||||
LEFT JOIN `cache_location` ON `searchtmp`.`cache_id`=`cache_location`.`cache_id`
|
||||
LEFT 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}', xmlentities($r['name']), $thisline);
|
||||
$thisline = mb_ereg_replace('{country}', $r['country_name'], $thisline);
|
||||
$thisline = mb_ereg_replace('{state}', 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>' . xmlentities($hint) . '</groundspeak:encoded_hints>
|
||||
', $thisline);
|
||||
|
||||
$thisline = mb_ereg_replace('{shortdesc}', xmlentities($r['short_desc']), $thisline);
|
||||
|
||||
$desc = str_replace('<img src="images/uploads/','<img src="' . $absolute_server_URI . 'images/uploads/', $r['desc']);
|
||||
$license = getLicenseDisclaimer(
|
||||
$r['userid'], $r['username'], $r['data_license'], $r['cacheid'], $locale, true, true);
|
||||
if ($license != "")
|
||||
$desc .= "<p><em>$license</em></p>\n";
|
||||
$desc .= get_desc_npas($r['cacheid']);
|
||||
$thisline = mb_ereg_replace('{desc}', xmlentities(decodeEntities($desc)), $thisline);
|
||||
|
||||
$thisline = mb_ereg_replace('{images}', xmlentities(getPictures($r['cacheid'])), $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}', xmlentities($r['username']), $thisline);
|
||||
$thisline = mb_ereg_replace('{userid}', xmlentities($r['userid']), $thisline);
|
||||
|
||||
if ($r['found'] > 0)
|
||||
$thisline = mb_ereg_replace('{sym}', xmlentities($gpxSymFound), $thisline);
|
||||
else
|
||||
$thisline = mb_ereg_replace('{sym}', 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}', xmlentities($login->username), $thislog);
|
||||
$thislog = mb_ereg_replace('{type}', $gpxLogType[3], $thislog);
|
||||
$thislog = mb_ereg_replace('{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", $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}', xmlentities($rLog['user_id']), $thislog);
|
||||
$thislog = mb_ereg_replace('{username}', 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}', 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 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}', xmlentities($rLog['user_id']), $thislog);
|
||||
$thislog = mb_ereg_replace('{username}', 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}', 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`
|
||||
FROM `caches_attributes`
|
||||
INNER JOIN `cache_attrib` ON `cache_attrib`.`id`=`caches_attributes`.`attrib_id`
|
||||
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}', 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}', 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}', xmlentities($r['name']), $thiswp);
|
||||
$thiswp = mb_ereg_replace('{comment}',xmlentities($childWaypoint['description']), $thiswp);
|
||||
$thiswp = mb_ereg_replace('{desc}', xmlentities($childWaypoint['name']), $thiswp);
|
||||
switch ($childWaypoint['type'])
|
||||
{
|
||||
case 1: $wp_typename = "Parking Area"; break; // well-known garmin symbols
|
||||
case 2: $wp_typename = "Flag, Green"; break; // stage / ref point
|
||||
case 3: $wp_typename = "Flag, Blue"; break; // path
|
||||
case 4: $wp_typename = "Circle with X"; break; // final
|
||||
case 5: $wp_typename = "Diamond, Green"; break; // point of interest
|
||||
default: $wp_typename = "Flag, Blue"; break; // for the case new types are forgotten here ..
|
||||
}
|
||||
$thiswp = mb_ereg_replace('{type}', $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}', xmlentities($r['name']), $thiswp);
|
||||
$thiswp = mb_ereg_replace('{comment}', xmlentities($cacheNote['note']), $thiswp);
|
||||
$thiswp = mb_ereg_replace('{desc}', $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 decodeEntities($str)
|
||||
{
|
||||
$str = changePlaceholder($str);
|
||||
$str = html_entity_decode($str, ENT_COMPAT, "UTF-8");
|
||||
$str = changePlaceholder($str, true);
|
||||
return $str;
|
||||
}
|
||||
|
||||
function changePlaceholder($str, $inverse = false)
|
||||
{
|
||||
static $translate = array(
|
||||
'<' => '{oc-placeholder-lt}',
|
||||
'>' => '{oc-placeholder-gt}',
|
||||
'&' => '{oc-placeholder-amp}'
|
||||
);
|
||||
|
||||
foreach ($translate as $entity => $placeholder)
|
||||
{
|
||||
if (!$inverse)
|
||||
{
|
||||
$str = mb_ereg_replace($entity, $placeholder, $str);
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = mb_ereg_replace($placeholder, $entity, $str);
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
function xmlentities($str)
|
||||
{
|
||||
$str = htmlspecialchars($str, ENT_NOQUOTES, "UTF-8");
|
||||
return filterevilchars($str);
|
||||
}
|
||||
|
||||
function filterevilchars($str)
|
||||
{
|
||||
return mb_ereg_replace('[\\x00-\\x09|\\x0B-\\x0C|\\x0E-\\x1F]', '', $str);
|
||||
}
|
||||
|
||||
function getCacheNote($userid, $cacheid)
|
||||
{
|
||||
$cacheNoteHandler = new CacheNote_Handler();
|
||||
$cacheNote = $cacheNoteHandler->getCacheNote($userid, $cacheid);
|
||||
|
||||
if (isset($cacheNote['note']) || isset($cacheNote['latitude']) || isset($cacheNote['longitude']))
|
||||
return $cacheNote;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// based on oc.pl code, but embedded thumbs instead of full pictures
|
||||
// (also to hide spoilers first)
|
||||
function getPictures($cacheid)
|
||||
{
|
||||
global $translate, $absolute_server_URI;
|
||||
|
||||
$retval = "";
|
||||
$rs = sql_slave("SELECT uuid, title, url, spoiler FROM pictures
|
||||
WHERE object_id='&1' AND object_type=2 AND display=1
|
||||
ORDER BY date_created", $cacheid);
|
||||
|
||||
while ($r = sql_fetch_array($rs))
|
||||
{
|
||||
$retval .= '<div style="float:left; padding:8px"><a href="' . $r['url'] . '" target="_blank">' .
|
||||
'<img src="' . $absolute_server_URI . 'thumbs.php?uuid=' . $r["uuid"]. '" >' .
|
||||
'</a><br />' . $r['title'];
|
||||
if ($r['spoiler'])
|
||||
$retval .= ' (' . $translate->t('click on spoiler to display','',basename(__FILE__), __LINE__) . ')';
|
||||
$retval .= "</div>";
|
||||
}
|
||||
mysql_free_result($rs);
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
(X)HTML search output
|
||||
Used by Ocprop
|
||||
****************************************************************************/
|
||||
|
||||
require_once($stylepath . '/lib/icons.inc.php');
|
||||
require_once('lib/cache_icon.inc.php');
|
||||
|
||||
$search_output_file_download = false;
|
||||
|
||||
$sAddFields .= ', `caches`.`name`, `caches`.`difficulty`, `caches`.`terrain`,
|
||||
`caches`.`desc_languages`, `caches`.`date_created`,
|
||||
`user`.`username`,
|
||||
`cache_type`.`icon_large`,
|
||||
`cache_type`.`name` `cacheTypeName`,
|
||||
IFNULL(`stat_caches`.`found`, 0) `founds`,
|
||||
IFNULL(`stat_caches`.`toprating`, 0) `topratings`,
|
||||
IF(ISNULL(`tbloconly`.`cache_id`), 0, 1) AS `oconly`';
|
||||
|
||||
$sAddJoin .= 'INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id`
|
||||
INNER JOIN `cache_type` ON `cache_type`.`id`=`caches`.`type`
|
||||
LEFT JOIN `caches_attributes` AS `tbloconly`
|
||||
ON `caches`.`cache_id`=`tbloconly`.`cache_id` AND `tbloconly`.`attrib_id`=6';
|
||||
|
||||
|
||||
function search_output()
|
||||
{
|
||||
global $sqldebug, $stylepath, $tplname, $logdateformat, $usr, $bgcolor1, $bgcolor2;
|
||||
global $string_by, $caches_olddays, $caches_newstring, $caches_oconlystring, $showonmap;
|
||||
global $options, $lat_rad, $lon_rad, $distance_unit, $startat, $caches_per_page, $sql;
|
||||
|
||||
$tplname = 'search.result.caches';
|
||||
$cache_line = read_file($stylepath . '/search.result.caches.row.tpl.php');
|
||||
$cache_line = mb_ereg_replace('{string_by}', $string_by, $cache_line);
|
||||
$caches_output = '';
|
||||
|
||||
// output range
|
||||
$startat = floor($startat / $caches_per_page) * $caches_per_page;
|
||||
$sql .= ' LIMIT ' . $startat . ', ' . $caches_per_page;
|
||||
|
||||
// run SQL query
|
||||
$nRowIndex = 0;
|
||||
$rs_caches = sql_slave("SELECT SQL_BUFFER_RESULT SQL_CALC_FOUND_ROWS " . $sql, $sqldebug);
|
||||
$resultcount = sql_value_slave('SELECT FOUND_ROWS()', 0);
|
||||
tpl_set_var('results_count', $resultcount);
|
||||
|
||||
while ($caches_record = sql_fetch_array($rs_caches))
|
||||
{
|
||||
$tmpline = $cache_line;
|
||||
|
||||
list($iconname, $inactive) = getCacheIcon($usr['userid'], $caches_record['cache_id'], $caches_record['status'],
|
||||
$caches_record['user_id'], $caches_record['icon_large']);
|
||||
|
||||
$tmpline = mb_ereg_replace('{icon_large}', $iconname, $tmpline);
|
||||
|
||||
$tmpline = mb_ereg_replace('{cachetype}', htmlspecialchars(t($caches_record['cacheTypeName']), ENT_COMPAT, 'UTF-8'), $tmpline);
|
||||
|
||||
// short_desc ermitteln TODO: nicht die erste sondern die richtige wählen
|
||||
$rsdesc = sql_slave("SELECT `short_desc` FROM `cache_desc` WHERE `cache_id`='&1' LIMIT 1", $caches_record['cache_id']);
|
||||
$desc_record = sql_fetch_array($rsdesc);
|
||||
mysql_free_result($rsdesc);
|
||||
|
||||
$tmpline = mb_ereg_replace('{short_desc}', htmlspecialchars($desc_record['short_desc'], ENT_COMPAT, 'UTF-8'), $tmpline);
|
||||
|
||||
$dDiff = abs(dateDiff('d', $caches_record['date_created'], date('Y-m-d')));
|
||||
if ($dDiff < $caches_olddays)
|
||||
$tmpline = mb_ereg_replace('{new}', $caches_newstring, $tmpline);
|
||||
else
|
||||
$tmpline = mb_ereg_replace('{new}', '', $tmpline);
|
||||
|
||||
$tmpline = mb_ereg_replace('{diffpic}', icon_difficulty("diff", $caches_record['difficulty']), $tmpline);
|
||||
$tmpline = mb_ereg_replace('{terrpic}', icon_difficulty("terr", $caches_record['terrain']), $tmpline);
|
||||
$tmpline = mb_ereg_replace('{ratpic}', icon_rating($caches_record['founds'], $caches_record['topratings']), $tmpline);
|
||||
|
||||
if ($caches_record['oconly'] == 1)
|
||||
$tmpline = mb_ereg_replace('{oconly}', $caches_oconlystring, $tmpline);
|
||||
else
|
||||
$tmpline = mb_ereg_replace('{oconly}', '', $tmpline);
|
||||
|
||||
// get last logs
|
||||
if ($options['sort'] != 'bymylastlog' || $usr === false)
|
||||
$ownlogs = "";
|
||||
else
|
||||
$ownlogs = " AND `cache_logs`.`user_id`='" . sql_escape($usr['userid']) . "'";
|
||||
$sql = 'SELECT `cache_logs`.`id` `id`, `cache_logs`.`type` `type`, `cache_logs`.`date` `date`, `log_types`.`icon_small` `icon_small`
|
||||
FROM `cache_logs`, `log_types`
|
||||
WHERE `cache_logs`.`cache_id`=\'' . sql_escape($caches_record['cache_id']) . '\'
|
||||
AND `log_types`.`id`=`cache_logs`.`type`' . $ownlogs . '
|
||||
ORDER BY `cache_logs`.`date` DESC LIMIT 6';
|
||||
$result = sql_slave($sql);
|
||||
|
||||
if ($row = sql_fetch_array($result))
|
||||
{
|
||||
$loglink = '<a href=\'viewlogs.php?cacheid='.htmlspecialchars($caches_record['cache_id'], ENT_COMPAT, 'UTF-8').'#log'.htmlspecialchars($row['id'], ENT_COMPAT, 'UTF-8').'\'>';
|
||||
$tmpline = mb_ereg_replace('{logimage1}',
|
||||
$loglink . icon_log_type($row['icon_small'], ""). '</a>{gray_s}' . $loglink. date($logdateformat, strtotime($row['date'])) . '{gray_e}</a>', $tmpline);
|
||||
$tmpline = mb_ereg_replace('{logdate1}', "", $tmpline);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmpline = mb_ereg_replace('{logimage1}', "<img src='images/trans.gif' border='0' width='16' height='16' />", $tmpline);
|
||||
$tmpline = mb_ereg_replace('{logdate1}', "--.--.----", $tmpline);
|
||||
}
|
||||
|
||||
$lastlogs = "";
|
||||
while ($row = sql_fetch_array($result))
|
||||
{
|
||||
$lastlogs .= '<a href=\'viewlogs.php?cacheid=' . urlencode($caches_record['cache_id']) . '#log' . htmlspecialchars($row['id'], ENT_COMPAT, 'UTF-8') . '\'>' . icon_log_type($row['icon_small'], '') . '</a> ';
|
||||
}
|
||||
$tmpline = mb_ereg_replace('{lastlogs}', $lastlogs, $tmpline);
|
||||
|
||||
// und jetzt noch die Richtung ...
|
||||
if ($caches_record['distance'] > 0)
|
||||
{
|
||||
$tmpline = mb_ereg_replace('{direction}', Bearing2Text(calcBearing($lat_rad / 3.14159 * 180, $lon_rad / 3.14159 * 180, $caches_record['latitude'], $caches_record['longitude']), 1), $tmpline);
|
||||
}
|
||||
else
|
||||
$tmpline = mb_ereg_replace('{direction}', '', $tmpline);
|
||||
|
||||
$desclangs = '';
|
||||
$aLangs = mb_split(',', $caches_record['desc_languages']);
|
||||
foreach ($aLangs AS $thislang)
|
||||
{
|
||||
$desclangs .= '<a href="viewcache.php?cacheid=' . urlencode($caches_record['cache_id']) . '&desclang=' . urlencode($thislang) . '" style="text-decoration:none;"><b><font color="blue">' . htmlspecialchars($thislang, ENT_COMPAT, 'UTF-8') . '</font></b></a> ';
|
||||
}
|
||||
|
||||
// strikeout inavtive caches
|
||||
// see also res_cachestatus_span.tpl
|
||||
$status_style = ""; // (colored) strike-through for inactive caches
|
||||
$line_style = ""; // color of the linked cache name
|
||||
$name_style = ""; // color of "by <username>"
|
||||
switch ($caches_record['status'])
|
||||
{
|
||||
case 2: // disabled
|
||||
$status_style = "text-decoration: line-through;";
|
||||
break;
|
||||
case 3: // archived
|
||||
case 6: // locked
|
||||
$status_style = "text-decoration: line-through; color: #c00000;";
|
||||
// $line_style = "color:grey";
|
||||
break;
|
||||
case 7: // locked, invisible
|
||||
$status_style = "text-decoration: line-through; color: #e00000";
|
||||
$name_style = "color: #e00000";
|
||||
// $line_style = "color:grey";
|
||||
break;
|
||||
case 5: // not published yet
|
||||
$name_style = "color: #e00000";
|
||||
break;
|
||||
default: $status_style = $line_style = "";
|
||||
}
|
||||
|
||||
$tmpline = mb_ereg_replace('{line_style}', $line_style, $tmpline);
|
||||
$tmpline = mb_ereg_replace('{status_style}', $status_style, $tmpline);
|
||||
$tmpline = mb_ereg_replace('{name_style}', $name_style, $tmpline);
|
||||
$tmpline = mb_ereg_replace('{desclangs}', $desclangs, $tmpline);
|
||||
$tmpline = mb_ereg_replace('{cachename}', htmlspecialchars($caches_record['name'], ENT_COMPAT, 'UTF-8'), $tmpline);
|
||||
$tmpline = mb_ereg_replace('{urlencode_cacheid}', htmlspecialchars(urlencode($caches_record['cache_id']), ENT_COMPAT, 'UTF-8'), $tmpline);
|
||||
$tmpline = mb_ereg_replace('{urlencode_userid}', htmlspecialchars(urlencode($caches_record['user_id']), ENT_COMPAT, 'UTF-8'), $tmpline);
|
||||
$tmpline = mb_ereg_replace('{username}', htmlspecialchars($caches_record['username'], ENT_COMPAT, 'UTF-8'), $tmpline);
|
||||
$tmpline = mb_ereg_replace('{position}', $nRowIndex + $startat + 1, $tmpline);
|
||||
|
||||
if ($caches_record['distance'] == NULL)
|
||||
$tmpline = mb_ereg_replace('{distance}', '', $tmpline);
|
||||
else
|
||||
$tmpline = mb_ereg_replace('{distance}', htmlspecialchars(sprintf("%01.1f", $caches_record['distance']), ENT_COMPAT, 'UTF-8'), $tmpline);
|
||||
|
||||
// backgroundcolor of line
|
||||
if (($nRowIndex % 2) == 1) $bgcolor = $bgcolor2;
|
||||
else $bgcolor = $bgcolor1;
|
||||
|
||||
if ($inactive)
|
||||
{
|
||||
//$bgcolor = $bgcolor_inactive;
|
||||
$tmpline = mb_ereg_replace('{gray_s}', "<span class='text_gray'>", $tmpline);
|
||||
$tmpline = mb_ereg_replace('{gray_e}', "</span>", $tmpline);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmpline = mb_ereg_replace('{gray_s}', "", $tmpline);
|
||||
$tmpline = mb_ereg_replace('{gray_e}', "", $tmpline);
|
||||
}
|
||||
|
||||
$tmpline = mb_ereg_replace('{bgcolor}', $bgcolor, $tmpline);
|
||||
|
||||
$nRowIndex++;
|
||||
$caches_output .= $tmpline;
|
||||
}
|
||||
mysql_free_result($rs_caches);
|
||||
|
||||
tpl_set_var('results', $caches_output);
|
||||
|
||||
// more than one page?
|
||||
if ($resultcount <= $caches_per_page)
|
||||
$pages = '';
|
||||
else
|
||||
{
|
||||
if ($startat > 0) // Ocprop: queryid=([0-9]+)
|
||||
$pages = '<a href="search.php?queryid=' . $options['queryid'] . '&startat=0"><img src="resource2/ocstyle/images/navigation/16x16-browse-first.png" width="16" height="16"></a> <a href="search.php?queryid=' . $options['queryid'] . '&startat=' . ($startat - $caches_per_page) . '"><img src="resource2/ocstyle/images/navigation/16x16-browse-prev.png" width="16" height="16"></a></a> ';
|
||||
else
|
||||
$pages = ' <img src="resource2/ocstyle/images/navigation/16x16-browse-first-inactive.png" width="16" height="16"></a> <img src="resource2/ocstyle/images/navigation/16x16-browse-prev-inactive.png" width="16" height="16"></a> ';
|
||||
|
||||
$frompage = ($startat / $caches_per_page) - 3;
|
||||
if ($frompage < 1) $frompage = 1;
|
||||
$maxpage = ceil($resultcount / $caches_per_page);
|
||||
$topage = $frompage + 8;
|
||||
if ($topage > $maxpage) $topage = $maxpage;
|
||||
|
||||
for ($i = $frompage; $i <= $topage; $i++)
|
||||
{
|
||||
if (($startat / $caches_per_page + 1) == $i)
|
||||
$pages .= ' <b>' . $i . '</b>';
|
||||
else
|
||||
$pages .= ' <a href="search.php?queryid=' . $options['queryid'] . '&startat=' . (($i - 1) * $caches_per_page) . '">' . $i . '</a>';
|
||||
}
|
||||
|
||||
if ($startat / $caches_per_page < ($maxpage - 1))
|
||||
$pages .= ' <a href="search.php?queryid=' . $options['queryid'] . '&startat=' . ($startat + $caches_per_page) . '"><img src="resource2/ocstyle/images/navigation/16x16-browse-next.png" width="16" height="16"></a> <a href="search.php?queryid=' . $options['queryid'] . '&startat=' . (($maxpage - 1) * $caches_per_page) . '"><img src="resource2/ocstyle/images/navigation/16x16-browse-last.png" width="16" height="16"></a> ';
|
||||
else
|
||||
$pages .= ' <img src="resource2/ocstyle/images/navigation/16x16-browse-next-inactive.png" width="16" height="16"> <img src="resource2/ocstyle/images/navigation/16x16-browse-last-inactive.png" width="16" height="16"></a>';
|
||||
}
|
||||
|
||||
//'<a href="search.php?queryid=' . $options['queryid'] . '&startat=20">20</a> 40 60 80 100';
|
||||
//$caches_per_page
|
||||
//count($caches) - 1
|
||||
tpl_set_var('pages', $pages);
|
||||
tpl_set_var('showonmap', $showonmap);
|
||||
|
||||
// downloads
|
||||
tpl_set_var('queryid', $options['queryid']);
|
||||
tpl_set_var('startat', $startat);
|
||||
|
||||
tpl_set_var('startatp1', min($resultcount,$startat + 1));
|
||||
|
||||
if (($resultcount - $startat) < 500)
|
||||
tpl_set_var('endat', $startat + $resultcount - $startat);
|
||||
else
|
||||
tpl_set_var('endat', $startat + 500);
|
||||
|
||||
// kompatibilität!
|
||||
if ($distance_unit == 'sm')
|
||||
tpl_set_var('distanceunit', 'mi');
|
||||
else if ($distance_unit == 'nm')
|
||||
tpl_set_var('distanceunit', 'sm');
|
||||
else
|
||||
tpl_set_var('distanceunit', $distance_unit);
|
||||
|
||||
tpl_set_var('displaylastlogs', $options['sort'] == 'bymylastlog' ? 'none' : 'inline');
|
||||
tpl_set_var('displayownlogs', $options['sort'] == 'bymylastlog' ? 'inline' : 'none');
|
||||
|
||||
if ($sqldebug == true)
|
||||
sqldbg_end();
|
||||
else
|
||||
tpl_BuildTemplate();
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
loc search output
|
||||
****************************************************************************/
|
||||
|
||||
$search_output_file_download = true;
|
||||
$content_type_plain = 'application/loc';
|
||||
|
||||
|
||||
function search_output()
|
||||
{
|
||||
global $state_temporarily_na, $state_archived, $state_locked;
|
||||
|
||||
$locHead = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><loc version="1.0" src="opencaching.de">' . "\n";
|
||||
|
||||
$locLine =
|
||||
'
|
||||
<waypoint>
|
||||
<name id="{waypoint}"><![CDATA[{archivedflag}{name} by {username}]]></name>
|
||||
<coord lat="{lat}" lon="{lon}"/>
|
||||
<type>Geocache</type>
|
||||
<link text="Beschreibung">http://www.opencaching.de/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}', 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('{username}', xmlentities($r['username']), $thisline);
|
||||
$thisline = mb_ereg_replace('{cacheid}', $r['cacheid'], $thisline);
|
||||
|
||||
append_output($thisline);
|
||||
}
|
||||
mysql_free_result($rs);
|
||||
|
||||
append_output($locFoot);
|
||||
}
|
||||
|
||||
|
||||
function xmlentities($str)
|
||||
{
|
||||
$from[0] = '&'; $to[0] = '&';
|
||||
$from[1] = '<'; $to[1] = '<';
|
||||
$from[2] = '>'; $to[2] = '>';
|
||||
$from[3] = '"'; $to[3] = '"';
|
||||
$from[4] = '\''; $to[4] = ''';
|
||||
|
||||
for ($i = 0; $i <= 4; $i++)
|
||||
$str = mb_ereg_replace($from[$i], $to[$i], $str);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
* For license information see doc/license.txt
|
||||
*
|
||||
* Unicode Reminder メモ
|
||||
*
|
||||
* Execute search request for map.php
|
||||
* (use caching of the same quries)
|
||||
* TODO:cleanup
|
||||
***************************************************************************/
|
||||
|
||||
global $dblink, $dbslaveid;
|
||||
|
||||
$sqlchecksum = sprintf('%u', crc32($cachesFilter."\n".$sqlFilter));
|
||||
|
||||
/* config */
|
||||
$opt['map']['maxcacheage'] = 3600;
|
||||
|
||||
// check if query was already executed within the cache period
|
||||
$rsMapCache = sql("SELECT `result_id` FROM `map2_result` WHERE `sqlchecksum`='&1' AND DATE_ADD(`date_created`, INTERVAL '&2' SECOND)>NOW() AND `sqlquery`='&3'", $sqlchecksum, $opt['map']['maxcacheage'], $sqlFilter);
|
||||
if ($rMapCache = sql_fetch_assoc($rsMapCache))
|
||||
{
|
||||
$resultId = $rMapCache['result_id'];
|
||||
sql("UPDATE `map2_result` SET `shared_counter`=`shared_counter`+1 WHERE `result_id`='" . ($resultId+0) . "'");
|
||||
}
|
||||
else
|
||||
{
|
||||
db_connect_anyslave();
|
||||
|
||||
// ensure that query is performed without errors before reserving the result_id
|
||||
sql_slave("CREATE TEMPORARY TABLE `tmpmapresult` (`cache_id` INT UNSIGNED NOT NULL, PRIMARY KEY (`cache_id`)) ENGINE=MEMORY");
|
||||
sql_slave("INSERT INTO `tmpmapresult` (`cache_id`) " . $sqlFilter);
|
||||
|
||||
sql("INSERT INTO `map2_result` (`slave_id`, `sqlchecksum`, `sqlquery`, `date_created`, `date_lastqueried`) VALUES ('&1', '&2', '&3', NOW(), NOW())", $dbslaveid, $sqlchecksum, $cachesFilter."\n".$sqlFilter);
|
||||
$resultId = mysql_insert_id($dblink);
|
||||
|
||||
sql_slave("INSERT IGNORE INTO `map2_data` (`result_id`, `cache_id`) SELECT '&1', `cache_id` FROM `tmpmapresult`", $resultId);
|
||||
sql_slave("DROP TEMPORARY TABLE `tmpmapresult`");
|
||||
}
|
||||
|
||||
if ($map2_bounds)
|
||||
{
|
||||
$rs = sql_slave("SELECT MIN(`latitude`) AS `lat_min`,
|
||||
MAX(`latitude`) AS `lat_max`,
|
||||
MIN(`longitude`) AS `lon_min`,
|
||||
MAX(`longitude`) AS `lon_max`
|
||||
FROM `map2_data`, `caches`
|
||||
WHERE `result_id`='&1'
|
||||
AND `caches`.`cache_id`=`map2_data`.`cache_id`",
|
||||
$resultId);
|
||||
if (($rBounds = sql_fetch_assoc($rs)) && $rBounds['lat_min'] !== null /* >0 caches */)
|
||||
{
|
||||
if ($rBounds['lat_min'] == $rBounds['lat_max'] &&
|
||||
$rBounds['lon_min'] == $rBounds['lon_max']) // 1 Cache
|
||||
{
|
||||
$halfwin = 0.02;
|
||||
$rBounds['lat_min'] -= $halfwin;
|
||||
$rBounds['lat_max'] += $halfwin;
|
||||
$rBounds['lon_min'] -= $halfwin;
|
||||
$rBounds['lon_max'] += $halfwin;
|
||||
}
|
||||
$bounds_param = "&lat_min=" . round($rBounds['lat_min'],5) . "&lat_max=" . round($rBounds['lat_max'],5) . '&lon_min=' . round($rBounds['lon_min'],5) . '&lon_max=' . round($rBounds['lon_max'],5);
|
||||
}
|
||||
sql_free_result($rs);
|
||||
|
||||
tpl_redirect('map2.php?queryid=' . $options['queryid'] . '&resultid=' . $resultId . $bounds_param);
|
||||
}
|
||||
else
|
||||
echo $resultId;
|
||||
|
||||
exit;
|
||||
?>
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
ov2 search output
|
||||
****************************************************************************/
|
||||
|
||||
$search_output_file_download = true;
|
||||
$content_type_plain = 'application/ov2';
|
||||
|
||||
|
||||
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`.`de` `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 convert_string($str)
|
||||
{
|
||||
$newstr = iconv("UTF-8", "ISO-8859-1", $str);
|
||||
if ($newstr == false)
|
||||
return "--- charset error ---";
|
||||
else
|
||||
return $newstr;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
ovl search output for TOP25, TOP50 etc.
|
||||
****************************************************************************/
|
||||
|
||||
$search_output_file_download = true;
|
||||
$content_type_plain = 'application/ovl';
|
||||
|
||||
|
||||
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}', convert_string($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);
|
||||
}
|
||||
|
||||
|
||||
function convert_string($str)
|
||||
{
|
||||
$newstr = iconv("UTF-8", "ISO-8859-1", $str);
|
||||
if ($newstr == false)
|
||||
return $str;
|
||||
else
|
||||
return $newstr;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
GPX search output
|
||||
****************************************************************************/
|
||||
|
||||
$search_output_file_download = true;
|
||||
$content_type_plain = 'text/plain';
|
||||
$zip_threshold = 1;
|
||||
$add_to_zipfile = false;
|
||||
|
||||
|
||||
function search_output()
|
||||
{
|
||||
global $absolute_server_URI, $locale;
|
||||
global $converted_from_html;
|
||||
global $phpzip, $bUseZip;
|
||||
|
||||
$txtLine = "Name: {cachename} von {owner}
|
||||
Koordinaten: {lon} {lat}
|
||||
Status: {status}
|
||||
|
||||
Versteckt am: {time}
|
||||
Wegpunkt: {waypoint}
|
||||
Land: {country}
|
||||
Cacheart: {type}
|
||||
Behälter: {container}
|
||||
D/T: {difficulty}/{terrain}
|
||||
Online: " . $absolute_server_URI . "viewcache.php?wp={waypoint}
|
||||
|
||||
Kurzbeschreibung: {shortdesc}
|
||||
|
||||
Beschreibung{htmlwarn}:
|
||||
<===================>
|
||||
{desc}
|
||||
<===================>
|
||||
|
||||
Zusätzliche Hinweise:
|
||||
<===================>
|
||||
{hints}
|
||||
<===================>
|
||||
A|B|C|D|E|F|G|H|I|J|K|L|M
|
||||
N|O|P|Q|R|S|T|U|V|W|X|Y|Z
|
||||
|
||||
Logeinträge:
|
||||
{logs}
|
||||
";
|
||||
|
||||
$txtLogs = "<===================>
|
||||
{username} / {date} / {type}
|
||||
|
||||
{text}
|
||||
";
|
||||
|
||||
$rs = sql_slave('
|
||||
SELECT SQL_BUFFER_RESULT
|
||||
`searchtmp`.`cache_id` `cacheid`,
|
||||
`searchtmp`.`longitude` `longitude`,
|
||||
`searchtmp`.`latitude` `latitude`,
|
||||
`caches`.`wp_oc` `waypoint`,
|
||||
`caches`.`date_hidden` `date_hidden`,
|
||||
`caches`.`name` `name`,
|
||||
`caches`.`country` `country`,
|
||||
`caches`.`terrain` `terrain`,
|
||||
`caches`.`difficulty` `difficulty`,
|
||||
`caches`.`desc_languages` `desc_languages`,
|
||||
`cache_size`.`de` `size`,
|
||||
`cache_type`.`de` `type`,
|
||||
`cache_status`.`de` `status`,
|
||||
`user`.`username` `username`,
|
||||
`cache_desc`.`desc` `desc`,
|
||||
`cache_desc`.`short_desc` `short_desc`,
|
||||
`cache_desc`.`hint` `hint`,
|
||||
`cache_desc`.`desc_html` `html`,
|
||||
`user`.`user_id`,
|
||||
`user`.`username`,
|
||||
`user`.`data_license`
|
||||
FROM
|
||||
`searchtmp`,
|
||||
`caches`,
|
||||
`user`,
|
||||
`cache_desc`,
|
||||
`cache_type`,
|
||||
`cache_status`,
|
||||
`cache_size`
|
||||
WHERE
|
||||
`searchtmp`.`cache_id`=`caches`.`cache_id` AND
|
||||
`caches`.`cache_id`=`cache_desc`.`cache_id` AND
|
||||
`caches`.`default_desclang`=`cache_desc`.`language` AND
|
||||
`searchtmp`.`user_id`=`user`.`user_id` AND
|
||||
`caches`.`type`=`cache_type`.`id` AND
|
||||
`caches`.`status`=`cache_status`.`id` AND
|
||||
`caches`.`size`=`cache_size`.`id`');
|
||||
|
||||
while ($r = sql_fetch_array($rs))
|
||||
{
|
||||
$thisline = $txtLine;
|
||||
|
||||
$lat = sprintf('%01.5f', $r['latitude']);
|
||||
$thisline = mb_ereg_replace('{lat}', help_latToDegreeStr($lat), $thisline);
|
||||
|
||||
$lon = sprintf('%01.5f', $r['longitude']);
|
||||
$thisline = mb_ereg_replace('{lon}', help_lonToDegreeStr($lon), $thisline);
|
||||
|
||||
$time = date('d.m.Y', 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}', $r['name'], $thisline);
|
||||
$thisline = mb_ereg_replace('{country}', db_CountryFromShort($r['country']), $thisline);
|
||||
|
||||
if ($r['hint'] == '')
|
||||
$thisline = mb_ereg_replace('{hints}', '', $thisline);
|
||||
else
|
||||
$thisline = mb_ereg_replace('{hints}', str_rot13_html(decodeEntities(strip_tags($r['hint']))), $thisline);
|
||||
|
||||
$thisline = mb_ereg_replace('{shortdesc}', $r['short_desc'], $thisline);
|
||||
|
||||
$license = getLicenseDisclaimer(
|
||||
$r['user_id'], $r['username'], $r['data_license'], $r['cacheid'], $locale, true, false, true);
|
||||
if ($license != "")
|
||||
$license = "\r\n\r\n$license";
|
||||
|
||||
if ($r['html'] == 0)
|
||||
{
|
||||
$thisline = mb_ereg_replace('{htmlwarn}', '', $thisline);
|
||||
$thisline = mb_ereg_replace('{desc}', decodeEntities(strip_tags($r['desc'])) . $license, $thisline);
|
||||
}
|
||||
else
|
||||
{
|
||||
$thisline = mb_ereg_replace('{htmlwarn}', " ($converted_from_html)", $thisline);
|
||||
$thisline = mb_ereg_replace('{desc}', html2txt($r['desc']) . $license, $thisline);
|
||||
}
|
||||
|
||||
$thisline = mb_ereg_replace('{type}', $r['type'], $thisline);
|
||||
$thisline = mb_ereg_replace('{container}', $r['size'], $thisline);
|
||||
$thisline = mb_ereg_replace('{status}', $r['status'], $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('{owner}', $r['username'], $thisline);
|
||||
|
||||
// logs ermitteln
|
||||
$logentries = '';
|
||||
$rsLogs = sql_slave("SELECT `cache_logs`.`id`, `cache_logs`.`text_html`, `log_types`.`de` `type`, `cache_logs`.`date`, `cache_logs`.`text`, `user`.`username` FROM `cache_logs`, `user`, `log_types` WHERE `cache_logs`.`user_id`=`user`.`user_id` AND `cache_logs`.`type`=`log_types`.`id` AND `cache_logs`.`cache_id`=&1 ORDER BY `cache_logs`.`date` DESC LIMIT 20", $r['cacheid']);
|
||||
while ($rLog = sql_fetch_array($rsLogs))
|
||||
{
|
||||
$thislog = $txtLogs;
|
||||
|
||||
$thislog = mb_ereg_replace('{id}', $rLog['id'], $thislog);
|
||||
if (substr($rLog['date'],11) == "00:00:00")
|
||||
$dateformat = "d.m.Y";
|
||||
else
|
||||
$dateformat = "d.m.Y H:i";
|
||||
$thislog = mb_ereg_replace('{date}', date($dateformat, strtotime($rLog['date'])), $thislog);
|
||||
$thislog = mb_ereg_replace('{username}', $rLog['username'], $thislog);
|
||||
|
||||
$logtype = $rLog['type'];
|
||||
|
||||
$thislog = mb_ereg_replace('{type}', $logtype, $thislog);
|
||||
if ($rLog['text_html'] == 0)
|
||||
$thislog = mb_ereg_replace('{text}', decodeEntities(strip_tags($rLog['text'])), $thislog);
|
||||
else
|
||||
$thislog = mb_ereg_replace('{text}', html2txt($rLog['text']), $thislog);
|
||||
|
||||
$logentries .= $thislog . "\n";
|
||||
}
|
||||
$thisline = mb_ereg_replace('{logs}', $logentries, $thisline);
|
||||
|
||||
$thisline = lf2crlf($thisline);
|
||||
if (($rCount['count'] == 1) && !$bUseZip)
|
||||
echo $thisline;
|
||||
else
|
||||
{
|
||||
$phpzip->add_data($r['waypoint'] . '.txt', $thisline);
|
||||
}
|
||||
}
|
||||
mysql_free_result($rs);
|
||||
}
|
||||
|
||||
|
||||
function decodeEntities($str)
|
||||
{
|
||||
$str = html_entity_decode($str, ENT_COMPAT, "UTF-8");
|
||||
return $str;
|
||||
}
|
||||
|
||||
function html2txt($html)
|
||||
{
|
||||
$str = mb_ereg_replace("\r\n", '', $html);
|
||||
$str = mb_ereg_replace("\n", '', $str);
|
||||
$str = mb_ereg_replace('<br />', "\n", $str);
|
||||
$str = strip_tags($str);
|
||||
$str = decodeEntities($str);
|
||||
return $str;
|
||||
}
|
||||
|
||||
function lf2crlf($str)
|
||||
{
|
||||
return mb_ereg_replace("\r\r\n" ,"\r\n" , mb_ereg_replace("\n" ,"\r\n" , $str));
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
/***************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
XML search output
|
||||
****************************************************************************/
|
||||
|
||||
$search_output_file_download = false;
|
||||
|
||||
|
||||
function search_output()
|
||||
{
|
||||
global $sqldebug;
|
||||
global $distance_unit, $startat, $count, $sql, $sqlLimit;
|
||||
|
||||
$encoding = 'UTF-8';
|
||||
|
||||
$xmlLine = " <cache>
|
||||
<name><![CDATA[{cachename}]]></name>
|
||||
<owner id=\"{ownerid}\"><![CDATA[{owner}]]></owner>
|
||||
<id>{cacheid}</id>
|
||||
<waypoint>{waypoint}</waypoint>
|
||||
<hidden>{time}</hidden>
|
||||
<status id=\"{statusid}\">{status}</status>
|
||||
<lon value=\"{lonvalue}\">{lon}</lon>
|
||||
<lat value=\"{latvalue}\">{lat}</lat>
|
||||
<distance unit=\"".$distance_unit."\">{distance}</distance>
|
||||
<type id=\"{typeid}\">{type}</type>
|
||||
<difficulty>{difficulty}</difficulty>
|
||||
<terrain>{terrain}</terrain>
|
||||
<size id=\"{sizeid}\">{container}</size>
|
||||
<country id=\"{countryid}\">{country}</country>
|
||||
<link><![CDATA[http://www.opencaching.de/viewcache.php?wp={waypoint}]]></link>
|
||||
<desc><![CDATA[{shortdesc}]]></desc>
|
||||
<hints><![CDATA[{hints}]]></hints>
|
||||
</cache>
|
||||
";
|
||||
|
||||
// create temporary table
|
||||
sql_slave('CREATE TEMPORARY TABLE `searchtmp`
|
||||
SELECT SQL_BUFFER_RESULT SQL_CALC_FOUND_ROWS ' . $sql . $sqlLimit);
|
||||
|
||||
$resultcount = sql_value_slave('SELECT FOUND_ROWS()', 0);
|
||||
|
||||
$rsCount = sql_slave('SELECT COUNT(*) `count` FROM `searchtmp`');
|
||||
$rCount = sql_fetch_array($rsCount);
|
||||
mysql_free_result($rsCount);
|
||||
|
||||
// start output
|
||||
if ($sqldebug == false)
|
||||
{
|
||||
header("Content-type: application/xml; charset=".$encoding);
|
||||
//header("Content-Disposition: attachment; filename=" . $sFilebasename . ".txt");
|
||||
}
|
||||
|
||||
echo "<?xml version=\"1.0\" encoding=\"".$encoding."\"?>\n";
|
||||
echo "<result>\n";
|
||||
|
||||
echo " <docinfo>\n";
|
||||
echo " <results>" . $rCount['count'] . "</results>\n";
|
||||
echo " <startat>" . $startat . "</startat>\n";
|
||||
echo " <perpage>" . $count . "</perpage>\n";
|
||||
echo " <total>" . $resultcount . "</total>\n";
|
||||
echo " </docinfo>\n";
|
||||
|
||||
$rs = sql_slave('SELECT `searchtmp`.`cache_id` `cacheid`,
|
||||
`searchtmp`.`longitude` `longitude`,
|
||||
`searchtmp`.`latitude` `latitude`,
|
||||
`caches`.`wp_oc` `waypoint`,
|
||||
`caches`.`date_hidden` `date_hidden`,
|
||||
`caches`.`name` `name`,
|
||||
`caches`.`country` `country`,
|
||||
`caches`.`terrain` `terrain`,
|
||||
`caches`.`difficulty` `difficulty`,
|
||||
`caches`.`desc_languages` `desc_languages`,
|
||||
`cache_size`.`name` `size`,
|
||||
`cache_size`.`id` `size_id`,
|
||||
`cache_type`.`name` `type`,
|
||||
`cache_type`.`id` `type_id`,
|
||||
`cache_status`.`name` `status`,
|
||||
`cache_status`.`id` `status_id`,
|
||||
`user`.`username` `username`,
|
||||
`user`.`user_id` `user_id`,
|
||||
`cache_desc`.`desc` `desc`,
|
||||
`cache_desc`.`short_desc` `short_desc`,
|
||||
`cache_desc`.`hint` `hint`,
|
||||
`cache_desc`.`desc_html` `html`,
|
||||
`searchtmp`.`distance` `distance`
|
||||
FROM `searchtmp`
|
||||
INNER JOIN `caches` ON `searchtmp`.`cache_id`=`caches`.`cache_id`
|
||||
INNER JOIN `user` ON `searchtmp`.`user_id`=`user`.`user_id`
|
||||
INNER JOIN `cache_desc` ON `caches`.`cache_id`=`cache_desc`.`cache_id` AND `caches`.`default_desclang`=`cache_desc`.`language`
|
||||
INNER JOIN `cache_type` ON `caches`.`type`=`cache_type`.`id`
|
||||
INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id`
|
||||
INNER JOIN `cache_size` ON `caches`.`size`=`cache_size`.`id`');
|
||||
while ($r = sql_fetch_array($rs))
|
||||
{
|
||||
$thisline = $xmlLine;
|
||||
|
||||
$lat = sprintf('%01.5f', $r['latitude']);
|
||||
$thisline = str_replace('{lat}', help_latToDegreeStr($lat), $thisline);
|
||||
$thisline = str_replace('{latvalue}', $lat, $thisline);
|
||||
|
||||
$lon = sprintf('%01.5f', $r['longitude']);
|
||||
$thisline = str_replace('{lon}', help_lonToDegreeStr($lon), $thisline);
|
||||
$thisline = str_replace('{lonvalue}', $lon, $thisline);
|
||||
|
||||
$time = date('d.m.Y', strtotime($r['date_hidden']));
|
||||
$thisline = str_replace('{time}', $time, $thisline);
|
||||
$thisline = str_replace('{waypoint}', $r['waypoint'], $thisline);
|
||||
$thisline = str_replace('{cacheid}', $r['cacheid'], $thisline);
|
||||
$thisline = str_replace('{cachename}', filterevilchars($r['name']), $thisline);
|
||||
$thisline = str_replace('{country}', db_CountryFromShort($r['country']), $thisline);
|
||||
$thisline = str_replace('{countryid}', $r['country'], $thisline);
|
||||
|
||||
if ($r['hint'] == '')
|
||||
$thisline = str_replace('{hints}', '', $thisline);
|
||||
else
|
||||
$thisline = str_replace('{hints}', str_rot13_html(filterevilchars(strip_tags($r['hint']))), $thisline);
|
||||
|
||||
$thisline = str_replace('{shortdesc}', filterevilchars($r['short_desc']), $thisline);
|
||||
|
||||
if ($r['html'] == 0)
|
||||
{
|
||||
$thisline = str_replace('{htmlwarn}', '', $thisline);
|
||||
$thisline = str_replace('{desc}', filterevilchars(strip_tags($r['desc'])), $thisline);
|
||||
}
|
||||
else
|
||||
{
|
||||
$thisline = str_replace('{htmlwarn}', ' (Text converted from HTML)', $thisline);
|
||||
$thisline = str_replace('{desc}', html2txt(filterevilchars($r['desc'])), $thisline);
|
||||
}
|
||||
|
||||
$thisline = str_replace('{type}', $r['type'], $thisline);
|
||||
$thisline = str_replace('{typeid}', $r['type_id'], $thisline);
|
||||
$thisline = str_replace('{container}', $r['size'], $thisline);
|
||||
$thisline = str_replace('{sizeid}', $r['size_id'], $thisline);
|
||||
$thisline = str_replace('{status}', $r['status'], $thisline);
|
||||
$thisline = str_replace('{statusid}', $r['status_id'], $thisline);
|
||||
|
||||
$difficulty = sprintf('%01.1f', $r['difficulty'] / 2);
|
||||
$thisline = str_replace('{difficulty}', $difficulty, $thisline);
|
||||
|
||||
$terrain = sprintf('%01.1f', $r['terrain'] / 2);
|
||||
$thisline = str_replace('{terrain}', $terrain, $thisline);
|
||||
|
||||
$thisline = str_replace('{owner}', filterevilchars($r['username']), $thisline);
|
||||
$thisline = str_replace('{ownerid}', filterevilchars($r['user_id']), $thisline);
|
||||
$thisline = str_replace('{distance}', htmlspecialchars(sprintf("%01.1f", $r['distance'])), $thisline);
|
||||
|
||||
$thisline = lf2crlf($thisline);
|
||||
|
||||
echo $thisline;
|
||||
}
|
||||
mysql_free_result($rs);
|
||||
sql_slave('DROP TABLE `searchtmp`');
|
||||
if ($sqldebug == true) sqldbg_end();
|
||||
echo "</result>\n";
|
||||
}
|
||||
|
||||
|
||||
function html2txt($html)
|
||||
{
|
||||
$str = str_replace("\r\n", '', $html);
|
||||
$str = str_replace("\n", '', $str);
|
||||
$str = str_replace('<br />', "\n", $str);
|
||||
$str = strip_tags($str);
|
||||
return $str;
|
||||
}
|
||||
|
||||
function lf2crlf($str)
|
||||
{
|
||||
return str_replace("\r\r\n" ,"\r\n" , str_replace("\n" ,"\r\n" , $str));
|
||||
}
|
||||
|
||||
function filterevilchars($str)
|
||||
{
|
||||
$evilchars = array(31 => 31, 30 => 30,
|
||||
29 => 29, 28 => 28, 27 => 27, 26 => 26, 25 => 25, 24 => 24,
|
||||
23 => 23, 22 => 22, 21 => 21, 20 => 20, 19 => 19, 18 => 18,
|
||||
17 => 17, 16 => 16, 15 => 15, 14 => 14, 12 => 12, 11 => 11,
|
||||
9 => 9, 8 => 8, 7 => 7, 6 => 6, 5 => 5, 4 => 4, 3 => 3,
|
||||
2 => 2, 1 => 1, 0 => 0);
|
||||
|
||||
foreach ($evilchars AS $ascii)
|
||||
$str = str_replace(chr($ascii), '', $str);
|
||||
|
||||
$str = preg_replace('/&([a-zA-Z]{1})caron;/', '\\1', $str);
|
||||
$str = preg_replace('/&([a-zA-Z]{1})acute;/', '\\1', $str);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user