Skip to content

Commit

Permalink
show search results on map; updates #30, updates #235
Browse files Browse the repository at this point in the history
  • Loading branch information
following5 committed Jun 19, 2013
1 parent bfefda8 commit eb4a4ae
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 55 deletions.
2 changes: 2 additions & 0 deletions htdocs/doc/sql/static-data/data.sql
Expand Up @@ -2505,6 +2505,7 @@ INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2083', 'NEW', '
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2084', 'show archived', '2013-04-25 23:00:00'); INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2084', 'show archived', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2085', 'hide archived', '2013-04-25 23:00:00'); INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2085', 'hide archived', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2086', 'unknown search type', '2013-04-25 23:00:00'); INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2086', 'unknown search type', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2087', 'Show on map', '2013-04-25 23:00:00');


-- Table sys_trans_ref -- Table sys_trans_ref
SET NAMES 'utf8'; SET NAMES 'utf8';
Expand Down Expand Up @@ -6462,6 +6463,7 @@ INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUE
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2084', 'DE', 'archivierte einblenden', '2013-04-25 23:00:00'); INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2084', 'DE', 'archivierte einblenden', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2085', 'DE', 'archivierte ausblenden', '2013-04-25 23:00:00'); INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2085', 'DE', 'archivierte ausblenden', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2086', 'DE', 'unbekannter Suchtyp', '2013-04-25 23:00:00'); INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2086', 'DE', 'unbekannter Suchtyp', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2087', 'DE', 'auf Karte anzeigen', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'EN', 'Reorder IDs \r', '2010-09-02 00:15:30'); INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'EN', 'Reorder IDs \r', '2010-09-02 00:15:30');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2', 'EN', 'The database could not be reconnected.', '2010-08-28 11:48:07'); INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2', 'EN', 'The database could not be reconnected.', '2010-08-28 11:48:07');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('3', 'EN', 'Testing – please do not login', '2010-08-28 11:48:07'); INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('3', 'EN', 'Testing – please do not login', '2010-08-28 11:48:07');
Expand Down
1 change: 1 addition & 0 deletions htdocs/lang/de/ocstyle/search.inc.php
Expand Up @@ -95,6 +95,7 @@
$search_in_gm_zip = '<a href="http://maps.google.de/maps?f=q&hl=de&q=' . urlencode("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."&output=kml&zip=1&count=max") . '" title="' . $translate->t('Show in Google Maps','','',0) . '">' . $translate->t('(in GM)','','',0) . '</a>'; $search_in_gm_zip = '<a href="http://maps.google.de/maps?f=q&hl=de&q=' . urlencode("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."&output=kml&zip=1&count=max") . '" title="' . $translate->t('Show in Google Maps','','',0) . '">' . $translate->t('(in GM)','','',0) . '</a>';


$unknown_searchtype = t('unknown search type'); $unknown_searchtype = t('unknown search type');
$showonmap = t('Show on map');




function dateDiff($interval, $dateTimeBegin, $dateTimeEnd) function dateDiff($interval, $dateTimeBegin, $dateTimeEnd)
Expand Down
48 changes: 24 additions & 24 deletions htdocs/lang/de/ocstyle/search.result.caches.tpl.php
Expand Up @@ -27,14 +27,21 @@
?> ?>


