} else { $rssfile = $_SERVER['DOCUMENT_ROOT'] . "/rss/{$format}{$opt_expand}.{$extension}"; $rss_timeout = 900; } $rss = new UniversalFeedCreator(); $rss->useCached($format, $rssfile, $rss_timeout); $rss->title = 'Geograph British Isles'; $rss->link = "http://{$_SERVER['HTTP_HOST']}/"; /** * Create a query the first time round! */ if (isset($q)) { require_once 'geograph/searchcriteria.class.php'; require_once 'geograph/searchengine.class.php'; require_once 'geograph/searchenginebuilder.class.php'; $engine = new SearchEngineBuilder('#'); $engine->searchuse = "syndicator"; $_GET['i'] = $engine->buildSimpleQuery($q, $CONF['default_search_distance'], false, isset($_GET['u']) ? $_GET['u'] : 0); if (function_exists('symlink') && isset($cacheid)) { //create a link so cache can be access as original query(cacheid) or directly via its 'i' number later... symlink($_SERVER['DOCUMENT_ROOT'] . "/rss/{$cacheid}-{$pg}-{$format}{$opt_expand}.{$extension}", $_SERVER['DOCUMENT_ROOT'] . "/rss/{$_GET['i']}-{$pg}-{$format}{$opt_expand}.{$extension}"); } if (!empty($engine->errormsg) && !empty($_GET['fatal'])) { die('error: ' . $engine->errormsg); } if (isset($engine->criteria) && $engine->criteria->is_multiple) { die('error: unable to identify a unique location'); } } /** * A full-text query
fclose($urlHandle); #$r = '{"Styles": {"loc": {"DefaultSymbol": {"URL": "http://developers.metacarta.com/img/symbols/LocationMarker.png", "Width": 30, "Height": 30}}}, "Warnings": [], "MinConfidence": 0.0, "Locations": [{"Confidence": 0.451807, "Name": "Skellingthorpe, United Kingdom", "Style": "loc", "Centroid": {"Latitude": 53.2333, "X": -0.616666, "Y": 53.2333, "Longitude": -0.616666}, "RemainingQuery": "mitchel close", "Path": ["Skellingthorpe", "United Kingdom"], "ViewBox": {"MaxX": -0.589905177287, "MaxY": 53.2600950873, "MaxLongitude": -0.589905177287, "MinY": 53.2065720927, "MinLatitude": 53.2065720927, "MinX": -0.643428171913, "MaxLatitude": 53.2600950873, "MinLongitude": -0.643428171913}}], "SRS": "epsg:4326", "SystemVersion": "MetaCarta GTS v3.7.0, JSON Query Parser API v1.0.0", "BBox": {"MaxX": 180.0, "MaxY": 90.0, "MaxLongitude": 180.0, "MinY": -90.0, "MinLongitude": -180.0, "MinX": -180.0, "MaxLatitude": 90.0, "MinLatitude": -90.0}, "Query": "mitchel close Skellingthorpe", "ResultsCreationTime": "Fri Mar 02 13:40:19 2007 UTC"}'; if (preg_match('/"RemainingQuery": "(.*?)"/', $r, $m)) { $q = $m[1]; } if (preg_match('/"Path": \\["(.*?)"/', $r, $m)) { $q .= ' near ' . $m[1]; } } } //remember the query in the session $_SESSION['searchq'] = $q; require_once 'geograph/searchcriteria.class.php'; require_once 'geograph/searchengine.class.php'; require_once 'geograph/searchenginebuilder.class.php'; $engine = new SearchEngineBuilder('#'); if (isset($_GET['rss'])) { $engine->page = "syndicator.php"; } elseif (isset($_GET['kml'])) { $engine->page = "kml.php"; } $engine->buildSimpleQuery($q, $CONF['default_search_distance'], isset($_GET['form']) && $_GET['form'] == 'simple' ? 'simple' : 'auto', !empty($_GET['user_id']) ? intval($_GET['user_id']) : 0); if (isset($engine->criteria) && $engine->criteria->is_multiple) { if (empty($_GET['distance'])) { $_GET['distance'] = $CONF['default_search_distance']; } //todo these shouldnt be hardcoded as there other possiblities for suggestions $smarty->assign('multipletitle', "Placename"); $smarty->assign('multipleon', "placename"); if (!empty($engine->criteria->realname)) { $smarty->assign('pos_realname', $engine->criteria->realname);
$cacheid = ''; if (isset($_REQUEST['i']) && ($i = intval($_REQUEST['i']))) { $pg = $_REQUEST['page']; if ($pg == '' or $pg < 1) { $pg = 1; } if ($i < 1) { if ($USER->registered) { $data = array(); $data['user_id'] = $USER->user_id; $data['orderby'] = 'gridimage_id'; $data['reverse_order_ind'] = 1; $sortorders = array('gridimage_id' => 'Date Submitted'); $data['adminoverride'] = 0; //prevent overriding it $engine = new SearchEngineBuilder('#'); $i = $engine->buildAdvancedQuery($data, false); } else { $i = 1522; } } $engine = new SearchEngine($i); if (isset($_REQUEST['submit'])) { $simple = $_REQUEST['simple']; if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'view') { $url = "http://{$_SERVER['HTTP_HOST']}/earth.php?i={$i}&simple={$simple}"; } elseif (isset($_REQUEST['type']) && $_REQUEST['type'] == 'mapsview') { $url = "http://{$_SERVER['HTTP_HOST']}/feed/results/{$i}.nl"; $_REQUEST['type'] = 'maps'; } else { $url = "http://{$_SERVER['HTTP_HOST']}/feed/results/{$i}/{$pg}.kml";
function handleLatLong() { $_GET['key'] = $this->params[2]; if (preg_match("/\\b(-?\\d+\\.?\\d*)[, ]+(-?\\d+\\.?\\d*)\\b/", $this->params[1], $ll)) { $this->beginResponse(); //todo - we could do this directly rather than via the search engine require_once 'geograph/searchcriteria.class.php'; require_once 'geograph/searchengine.class.php'; $engine = new SearchEngineBuilder('#'); $engine->searchuse = "syndicator"; $_GET['i'] = $engine->buildSimpleQuery($this->params[1], floatval($this->params[0]), false, isset($_GET['u']) ? $_GET['u'] : 0); $images = new SearchEngine($_GET['i']); $images->Execute($pg); if (!empty($images->results)) { $images =& $images->results; $count = count($images); #FIXME title1,title2,comment1,comment2 if ($this->output == 'json') { require_once '3rdparty/JSON.php'; $json = new Services_JSON(); $whitelist = array('gridimage_id' => 1, 'seq_no' => 1, 'user_id' => 1, 'ftf' => 1, 'moderation_status' => 1, 'title' => 1, 'comment' => 1, 'submitted' => 1, 'realname' => 1, 'nateastings' => 1, 'natnorthings' => 1, 'natgrlen' => 1, 'imageclass' => 1, 'imagetaken' => 1, 'upd_timestamp' => 1, 'viewpoint_eastings' => 1, 'viewpoint_northings' => 1, 'viewpoint_grlen' => 1, 'view_direction' => 1, 'use6fig' => 1, 'credit_realname' => 1, 'profile_link' => 1, 'wgs84_lat' => 1, 'wgs84_long' => 1); foreach ($images as $i => $image) { foreach ($image as $k => $v) { if (empty($v) || empty($whitelist[$k])) { unset($images[$i]->{$k}); } } $images[$i]->image = $image->_getFullpath(true, true); $images[$i]->thumbnail = $image->getThumbnail(120, 120, true); } print $json->encode($images); } else { echo '<status state="ok" count="' . $count . '" total="' . $images->resultCount . '"/>'; foreach ($images as $i => $image) { if ($image->moderation_status == 'geograph' || $image->moderation_status == 'accepted') { echo " <image url=\"http://{$_SERVER['HTTP_HOST']}/photo/{$image->gridimage_id}\">"; echo ' <title>' . utf8_encode(htmlentities($image->title)) . '</title>'; echo " <user profile=\"http://{$_SERVER['HTTP_HOST']}{$image->profile_link}\">" . utf8_encode(htmlentities($image->realname)) . '</user>'; echo ' ' . preg_replace('/alt=".*?" /', '', $image->getThumbnail(120, 120)); if (!empty($image->nateastings)) { echo ' <location grid="' . $image->reference_index . '" eastings="' . $image->nateastings . '" northings="' . $image->natnorthings . '" figures="' . $image->natgrlen . '"/>'; } if (!empty($image->wgs84_lat)) { echo ' <location grid="' . $image->reference_index . '" lat="' . $image->wgs84_lat . '" long="' . $image->wgs84_long . '"/>'; } echo '</image>'; } } } } else { if ($this->output == 'json') { print "{error: '0 results'}"; } else { echo '<status state="ok" count="0"/>'; } } $this->endResponse(); } else { $this->error("Invalid grid reference " . $this->params[0]); } }