X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=items.php;h=a2a04464e398110e1cd1e2bc71f66b3d87a9e3c8;hp=af0192f5ef61bdedd76a9c75876a4fbcd6cb5c61;hb=3c74920cb66b4e6c47c7e8a0eaeed40ffb7e8544;hpb=e4a4e5149d55cf01a86f26392c52fdca803654ce diff --git a/items.php b/items.php index af0192f..a2a0446 100644 --- a/items.php +++ b/items.php @@ -2,13 +2,22 @@ /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD license. */ -require_once ("./inc/settings.php"); -require_once ("./inc/utils.php"); -require_once ("./inc/db/mysql.php"); +function headers_callback ($output) { + $etag = md5 ($output); + if ((isset ($_SERVER ["HTTP_IF_NONE_MATCH"])) && + ($_SERVER ["HTTP_IF_NONE_MATCH"] == $etag)) { + header ("HTTP/1.1 304 Not Modified"); + exit (); + } -function main ($features) { + header ("Content-type: application/vnd.google-earth.kml+xml"); + header ("Cache-control: must-revalidate"); + header (sprintf ("ETag: %s", $etag)); - header("Cache-control: no-cache"); + return $output; +} + +function main ($features) { echo ' @@ -16,14 +25,17 @@ function main ($features) { '; if (SITETITLE) { - printf (' %s', SITETITLE); + printf (' %s', htmlspecialchars (SITETITLE)); } foreach ($features as $feature) { $id = $feature->id; $title = htmlspecialchars ($feature->title, ENT_QUOTES); $description = htmlspecialchars ($feature->description, ENT_QUOTES); $imgurl = ($feature->imgpath ? - full_url_from_imgpath ($feature->imgpath) + image_url_from_imgpath ($feature->imgpath) + : ""); + $thumburl = ($feature->imgpath ? + thumb_url_from_imgpath ($feature->imgpath) : ""); $lon = $feature->lon; $lat = $feature->lat; @@ -32,7 +44,7 @@ function main ($features) { $title; if ($imgurl) { - $imgurlHTML = sprintf ('%s', $alt, $imgurl); + $imgurlHTML = sprintf ('%s', $imgurl, $alt, $thumburl); } else { $imgurlHTML = ""; } @@ -61,12 +73,20 @@ function main ($features) { '; } +if (!@include_once ("./inc/settings.php")) { + exit ("server error"); +} +require_once ("./inc/utils.php"); +require_once ("./inc/db/mysql.php"); + try { $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX); - $features = $connection->listfeatures (); + $features = $connection->listfeatures ($_GET ['from_user']); } catch (Exception $e) { exit ("server error"); } -header ("Content-type: application/vnd.google-earth.kml+xml"); + +ob_start ("headers_callback"); main ($features); +ob_end_flush () ?>