<div class="content2-container bg-blue02" style="margin-top:20px;"> <div class="content2-container bg-blue02" style="margin-top:20px;">
<p class="content-title-noshade-size3"> <table cellspacing="0" cellpadding="0" width="100%" border="0"><tr>
<img src="resource2/ocstyle/images/cacheicon/traditional.gif" width="32" height="32" style="align:left;" alt="{t}Search{/t}" />&nbsp; <td style="white-space:nowrap">
{t}{results_count} caches<span style="{search_headline_caches}"> matched</span>{/t} <p class="content-title-noshade-size15" style="padding:0; margin:4px;">&nbsp;{t}{results_count} caches<span style="{search_headline_caches}"> matched</span>{/t}&nbsp;</p>
<span style="font-weight:normal;float:right;font-size:80%;" > </td>
[<a href="query.php?action=save&queryid={queryid}">{t}Save options{/t}</a>]&nbsp; <td style="text-align:right; width:1px">
[<a href="search.php?queryid={queryid}&showresult=0">{t}Edit options{/t}</a>] <a href="search.php?queryid={queryid}&output=map2bounds&showresult=1&skipqueryid=1&expert=0&utf8=1" class="nooutline"><img src="resource2/ocstyle/images/misc/32x32-world.png"/></a>
</span> </td>
</p> <td style="white-space:nowrap; text-align:left; padding-bottom:2px">
<p class="inheader"><a href="search.php?queryid={queryid}&output=map2bounds&showresult=1&skipqueryid=1&expert=0&utf8=1">{showonmap}</a></p>
</td>
<td style="text-align:right; padding-bottom:2px"><p class="inheader">
<span style="white-space:nowrap">[<a href="query.php?action=save&queryid={queryid}">{t}Save options{/t}</a>]</span>
&nbsp;<span style="white-space:nowrap">[<a href="search.php?queryid={queryid}&showresult=0">{t}Edit options{/t}</a>]</span></p>
</td>
</tr></table>
</div> </div>
<div class="buffer" style="height:5px;"></div> <div class="buffer" style="height:5px;"></div>


