Beispiel #1
0
             $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);
         $smarty->assign('pos_user_id', $engine->criteria->user_id);
         if (!empty($engine->criteria->nickname)) {
             $smarty->assign('pos_nickname', $engine->criteria->nickname);
         }
     } else {
         $usercriteria = new SearchCriteria_All();
    $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
 */
if (isset($sphinx)) {
Beispiel #3
0
 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]);
     }
 }