Example #1
0
}
$smarty->register_modifier("articletext", "smarty_function_articletext");
$db = NewADOConnection($GLOBALS['DSN']);
$page = $db->getRow("\r\nselect article.*,realname,gs.grid_reference,category_name\r\nfrom article \r\n\tleft join user using (user_id)\r\n\tleft join article_cat c on (article.article_cat_id = c.article_cat_id)\r\n\tleft join gridsquare gs on (article.gridsquare_id = gs.gridsquare_id)\r\nwhere ( (licence != 'none' and approved > 0) \r\n\tor user.user_id = {$USER->user_id}\r\n\tor {$isadmin} )\r\n\tand url = " . $db->Quote($_GET['page']) . '
limit 1');
if (count($page)) {
    if ($page['user_id'] == $USER->user_id) {
        $cacheid .= '|' . $USER->user_id;
    }
    if (!isset($_GET['dontcount']) && @strpos($_SERVER['HTTP_REFERER'], $page['url']) === FALSE) {
        $db->Execute("UPDATE LOW_PRIORITY article_stat SET views=views+1 WHERE article_id = " . $page['article_id']);
    }
    //when this page was modified
    $mtime = strtotime($page['update_time']);
    //can't use IF_MODIFIED_SINCE for logged in users as has no concept as uniqueness
    customCacheControl($mtime, $cacheid, $USER->user_id == 0);
} else {
    $template = 'static_404.tpl';
}
if (!$smarty->is_cached($template, $cacheid)) {
    if (count($page)) {
        $CONF['global_thumb_limit'] *= 2;
        $CONF['post_thumb_limit'] *= 2;
        $smarty->assign($page);
        if (!empty($page['extract'])) {
            $smarty->assign('meta_description', "User contributed article about, " . $page['extract']);
        }
        if (!empty($page['gridsquare_id'])) {
            $square = new GridSquare();
            $square->loadFromId($page['gridsquare_id']);
            $smarty->assign('grid_reference', $square->grid_reference);
Example #2
0
 /**
  * returns an image with appropriate headers
  * @access public
  */
 function returnImage()
 {
     //if thumbs level on depeth map, can just use normal render.
     if ($this->type_or_user == -1 && $this->pixels_per_km > 4) {
         $this->type_or_user = 0;
     }
     $file = $this->getImageFilename();
     $full = $_SERVER['DOCUMENT_ROOT'] . $file;
     if (!$this->caching || !@file_exists($full)) {
         $this->_renderMap();
     }
     if (!@file_exists($full)) {
         $full = $_SERVER['DOCUMENT_ROOT'] . "/maps/errortile.png";
     }
     $type = "image/png";
     if (strpos($full, ".jpg") > 0) {
         $type = "image/jpeg";
     }
     //Last-Modified: Sun, 20 Mar 2005 18:19:58 GMT
     $t = filemtime($full);
     //use the filename as a hash
     //can use if-last-mod as file is not unique per user
     customCacheControl($t, $full, true);
     customExpiresHeader(3600 * 6, true);
     $size = filesize($full);
     header("Content-Type: {$type}");
     header("Content-Size: {$size}");
     header("Content-Length: {$size}");
     //header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
     //header("Cache-Control: post-check=0, pre-check=0", false);
     //header("Pragma: no-cache");
     readfile($full);
 }
Example #3
0
     exit;
 }
 /////////////////////////
 //check if we have a cached tile
 $mustgenerate = false;
 if ($memcache->valid && !isset($_GET['refresh'])) {
     $mkey = "{$_GET['l']}:{$e},{$n},{$reference_index},{$widthdist}";
     $lastmod =& $memcache->name_get('tl', $mkey);
     if (!$lastmod) {
         $lastmod = time();
         $mustgenerate = true;
     }
 } else {
     $lastmod = time();
 }
 customCacheControl($lastmod, "{$e},{$n},{$reference_index}");
 customExpiresHeader(86400, true);
 if ($memcache->valid && $mkey && !$mustgenerate) {
     $data =& $memcache->name_get('td', $mkey);
     if ($data) {
         if ($data == 'blank') {
             header("HTTP/1.0 302 Found");
             header("Status: 302 Found");
             header("Location: http://{$CONF['CONTENT_HOST']}/maps/blank.png");
         } else {
             header("Content-Type: image/png");
             print $data;
         }
         exit;
     }
 }
    $r = '';
    if (mysql_num_rows($result) > 0) {
        $rows = array();
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $rows[$row['id']] = $row;
        }
        foreach ($ids as $id) {
            $row = $rows[$id];
            $lines = wordwrap($row['localities'], 50, "\n");
            $row['localities'] = preg_replace("/\n.*/s", '', $lines);
            $r .= join("\t", array_values($row)) . "\n";
        }
        $r .= "\t{$query_info}\t\t\tGreat Britain results (c) Crown copyright Ordnance Survey. All Rights Reserved. 100045616";
    } else {
        $r = "\t--none--";
    }
}
if ($r) {
    if ($encoding) {
        $r = gzencode($r, 9, $encoding == 'gzip' ? FORCE_GZIP : FORCE_DEFLATE);
    }
    customExpiresHeader(3600 * 24 * 24, true);
    if (empty($nocache)) {
        file_put_contents($cachepath, $r);
        $mtime = @filemtime($cachepath);
        customCacheControl($mtime, $cachepath);
    }
    header('Content-length: ' . strlen($r));
    print $r;
}
exit;
Example #5
0
require_once 'geograph/global.inc.php';
if (!empty($_SERVER["PATH_INFO"])) {
    $filename = $_SERVER["PATH_INFO"];
} else {
    $filename = $_SERVER["SCRIPT_NAME"];
}
$path = "/{$_SERVER['HTTP_HOST']}/";
if (preg_match('/\\/(\\d{6,})_/', $filename, $m)) {
    #
    $id = intval($m[1]);
    $path .= "photo/" . $id;
}
$t = time() + 3600 * 24 * 7;
$expires = strftime("%a, %d %b %Y %H:%M:%S GMT", $t);
header("Expires: {$expires}");
customCacheControl(filemtime(__FILE__), $m[1]);
$img = imagecreate(250, 112);
$blue = imagecolorallocate($img, 101, 117, 255);
imagefill($img, 0, 0, $blue);
$black = imagecolorallocate($img, 255, 255, 255);
if ($id) {
    //die as quickly as possible with the minimum
    $db = NewADOConnection($GLOBALS['DSN']);
    $realname =& $db->getOne($sql = "select realname from gridimage_search where gridimage_id=" . intval($id));
}
if (!empty($realname)) {
    imagestring($img, 2, 8, 5, "c Copyright", $black);
    imageellipse($img, 10, 12, 12, 12, $black);
    imagestring($img, 3, 78, 5, $realname, $black);
} else {
    imagestring($img, 2, 5, 5, "Image from", $black);
    $NetworkLink->setItemCDATA('description', "Please upgrade to Google Earth Version 4 to take advantage latest Superlayer");
    $NetworkLink->setItem('open', 0);
    $UrlTag = $NetworkLink->useUrl("http://{$_SERVER['HTTP_HOST']}/earth.php?simple=1" . ($i ? "&i={$i}" : ''));
    $NetworkLink->setItem('visibility', 0);
    $UrlTag->setItem('viewRefreshMode', 'onStop');
    $UrlTag->setItem('viewRefreshTime', 4);
    $UrlTag->setItem('viewFormat', 'BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]&LOOKAT=[lookatLon],[lookatLat],[lookatRange],[lookatTilt],[lookatHeading],[horizFov],[vertFov]');
} elseif ($m[2] == 4 || isset($_GET['download'])) {
    if ($i) {
        $cache_file = "kml/{$i}/geograph.kmz";
    } else {
        $cache_file = "kml/geograph.kmz";
    }
    $mtime = filemtime($cache_file);
    //use the filename as a hash
    customCacheControl($mtime, $cache_file);
    Header("Content-Type: application/vnd.google-earth.kmz+xml; charset=utf-8; filename=geograph.kmz");
    Header("Content-Disposition: attachment; filename=\"geograph{$i}.kmz\"");
    header('Content-length: ' . filesize($cache_file));
    readfile($cache_file);
    exit;
} else {
    $networklink = new kmlNetworkLink(null, 'Geograph SuperLayer');
    $desc = <<<END_HTML
<table bgcolor="#000066" border="0"><tr bgcolor="#000066"><td bgcolor="#000066">
<a href="http://{$_SERVER['HTTP_HOST']}/"><img src="http://{$_SERVER['HTTP_HOST']}/templates/basic/img/logo.gif" height="74" width="257"/></a>
</td></tr></table>

<p><i>The Geograph British Isles project aims to collect geographically representative photographs and information for every square kilometre of the UK and the Republic of Ireland, and you can be part of it.</i></p>

<p>Click on the Camera Icon or Thumbnails to view a bigger image, and follow the link to view the full resolution image on the geograph website.</p>
Example #7
0
            $cacheid = 0;
            $rejected = true;
        }
    }
}
//do we have a valid image?
if ($image->isValid()) {
    //what style should we use?
    $style = $USER->getStyle();
    $cacheid .= $style;
    //when this image was modified
    $mtime = strtotime($image->upd_timestamp);
    //page is unqiue per user (the profile and links)
    $hash = $cacheid . '.' . $USER->user_id;
    //can't use IF_MODIFIED_SINCE for logged in users as has no concept as uniqueness
    customCacheControl($mtime, $hash, $USER->user_id == 0);
    if (!empty($CONF['sphinx_host']) && stripos($_SERVER['HTTP_REFERER'], $CONF['CONTENT_HOST']) === FALSE && stripos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) === FALSE && preg_match('/\\b(q|query|qry|search|su|searchfor|s|qs|p|key|buscar|w)=([\\w%\\+\\.\\(\\)\\"\':]+)(\\&|$)/', $_SERVER['HTTP_REFERER'], $m) && !is_numeric($m[2]) && ($q = trim(preg_replace('/\\b(geograph|photo|image|picture|site:[\\w\\.-]+|inurl:[\\w\\.-]+)s?\\b/', '', urldecode($m[2])))) && strlen($q) > 3) {
        $smarty->assign("search_keywords", $q);
        $mkey = $image->grid_reference . ' ' . $q;
        $info =& $memcache->name_get('sn', $mkey);
        if (!empty($info)) {
            list($count, $when) = $info;
            $smarty->assign("search_count", $count);
            $smarty->assign_by_ref("image", $image);
            //we dont need the full assignToSmarty
        } else {
            $sphinx = new sphinxwrapper($mkey);
            $sphinx->processQuery();
            $count = $sphinx->countMatches('_images');
            $smarty->assign("search_count", $count);
            //fails quickly if not using memcached!
Example #8
0
     if (in_array(intval($_REQUEST['size']), $CONF['show_sizes'])) {
         $filepath = $image->getImageFromOriginal(intval($_REQUEST['size']), intval($_REQUEST['size']), true);
     } elseif ($_REQUEST['size'] == 'original') {
         $filepath = $image->_getOriginalpath();
     } else {
         $filepath = $image->_getFullpath();
     }
     $filename = basename($filepath);
     $filename = "geograph-" . preg_replace('/_\\w+(\\.jpg)/', " by {$image->realname}\$1", $filename);
     $filename = preg_replace('/ /', '-', trim($filename));
     $filename = preg_replace('/[^\\w-\\.,]+/', '', $filename);
     $lastmod = filemtime($_SERVER['DOCUMENT_ROOT'] . $filepath);
     header("Content-Type: image/jpeg");
     header("Content-Disposition: attachment; filename=\"{$filename}\"");
     customExpiresHeader(86400, true);
     customCacheControl($lastmod, $image->gridimage_id);
     readfile($_SERVER['DOCUMENT_ROOT'] . $filepath);
     exit;
 }
 $smarty->assign_by_ref('msg', $msg);
 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);
 list($latdm, $longdm) = $conv->wgs84_to_friendly($lat, $long);
 $smarty->assign('latdm', $latdm);
 $smarty->assign('longdm', $longdm);
 if (!empty($image->viewpoint_northings)) {
     list($lat, $long) = $conv->national_to_wgs84($image->viewpoint_eastings, $image->viewpoint_northings, $image->grid_square->reference_index);
     $smarty->assign('photographer_lat', $lat);
 /**
  * @since 1.4
  * @access private
  */
 function _redirect($filename)
 {
     //uses Geograph specific functions, get them seperatly or just comment out.
     $mtime = filemtime($filename);
     customCacheControl($mtime, $mtime);
     $timeout = 3600;
     if (!empty($GLOBALS['rss_timeout'])) {
         $timeout = $GLOBALS['rss_timeout'];
     }
     customExpiresHeader($timeout - (time() - $mtime), true);
     //end;
     if ($filesize = filesize($filename)) {
         header('Content-Length: ' . $filesize);
     }
     Header("Content-Type: " . $this->contentType . "; charset=" . $this->encoding);
     if (preg_match("/\\.(kml|gpx)\$/", $filename)) {
         Header("Content-Disposition: attachment; filename=" . basename($filename));
     } else {
         Header("Content-Disposition: inline; filename=" . basename($filename));
     }
     readfile($filename, "r");
     die;
 }
Example #10
0
     header("HTTP/1.0 301 Moved Permanently");
     header("Status: 301 Moved Permanently");
     header("Location: /photo/" . intval($_GET['id']) . ".kml");
     print "<a href=\"http://{$_SERVER['HTTP_HOST']}/photo/" . intval($_GET['id']) . ".kml\">View file</a>";
     exit;
 }
 $version42plus = false;
 if ($_GET['new']) {
     $version42plus = true;
 }
 //if (check version) {
 //	$version42plus = true;
 //}
 //when this image was modified
 $mtime = strtotime($image->upd_timestamp);
 customCacheControl($mtime, $image->gridimage_id . '|' . $version42plus);
 customExpiresHeader(3600 * 24 * 48, true);
 require_once 'geograph/conversions.class.php';
 $conv = new Conversions();
 //because we not loading from the search cache need to recalculate this
 list($image->wgs84_lat, $image->wgs84_long) = $conv->gridsquare_to_wgs84($image->grid_square);
 $kml = new kmlFile();
 $kml->atom = true;
 $stylefile = "http://{$CONF['KML_HOST']}/kml/style.kmz";
 $kml->filename = "Geograph" . $image->gridimage_id . ".kml";
 $point = new kmlPoint($image->wgs84_lat, $image->wgs84_long);
 $placemark = $kml->addChild(new kmlPlacemark_Photo('id' . $image->gridimage_id, $image->grid_reference . " : " . $image->title, $point));
 $placemark->useHoverStyle();
 $placemark->useCredit($image->realname, "http://{$_SERVER['HTTP_HOST']}/photo/" . $image->gridimage_id);
 $linkTag = "<a href=\"http://{$_SERVER['HTTP_HOST']}/photo/" . $image->gridimage_id . "\">";
 $details = $image->getThumbnail(120, 120, 2);
Example #11
0
<?php

require_once 'geograph/global.inc.php';
customCacheControl(getlastmod(), $_SERVER['SERVER_NAME']);
customExpiresHeader(3600, true);
header('Content-type: application/x-java-jnlp-file');
echo '<?xml version="1.0" encoding="utf8"?>';
?>

<jnlp spec="1.0+" href="get-juppy.jnlp" 
<?php 
echo 'codebase="http://' . $_SERVER['SERVER_NAME'] . '">';
?>

 <information>
  <title>JUppy Geograph uploader</title>
  <vendor>Those nice Geograph people</vendor> 
  <homepage href="http://www.geograph.org.uk" />
  <description kind="one-line">
   JUppy - Java batch uploader for geograph project
  </description>
  <description kind="short">
   JUppy is the Geograph project batch uploader. This permits off-line
   compilation of an image queue which can be sent to the Geograph
   project when a connection is available.
  </description>
  <offline-allowed />
  <shortcut online="true">
    <desktop />
  </shortcut>