Expand All @@ -44,9 +51,9 @@
<td class="header-small" colspan="2"> <td class="header-small" colspan="2">
<table width="98.5%"> <table width="98.5%">
<tr> <tr>
<td width="100%">{pages}</td> <td rowspan="1" style="vertical-align:top; width:300px">{pages}</td>
<td>{t}Download{/t}:</td> <td style="text-align:right;">{t}Download{/t}:&nbsp;</td>
<td> <td><nobr>
<select name="wpdownload-page" class="wpdownload" onChange="location.href=this.options[this.selectedIndex].value"> <select name="wpdownload-page" class="wpdownload" onChange="location.href=this.options[this.selectedIndex].value">
<option value="#">{t}Results on this page{/t}</option> <option value="#">{t}Results on this page{/t}</option>
<option value="search.php?queryid={queryid}&output=gpx&startat={startat}">GPX</option> <option value="search.php?queryid={queryid}&output=gpx&startat={startat}">GPX</option>
Expand All @@ -56,8 +63,6 @@
<option value="search.php?queryid={queryid}&output=ovl&startat={startat}">OVL</option> <option value="search.php?queryid={queryid}&output=ovl&startat={startat}">OVL</option>
<option value="search.php?queryid={queryid}&output=txt&startat={startat}">TXT</option> <option value="search.php?queryid={queryid}&output=txt&startat={startat}">TXT</option>
</select> </select>
</td>
<td style="width:120px">
<select name="wpdownload-all" class="wpdownload" onChange="location.href=this.options[this.selectedIndex].value"> <select name="wpdownload-all" class="wpdownload" onChange="location.href=this.options[this.selectedIndex].value">
<option value="#">{t}Result {startatp1} to {endat} (as zip){/t}</option> <option value="#">{t}Result {startatp1} to {endat} (as zip){/t}</option>
<option value="search.php?queryid={queryid}&output=gpx&startat={startat}&count=max&zip=1">GPX</option> <option value="search.php?queryid={queryid}&output=gpx&startat={startat}&count=max&zip=1">GPX</option>
Expand All @@ -66,7 +71,7 @@
<option value="search.php?queryid={queryid}&output=ov2&startat={startat}&count=max&zip=1">OV2</option> <option value="search.php?queryid={queryid}&output=ov2&startat={startat}&count=max&zip=1">OV2</option>
<option value="search.php?queryid={queryid}&output=ovl&startat={startat}&count=max&zip=1">OVL</option> <option value="search.php?queryid={queryid}&output=ovl&startat={startat}&count=max&zip=1">OVL</option>
<option value="search.php?queryid={queryid}&output=txt&startat={startat}&count=max&zip=1">TXT</option> <option value="search.php?queryid={queryid}&output=txt&startat={startat}&count=max&zip=1">TXT</option>
</select> </select></nobr>
</td> </td>
</tr> </tr>
</table> </table>
Expand Down Expand Up @@ -94,12 +99,12 @@
<tr> <tr>
<td colspan="2" class="header-small">{pages}</td> <td colspan="2" class="header-small">{pages}</td>
</tr> </tr>
<tr><td class="spacer" colspan="2">&nbsp;</td></tr> <tr><td style="height:0.6em"></td></tr>
</table> </table>
<table class="content" width="100%"> <table width="100%">
<tr> <tr>
<td><b>{t}Download{/t}:</b></td> <td style="text-align:right; width:50%">{t}Download{/t}:&nbsp;&nbsp;</td>
<td align="right" style="padding-right:20px;"> <td align="right" style="padding-right:20px; white-space:nowrap">
<b>{t}Results on this page:{/t}</b> <b>{t}Results on this page:{/t}</b>
<a href="search.php?queryid={queryid}&output=gpx&startat={startat}" title="{t}GPS Exchange Format .gpx{/t}">GPX</a> <a href="search.php?queryid={queryid}&output=gpx&startat={startat}" title="{t}GPS Exchange Format .gpx{/t}">GPX</a>
<a href="search.php?queryid={queryid}&output=loc&startat={startat}" title="{t}Waypointfile .loc{/t}">LOC</a> <a href="search.php?queryid={queryid}&output=loc&startat={startat}" title="{t}Waypointfile .loc{/t}">LOC</a>
Expand All @@ -108,12 +113,7 @@
<a href="search.php?queryid={queryid}&output=ov2&startat={startat}" title="{t}TomTom POI .ov2{/t}">OV2</a> <a href="search.php?queryid={queryid}&output=ov2&startat={startat}" title="{t}TomTom POI .ov2{/t}">OV2</a>
<a href="search.php?queryid={queryid}&output=ovl&startat={startat}" title="{t}TOP50-Overlay .ovl{/t}">OVL</a> <a href="search.php?queryid={queryid}&output=ovl&startat={startat}" title="{t}TOP50-Overlay .ovl{/t}">OVL</a>
<a href="search.php?queryid={queryid}&output=txt&startat={startat}" title="{t}Textfile .txt{/t}">TXT</a> <a href="search.php?queryid={queryid}&output=txt&startat={startat}" title="{t}Textfile .txt{/t}">TXT</a>
</td> <br />
</tr>
<tr>
<td class="help">
</td>
<td align="right" style="padding-right:20px;">
<b>{t}Result {startatp1} to {endat} (as zip):{/t}</b> <b>{t}Result {startatp1} to {endat} (as zip):{/t}</b>
<a href="search.php?queryid={queryid}&output=gpx&startat={startat}&count=max&zip=1" title="{t}GPS Exchange Format .gpx{/t}">GPX</a> <a href="search.php?queryid={queryid}&output=gpx&startat={startat}&count=max&zip=1" title="{t}GPS Exchange Format .gpx{/t}">GPX</a>
<a href="search.php?queryid={queryid}&output=loc&startat={startat}&count=max&zip=1" title="{t}Waypointfile .loc{/t}">LOC</a> <a href="search.php?queryid={queryid}&output=loc&startat={startat}&count=max&zip=1" title="{t}Waypointfile .loc{/t}">LOC</a>
Expand Down
3 changes: 2 additions & 1 deletion htdocs/lib/search.html.inc.php
Expand Up @@ -325,12 +325,13 @@
//$caches_per_page //$caches_per_page
//count($caches) - 1 //count($caches) - 1
tpl_set_var('pages', $pages); tpl_set_var('pages', $pages);
tpl_set_var('showonmap', $showonmap);


// downloads // downloads
tpl_set_var('queryid', $options['queryid']); tpl_set_var('queryid', $options['queryid']);
tpl_set_var('startat', $startat); tpl_set_var('startat', $startat);


