$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat'] : 0; if (!is_numeric($startat)) { $startat = 0; } if (!is_numeric($caches_per_page)) { $caches_per_page = 20; } $startat = floor($startat / $caches_per_page) * $caches_per_page; $sql .= ' LIMIT ' . $startat . ', ' . $caches_per_page; $nRowIndex = 0; $rs_caches = sql_slave($sql, $sqldebug); $resultcount = sql_value_slave('SELECT FOUND_ROWS()', 0); tpl_set_var('results_count', $resultcount); while ($caches_record = sql_fetch_array($rs_caches)) { $tmpline = $cache_line; list($iconname, $inactive) = getCacheIcon($usr['userid'], $caches_record['cache_id'], $caches_record['status'], $caches_record['user_id'], $caches_record['icon_large']); $tmpline = mb_ereg_replace('{icon_large}', $iconname, $tmpline); $tmpline = mb_ereg_replace('{cachetype}', htmlspecialchars(t($caches_record['cacheTypeName']), ENT_COMPAT, 'UTF-8'), $tmpline); // short_desc ermitteln TODO: nicht die erste sondern die richtige wählen $rsdesc = sql_slave("SELECT `short_desc` FROM `cache_desc` WHERE `cache_id`='&1' LIMIT 1", $caches_record['cache_id']); $desc_record = sql_fetch_array($rsdesc); mysql_free_result($rsdesc); $tmpline = mb_ereg_replace('{short_desc}', htmlspecialchars($desc_record['short_desc'], ENT_COMPAT, 'UTF-8'), $tmpline); $dDiff = abs(dateDiff('d', $caches_record['date_created'], date('Y-m-d'))); if ($dDiff < $caches_olddays) { $tmpline = mb_ereg_replace('{new}', $caches_newstring, $tmpline); } else { $tmpline = mb_ereg_replace('{new}', '', $tmpline); } $tmpline = mb_ereg_replace('{diffpic}', icon_difficulty("diff", $caches_record['difficulty']), $tmpline); $tmpline = mb_ereg_replace('{terrpic}', icon_difficulty("terr", $caches_record['terrain']), $tmpline);
function search_output() { global $opt, $tpl, $login; global $enable_mapdisplay; global $called_by_search, $called_by_profile_query, $options, $lat_rad, $lon_rad, $distance_unit; global $startat, $caches_per_page, $sql, $query_userid, $query_name; $tpl->name = 'search.result.caches'; $tpl->menuitem = MNU_CACHES_SEARCH_RESULT; $startat = floor($startat / $caches_per_page) * $caches_per_page; $sql .= ' LIMIT ' . $startat . ', ' . $caches_per_page; // run SQL query sql_enable_foundrows(); $rs_caches = sql_slave("SELECT SQL_BUFFER_RESULT SQL_CALC_FOUND_ROWS " . $sql); $resultcount = sql_value_slave('SELECT FOUND_ROWS()', 0); sql_foundrows_done(); $tpl->assign('results_count', $resultcount); $tpl->assign('startat', $startat); $caches = array(); while ($rCache = sql_fetch_array($rs_caches)) { // select best-fitting short desc for active language $rCache['short_desc'] = sql_value_slave("\n SELECT `short_desc`\n FROM `cache_desc`\n WHERE `cache_id`='&1'\n AND `language`='&2'", false, $rCache['cache_id'], $opt['template']['locale']); if ($rCache['short_desc'] === false) { $rCache['short_desc'] = sql_value_slave("\n\t\t\t\tSELECT `short_desc`\n\t\t\t\tFROM `cache_desc`\n\t\t\t\tWHERE `cache_id`='&1'\n\t\t\t\tAND `language`='EN'", false, $rCache['cache_id']); } if ($rCache['short_desc'] === false) { $rCache['short_desc'] = sql_value_slave("\n\t\t\t\tSELECT `short_desc`\n\t\t\t\tFROM `cache_desc`\n\t\t\t\tWHERE `cache_id`='&1'\n\t\t\t\tORDER BY `date_created`\n\t\t\t\tLIMIT 1", '', $rCache['cache_id']); } $rCache['desclangs'] = mb_split(',', $rCache['desc_languages']); // decide if the cache is new $dDiff = dateDiff('d', $rCache['date_created'], date('Y-m-d')); $rCache['isnew'] = $dDiff <= NEWCACHES_DAYS; // get last logs if ($options['sort'] != 'bymylastlog' || !$login->logged_in()) { $ownlogs = ""; } else { $ownlogs = " AND `cache_logs`.`user_id`='" . sql_escape($login->userid) . "'"; } $sql = "\n\t\t\t\tSELECT `cache_logs`.`id`, `cache_logs`.`type`, `cache_logs`.`date`, `log_types`.`icon_small`\n\t\t\t\tFROM `cache_logs`, `log_types`\n\t\t\t\tWHERE `cache_logs`.`cache_id`='" . sql_escape($rCache['cache_id']) . "'\n\t\t\t\t AND `log_types`.`id`=`cache_logs`.`type`" . $ownlogs . "\n\t\t\t\tORDER BY `cache_logs`.`order_date` DESC, `cache_logs`.`date_created` DESC, `cache_logs`.`id` DESC\n\t\t\t\tLIMIT 6"; $rs = sql_slave($sql); $rCache['logs'] = sql_fetch_assoc_table($rs); $rCache['firstlog'] = array_shift($rCache['logs']); // get direction from search coordinate if ($rCache['distance'] > 0) { $direction = geomath::calcBearing($lat_rad / 3.14159 * 180, $lon_rad / 3.14159 * 180, $rCache['latitude'], $rCache['longitude']); $rCache['direction_deg'] = round($direction / 22.5) * 22.5; $rCache['direction_txt'] = geomath::Bearing2Text($direction, 0, $opt['template']['locale']); } else { $rCache['direction_deg'] = false; } // 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->assign('caches', $caches); $page = 'search.php?queryid=' . $options['queryid'] . '&startat={offset}&sortby=' . $options['sort']; if (isset($options['sortorder']) && $options['sortorder']) { $page .= "&sortorder=" . $options['sortorder']; } if (isset($options['creationdate']) && $options['creationdate']) { $page .= "&creationdate=" . $options['creationdate']; } $pager = new pager($page, 2, 9); $pager->make_from_offset($startat, $resultcount, $caches_per_page); // downloads $tpl->assign('queryid', $options['queryid']); if (isset($query_userid)) { $tpl->assign('query_name', $query_name); } $tpl->assign('startatp1', min($resultcount, $startat + 1)); if ($resultcount - $startat < 500) { $tpl->assign('endat', $startat + $resultcount - $startat); } else { $tpl->assign('endat', $startat + 500); } // kompatibilität! if ($distance_unit == 'sm') { $tpl->assign('distanceunit', 'mi'); } elseif ($distance_unit == 'nm') { $tpl->assign('distanceunit', 'sm'); } else { $tpl->assign('distanceunit', $distance_unit); } $tpl->assign('displayownlogs', $options['sort'] == 'bymylastlog'); $tpl->assign('search_headline_caches', $called_by_search); $tpl->assign('enable_mapdisplay', $enable_mapdisplay); // sort results by $tpl->assign('sortby', $options['sort']); if (isset($options['sortorder'])) { $tpl->assign('sortorder', $options['sortorder']); } if ($options['sort'] == 'bycreated' || isset($options['creationdate'])) { $tpl->assign('creationdate', true); } // cachelist data if (isset($options['cachelist'])) { $tpl->assign('cachelist', $options['cachelist']); $tpl->assign('cachelist_pw', $options['cachelist_pw']); } else { $tpl->assign('cachelist', false); } // disable "edit options" for internally generated searches if ($options['searchtype'] == 'bylist') { $tpl->assign('disable_edit_options', true); } $tpl->display(); }
$npa_content .= $npa_item . '<br />'; } $npa_content .= "</td><td align=\"center\" valign=\"middle\"><img src=\"tpl/stdstyle/images/misc/natura2000.png\"></td>\n </tr></table>"; } if ($npac == "0") { tpl_set_var('hidenpa_start', '<!--'); tpl_set_var('hidenpa_end', '-->'); tpl_set_var('npa_content', ''); } else { tpl_set_var('hidenpa_start', ''); tpl_set_var('hidenpa_end', ''); tpl_set_var('npa_content', $npa_content); } $icons = $geocache->dictionary->getCacheTypeIcons(); //cache data list($iconname) = getCacheIcon($usr['userid'], $geocache->getCacheId(), $geocache->getStatus(), $geocache->getOwner()->getUserId(), $icons[$geocache->getCacheType()]['icon']); list($lat_dir, $lat_h, $lat_min) = help_latToArray($geocache->getCoordinates()->getLatitude()); list($lon_dir, $lon_h, $lon_min) = help_lonToArray($geocache->getCoordinates()->getLongitude()); $tpl_subtitle = htmlspecialchars($geocache->getCacheName(), ENT_COMPAT, 'UTF-8') . ' - '; $map_msg = mb_ereg_replace("{target}", urlencode("viewcache.php?cacheid=" . $cache_id), tr('map_msg')); tpl_set_var('googlemap_key', $googlemap_key); tpl_set_var('map_msg', $map_msg); tpl_set_var('typeLetter', typeToLetter($geocache->getCacheType())); tpl_set_var('cacheid_urlencode', htmlspecialchars(urlencode($cache_id), ENT_COMPAT, 'UTF-8')); tpl_set_var('cachename', htmlspecialchars($geocache->getCacheName(), ENT_COMPAT, 'UTF-8')); if ($geocache->isTitled()) { $ntitled_cache = $titled_cache_period_prefix . '_titled_cache'; tpl_set_var('icon_titled', '<img src="tpl/stdstyle/images/free_icons/award_star_gold_1.png" class="icon16" alt="' . tr($ntitled_cache) . '" title="' . tr($ntitled_cache) . '"/>'); } else { tpl_set_var('icon_titled', ''); }