ported search.php & tools to lib2, and ...
- fixed logentry sorting for logs with identical date - fixed ä etc. display in short descriptions on search results page - try to select a matching language for the short descriptions - added some translations - hide download and map links if no search results (updates #235) - nicer display of selectlocid page - use site-dependent urls in GPX, LOC, TXT and KML - unified XML encoding, now all done via two functions in lib2/util.inc.php (updates #121) - some preventive XML encoding adjustments in GPX - removed XML encoding in LOC CDATA section - improved charset conversion for OVL and OV2 output - some optimizations - discarded lots of obsolete code - disabled debug mode force_compile in OcSmarty class (performance)
This commit is contained in:
@@ -62,8 +62,12 @@ class OcSmarty extends Smarty
|
||||
$this->load_filter('output', 'session');
|
||||
|
||||
// cache control
|
||||
/* This will make templates with many includes (e.g. search result list,
|
||||
images galleries ..) VERY slow, and it is not necessary - auto-compile
|
||||
when file time is touched will work find. -- following 2013/7/13
|
||||
if (($opt['debug'] & DEBUG_TEMPLATES) == DEBUG_TEMPLATES)
|
||||
$this->force_compile = true;
|
||||
*/
|
||||
|
||||
// process debug level
|
||||
if (($opt['debug'] & DEBUG_SQLDEBUGGER) == DEBUG_SQLDEBUGGER)
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/****************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
charset related functions
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
// replacement table for Unicode 0x100 to 0x1FF
|
||||
$utf_xlatin = "A a A a A a C c C c C c C c D d D d E e E e E e E e E e G g G g " .
|
||||
"G g G g H h H h I i I i I i I i I i IJijJ j K k K L l L l L l L " .
|
||||
"l L l N n N n N n n n n O o O o Ö ö OEoeR r R r R r S s S s S s " .
|
||||
"S s T t T t T t U u U u U u U u Ü ü U u W w Y y Y Z z Z z Z z ";
|
||||
|
||||
// replacement table for Unicode 0x2000 to 0x203F
|
||||
$utf_punct = " ------|_'','\"\"\"\"++*>.... %%´\"\"`\"\"^<> !?- ";
|
||||
|
||||
|
||||
// convert utf-8 string to iso-8859-1 and use replacemend characters if possible
|
||||
|
||||
function utf8ToIso88591($s)
|
||||
{
|
||||
global $utf_xlatin, $utf_punct;
|
||||
|
||||
$pos = 0;
|
||||
$result = "";
|
||||
|
||||
while ($pos < strlen($s))
|
||||
{
|
||||
$c1 = ord($s[$pos++]);
|
||||
if ($c1 < 0xC0)
|
||||
$result .= chr($c1);
|
||||
else if ($pos < strlen($s))
|
||||
{
|
||||
$c2 = ord($s[$pos++]);
|
||||
if ($c1 < 0xE0)
|
||||
{
|
||||
$code = 0x40 * ($c1 & 0x1F) + ($c2 & 0x3F);
|
||||
if ($code < 0x100)
|
||||
$result .= chr($code);
|
||||
else if ($code < 0x200)
|
||||
{
|
||||
$result .= $utf_xlatin[2*($code - 0x100)];
|
||||
if ($utf_xlatin[2*($code - 0x100) + 1] != ' ')
|
||||
$result .= $utf_xlatin[2*($code - 0x100) + 1];
|
||||
}
|
||||
else
|
||||
$result .= "?";
|
||||
}
|
||||
else if ($pos < strlen($s))
|
||||
{
|
||||
$c3 = ord($s[$pos++]);
|
||||
$code = 0x1000 * ($c1 & 0x0F) + 0x40 * ($c2 & 0x3F) + ($c3 & 0x3F);
|
||||
switch ($code)
|
||||
{
|
||||
case 0x2026 : $result .= "..."; break;
|
||||
case 0x2025 : $result .= ".."; break;
|
||||
case 0x20AC : $result .= "Euro"; break;
|
||||
default:
|
||||
if ($code >= 0x2000 && $code <= 0x203F)
|
||||
$result .= $utf_punct[$code - 0x2000];
|
||||
else
|
||||
$result .= "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -148,6 +148,8 @@ function configure_php()
|
||||
ini_set('display_errors', true);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
ini_set('mysql.trace_mode', true);
|
||||
// SQL_CALC_FOUND_ROWS will not work with trace_mode on!
|
||||
// Use the next two functions below as workaround.
|
||||
|
||||
// not for production use yet (has to be tested thoroughly)
|
||||
register_errorhandlers();
|
||||
@@ -160,6 +162,19 @@ function configure_php()
|
||||
}
|
||||
}
|
||||
|
||||
function sql_enable_foundrows()
|
||||
{
|
||||
ini_set('mysql.trace_mode', false);
|
||||
}
|
||||
|
||||
function sql_foundrows_done()
|
||||
{
|
||||
global $opt;
|
||||
|
||||
if ($opt['php']['debug'] == PHP_DEBUG_ON)
|
||||
ini_set('mysql.trace_mode', true);
|
||||
}
|
||||
|
||||
function set_domain()
|
||||
{
|
||||
global $opt;
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
data-lice related functions
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* userid: user-id of the copyright holder
|
||||
* username: username of the copyright holder
|
||||
* userlicense: user.date_license of the copyright holder
|
||||
* cacheid: cache to which the licensed content is attached
|
||||
* language: language code for translation of the license disclaimer
|
||||
* for_cachedesc: include date and append "all logs entries © their authors"
|
||||
*
|
||||
* username and userlicense are not queried *here* for performance reasons.
|
||||
*/
|
||||
|
||||
function getLicenseDisclaimer($userid, $username, $userlicense, $cacheid, $language,
|
||||
$for_cachedesc, $html, $twolines=false)
|
||||
{
|
||||
global $opt, $translate, $absolute_server_URI;
|
||||
|
||||
$ltext = "";
|
||||
$language = strtoupper($language);
|
||||
if (isset($absolute_server_URI))
|
||||
$server_address = $absolute_server_URI;
|
||||
else
|
||||
$server_address = $opt['page']['absolute_url'];
|
||||
|
||||
if ($opt['logic']['license']['disclaimer'])
|
||||
{
|
||||
if ($userlicense == NEW_DATA_LICENSE_ACTIVELY_ACCEPTED ||
|
||||
$userlicense == NEW_DATA_LICENSE_PASSIVELY_ACCEPTED)
|
||||
{
|
||||
// © $USERNAME, Opencaching.de, CC BY-NC-ND[, as of $DATUM]
|
||||
$asof = $translate->t('as of', '', '', 0, '', 1, $language);
|
||||
|
||||
if (isset($opt['locale'][$language]['page']['license_url']))
|
||||
$lurl = $opt['locale'][$language]['page']['license_url'];
|
||||
else
|
||||
$lurl = $opt['locale']['EN']['page']['license_url'];
|
||||
if (isset($opt['locale'][$language]['format']['phpdate']))
|
||||
$df = $opt['locale'][$language]['format']['phpdate'];
|
||||
else
|
||||
$df = 'd-m-Y';
|
||||
|
||||
$purl = parse_url($server_address);
|
||||
// may be shortened if linked to www.opencaching.de
|
||||
if ($html && strpos($purl['host'],'opencaching.de'))
|
||||
$purl['host'] = "Opencaching.de";
|
||||
|
||||
$ltext = "© ";
|
||||
if ($html) $ltext .= "<a href='" . $server_address . "viewprofile.php?userid=" . $userid . "' target='_blank'>";
|
||||
$ltext .= $username;
|
||||
if ($html) $ltext .= "</a>";
|
||||
$ltext .= ", ";
|
||||
if ($html) $ltext .= "<a href='" . $server_address . "viewcache.php?cacheid=" . $cacheid . "' target='_blank'>";
|
||||
$ltext .= $purl['host'];
|
||||
if ($html) $ltext .= "</a>";
|
||||
$ltext .= ", ";
|
||||
if ($html) $ltext .= "<a href='" . $lurl . "' target='_blank'>";
|
||||
$ltext .= "CC BY-NC-ND";
|
||||
if ($html) $ltext .= "</a>";
|
||||
if ($for_cachedesc)
|
||||
$ltext .= ", " . $asof . " " . date($df);
|
||||
}
|
||||
|
||||
if ($for_cachedesc)
|
||||
{
|
||||
if ($ltext != "")
|
||||
if ($twolines) $ltext .= ";\r\n";
|
||||
else $ltext .= "; ";
|
||||
$ltext .= $translate->t('all log entries © their authors', '', '', 0, '', 1, $language);
|
||||
}
|
||||
}
|
||||
|
||||
if ($html)
|
||||
return $ltext;
|
||||
else
|
||||
return mb_ereg_replace("©","©",$ltext);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -337,7 +337,8 @@ class cache
|
||||
LEFT JOIN `cache_rating` ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id` AND `cache_logs`.`user_id`=`cache_rating`.`user_id` AND `cache_logs`.`date`=`cache_rating`.`rating_date`
|
||||
".$addjoin."
|
||||
WHERE `cache_logs`.`cache_id`='&1'
|
||||
ORDER BY `cache_logs`.`date` DESC, `cache_logs`.`Id` DESC LIMIT &2, &3", $cacheid, $start+0, $count+0);
|
||||
ORDER BY `cache_logs`.`date` DESC, `cache_logs`.`date_created` DESC
|
||||
LIMIT &2, &3", $cacheid, $start+0, $count+0);
|
||||
|
||||
$logs = array();
|
||||
while ($rLog = sql_fetch_assoc($rsLogs))
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/****************************************************************************
|
||||
|
||||
For license information see doc/license.txt
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
Nature Protection Area functions
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
function get_npas($cache_id)
|
||||
{
|
||||
$rsNPA = sql(
|
||||
"SELECT `npa_areas`.`name` AS `npaName`, `npa_types`.`name` AS `npaTypeName`
|
||||
FROM `cache_npa_areas`
|
||||
INNER JOIN `npa_areas` ON `cache_npa_areas`.`npa_id`=`npa_areas`.`id`
|
||||
INNER JOIN `npa_types` ON `npa_areas`.`type_id`=`npa_types`.`id`
|
||||
WHERE `cache_npa_areas`.`cache_id`='&1'
|
||||
GROUP BY `npa_areas`.`type_id`, `npa_areas`.`name`
|
||||
ORDER BY `npa_types`.`ordinal` ASC",
|
||||
$cache_id);
|
||||
$npas = array();
|
||||
while ($rNPA = sql_fetch_array($rsNPA))
|
||||
$npas[] = $rNPA;
|
||||
sql_free_result($rsNPA);
|
||||
|
||||
return $npas;
|
||||
}
|
||||
|
||||
|
||||
function get_desc_npas($cache_id)
|
||||
{
|
||||
global $opt;
|
||||
|
||||
$npas = get_npas($cache_id);
|
||||
if ($npas)
|
||||
{
|
||||
$desc = "<p>" . str_replace('%1',$opt['cms']['npa'], _('This geocache is probably placed within the following nature protection areas (<a href="%1">Info</a>):')) . "</p>\n" .
|
||||
"<ul>\n";
|
||||
foreach ($npas as $npa)
|
||||
$desc .= "<li>" . $npa['npaTypeName'] . ": <a href='http://www.google.de/search?q=".urlencode($npa['npaTypeName'].' '.$npa['npaName'])."' target='_blank'>" . $npa['npaName'] . "</a></li>\n";
|
||||
$desc .= "</ul>\n";
|
||||
}
|
||||
else
|
||||
$desc = "";
|
||||
|
||||
return $desc;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,17 +1,10 @@
|
||||
<?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
|
||||
functions for the full text search-engine
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
@@ -105,7 +98,7 @@ function ftsearch_split(&$str, $simple)
|
||||
else
|
||||
{
|
||||
if ($simple)
|
||||
$astr[$i] = ftsearch_text2simple($astr[$i]);
|
||||
$astr[$i] = ftsearch_text2simple($astr[$i]);
|
||||
|
||||
if ($astr[$i] == '')
|
||||
unset($astr[$i]);
|
||||
@@ -323,7 +316,7 @@ function ftsearch_strip_html($text)
|
||||
$text = str_replace('<br>', ' ', $text);
|
||||
$text = strip_tags($text);
|
||||
$text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');
|
||||
|
||||
|
||||
return $text;
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
<?php
|
||||
/****************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
|
||||
GPX search output (GC compatible)
|
||||
used by Ocprop
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
require_once('lib/npas.inc.php');
|
||||
require_once('lib2/logic/npas.inc.php');
|
||||
|
||||
$search_output_file_download = true;
|
||||
$content_type_plain = 'application/gpx';
|
||||
@@ -17,29 +16,32 @@
|
||||
|
||||
function search_output()
|
||||
{
|
||||
global $absolute_server_URI, $locale, $usr, $login;
|
||||
global $opt, $login;
|
||||
global $cache_note_text;
|
||||
|
||||
$gpxHead =
|
||||
$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://www.opencaching.de</url>
|
||||
<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 =
|
||||
|
||||
$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>
|
||||
<src>'.$server_domain.'</src>
|
||||
<url>' . $server_address . 'viewcache.php?cacheid={cacheid}</url>
|
||||
<urlname>{cachename}</urlname>
|
||||
<sym>{sym}</sym>
|
||||
<type>Geocache|{type}</type>
|
||||
@@ -104,7 +106,7 @@ function search_output()
|
||||
<name>{name}</name>
|
||||
<cmt>{comment}</cmt>
|
||||
<desc>{desc}</desc>
|
||||
<url>' . $absolute_server_URI . 'viewcache.php?cacheid={cacheid}</url>
|
||||
<url>' . $server_address . 'viewcache.php?cacheid={cacheid}</url>
|
||||
<urlname>{parent} {cachename}</urlname>
|
||||
<sym>{type}</sym>
|
||||
<type>Waypoint|{type}</type>
|
||||
@@ -145,7 +147,7 @@ function search_output()
|
||||
$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';
|
||||
@@ -164,41 +166,40 @@ function search_output()
|
||||
$childwphandler = new ChildWp_Handler();
|
||||
$children='';
|
||||
$rs = sql('SELECT `searchtmp`.`cache_id` `cacheid` FROM `searchtmp`');
|
||||
while ($r = sql_fetch_array($rs))
|
||||
while ($r = sql_fetch_array($rs) && $children == '')
|
||||
{
|
||||
if (count($childwphandler->getChildWps($r['cacheid'])))
|
||||
$children=" (HasChildren)";
|
||||
$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`,
|
||||
$user_id = $login->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`
|
||||
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`
|
||||
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);
|
||||
|
||||
@@ -206,44 +207,44 @@ function search_output()
|
||||
$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);
|
||||
|
||||
$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>' . xmlentities($hint) . '</groundspeak:encoded_hints>
|
||||
$thisline = mb_ereg_replace('{hints}', ' <groundspeak:encoded_hints>' . text_xmlentities($hint) . '</groundspeak:encoded_hints>
|
||||
', $thisline);
|
||||
|
||||
$thisline = mb_ereg_replace('{shortdesc}', xmlentities($r['short_desc']), $thisline);
|
||||
$thisline = mb_ereg_replace('{shortdesc}', text_xmlentities($r['short_desc']), $thisline);
|
||||
|
||||
$desc = str_replace('<img src="images/uploads/','<img src="' . $absolute_server_URI . 'images/uploads/', $r['desc']);
|
||||
$desc = str_replace('<img src="images/uploads/','<img src="' . $server_address . 'images/uploads/', $r['desc']);
|
||||
$license = getLicenseDisclaimer(
|
||||
$r['userid'], $r['username'], $r['data_license'], $r['cacheid'], $locale, true, true);
|
||||
$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}', xmlentities(decodeEntities($desc)), $thisline);
|
||||
$thisline = mb_ereg_replace('{desc}', text_xmlentities(decodeEntities($desc)), $thisline);
|
||||
|
||||
$thisline = mb_ereg_replace('{images}', xmlentities(getPictures($r['cacheid'])), $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);
|
||||
$thisline = mb_ereg_replace('{type}', $gpxType[$r['type']], $thisline);
|
||||
else
|
||||
$thisline = mb_ereg_replace('{type}', $gpxType[0], $thisline);
|
||||
$thisline = mb_ereg_replace('{type}', $gpxType[0], $thisline);
|
||||
|
||||
if (isset($gpxContainer[$r['size']]))
|
||||
$thisline = mb_ereg_replace('{container}', $gpxContainer[$r['size']], $thisline);
|
||||
$thisline = mb_ereg_replace('{container}', $gpxContainer[$r['size']], $thisline);
|
||||
else
|
||||
$thisline = mb_ereg_replace('{container}', $gpxContainer[0], $thisline);
|
||||
$thisline = mb_ereg_replace('{container}', $gpxContainer[0], $thisline);
|
||||
|
||||
if (isset($gpxStatus[$r['status']]))
|
||||
$thisline = mb_ereg_replace('{status}', $gpxStatus[$r['status']], $thisline);
|
||||
$thisline = mb_ereg_replace('{status}', $gpxStatus[$r['status']], $thisline);
|
||||
else
|
||||
$thisline = mb_ereg_replace('{status}', $gpxStatus[0], $thisline);
|
||||
$thisline = mb_ereg_replace('{status}', $gpxStatus[0], $thisline);
|
||||
|
||||
$sDiffDecimals = '';
|
||||
if ($r['difficulty'] % 2) $sDiffDecimals = '.5';
|
||||
@@ -255,13 +256,13 @@ function search_output()
|
||||
$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);
|
||||
$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}', xmlentities($gpxSymFound), $thisline);
|
||||
$thisline = mb_ereg_replace('{sym}', text_xmlentities($gpxSymFound), $thisline);
|
||||
else
|
||||
$thisline = mb_ereg_replace('{sym}', xmlentities($gpxSymNormal), $thisline);
|
||||
$thisline = mb_ereg_replace('{sym}', text_xmlentities($gpxSymNormal), $thisline);
|
||||
|
||||
// clear cache specific data
|
||||
$logentries = '';
|
||||
@@ -283,56 +284,56 @@ function search_output()
|
||||
$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('{username}', text_xmlentities($login->username), $thislog);
|
||||
$thislog = mb_ereg_replace('{type}', $gpxLogType[3], $thislog);
|
||||
$thislog = mb_ereg_replace('{text}', xmlentities($cacheNote['note']), $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", $r['cacheid'], $user_id);
|
||||
$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}', xmlentities($rLog['user_id']), $thislog);
|
||||
$thislog = mb_ereg_replace('{username}', xmlentities($rLog['username']), $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}', xmlentities(decodeEntities($rLog['text'])), $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 LIMIT 20", $r['cacheid'], $user_id);
|
||||
$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}', xmlentities($rLog['user_id']), $thislog);
|
||||
$thislog = mb_ereg_replace('{username}', xmlentities($rLog['username']), $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}', xmlentities(decodeEntities($rLog['text'])), $thislog);
|
||||
|
||||
$thislog = mb_ereg_replace('{text}', text_xmlentities(decodeEntities($rLog['text'])), $thislog);
|
||||
|
||||
$logentries .= $thislog . "\n";
|
||||
}
|
||||
mysql_free_result($rsLogs);
|
||||
@@ -353,7 +354,7 @@ function search_output()
|
||||
{
|
||||
$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);
|
||||
$thisattribute = mb_ereg_replace('{attrib_name}', text_xmlentities($rAttrib['gc_name']), $thisattribute);
|
||||
$attribentries .= $thisattribute . "\n";
|
||||
$gc_ids[$rAttrib['gc_id']] = true;
|
||||
}
|
||||
@@ -370,8 +371,8 @@ function search_output()
|
||||
|
||||
$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);
|
||||
|
||||
$thiskrety = mb_ereg_replace('{gkname}', text_xmlentities($rGK['name']), $thiskrety);
|
||||
|
||||
$gkentries .= $thiskrety . "\n";
|
||||
}
|
||||
mysql_free_result($rsGeokrety);
|
||||
@@ -389,9 +390,9 @@ function search_output()
|
||||
$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);
|
||||
$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
|
||||
@@ -401,7 +402,7 @@ function search_output()
|
||||
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('{type}', text_xmlentities($wp_typename), $thiswp);
|
||||
$thiswp = mb_ereg_replace('{parent}', $r['waypoint'], $thiswp);
|
||||
$thiswp = mb_ereg_replace('{cacheid}', $r['cacheid'], $thiswp);
|
||||
$waypoints .= $thiswp;
|
||||
@@ -415,9 +416,9 @@ function search_output()
|
||||
$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('{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);
|
||||
@@ -453,28 +454,13 @@ function search_output()
|
||||
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();
|
||||
@@ -488,22 +474,20 @@ function search_output()
|
||||
|
||||
// based on oc.pl code, but embedded thumbs instead of full pictures
|
||||
// (also to hide spoilers first)
|
||||
function getPictures($cacheid)
|
||||
function getPictures($cacheid, $server_address)
|
||||
{
|
||||
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
|
||||
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"]. '" >' .
|
||||
'<img src="' . $server_address . 'thumbs.php?uuid=' . $r["uuid"]. '" >' .
|
||||
'</a><br />' . $r['title'];
|
||||
if ($r['spoiler'])
|
||||
$retval .= ' (' . $translate->t('click on spoiler to display','',basename(__FILE__), __LINE__) . ')';
|
||||
$retval .= ' (' . _('click on spoiler to display') . ')';
|
||||
$retval .= "</div>";
|
||||
}
|
||||
mysql_free_result($rs);
|
||||
|
||||
@@ -4,12 +4,10 @@
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
(X)HTML search output
|
||||
Used by Ocprop
|
||||
****************************************************************************/
|
||||
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;
|
||||
|
||||
@@ -17,183 +15,100 @@
|
||||
`caches`.`desc_languages`, `caches`.`date_created`,
|
||||
`user`.`username`,
|
||||
`cache_type`.`icon_large`,
|
||||
`cache_type`.`name` `cacheTypeName`,
|
||||
`stt`.`text` AS `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';
|
||||
$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
|
||||
LEFT JOIN `sys_trans_text` `stt` ON `stt`.`trans_id`=`cache_type`.`trans_id`';
|
||||
|
||||
$sAddWhere .= ' AND `stt`.`lang`=\'' . sql_escape($opt['template']['locale']) . '\'';
|
||||
|
||||
|
||||
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;
|
||||
global $opt, $tpl, $login;
|
||||
global $newcache_days, $showonmap;
|
||||
global $calledbysearch, $options, $lat_rad, $lon_rad, $distance_unit;
|
||||
global $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 = '';
|
||||
$tpl->name = 'search.result.caches';
|
||||
$tpl->menuitem = MNU_CACHES_SEARCH_RESULT;
|
||||
|
||||
// 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);
|
||||
sql_enable_foundrows();
|
||||
$rs_caches = sql_slave("SELECT SQL_BUFFER_RESULT SQL_CALC_FOUND_ROWS " . $sql);
|
||||
$resultcount = sql_value_slave('SELECT FOUND_ROWS()', 0);
|
||||
tpl_set_var('results_count', $resultcount);
|
||||
sql_foundrows_done();
|
||||
$tpl->assign('results_count', $resultcount);
|
||||
$tpl->assign('startat',$startat);
|
||||
|
||||
while ($caches_record = sql_fetch_array($rs_caches))
|
||||
$caches = array();
|
||||
while ($rCache = sql_fetch_array($rs_caches))
|
||||
{
|
||||
$tmpline = $cache_line;
|
||||
// select best-fitting short desc for active language
|
||||
$rCache['short_desc'] = sql_value_slave("
|
||||
SELECT `short_desc`
|
||||
FROM `cache_desc`
|
||||
WHERE `cache_id`='&1' AND `language`='&2'",
|
||||
false, $rCache['cache_id'], $opt['template']['locale']);
|
||||
if ($rCache['short_desc'] === false) $rCache['short_desc'] = sql_value_slave("
|
||||
SELECT `short_desc`
|
||||
FROM `cache_desc`
|
||||
WHERE `cache_id`='&1' AND `language`='EN'",
|
||||
false, $rCache['cache_id']);
|
||||
if ($rCache['short_desc'] === false) $rCache['short_desc'] = sql_value_slave("
|
||||
SELECT `short_desc`
|
||||
FROM `cache_desc`
|
||||
WHERE `cache_id`='&1'
|
||||
ORDER BY `date_created`
|
||||
LIMIT 1",
|
||||
'', $rCache['cache_id']);
|
||||
|
||||
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);
|
||||
$rCache['desclangs'] = mb_split(',', $rCache['desc_languages']);
|
||||
|
||||
// decide if the cache is new
|
||||
$dDiff = abs(dateDiff('d', $rCache['date_created'], date('Y-m-d')));
|
||||
$rCache['isnew'] = ($dDiff <= $newcache_days);
|
||||
|
||||
// get last logs
|
||||
if ($options['sort'] != 'bymylastlog' || $usr === false)
|
||||
if ($options['sort'] != 'bymylastlog' || !$login->logged_in())
|
||||
$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`
|
||||
$ownlogs = " AND `cache_logs`.`user_id`='" . sql_escape($login->userid) . "'";
|
||||
$sql = "
|
||||
SELECT `cache_logs`.`id`, `cache_logs`.`type`, `cache_logs`.`date`, `log_types`.`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);
|
||||
WHERE `cache_logs`.`cache_id`='" . sql_escape($rCache['cache_id']) . "'
|
||||
AND `log_types`.`id`=`cache_logs`.`type`" . $ownlogs . "
|
||||
ORDER BY `cache_logs`.`date` DESC, `cache_logs`.`date_created` DESC
|
||||
LIMIT 6";
|
||||
$rs = sql_slave($sql);
|
||||
$rCache['logs'] = sql_fetch_assoc_table($rs);
|
||||
$rCache['firstlog'] = array_shift($rCache['logs']);
|
||||
|
||||
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;
|
||||
// get direction from search coordinate
|
||||
if ($rCache['distance'] > 0)
|
||||
$rCache['direction'] = geomath::Bearing2Text(geomath::calcBearing($lat_rad / 3.14159 * 180, $lon_rad / 3.14159 * 180, $rCache['latitude'], $rCache['longitude']), 1);
|
||||
else
|
||||
$rCache['direction'] = '';
|
||||
|
||||
// other data
|
||||
$rCache['icon'] = getCacheIcon($login->userid, $rCache['cache_id'], $rCache['status'], $rCache['user_id'], $rCache['icon_large']);
|
||||
$rCache['redname'] = ($rCache['status']==5 || $rCache['status']==7);
|
||||
|
||||
$caches[] = $rCache;
|
||||
}
|
||||
mysql_free_result($rs_caches);
|
||||
|
||||
tpl_set_var('results', $caches_output);
|
||||
$tpl->assign('caches', $caches);
|
||||
|
||||
// more than one page?
|
||||
if ($resultcount <= $caches_per_page)
|
||||
@@ -201,9 +116,9 @@ function search_output()
|
||||
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> ';
|
||||
$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> ';
|
||||
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> ';
|
||||
$pages = ' <img src="resource2/ocstyle/images/navigation/16x16-browse-first-inactive.png" width="16" height="16"> <img src="resource2/ocstyle/images/navigation/16x16-browse-prev-inactive.png" width="16" height="16"> ';
|
||||
|
||||
$frompage = ($startat / $caches_per_page) - 3;
|
||||
if ($frompage < 1) $frompage = 1;
|
||||
@@ -222,41 +137,130 @@ function search_output()
|
||||
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>';
|
||||
$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 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);
|
||||
$tpl->assign('pages', $pages);
|
||||
$tpl->assign('showonmap', $showonmap);
|
||||
|
||||
// downloads
|
||||
tpl_set_var('queryid', $options['queryid']);
|
||||
tpl_set_var('startat', $startat);
|
||||
|
||||
tpl_set_var('startatp1', min($resultcount,$startat + 1));
|
||||
$tpl->assign('queryid', $options['queryid']);
|
||||
|
||||
$tpl->assign('startatp1', min($resultcount,$startat + 1));
|
||||
if (($resultcount - $startat) < 500)
|
||||
tpl_set_var('endat', $startat + $resultcount - $startat);
|
||||
$tpl->assign('endat', $startat + $resultcount - $startat);
|
||||
else
|
||||
tpl_set_var('endat', $startat + 500);
|
||||
$tpl->assign('endat', $startat + 500);
|
||||
|
||||
// kompatibilität!
|
||||
if ($distance_unit == 'sm')
|
||||
tpl_set_var('distanceunit', 'mi');
|
||||
$tpl->assign('distanceunit', 'mi');
|
||||
else if ($distance_unit == 'nm')
|
||||
tpl_set_var('distanceunit', 'sm');
|
||||
$tpl->assign('distanceunit', 'sm');
|
||||
else
|
||||
tpl_set_var('distanceunit', $distance_unit);
|
||||
$tpl->assign('distanceunit', $distance_unit);
|
||||
|
||||
tpl_set_var('displaylastlogs', $options['sort'] == 'bymylastlog' ? 'none' : 'inline');
|
||||
tpl_set_var('displayownlogs', $options['sort'] == 'bymylastlog' ? 'inline' : 'none');
|
||||
$tpl->assign('displayownlogs', $options['sort'] == 'bymylastlog');
|
||||
$tpl->assign('search_headline_caches', $calledbysearch);
|
||||
|
||||
if ($sqldebug == true)
|
||||
sqldbg_end();
|
||||
else
|
||||
tpl_BuildTemplate();
|
||||
$tpl->display();
|
||||
}
|
||||
|
||||
|
||||
function dateDiff($interval, $dateTimeBegin, $dateTimeEnd)
|
||||
{
|
||||
//Parse about any English textual datetime
|
||||
//$dateTimeBegin, $dateTimeEnd
|
||||
|
||||
$dateTimeBegin = strtotime($dateTimeBegin);
|
||||
if ($dateTimeBegin === -1)
|
||||
return("..begin date Invalid");
|
||||
|
||||
$dateTimeEnd = strtotime($dateTimeEnd);
|
||||
if ($dateTimeEnd === -1)
|
||||
return("..end date Invalid");
|
||||
|
||||
$dif = $dateTimeEnd - $dateTimeBegin;
|
||||
|
||||
switch($interval)
|
||||
{
|
||||
case "s"://seconds
|
||||
return($dif);
|
||||
|
||||
case "n"://minutes
|
||||
return(floor($dif/60)); //60s=1m
|
||||
|
||||
case "h"://hours
|
||||
return(floor($dif/3600)); //3600s=1h
|
||||
|
||||
case "d"://days
|
||||
return(floor($dif/86400)); //86400s=1d
|
||||
|
||||
case "ww"://Week
|
||||
return(floor($dif/604800)); //604800s=1week=1semana
|
||||
|
||||
case "m": //similar result "m" dateDiff Microsoft
|
||||
$monthBegin = (date("Y",$dateTimeBegin)*12) + date("n",$dateTimeBegin);
|
||||
$monthEnd = (date("Y",$dateTimeEnd)*12) + date("n",$dateTimeEnd);
|
||||
$monthDiff = $monthEnd - $monthBegin;
|
||||
return($monthDiff);
|
||||
|
||||
case "yyyy": //similar result "yyyy" dateDiff Microsoft
|
||||
return(date("Y",$dateTimeEnd) - date("Y",$dateTimeBegin));
|
||||
|
||||
default:
|
||||
return(floor($dif/86400)); //86400s=1d
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getCacheIcon($user_id, $cache_id, $cache_status, $cache_userid, $iconname)
|
||||
{
|
||||
$iconname = mb_eregi_replace("cache/", "", $iconname);
|
||||
$iconext = "." . mb_eregi_replace("^.*\.", "", $iconname);
|
||||
$iconname = mb_eregi_replace("\..*", "", $iconname);
|
||||
|
||||
// add status
|
||||
switch ($cache_status)
|
||||
{
|
||||
case 1: $iconname .= "-s"; break;
|
||||
case 2: $iconname .= "-n"; break;
|
||||
case 3: $iconname .= "-a"; break;
|
||||
case 4: $iconname .= "-a"; break;
|
||||
case 5: $iconname .= "-s"; break; // fix for RT ticket #3403
|
||||
case 6: $iconname .= "-a"; break;
|
||||
case 7: $iconname .= "-a"; break;
|
||||
}
|
||||
|
||||
// mark if (not) found
|
||||
if ($user_id)
|
||||
{
|
||||
if ($cache_userid == $user_id)
|
||||
{
|
||||
$iconname .= "-owner";
|
||||
}
|
||||
else
|
||||
{
|
||||
$logtype = sql_value_slave("
|
||||
SELECT `type`
|
||||
FROM `cache_logs`
|
||||
WHERE `cache_id`='&1' AND `user_id`='&2' AND `type` IN (1,2,7)
|
||||
ORDER BY `type`
|
||||
LIMIT 1",
|
||||
0, $cache_id, $user_id);
|
||||
|
||||
if ($logtype == 1 || $logtype == 7)
|
||||
$iconname .= '-found';
|
||||
elseif ($logtype == 2)
|
||||
$iconname .= '-dnf';
|
||||
}
|
||||
}
|
||||
|
||||
return $iconname . $iconext;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/****************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
functions for the search-engine
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
/* begin conversion rules */
|
||||
|
||||
$search_simplerules[] = array('qu', 'k');
|
||||
$search_simplerules[] = array('ts', 'z');
|
||||
$search_simplerules[] = array('tz', 'z');
|
||||
$search_simplerules[] = array('alp', 'alb');
|
||||
$search_simplerules[] = array('y', 'i');
|
||||
$search_simplerules[] = array('ai', 'ei');
|
||||
$search_simplerules[] = array('ou', 'u');
|
||||
$search_simplerules[] = array('th', 't');
|
||||
$search_simplerules[] = array('ph', 'f');
|
||||
$search_simplerules[] = array('oh', 'o');
|
||||
$search_simplerules[] = array('ah', 'a');
|
||||
$search_simplerules[] = array('eh', 'e');
|
||||
$search_simplerules[] = array('aux', 'o');
|
||||
$search_simplerules[] = array('eau', 'o');
|
||||
$search_simplerules[] = array('eux', 'oe');
|
||||
$search_simplerules[] = array('^ch', 'sch');
|
||||
$search_simplerules[] = array('ck', 'k');
|
||||
$search_simplerules[] = array('ie', 'i');
|
||||
$search_simplerules[] = array('ih', 'i');
|
||||
$search_simplerules[] = array('ent', 'end');
|
||||
$search_simplerules[] = array('uh', 'u');
|
||||
$search_simplerules[] = array('sh', 'sch');
|
||||
$search_simplerules[] = array('ver', 'wer');
|
||||
$search_simplerules[] = array('dt', 't');
|
||||
$search_simplerules[] = array('hard', 'hart');
|
||||
$search_simplerules[] = array('egg', 'ek');
|
||||
$search_simplerules[] = array('eg', 'ek');
|
||||
$search_simplerules[] = array('cr', 'kr');
|
||||
$search_simplerules[] = array('ca', 'ka');
|
||||
$search_simplerules[] = array('ce', 'ze');
|
||||
$search_simplerules[] = array('x', 'ks');
|
||||
$search_simplerules[] = array('ve', 'we');
|
||||
$search_simplerules[] = array('va', 'wa');
|
||||
|
||||
/* end conversion rules */
|
||||
|
||||
function search_text2simple($str)
|
||||
{
|
||||
global $search_simplerules;
|
||||
|
||||
$str = search_text2sort($str);
|
||||
|
||||
// regeln anwenden
|
||||
foreach ($search_simplerules AS $rule)
|
||||
{
|
||||
$str = mb_ereg_replace($rule[0], $rule[1], $str);
|
||||
}
|
||||
|
||||
// doppelte chars ersetzen
|
||||
for ($c = ord('a'); $c <= ord('z'); $c++)
|
||||
$str = mb_ereg_replace(chr($c) . chr($c), chr($c), $str);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
function search_text2sort($str)
|
||||
{
|
||||
$str = mb_strtolower($str);
|
||||
|
||||
// alles was nicht a-z ist ersetzen
|
||||
$str = mb_ereg_replace('0', '', $str);
|
||||
$str = mb_ereg_replace('1', '', $str);
|
||||
$str = mb_ereg_replace('2', '', $str);
|
||||
$str = mb_ereg_replace('3', '', $str);
|
||||
$str = mb_ereg_replace('4', '', $str);
|
||||
$str = mb_ereg_replace('5', '', $str);
|
||||
$str = mb_ereg_replace('6', '', $str);
|
||||
$str = mb_ereg_replace('7', '', $str);
|
||||
$str = mb_ereg_replace('8', '', $str);
|
||||
$str = mb_ereg_replace('9', '', $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);
|
||||
|
||||
// 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);
|
||||
|
||||
// sonstiges
|
||||
$str = str_replace('', '', $str);
|
||||
|
||||
// der rest
|
||||
$str = mb_ereg_replace('[^a-z]', '', $str);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
kml search output
|
||||
****************************************************************************/
|
||||
|
||||
$search_output_file_download = true;
|
||||
$content_type_plain = 'vnd.google-earth.kml';
|
||||
$content_type_zipped = 'vnd.google-earth.kmz';
|
||||
|
||||
|
||||
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("templates2/$style/search.result.caches.kml.head.tpl");
|
||||
|
||||
$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.'ocstyle/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);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
|
||||
loc search output
|
||||
****************************************************************************/
|
||||
|
||||
@@ -13,24 +13,28 @@
|
||||
|
||||
function search_output()
|
||||
{
|
||||
global $opt;
|
||||
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 =
|
||||
$server_address = $opt['page']['absolute_url'];
|
||||
$server_domain = parse_url($server_address, PHP_URL_HOST);
|
||||
|
||||
$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">http://www.opencaching.de/viewcache.php?cacheid={cacheid}</link>
|
||||
<link text="Beschreibung">'.$server_address.'viewcache.php?cacheid={cacheid}</link>
|
||||
</waypoint>
|
||||
';
|
||||
|
||||
$locFoot = '</loc>';
|
||||
|
||||
append_output($locHead);
|
||||
|
||||
|
||||
/*
|
||||
{waypoint}
|
||||
status -> {archivedflag}
|
||||
@@ -61,16 +65,16 @@ function search_output()
|
||||
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);
|
||||
|
||||
$thisline = mb_ereg_replace('{name}', $r['name'], $thisline);
|
||||
|
||||
if (($r['status'] == 2) || ($r['status'] == 3) || ($r['status'] == 6))
|
||||
{
|
||||
if ($r['status'] == 2)
|
||||
@@ -82,30 +86,15 @@ function search_output()
|
||||
}
|
||||
else
|
||||
$thisline = mb_ereg_replace('{archivedflag}', '', $thisline);
|
||||
|
||||
$thisline = mb_ereg_replace('{username}', xmlentities($r['username']), $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);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -6,16 +6,10 @@
|
||||
*
|
||||
* 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))
|
||||
@@ -25,14 +19,12 @@
|
||||
}
|
||||
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("INSERT INTO `map2_result` (`slave_id`, `sqlchecksum`, `sqlquery`, `date_created`, `date_lastqueried`) VALUES ('&1', '&2', '&3', NOW(), NOW())", $db['slave_id'], $sqlchecksum, $cachesFilter."\n".$sqlFilter);
|
||||
$resultId = sql_insert_id();
|
||||
|
||||
sql_slave("INSERT IGNORE INTO `map2_data` (`result_id`, `cache_id`) SELECT '&1', `cache_id` FROM `tmpmapresult`", $resultId);
|
||||
sql_slave("DROP TEMPORARY TABLE `tmpmapresult`");
|
||||
@@ -63,7 +55,7 @@
|
||||
}
|
||||
sql_free_result($rs);
|
||||
|
||||
tpl_redirect('map2.php?queryid=' . $options['queryid'] . '&resultid=' . $resultId . $bounds_param);
|
||||
$tpl->redirect('map2.php?queryid=' . $options['queryid'] . '&resultid=' . $resultId . $bounds_param);
|
||||
}
|
||||
else
|
||||
echo $resultId;
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
|
||||
ov2 search output
|
||||
****************************************************************************/
|
||||
|
||||
require_once($opt['rootpath'] . 'lib2/charset.inc.php');
|
||||
|
||||
$search_output_file_download = true;
|
||||
$content_type_plain = 'application/ov2';
|
||||
|
||||
@@ -68,7 +70,7 @@ function search_output()
|
||||
|
||||
$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);
|
||||
@@ -77,11 +79,7 @@ function search_output()
|
||||
|
||||
function convert_string($str)
|
||||
{
|
||||
$newstr = iconv("UTF-8", "ISO-8859-1", $str);
|
||||
if ($newstr == false)
|
||||
return "--- charset error ---";
|
||||
else
|
||||
return $newstr;
|
||||
return utf8ToIso88591($str);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
|
||||
ovl search output for TOP25, TOP50 etc.
|
||||
****************************************************************************/
|
||||
|
||||
require_once($opt['rootpath'] . 'lib2/charset.inc.php');
|
||||
|
||||
$search_output_file_download = true;
|
||||
$content_type_plain = 'application/ovl';
|
||||
|
||||
@@ -43,16 +45,16 @@ function search_output()
|
||||
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('{cachename}', utf8ToIso88591($r['name']), $thisline);
|
||||
$thisline = mb_ereg_replace('{symbolnr1}', $nr, $thisline);
|
||||
$thisline = mb_ereg_replace('{symbolnr2}', $nr + 1, $thisline);
|
||||
|
||||
@@ -60,19 +62,10 @@ function search_output()
|
||||
$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;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -3,7 +3,7 @@
|
||||
For license information see doc/license.txt
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
|
||||
GPX search output
|
||||
****************************************************************************/
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
function search_output()
|
||||
{
|
||||
global $absolute_server_URI, $locale;
|
||||
global $opt;
|
||||
global $converted_from_html;
|
||||
global $phpzip, $bUseZip;
|
||||
|
||||
@@ -29,7 +29,7 @@ Land: {country}
|
||||
Cacheart: {type}
|
||||
Behälter: {container}
|
||||
D/T: {difficulty}/{terrain}
|
||||
Online: " . $absolute_server_URI . "viewcache.php?wp={waypoint}
|
||||
Online: " . $opt['page']['absolute_url'] . "viewcache.php?wp={waypoint}
|
||||
|
||||
Kurzbeschreibung: {shortdesc}
|
||||
|
||||
@@ -63,10 +63,10 @@ Logeinträge:
|
||||
`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`,
|
||||
`sys_trans_text`.`text` AS `country`,
|
||||
`cache_size`.`de` `size`,
|
||||
`cache_type`.`de` `type`,
|
||||
`cache_status`.`de` `status`,
|
||||
@@ -79,29 +79,26 @@ Logeinträge:
|
||||
`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`');
|
||||
`searchtmp`
|
||||
INNER JOIN `caches` ON `searchtmp`.`cache_id`=`caches`.`cache_id`
|
||||
INNER JOIN `cache_desc` ON `cache_desc`.`cache_id`=`caches`.`cache_id`
|
||||
AND `caches`.`default_desclang`=`cache_desc`.`language`
|
||||
INNER JOIN `cache_type` ON `cache_type`.`id`=`caches`.`type`
|
||||
INNER JOIN `cache_size` ON `cache_size`.`id`=`caches`.`size`
|
||||
INNER JOIN `cache_status` ON `cache_status`.`id`=`caches`.`status`
|
||||
INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`
|
||||
LEFT JOIN `countries` ON `countries`.`short`=`caches`.`country`
|
||||
LEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`countries`.`trans_id`
|
||||
AND `sys_trans_text`.`lang`=\'&1\'',
|
||||
$opt['template']['locale']);
|
||||
|
||||
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);
|
||||
|
||||
@@ -110,17 +107,17 @@ Logeinträge:
|
||||
$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);
|
||||
|
||||
$thisline = mb_ereg_replace('{country}', $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('{hints}', str_rot13_gc(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);
|
||||
$r['user_id'], $r['username'], $r['data_license'], $r['cacheid'], $opt['template']['locale'], true, false, true);
|
||||
if ($license != "")
|
||||
$license = "\r\n\r\n$license";
|
||||
|
||||
@@ -134,11 +131,11 @@ Logeinträge:
|
||||
$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);
|
||||
|
||||
@@ -153,7 +150,7 @@ Logeinträge:
|
||||
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";
|
||||
@@ -161,9 +158,9 @@ Logeinträge:
|
||||
$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);
|
||||
@@ -184,12 +181,11 @@ Logeinträge:
|
||||
}
|
||||
mysql_free_result($rs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function decodeEntities($str)
|
||||
{
|
||||
$str = html_entity_decode($str, ENT_COMPAT, "UTF-8");
|
||||
return $str;
|
||||
return html_entity_decode($str, ENT_COMPAT, "UTF-8");
|
||||
}
|
||||
|
||||
function html2txt($html)
|
||||
@@ -201,7 +197,7 @@ Logeinträge:
|
||||
$str = decodeEntities($str);
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
function lf2crlf($str)
|
||||
{
|
||||
return mb_ereg_replace("\r\r\n" ,"\r\n" , mb_ereg_replace("\n" ,"\r\n" , $str));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/***************************************************************************
|
||||
For license information see doc/license.txt
|
||||
|
||||
|
||||
XML search output
|
||||
****************************************************************************/
|
||||
|
||||
@@ -11,9 +11,9 @@ $search_output_file_download = false;
|
||||
|
||||
function search_output()
|
||||
{
|
||||
global $sqldebug;
|
||||
global $opt;
|
||||
global $distance_unit, $startat, $count, $sql, $sqlLimit;
|
||||
|
||||
|
||||
$encoding = 'UTF-8';
|
||||
|
||||
$xmlLine = " <cache>
|
||||
@@ -48,15 +48,12 @@ function search_output()
|
||||
mysql_free_result($rsCount);
|
||||
|
||||
// start output
|
||||
if ($sqldebug == false)
|
||||
{
|
||||
header("Content-type: application/xml; charset=".$encoding);
|
||||
//header("Content-Disposition: attachment; filename=" . $sFilebasename . ".txt");
|
||||
}
|
||||
|
||||
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";
|
||||
@@ -64,44 +61,50 @@ function search_output()
|
||||
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`
|
||||
$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` `countrycode`,
|
||||
`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`,
|
||||
`sys_trans_text`.`text` `country`
|
||||
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`');
|
||||
INNER JOIN `cache_size` ON `caches`.`size`=`cache_size`.`id`
|
||||
LEFT JOIN `countries` ON `countries`.`short`=`caches`.`country`
|
||||
LEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`countries`.`trans_id`
|
||||
AND `sys_trans_text`.`lang`='&1'",
|
||||
$opt['template']['locale']);
|
||||
|
||||
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);
|
||||
@@ -111,16 +114,16 @@ function search_output()
|
||||
$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('{country}', text_xmlentities($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('{hints}', str_rot13_gc(decodeEntities(filterevilchars(strip_tags($r['hint'])))), $thisline);
|
||||
|
||||
$thisline = str_replace('{shortdesc}', filterevilchars($r['short_desc']), $thisline);
|
||||
|
||||
|
||||
if ($r['html'] == 0)
|
||||
{
|
||||
$thisline = str_replace('{htmlwarn}', '', $thisline);
|
||||
@@ -131,14 +134,14 @@ function search_output()
|
||||
$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);
|
||||
|
||||
@@ -147,7 +150,7 @@ function search_output()
|
||||
|
||||
$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 = str_replace('{distance}', text_xmlentities(sprintf("%01.1f", $r['distance'])), $thisline);
|
||||
|
||||
$thisline = lf2crlf($thisline);
|
||||
|
||||
@@ -155,11 +158,16 @@ function search_output()
|
||||
}
|
||||
mysql_free_result($rs);
|
||||
sql_slave('DROP TABLE `searchtmp`');
|
||||
if ($sqldebug == true) sqldbg_end();
|
||||
|
||||
echo "</result>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
function decodeEntities($str)
|
||||
{
|
||||
return html_entity_decode($str, ENT_COMPAT, "UTF-8");
|
||||
}
|
||||
|
||||
function html2txt($html)
|
||||
{
|
||||
$str = str_replace("\r\n", '', $html);
|
||||
@@ -168,24 +176,24 @@ function search_output()
|
||||
$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);
|
||||
$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);
|
||||
|
||||
|
||||
@@ -1410,7 +1410,6 @@ class Smarty
|
||||
*/
|
||||
function _compile_resource($resource_name, $compile_path)
|
||||
{
|
||||
|
||||
$_params = array('resource_name' => $resource_name);
|
||||
if (!$this->_fetch_resource_info($_params)) {
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,271 @@
|
||||
<?PHP
|
||||
/** SS_ZIP class is designed to work with ZIP archives
|
||||
@author Yuriy Horobey, smiledsoft.com
|
||||
@email info@smiledsoft.com
|
||||
*/
|
||||
class ss_zip{
|
||||
/** contains whole zipfile
|
||||
@see ss_zip::archive()
|
||||
@see ss_zip::ss_zip()
|
||||
*/
|
||||
var $zipfile="";
|
||||
/** compression level */
|
||||
var $complevel=6;
|
||||
/** entry counter */
|
||||
var $cnt=0;
|
||||
/** current offset in zipdata segment */
|
||||
var $offset=0;
|
||||
/** index of current entry
|
||||
@see ss_zip::read()
|
||||
*/
|
||||
var $idx=0;
|
||||
/**
|
||||
ZipData segment, each element of this array contains local file header plus zipped data
|
||||
*/
|
||||
var $zipdata=array();
|
||||
/** central directory array */
|
||||
var $cdir=array();
|
||||
/** constructor
|
||||
@param string zipfile if not empty must contain path to valid zip file, ss_zip will try to open and parse it.
|
||||
If this parameter is empty, the new empty zip archive is created. This parameter has no meaning in LIGHT verion, please upgrade to PROfessional version.
|
||||
@param int complevel compression level, 1-minimal compression, 9-maximal, default is 6
|
||||
*/
|
||||
function ss_zip($zipfile="",$complevel=6){
|
||||
$this->clear();
|
||||
if($complevel<1)$complevel=1;
|
||||
if($complevel>9)$complevel=9;
|
||||
$this->complevel=$complevel;
|
||||
$this->open($zipfile);
|
||||
}
|
||||
|
||||
/**Resets the objec, clears all the structures
|
||||
*/
|
||||
function clear(){
|
||||
$this->zipfile="";
|
||||
$this->complevel=6;
|
||||
$this->cnt=0;
|
||||
$this->offset=0;
|
||||
$this->idx=0;
|
||||
$this->zipdata=array();
|
||||
$this->cdir=array();
|
||||
}
|
||||
/**opens zip file.
|
||||
<center><hr nashade>*** This functionality is available in PRO version only. ***<br><a href='http://smiledsoft.com/demos/phpzip/' target='_blank'>please upgrade </a><hr nashade></center>
|
||||
This function opens file pointed by zipfile parameter and creates all necessary structures
|
||||
@param str zipfile path to the file
|
||||
@param bool append if true the newlly opened archive will be appended to existing object structure
|
||||
*/
|
||||
function open($zipfile, $append=false){}
|
||||
|
||||
|
||||
/**saves to the disc or sends zipfile to the browser.
|
||||
@param str zipfile path under which to store the file on the server or file name under which the browser will receive it.
|
||||
If you are saving to the server, you are responsible to obtain appropriate write permissions for this operation.
|
||||
@param char where indicates where should the file be sent
|
||||
<ul>
|
||||
<li>'f' -- filesystem </li>
|
||||
<li>'b' -- browser</li>
|
||||
<li>'r' -- raw</li>
|
||||
</ul>
|
||||
Please remember that there should not be any other output before you call this function. The only exception is
|
||||
that other headers may be sent. See <a href='http://php.net/header' target='_blank'>http://php.net/header</a>
|
||||
*/
|
||||
function save($zipfile, $where='f'){
|
||||
if(!$this->zipfile)$this->archive();
|
||||
$zipfile=trim($zipfile);
|
||||
|
||||
if(strtolower(trim($where))=='f'){
|
||||
$this->_write($zipfile,$this->zipfile);
|
||||
}elseif(strtolower(trim($where))=='r'){
|
||||
$zipfile = basename($zipfile);
|
||||
print $this->archive();
|
||||
}else{
|
||||
$zipfile = basename($zipfile);
|
||||
header("Content-type: application/octet-stream");
|
||||
header("Content-disposition: attachment; filename=\"$zipfile\"");
|
||||
print $this->archive();
|
||||
}
|
||||
}
|
||||
|
||||
/** adds data to zip file
|
||||
@param str filename path under which the content of data parameter will be stored into the zip archive
|
||||
@param str data content to be stored under name given by path parameter
|
||||
@see ss_zip::add_file()
|
||||
*/
|
||||
function add_data($filename,$data=null){
|
||||
|
||||
$filename=trim($filename);
|
||||
$filename=str_replace('\\', '/', $filename);
|
||||
if($filename[0]=='/') $filename=substr($filename,1);
|
||||
|
||||
if( ($attr=(($datasize = strlen($data))?32:16))==32 ){
|
||||
$crc = crc32($data);
|
||||
$gzdata = gzdeflate($data,$this->complevel);
|
||||
$gzsize = strlen($gzdata);
|
||||
$dir=dirname($filename);
|
||||
// if($dir!=".") $this->add_data("$dir/");
|
||||
}else{
|
||||
$crc = 0;
|
||||
$gzdata = "";
|
||||
$gzsize = 0;
|
||||
|
||||
}
|
||||
$fnl=strlen($filename);
|
||||
$fh = "\x14\x00"; // ver needed to extract
|
||||
$fh .= "\x00\x00"; // gen purpose bit flag
|
||||
$fh .= "\x08\x00"; // compression method
|
||||
$fh .= "\x00\x00\x00\x00"; // last mod time and date
|
||||
$fh .=pack("V3v2",
|
||||
$crc, //crc
|
||||
$gzsize,//c size
|
||||
$datasize,//unc size
|
||||
$fnl, //fname lenght
|
||||
0 //extra field length
|
||||
);
|
||||
|
||||
|
||||
//local file header
|
||||
$lfh="PK\x03\x04";
|
||||
$lfh .= $fh.$filename;
|
||||
$zipdata = $lfh;
|
||||
$zipdata .= $gzdata;
|
||||
$zipdata .= pack("V3",$crc,$gzsize,$datasize);
|
||||
$this->zipdata[]=$zipdata;
|
||||
//Central Directory Record
|
||||
$cdir="PK\x01\x02";
|
||||
$cdir.=pack("va*v3V2",
|
||||
0,
|
||||
$fh,
|
||||
0, // file comment length
|
||||
0, // disk number start
|
||||
0, // internal file attributes
|
||||
$attr, // external file attributes - 'archive/directory' bit set
|
||||
$this->offset
|
||||
).$filename;
|
||||
|
||||
$this->offset+= 42+$fnl+$gzsize;
|
||||
$this->cdir[]=$cdir;
|
||||
$this->cnt++;
|
||||
$this->idx = $this->cnt-1;
|
||||
}
|
||||
/** adds a file to the archive
|
||||
@param str filename contains valid path to file to be stored in the arcive.
|
||||
@param str storedasname the path under which the file will be stored to the archive. If empty, the file will be stored under path given by filename parameter
|
||||
@see ss_zip::add_data()
|
||||
*/
|
||||
function add_file($filename, $storedasname=""){
|
||||
$fh= fopen($filename,"r");
|
||||
$data=fread($fh,filesize($filename));
|
||||
if(!trim($storedasname))$storedasname=$filename;
|
||||
return $this->add_data($storedasname, $data);
|
||||
}
|
||||
/** compile the arcive.
|
||||
This function produces ZIP archive and returns it.
|
||||
@return str string with zipfile
|
||||
*/
|
||||
function archive(){
|
||||
if(!$this->zipdata) return "";
|
||||
$zds=implode('',$this->zipdata);
|
||||
$cds=implode('',$this->cdir);
|
||||
$zdsl=strlen($zds);
|
||||
$cdsl=strlen($cds);
|
||||
$this->zipfile=
|
||||
$zds
|
||||
.$cds
|
||||
."PK\x05\x06\x00\x00\x00\x00"
|
||||
.pack('v2V2v'
|
||||
,$this->cnt // total # of entries "on this disk"
|
||||
,$this->cnt // total # of entries overall
|
||||
,$cdsl // size of central dir
|
||||
,$zdsl // offset to start of central dir
|
||||
,0); // .zip file comment length
|
||||
return $this->zipfile;
|
||||
}
|
||||
/** changes pointer to current entry.
|
||||
Most likely you will always use it to 'rewind' the archive and then using read()
|
||||
Checks for bopundaries, so will not allow index to be set to values < 0 ro > last element
|
||||
@param int idx the new index to which you want to rewind the archive curent pointer
|
||||
@return int idx the index to which the curent pointer was actually set
|
||||
@see ss_zip::read()
|
||||
*/
|
||||
function seek_idx($idx){
|
||||
if($idx<0)$idx=0;
|
||||
if($idx>=$this->cnt)$idx=$this->cnt-1;
|
||||
$this->idx=$idx;
|
||||
return $idx;
|
||||
}
|
||||
/** Reads an entry from the arcive which is pointed by inner index pointer.
|
||||
<center><hr nashade>*** This functionality is available in PRO version only. ***<br><a href='http://smiledsoft.com/demos/phpzip/' target='_blank'>please upgrade </a><hr nashade></center>
|
||||
The curent index can be changed by seek_idx() method.
|
||||
@return array Returns associative array of the following structure
|
||||
<ul>
|
||||
<li>'idx'=> index of the entry </li>
|
||||
<li>'name'=>full path to the entry </li>
|
||||
<li>'attr'=>integer file attribute of the entry </li>
|
||||
<li>'attrstr'=>string file attribute of the entry <br>
|
||||
This can be:
|
||||
<ul>
|
||||
<li>'file' if the integer attribute was 32</li>
|
||||
<li>'dir' if the integer attribute was 16 or 48</li>
|
||||
<li>'unknown' for other values</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@see ss_zip::seek_idx()
|
||||
*/
|
||||
function read(){}
|
||||
|
||||
|
||||
|
||||
/** Removes entry from the archive.
|
||||
please be very carefull with this function, there is no undo after you save the archive
|
||||
@return bool true on success or false on failure
|
||||
@param int idx
|
||||
*/
|
||||
function remove($idx){}
|
||||
|
||||
|
||||
|
||||
/** extracts data from the archive and return it as a string.
|
||||
<center><hr nashade>*** This functionality is available in PRO version only. ***<br><a href='http://smiledsoft.com/demos/phpzip/' target='_blank'>please upgrade </a><hr nashade></center>
|
||||
This function returns data identified by idx parameter.
|
||||
@param int idx index of the entry
|
||||
@return array returns associative array of the folloving structure:
|
||||
<ul>
|
||||
<li>'file' path under which the entry is stored in the archive</li>
|
||||
<li>'data' In case if the entry was file, contain its data. For directory entry this is empty</li>
|
||||
<li>'size' size of the data</li>
|
||||
<li>'error' the error if any has happened. The bit 0 indicates incorect datasize, bit 1 indicates CRC error</li>
|
||||
</ul>
|
||||
@see ss_zip::extract_file
|
||||
*/
|
||||
function extract_data($idx){}
|
||||
|
||||
|
||||
/** extracts the entry and creates it in the file system.
|
||||
<center><hr nashade>*** This functionality is available in PRO version only. ***<br><a href='http://smiledsoft.com/demos/phpzip/' target='_blank'>please upgrade </a><hr nashade></center>
|
||||
@param int idx Index of the entry
|
||||
@param string path the first part of the path where the entry will be stored. So if this
|
||||
is '/my/server/path' and entry is arhived/file/path/file.txt then the function will attempt to
|
||||
store it under /my/server/path/arhived/file/path/file.txt You are responsible to ensure that you
|
||||
have write permissions for this operation under your operation system.
|
||||
*/
|
||||
function extract_file($idx,$path="."){}
|
||||
|
||||
|
||||
function _check_idx($idx){
|
||||
return $idx>=0 and $idx<$this->cnt;
|
||||
}
|
||||
function _write($name,$data){
|
||||
$fp=fopen($name,"w");
|
||||
fwrite($fp,$data);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
/** debug helper.
|
||||
the only job for this function is take parameter $v and ouput it with print_r() preceding with < xmp > etc
|
||||
The $l is a label like l=myvar
|
||||
*/
|
||||
function dbg($v,$l='var'){echo"<xmp>$l=";print_r($v);echo"</xmp>";}
|
||||
?>
|
||||
+104
-14
@@ -273,27 +273,117 @@ function read_file($filename, $maxlength)
|
||||
return $content;
|
||||
}
|
||||
|
||||
// encodes &<>"'
|
||||
function xmlentities($str)
|
||||
{
|
||||
$from[0] = '&'; $to[0] = '&';
|
||||
$from[1] = '<'; $to[1] = '<';
|
||||
$from[2] = '>'; $to[2] = '>';
|
||||
$from[3] = '"'; $to[3] = '"';
|
||||
$from[4] = '\''; $to[4] = ''';
|
||||
return htmlspecialchars(xmlfilterevilchars($str), ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
for ($i = 0; $i <= 4; $i++)
|
||||
$str = mb_ereg_replace($from[$i], $to[$i], $str);
|
||||
|
||||
return xmlfilterevilchars($str);
|
||||
// encodes &<>
|
||||
// This is ok for XML content text between tags, but not for XML attribute contents.
|
||||
function text_xmlentities($str)
|
||||
{
|
||||
return htmlspecialchars(xmlfilterevilchars($str), ENT_NOQUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
function xmlfilterevilchars($str)
|
||||
{
|
||||
global $sCharset;
|
||||
|
||||
// the same for for ISO-8859-1 and UTF-8
|
||||
$str = mb_ereg_replace('[\x{00}-\x{09}\x{0B}\x{0C}\x{0E}-\x{1F}]*', '', $str);
|
||||
|
||||
return $str;
|
||||
return mb_ereg_replace('[\x{00}-\x{09}\x{0B}\x{0C}\x{0E}-\x{1F}]*', '', $str);
|
||||
}
|
||||
|
||||
|
||||
// decimal longitude to string E/W hhh°mm.mmm
|
||||
function help_lonToDegreeStr($lon)
|
||||
{
|
||||
if ($lon < 0)
|
||||
{
|
||||
$retval = 'W ';
|
||||
$lon = -$lon;
|
||||
}
|
||||
else
|
||||
{
|
||||
$retval = 'E ';
|
||||
}
|
||||
|
||||
$retval = $retval . sprintf("%03d", floor($lon)) . '° ';
|
||||
$lon = $lon - floor($lon);
|
||||
$retval = $retval . sprintf("%06.3f", round($lon * 60, 3)) . '\'';
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// decimal latitude to string N/S hh°mm.mmm
|
||||
function help_latToDegreeStr($lat)
|
||||
{
|
||||
if ($lat < 0)
|
||||
{
|
||||
$retval = 'S ';
|
||||
$lat = -$lat;
|
||||
}
|
||||
else
|
||||
{
|
||||
$retval = 'N ';
|
||||
}
|
||||
|
||||
$retval = $retval . sprintf("%02d", floor($lat)) . '° ';
|
||||
$lat = $lat - floor($lat);
|
||||
$retval = $retval . sprintf("%06.3f", round($lat * 60, 3)) . '\'';
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
|
||||
function escape_javascript($text)
|
||||
{
|
||||
return str_replace('\'', '\\\'', str_replace('"', '"', $text));
|
||||
}
|
||||
|
||||
|
||||
// perform str_rot13 without renaming parts in []
|
||||
function str_rot13_gc($str)
|
||||
{
|
||||
$delimiter[0][0] = '[';
|
||||
$delimiter[0][1] = ']';
|
||||
|
||||
$retval = '';
|
||||
|
||||
while (mb_strlen($retval) < mb_strlen($str))
|
||||
{
|
||||
$nNextStart = false;
|
||||
$sNextEndChar = '';
|
||||
foreach ($delimiter AS $del)
|
||||
{
|
||||
$nThisStart = mb_strpos($str, $del[0], mb_strlen($retval));
|
||||
|
||||
if ($nThisStart !== false)
|
||||
if (($nNextStart > $nThisStart) || ($nNextStart === false))
|
||||
{
|
||||
$nNextStart = $nThisStart;
|
||||
$sNextEndChar = $del[1];
|
||||
}
|
||||
}
|
||||
|
||||
if ($nNextStart === false)
|
||||
{
|
||||
$retval .= str_rot13(mb_substr($str, mb_strlen($retval), mb_strlen($str) - mb_strlen($retval)));
|
||||
}
|
||||
else
|
||||
{
|
||||
// crypted part
|
||||
$retval .= str_rot13(mb_substr($str, mb_strlen($retval), $nNextStart - mb_strlen($retval)));
|
||||
|
||||
// uncrypted part
|
||||
$nNextEnd = mb_strpos($str, $sNextEndChar, $nNextStart);
|
||||
|
||||
if ($nNextEnd === false)
|
||||
$retval .= mb_substr($str, $nNextStart, mb_strlen($str) - mb_strlen($retval));
|
||||
else
|
||||
$retval .= mb_substr($str, $nNextStart, $nNextEnd - $nNextStart + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user