tpl_set_var('startatp1', $startat + 1); tpl_set_var('startatp1', min($resultcount,$startat + 1));


if (($resultcount - $startat) < 500) if (($resultcount - $startat) < 500)
tpl_set_var('endat', $startat + $resultcount - $startat); tpl_set_var('endat', $startat + $resultcount - $startat);
Expand Down
38 changes: 34 additions & 4 deletions htdocs/lib/search.map2.inc.php
Expand Up @@ -10,8 +10,9 @@
***************************************************************************/ ***************************************************************************/


global $dblink, $dbslaveid; global $dblink, $dbslaveid;
$sqlchecksum = sprintf('%u', crc32($sqlFilter));

$sqlchecksum = sprintf('%u', crc32($cachesFilter."\n".$sqlFilter));

/* config */ /* config */
$opt['map']['maxcacheage'] = 3600; $opt['map']['maxcacheage'] = 3600;


Expand All @@ -30,13 +31,42 @@
sql_slave("CREATE TEMPORARY TABLE `tmpmapresult` (`cache_id` INT UNSIGNED NOT NULL, PRIMARY KEY (`cache_id`)) ENGINE=MEMORY"); 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_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, $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); $resultId = mysql_insert_id($dblink);


sql_slave("INSERT IGNORE INTO `map2_data` (`result_id`, `cache_id`) SELECT '&1', `cache_id` FROM `tmpmapresult`", $resultId); sql_slave("INSERT IGNORE INTO `map2_data` (`result_id`, `cache_id`) SELECT '&1', `cache_id` FROM `tmpmapresult`", $resultId);
sql_slave("DROP TEMPORARY TABLE `tmpmapresult`"); sql_slave("DROP TEMPORARY TABLE `tmpmapresult`");
} }


echo $resultId; if ($map2_bounds)
{
$rs = sql_slave("SELECT MIN(`latitude`) AS `lat_min`,
MAX(`latitude`) AS `lat_max`,
MIN(`longitude`) AS `lon_min`,
MAX(`longitude`) AS `lon_max`
FROM `map2_data`, `caches`
WHERE `result_id`='&1'
AND `caches`.`cache_id`=`map2_data`.`cache_id`",
$resultId);
if (($rBounds = sql_fetch_assoc($rs)) && $rBounds['lat_min'] !== null /* >0 caches */)
{
if ($rBounds['lat_min'] == $rBounds['lat_max'] &&
$rBounds['lon_min'] == $rBounds['lon_max']) // 1 Cache
{
$halfwin = 0.02;
$rBounds['lat_min'] -= $halfwin;
$rBounds['lat_max'] += $halfwin;
$rBounds['lon_min'] -= $halfwin;
$rBounds['lon_max'] += $halfwin;
}
$bounds_param = "&lat_min=" . round($rBounds['lat_min'],5) . "&lat_max=" . round($rBounds['lat_max'],5) . '&lon_min=' . round($rBounds['lon_min'],5) . '&lon_max=' . round($rBounds['lon_max'],5);
}
sql_free_result($rs);

tpl_redirect('map2.php?queryid=' . $options['queryid'] . '&resultid=' . $resultId . $bounds_param);
}
else
echo $resultId;

exit; exit;
?> ?>
36 changes: 27 additions & 9 deletions htdocs/map2.php
Expand Up @@ -52,9 +52,10 @@
$nLat2 = isset($_REQUEST['lat2']) ? $_REQUEST['lat2']+0 : 0; $nLat2 = isset($_REQUEST['lat2']) ? $_REQUEST['lat2']+0 : 0;
$cachenames = isset($_REQUEST['cachenames']) ? $_REQUEST['cachenames']+0 : 0; $cachenames = isset($_REQUEST['cachenames']) ? $_REQUEST['cachenames']+0 : 0;
$smallmap = isset($_REQUEST['smallmap']) ? $_REQUEST['smallmap']+0 : 0; $smallmap = isset($_REQUEST['smallmap']) ? $_REQUEST['smallmap']+0 : 0;
$showlockedcaches = isset($_REQUEST['locked']) ? $_REQUEST['locked']<>0 : true;


