X-Git-Url: https://dev.renevier.net/?a=blobdiff_plain;ds=inline;f=items.php;h=e2fe1dbbe272b222d6f12d5df6e03a75ffbd6044;hb=929c95de6072a424c01a74f81624008e61abbf03;hp=bcf5f1fc9757c50b33097c72bec649a0c9f738f4;hpb=57511b4efd7402ef58de66ac1fe2c01ed1b1d7b5;p=syp.git
diff --git a/items.php b/items.php
index bcf5f1f..e2fe1db 100644
--- a/items.php
+++ b/items.php
@@ -2,9 +2,21 @@
/* 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 ();
+ }
+
+ header ("Content-type: application/vnd.google-earth.kml+xml");
+ // no-cache is needed otherwise IE does not try to get new version.
+ header ("Cache-control: no-cache, must-revalidate");
+ header (sprintf ("ETag: %s", $etag));
+
+ return $output;
+}
function main ($features) {
@@ -14,14 +26,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_filename ($feature->imgpath)
+ image_url_from_imgpath ($feature->imgpath)
+ : "");
+ $thumburl = ($feature->imgpath ?
+ thumb_url_from_imgpath ($feature->imgpath)
: "");
$lon = $feature->lon;
$lat = $feature->lat;
@@ -30,7 +45,7 @@ function main ($features) {
$title;
if ($imgurl) {
- $imgurlHTML = sprintf ('', $alt, $imgurl);
+ $imgurlHTML = sprintf ('', $imgurl, $alt, $thumburl);
} else {
$imgurlHTML = "";
}
@@ -59,12 +74,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 ()
?>