function smarty_function_articletext($input) { global $imageCredits, $smarty, $CONF; $output = preg_replace('/\\n(-{7,})\\n(.*?)\\n(-{7,})/es', "article_make_table('\$2')", str_replace("\r", '', $input)); if ($CONF['CONTENT_HOST'] != $_SERVER['HTTP_HOST']) { $output = str_replace($CONF['CONTENT_HOST'], $_SERVER['HTTP_HOST'], $output); } $output = preg_replace('/\\!(\\[+)/e', 'str_repeat("¬",strlen("$1"))', $output); $output = str_replace(array('[b]', '[/b]', '[big]', '[/big]', '[small]', '[/small]', '[i]', '[/i]', '[h2]', '[/h2]', '[h3]', '[/h3]', '[h4]', '[/h4]', '[tt]', '[/tt]', '[float]', '[/float]', '[br/]', '[hr/]', '[reveal]', '[/reveal]'), array('<b>', '</b>', '<big>', '</big>', '<small>', '</small>', '<i>', '</i>', '<h2>', '</h2>', '<h3>', '</h3>', '<h4>', '</h4>', '<tt>', '</tt>', '<div style="float:left;padding-right:10px;padding-bottom:10px;position:relative">', '</div>', '<br style="clear:both"/>', '<hr align="center" width="75%"/>', '<span style="color:white">', '</span>'), $output); $pattern = array(); $replacement = array(); if (preg_match_all('/<h(\\d)>([^\\n]+?)<\\/h(\\d)>/', $output, $matches)) { $list = array(); foreach ($matches[1] as $i => $level) { $list[] = "<li class=\"h{$level}\"><a href=\"#p{$i}\">{$matches[2][$i]}</a></li>"; $pattern[] = '/<h(' . $level . ')>(' . preg_quote($matches[2][$i], '/') . ')<\\/h(' . $level . ')>/'; $replacement[] = '<h$1><a name="p' . $i . '"></a>$2</h$3>'; } $list = implode("\n", $list); $smarty->assign("tableContents", $list); } $pattern[] = '/<\\/h(\\d)>\\n(?!\\*)/'; $replacement[] = '</h$1>'; $pattern[] = '/(?<!["\'\\[\\/\\!\\w])([STNH]?[A-Z]{1}\\d{4,10}|[A-Z]{3}\\d{4,10})(?!["\'\\]\\/\\!\\w])/'; $replacement[] = "<a href=\"http://{$_SERVER['HTTP_HOST']}/gridref/\\1\" target=\"_blank\">\\1</a>"; $pattern[] = '/\\[image id=(\\d+) text=([^\\]]+)\\]/e'; $replacement[] = "smarty_function_gridimage(array(id => '\$1',extra => '\$2'))"; $pattern[] = '/(\\!)([STNH]?[A-Z]{1}\\d{4,10}|[A-Z]{3}\\d{4,10})(?!["\'\\]\\/\\!\\w])/'; $replacement[] = "\\2"; $pattern[] = '/\\[img=([^\\] ]+)(| [^\\]]+)\\]/'; $replacement[] = '<img src="\\1" alt="\\2" title="\\2"/>'; $pattern[] = '/\\[mooflow=(\\d+)\\]/'; $replacement[] = '<iframe src="/search.php?i=\\1&temp_displayclass=mooflow_embed" width="750" height="430"></iframe>'; $pattern[] = '/\\n\\* ?([^\\n]+)(\\n{2})?/e'; $replacement[] = "'<ul style=\"margin-bottom:0px;margin-top:0px\"><li>'.stripslashes('\$1').'</li></ul>'.('\$2'?'\n':'')"; $pattern[] = '/<\\/ul>\\n?<ul style=\\"margin-bottom:0px;margin-top:0px\\">/'; $replacement[] = ''; //fix a bug where double spacing on a previous match would swallow the newline needed for the next $pattern[] = '/\\n\\n(<\\w{1,3}>)\\#/'; $replacement[] = "\n\$1#"; $pattern[] = '/\\n\\n\\#/'; $replacement[] = "\n\r\n\$1#"; $pattern[] = '/\\n(<\\w{1,3}>)?\\#([\\w]{1,2})? ([^\\n]+)(<\\/\\w{1,3}>)?(\\n{2})?/e'; $replacement[] = "'<ol style=\"margin-bottom:0px;'.('\$1'?'':'margin-top:0px').'\"'.('\$2'?' start=\"\$2\"':'').'><li>\$1\$3\$4</li></ol>'.('\$5'?'\n':'')"; $pattern[] = '/<\\/ol>\\n?<ol style=\\"margin-bottom:0px;margin-top:0px\\">/'; $replacement[] = ''; $pattern[] = "/\\[url[=]?\\](.+?)\\[\\/url\\]/i"; $replacement[] = '\\1'; $pattern[] = "/\\[url=((f|ht)tp[s]?:\\/\\/[^<> \n]+?)\\](.+?)\\[\\/url\\]/ie"; $replacement[] = "smarty_function_external(array('href'=>\"\$1\",'text'=>'\$3','title'=>\"\$1\"))"; $pattern[] = "/\n/"; $replacement[] = "<br/>\n"; $output = preg_replace($pattern, $replacement, $output); $output = GeographLinks($output, true); $pattern = array(); $replacement = array(); if (preg_match_all('/\\[(small|)map *([STNH]?[A-Z]{1}[ \\.]*\\d{2,5}[ \\.]*\\d{2,5}|[A-Z]{3}[ \\.]*\\d{2,5}[ \\.]*\\d{2,5})( \\w+|)\\]/', $output, $m)) { foreach ($m[0] as $i => $full) { //lets add an rastermap too $square = new Gridsquare(); $square->setByFullGridRef($m[2][$i], true); $square->grid_reference_full = $m[2][$i]; if (!empty($_GET['epoch'])) { $rastermap = new RasterMap($square, false, true, false, $_GET['epoch']); } elseif (!empty($m[3][$i])) { $rastermap = new RasterMap($square, false, true, false, trim($m[3][$i])); } else { $rastermap = new RasterMap($square, false); } if ($rastermap->service == 'OS50k') { if ($m[1][$i]) { $rastermap->service = 'OS50k-small'; $rastermap->width = 125; } $pattern[] = "/" . preg_quote($full, '/') . "/"; $replacement[] = $rastermap->getImageTag(); } } } $output = preg_replace($pattern, $replacement, $output); $output = str_replace('¬', '[', $output); if (count($m[0])) { $smarty->assign("copyright", '<div class="copyright">Great Britain 1:50 000 Scale Colour Raster Mapping Extracts © Crown copyright Ordnance Survey. All Rights Reserved. Educational licence 100045616.</div>'); } if (count($imageCredits)) { arsort($imageCredits); $imageCreditsStr = implode(', ', array_keys($imageCredits)); $imageCreditsStr = preg_replace('/, ([^,]+)$/', ' and $1', $imageCreditsStr); $smarty->assign("imageCredits", $imageCreditsStr); } return $output; }
$smarty->assign('photographer_gridref', $photographer_gridref = $_REQUEST['photographer_gridref']); $step = 3; } } else { $smarty->assign('errormsg', $square->errormsg); } } if (!empty($_REQUEST['step'])) { $step = intval($_REQUEST['step']); } if (empty($_REQUEST['grid_reference']) && $step == 2) { $step = 1; } if ($step == 2) { require_once 'geograph/rastermap.class.php'; $rastermap = new RasterMap($square, true); if (isset($_POST['photographer_gridref'])) { $square2 = new GridSquare(); $ok = $square2->setByFullGridRef($_POST['photographer_gridref'], false, false, true); $rastermap->addViewpoint($square2->reference_index, $square2->nateastings, $square2->natnorthings, $square2->natgrlen, $_POST['view_direction']); } elseif (isset($_POST['view_direction']) && strlen($_POST['view_direction']) && $_POST['view_direction'] != -1) { $rastermap->addViewDirection($_POST['view_direction']); } $smarty->assign_by_ref('rastermap', $rastermap); $smarty->assign_by_ref('square', $square); $smarty->assign('reference_index', $square->reference_index); require_once 'geograph/conversions.class.php'; $conv = new Conversions(); list($lat, $long) = $conv->gridsquare_to_wgs84($square); $smarty->assign('lat', $lat); $smarty->assign('long', $long);
$s = intval(($b[2] - $b[0]) / 1000); imagestring($img, 1, 20, 20, "{$s} km", $colMarker); imagestring($img, 1, 50, 50, "z=" . $_GET['z'], $colMarker); header("Content-Type: image/png"); imagepng($img); exit; ############### } list($e, $n, $reference_index) = array(intval($_GET['e']) * 1000, intval($_GET['n']) * 1000, 1); /************************** * Great Britain Only */ if ($reference_index == 1) { require_once 'geograph/rastermap.class.php'; $square = false; $rastermap = new RasterMap($square); if (isset($_GET['debug'])) { init_session(); } if (isset($_GET['z'])) { switch ($_GET['z']) { case 0: $rastermap->service = 'OS250k-m40k'; break; case 1: $rastermap->service = 'OS250k-m10k'; break; case 2: $rastermap->service = 'OS50k-mapper2'; break; #4k
$smarty->assign('map_token', $mosaic->getGridSquareToken($square)); } } } } else { //no square specifed - populate with remembered values $smarty->assign('gridsquare', $_SESSION['gridsquare']); $smarty->assign('eastings', $_SESSION['eastings']); $smarty->assign('northings', $_SESSION['northings']); } if (!isset($_GET['inner'])) { #//lets find some recent photos #new RecentImageList($smarty); //lets add an overview map too if ($grid_ok) { $overview = new GeographMapMosaic('largeoverview'); $overview->setCentre($square->x, $square->y); //does call setAlignedOrigin $smarty->assign('marker', $overview->getSquarePoint($square)); //TODO if centisquare is specified use that to plot a circle! //lets add an rastermap too $rastermap = new RasterMap($square, false, $square->natspecified); $rastermap->addLatLong($lat, $long); $smarty->assign_by_ref('rastermap', $rastermap); } else { $overview = new GeographMapMosaic('overview'); } $overview->assignToSmarty($smarty, 'overview'); } #} $smarty->display($template, $cacheid);
} echo $distance; exit; } die('unknown error'); } elseif (isset($_GET['map'])) { if (empty($ok) || !$ok) { die("Game Expired, please start again"); } if (!$game->l) { die("Game Expired, please start again"); } $square = new GridSquare(); $grid_ok = $square->setByFullGridRef($_GET['grid_reference'], true); if ($grid_ok && $square->grid_reference) { $rastermap = new RasterMap($square, false, $square->natspecified); print $rastermap->getImageTag(); print '<br/>Map for <b>' . htmlspecialchars($_GET['grid_reference']) . '</b>'; exit; } else { die('<span style="color:red">Please enter a Grid Reference</span>'); } } elseif (isset($_REQUEST['next']) || isset($_REQUEST['save'])) { if (empty($ok) || !$ok) { die("Game Expired, please start again"); } if (empty($_REQUEST['grid_reference'])) { } else { $square = new GridSquare(); $grid_ok = $square->setByFullGridRef($_REQUEST['grid_reference'], true); $match = $game->image->grid_reference == $square->grid_reference;
} else { $smarty->assign('error', "No Grid Reference Found"); $smarty->display($template, $cacheid); exit; } } if ($grid_ok) { //geotag the page require_once 'geograph/conversions.class.php'; $conv = new Conversions(); list($lat, $long) = $conv->gridsquare_to_wgs84($square); $smarty->assign('lat', $lat); $smarty->assign('long', $long); $smarty->assign_by_ref('square', $square); //lets add an rastermap too $rastermap = new RasterMap($square, false, $square->natspecified, true); $rastermap->addLatLong($lat, $long); $smarty->assign_by_ref('gridref', $gridref); if (!empty($photographer_gridref)) { $psquare = new GridSquare(); $pgrid_given = true; $pgrid_ok = $psquare->setByFullGridRef($photographer_gridref, true, false, true); if (!empty($psquare->nateastings)) { $rastermap->addViewpoint($psquare->reference_index, $psquare->nateastings, $psquare->natnorthings, $psquare->natgrlen); $smarty->assign_by_ref('photographer_gridref', $photographer_gridref); } } if (isset($view_direction) && strlen($view_direction) && $view_direction != -1) { $rastermap->addViewDirection(intval($view_direction)); $smarty->assign_by_ref('view_direction', $view_direction); }
$_SESSION['editpage_options'] = array(); } $_SESSION['editpage_options'][] = 'simple'; } } if (isset($_GET['form'])) { $smarty->assign('showfull', 0); } elseif (!isset($_SESSION['editpage_options']) || !in_array('simple', $_SESSION['editpage_options'])) { $smarty->assign('showfull', 1); if ($CONF['forums']) { //let's find posts in the gridref discussion forum $image->grid_square->assignDiscussionToSmarty($smarty); } } require_once 'geograph/rastermap.class.php'; $rastermap = new RasterMap($image->grid_square, true); if (!empty($image->viewpoint_northings)) { $rastermap->addViewpoint($image->viewpoint_refindex, $image->viewpoint_eastings, $image->viewpoint_northings, $image->viewpoint_grlen, $image->view_direction); } elseif (isset($image->view_direction) && strlen($image->view_direction) && $image->view_direction != -1) { $rastermap->addViewDirection($image->view_direction); } require_once 'geograph/conversions.class.php'; $conv = new Conversions(); list($lat, $long) = $conv->gridsquare_to_wgs84($image->grid_square); $smarty->assign('lat', $lat); $smarty->assign('long', $long); $rastermap->addLatLong($lat, $long); $smarty->assign_by_ref('rastermap', $rastermap); //build a list of view directions $dirs = array(-1 => ''); $jump = 360 / 16;
function assignToSmarty($smarty) { global $CONF; $taken = $this->getFormattedTakenDate(); //get the grid references $this->getSubjectGridref(true); $this->getPhotographerGridref(true); //remove grid reference from title $this->bigtitle = trim(preg_replace("/^{$this->grid_reference}/", '', $this->title)); $this->bigtitle = preg_replace('/(?<![\\.])\\.$/', '', $this->bigtitle); $rid = $this->grid_square->reference_index; $gridrefpref = $CONF['gridrefname'][$rid]; $smarty->assign('page_title', $this->bigtitle . ":: {$gridrefpref}{$this->grid_reference}"); $smarty->assign('image_taken', $taken); $smarty->assign('ismoderator', $ismoderator); $smarty->assign_by_ref('image', $this); //get a token to show a suroudding geograph map $mosaic = new GeographMapMosaic(); $smarty->assign('map_token', $mosaic->getGridSquareToken($this->grid_square)); //find a possible place within 25km $place = $this->grid_square->findNearestPlace(75000); $smarty->assign_by_ref('place', $place); if (empty($this->comment)) { $smarty->assign('meta_description', "{$this->grid_reference} :: {$this->bigtitle}, " . strip_tags(smarty_function_place(array('place' => $place)))); } else { $smarty->assign('meta_description', $this->comment); } if (!empty($CONF['forums'])) { //let's find posts in the gridref discussion forum $this->grid_square->assignDiscussionToSmarty($smarty); } //count the number of photos in this square $smarty->assign('square_count', $this->grid_square->imagecount); //lets add an overview map too $overview = new GeographMapMosaic('largeoverview'); $overview->setCentre($this->grid_square->x, $this->grid_square->y); //does call setAlignedOrigin $overview->assignToSmarty($smarty, 'overview'); $smarty->assign('marker', $overview->getSquarePoint($this->grid_square)); require_once 'geograph/conversions.class.php'; $conv = new Conversions(); list($lat, $long) = $conv->gridsquare_to_wgs84($this->grid_square); $smarty->assign('lat', $lat); $smarty->assign('long', $long); list($latdm, $longdm) = $conv->wgs84_to_friendly($lat, $long); $smarty->assign('latdm', $latdm); $smarty->assign('longdm', $longdm); //lets add an rastermap too $rastermap = new RasterMap($this->grid_square, false); $rastermap->addLatLong($lat, $long); if (!empty($this->viewpoint_northings)) { $rastermap->addViewpoint($this->viewpoint_refindex, $this->viewpoint_eastings, $this->viewpoint_northings, $this->viewpoint_grlen, $this->view_direction); } elseif (isset($this->view_direction) && strlen($this->view_direction) && $this->view_direction != -1) { $rastermap->addViewDirection($this->view_direction); } $smarty->assign_by_ref('rastermap', $rastermap); $smarty->assign('x', $this->grid_square->x); $smarty->assign('y', $this->grid_square->y); if ($this->view_direction > -1) { $smarty->assign('view_direction', $this->view_direction % 90 == 0 ? strtoupper(heading_string($this->view_direction)) : ucwords(heading_string($this->view_direction))); } $level = $this->grid_square->imagecount > 1 ? 6 : 5; $smarty->assign('sitemap', getSitemapFilepath($level, $this->grid_square)); }