output_searchresult($nResultId, $compact, $nLon1, $nLon2, $nLat1, $nLat2, output_searchresult($nResultId, $compact, $nLon1, $nLon2, $nLat1, $nLat2,
$cachenames, $smallmap); $cachenames, $smallmap, $showlockedcaches);
} }
else if ($sMode == 'fullscreen' || else if ($sMode == 'fullscreen' ||
($sMode == '' && ($sMode == '' &&
Expand All @@ -70,6 +71,21 @@
$fullscreen = false; $fullscreen = false;
} }


// set queryid data for displaying search results on map
$nQueryId = isset($_REQUEST['queryid']) ? $_REQUEST['queryid']+0 : 0;
$nResultId = isset($_REQUEST['resultid']) ? $_REQUEST['resultid']+0 : 0;
$tpl->assign('queryid',$nQueryId);

if (!isset($_REQUEST['lat_min']))
$tpl->assign('lat_min',null);
else
{
$tpl->assign('lat_min',$_REQUEST['lat_min']);
$tpl->assign('lat_max',$_REQUEST['lat_max']);
$tpl->assign('lon_min',$_REQUEST['lon_min']);
$tpl->assign('lon_max',$_REQUEST['lon_max']);
}

// save options // save options
if (isset($_REQUEST['submit']) && $_REQUEST['submit'] && $login->userid > 0) if (isset($_REQUEST['submit']) && $_REQUEST['submit'] && $login->userid > 0)
{ {
Expand Down Expand Up @@ -386,7 +402,7 @@ function output_namesearch($sName, $nLat, $nLon, $nResultId)
} }


function output_searchresult($nResultId, $compact, $nLon1, $nLon2, $nLat1, $nLat2, function output_searchresult($nResultId, $compact, $nLon1, $nLon2, $nLat1, $nLat2,
$cachenames, $smallmap) $cachenames, $smallmap, $showlockedcaches)
{ {
global $login, $opt, $useragent_msie; global $login, $opt, $useragent_msie;


Expand Down Expand Up @@ -433,7 +449,8 @@ function output_searchresult($nResultId, $compact, $nLon1, $nLon2, $nLat1, $nLat
{ {
$namequery = ($cachenames ? ", `caches`.`name` AS `cachename`" : ""); $namequery = ($cachenames ? ", `caches`.`name` AS `cachename`" : "");
$rs = sql_slave("SELECT SQL_BUFFER_RESULT $rs = sql_slave("SELECT SQL_BUFFER_RESULT
`caches`.`wp_oc`, `caches`.`longitude`, `caches`.`latitude`, distinct `caches`.`wp_oc`,
`caches`.`longitude`, `caches`.`latitude`,
`caches`.`type`, `caches`.`type`,
`caches`.`status`>1 AS `inactive`, `caches`.`status`>1 AS `inactive`,
`caches`.`type`=6 AND `caches`.`date_hidden`+INTERVAL 1 DAY < NOW() AS `oldevent`, `caches`.`type`=6 AND `caches`.`date_hidden`+INTERVAL 1 DAY < NOW() AS `oldevent`,
Expand All @@ -444,19 +461,21 @@ function output_searchresult($nResultId, $compact, $nLon1, $nLon2, $nLat1, $nLat
$namequery . " $namequery . "
FROM `map2_data` FROM `map2_data`
INNER JOIN `caches` ON `map2_data`.`cache_id`=`caches`.`cache_id` INNER JOIN `caches` ON `map2_data`.`cache_id`=`caches`.`cache_id`
LEFT JOIN `user` ON `user`.`user_id`=`caches`.`user_id` INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`
LEFT JOIN `cache_logs` `found_logs` ON `found_logs`.`cache_id`=`caches`.`cache_id` AND `found_logs`.`user_id`='&6' AND `found_logs`.`type` IN (1,7) LEFT JOIN `cache_logs` `found_logs` ON `found_logs`.`cache_id`=`caches`.`cache_id` AND `found_logs`.`user_id`='&6' AND `found_logs`.`type` IN (1,7)
LEFT JOIN `cache_logs` `notfound_logs` ON `notfound_logs`.`cache_id`=`caches`.`cache_id` AND `notfound_logs`.`user_id`='&6' AND `notfound_logs`.`type`=2 LEFT JOIN `cache_logs` `notfound_logs` ON `notfound_logs`.`cache_id`=`caches`.`cache_id` AND `notfound_logs`.`user_id`='&6' AND `notfound_logs`.`type`=2
LEFT JOIN `caches_attributes` ON `caches_attributes`.`cache_id`=`caches`.`cache_id` AND `caches_attributes`.`attrib_id`=6 LEFT JOIN `caches_attributes` ON `caches_attributes`.`cache_id`=`caches`.`cache_id` AND `caches_attributes`.`attrib_id`=6
WHERE `map2_data`.`result_id`='&1' AND `caches`.`longitude`>'&2' AND `caches`.`longitude`<'&3' AND `caches`.`latitude`>'&4' AND `caches`.`latitude`<'&5' WHERE `map2_data`.`result_id`='&1' AND `caches`.`longitude`>'&2' AND `caches`.`longitude`<'&3' AND `caches`.`latitude`>'&4' AND `caches`.`latitude`<'&5'
AND `caches`.`status`<>6 /* hide vandalized listings, locked duplicates etc. */ AND `caches`.`status`<>'&7' /* hide vandalized listings, locked duplicates etc. */
AND `caches`.`status`<>7 /* ... and locked/invisible caches */ AND `caches`.`status`<>7 /* ... and locked/invisible caches */
ORDER BY `caches`.`status` DESC, `oconly` AND NOT (`found` OR `notfound`), NOT (`found` OR `notfound`), `caches`.`type`<>4, MD5(`caches`.`name`) ORDER BY `caches`.`status` DESC, `oconly` AND NOT (`found` OR `notfound`), NOT (`found` OR `notfound`), `caches`.`type`<>4, MD5(`caches`.`name`)
LIMIT &7", LIMIT &8",
// sort in reverse order, because last are on top of map; // sort in reverse order, because last are on top of map;
// fixed order avoids oscillations when panning; // fixed order avoids oscillations when panning;
// MD5 pseudo-randomness gives equal changes for all kinds of caches to be on top // MD5 pseudo-randomness gives equal changes for all kinds of caches to be on top
$nResultId, $nLon1, $nLon2, $nLat1, $nLat2, $login->userid, $maxrecords); $nResultId, $nLon1, $nLon2, $nLat1, $nLat2, $login->userid,
$showlockedcaches ? 0 : 6,
$maxrecords);


while ($r = sql_fetch_assoc($rs)) while ($r = sql_fetch_assoc($rs))
{ {
Expand All @@ -466,7 +485,6 @@ function output_searchresult($nResultId, $compact, $nLon1, $nLon2, $nLat1, $nLat
if ($r['notfound']) $flags |= 4; if ($r['notfound']) $flags |= 4;
if ($r['inactive'] || $r['oldevent']) $flags |= 8; if ($r['inactive'] || $r['oldevent']) $flags |= 8;
if ($r['oconly']) $flags |= 16; if ($r['oconly']) $flags |= 16;

if ($compact) if ($compact)
echo '<c d="' . echo '<c d="' .
xmlentities( xmlentities(
Expand Down
1 change: 1 addition & 0 deletions htdocs/resource2/ocstyle/css/style_screen.css
Expand Up @@ -302,6 +302,7 @@ p.embed-caption {float: left; margin: 5px 0px 0px 0px; padding: 0px; font-style:
div.cachedesc {font-size: 120%;} div.cachedesc {font-size: 120%;}
div.cachedesc p {font-size: 100%;} div.cachedesc p {font-size: 100%;}
div.welcome p {line-height: 1.6em;} div.welcome p {line-height: 1.6em;}
p.inheader {margin:4px; font-size:125%;}


/* Quote */ /* Quote */
p.quote {clear: left; margin: 0em 30px 0.6em 30px; line-height: 120%; font-size: 110%;} p.quote {clear: left; margin: 0em 30px 0.6em 30px; line-height: 120%; font-size: 110%;}
Expand Down
36 changes: 28 additions & 8 deletions htdocs/search.php
Expand Up @@ -445,10 +445,13 @@
if (!isset($options['showresult'])) $options['showresult']='0'; if (!isset($options['showresult'])) $options['showresult']='0';
if ($options['showresult'] == 1) if ($options['showresult'] == 1)
{ {

//=============================================================== //===============================================================
// X6. build SQL statement from search options // X6. build SQL statement from search options
//=============================================================== //===============================================================


$cachesFilter = '';

if(!isset($options['output'])) $options['output']=''; if(!isset($options['output'])) $options['output']='';
if ((mb_strpos($options['output'], '.') !== false) || if ((mb_strpos($options['output'], '.') !== false) ||
(mb_strpos($options['output'], '/') !== false) || (mb_strpos($options['output'], '/') !== false) ||
Expand Down Expand Up @@ -551,7 +554,8 @@
$lon_rad = $lon * 3.14159 / 180; $lon_rad = $lon * 3.14159 / 180;
$lat_rad = $lat * 3.14159 / 180; $lat_rad = $lat * 3.14159 / 180;


sql_slave('CREATE TEMPORARY TABLE result_caches ENGINE=MEMORY $cachesFilter =
'CREATE TEMPORARY TABLE result_caches ENGINE=MEMORY
SELECT SELECT
(' . getSqlDistanceFormula($lon, $lat, $distance, $multiplier[$distance_unit]) . ') `distance`, (' . getSqlDistanceFormula($lon, $lat, $distance, $multiplier[$distance_unit]) . ') `distance`,
`caches`.`cache_id` `cache_id` `caches`.`cache_id` `cache_id`
Expand All @@ -560,7 +564,8 @@
AND `longitude` < ' . ($lon + $max_lon_diff) . ' AND `longitude` < ' . ($lon + $max_lon_diff) . '
AND `latitude` > ' . ($lat - $max_lat_diff) . ' AND `latitude` > ' . ($lat - $max_lat_diff) . '
AND `latitude` < ' . ($lat + $max_lat_diff) . ' AND `latitude` < ' . ($lat + $max_lat_diff) . '
HAVING `distance` < ' . ($distance+0)); HAVING `distance` < ' . ($distance+0);
sql_slave($cachesFilter);
sql_slave('ALTER TABLE result_caches ADD PRIMARY KEY ( `cache_id` )'); sql_slave('ALTER TABLE result_caches ADD PRIMARY KEY ( `cache_id` )');


$sql_select[] = '`result_caches`.`cache_id`'; $sql_select[] = '`result_caches`.`cache_id`';
Expand Down Expand Up @@ -691,7 +696,8 @@
//TODO: check!!! //TODO: check!!!
$max_lon_diff = $distance * 180 / (abs(sin((90 - $lat) * 3.14159 / 180 )) * 6378 * $multiplier[$distance_unit] * 3.14159); $max_lon_diff = $distance * 180 / (abs(sin((90 - $lat) * 3.14159 / 180 )) * 6378 * $multiplier[$distance_unit] * 3.14159);


sql_slave('CREATE TEMPORARY TABLE result_caches ENGINE=MEMORY $cachesFilter =
'CREATE TEMPORARY TABLE result_caches ENGINE=MEMORY
SELECT SELECT
(' . getSqlDistanceFormula($lon, $lat, $distance, $multiplier[$distance_unit]) . ') `distance`, (' . getSqlDistanceFormula($lon, $lat, $distance, $multiplier[$distance_unit]) . ') `distance`,
`caches`.`cache_id` `cache_id` `caches`.`cache_id` `cache_id`
Expand All @@ -700,7 +706,8 @@
AND `longitude` < ' . ($lon + $max_lon_diff) . ' AND `longitude` < ' . ($lon + $max_lon_diff) . '
AND `latitude` > ' . ($lat - $max_lat_diff) . ' AND `latitude` > ' . ($lat - $max_lat_diff) . '
AND `latitude` < ' . ($lat + $max_lat_diff) . ' AND `latitude` < ' . ($lat + $max_lat_diff) . '
HAVING `distance` < ' . ($distance+0)); HAVING `distance` < ' . ($distance+0);
sql_slave($cachesFilter);
sql_slave('ALTER TABLE result_caches ADD PRIMARY KEY ( `cache_id` )'); sql_slave('ALTER TABLE result_caches ADD PRIMARY KEY ( `cache_id` )');


$sql_select[] = '`result_caches`.`cache_id`'; $sql_select[] = '`result_caches`.`cache_id`';
Expand Down Expand Up @@ -805,7 +812,8 @@
$lon_rad = $lon * 3.14159 / 180; $lon_rad = $lon * 3.14159 / 180;
$lat_rad = $lat * 3.14159 / 180; $lat_rad = $lat * 3.14159 / 180;


sql_slave('CREATE TEMPORARY TABLE result_caches ENGINE=MEMORY $cachesFilter =
'CREATE TEMPORARY TABLE result_caches ENGINE=MEMORY
SELECT SELECT
(' . getSqlDistanceFormula($lon, $lat, $distance, $multiplier[$distance_unit]) . ') `distance`, (' . getSqlDistanceFormula($lon, $lat, $distance, $multiplier[$distance_unit]) . ') `distance`,
`caches`.`cache_id` `cache_id` `caches`.`cache_id` `cache_id`
Expand All @@ -814,7 +822,8 @@
AND `longitude` < ' . ($lon + $max_lon_diff) . ' AND `longitude` < ' . ($lon + $max_lon_diff) . '
AND `latitude` > ' . ($lat - $max_lat_diff) . ' AND `latitude` > ' . ($lat - $max_lat_diff) . '
AND `latitude` < ' . ($lat + $max_lat_diff) . ' AND `latitude` < ' . ($lat + $max_lat_diff) . '
HAVING `distance` < ' . ($distance+0)); HAVING `distance` < ' . ($distance+0);
sql_slave($cachesFilter);
sql_slave('ALTER TABLE result_caches ADD PRIMARY KEY ( `cache_id` )'); sql_slave('ALTER TABLE result_caches ADD PRIMARY KEY ( `cache_id` )');


$sql_select[] = '`result_caches`.`cache_id`'; $sql_select[] = '`result_caches`.`cache_id`';
Expand Down Expand Up @@ -1054,11 +1063,22 @@
// $options['sortby'] // $options['sortby']
// $options['orderRatingFirst'] // $options['orderRatingFirst']
// $options['queryid'] // $options['queryid']
// $sqlFilter // $cachesFilter, $sqlFilter
// $map2_bounds
//================================================================= //=================================================================


$map2_bounds = ($options['output'] == 'map2bounds');
if ($map2_bounds)
$options['output'] = 'map2';

// Ocprop: HTML, gpx // Ocprop: HTML, gpx
if (!file_exists($opt['rootpath'] . 'lib/search.' . mb_strtolower($options['output']) . '.inc.php')) if ($map2_bounds && $options['queryid'] == 0)
{
tpl_set_var('tplname', $tplname);
$tplname = 'error';
tpl_set_var('error_msg', 'map2bounds requires queryid');
}
elseif (!file_exists($opt['rootpath'] . 'lib/search.' . mb_strtolower($options['output']) . '.inc.php'))
{ {
tpl_set_var('tplname', $tplname); tpl_set_var('tplname', $tplname);
$tplname = 'error'; $tplname = 'error';
Expand Down

0 comments on commit eb4a4ae

Please sign in to comment.