X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=items.php;h=e7a97231572a689dc0d4185706e66d2a7aab7b33;hp=2ce7c41bac98dcdb213c9cf14a421f7b1f4b38d2;hb=12376baf148afee289fbb53dd16ee2a0841d5290;hpb=4acc8da49e3d4083fd9906388dd8fe0212bb9f42 diff --git a/items.php b/items.php index 2ce7c41..e7a9723 100644 --- a/items.php +++ b/items.php @@ -6,9 +6,22 @@ require_once ("./inc/settings.php"); require_once ("./inc/utils.php"); require_once ("./inc/db/mysql.php"); -function main ($features) { +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 (); + } + + header ("Content-type: application/vnd.google-earth.kml+xml"); + header ("Cache-control: must-revalidate"); + header (sprintf ("ETag: %s", $etag)); + + return $output; +} - header ("Cache-control: no-cache"); +function main ($features) { echo ' @@ -23,7 +36,10 @@ function main ($features) { $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 +48,7 @@ function main ($features) { $title; if ($imgurl) { - $imgurlHTML = sprintf ('%s', $alt, $imgurl); + $imgurlHTML = sprintf ('%s', $imgurl, $alt, $thumburl); } else { $imgurlHTML = ""; } @@ -67,6 +83,8 @@ try { } catch (Exception $e) { exit ("server error"); } -header ("Content-type: application/vnd.google-earth.kml+xml"); + +ob_start ("headers_callback"); main ($features); +ob_end_flush () ?>