]> dev.renevier.net Git - syp.git/blobdiff - items.php
add German lang file from Openlayers
[syp.git] / items.php
index c36318379964d0790564a47587ccf7b4416ef27a..e2fe1dbbe272b222d6f12d5df6e03a75ffbd6044 100644 (file)
--- a/items.php
+++ b/items.php
@@ -2,13 +2,23 @@
 /* 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");
+    // 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));
 
-    header ("Cache-control: no-cache");
+    return $output;
+}
+
+function main ($features) {
 
     echo '<?xml version="1.0" encoding="UTF-8"?>
 <kml xmlns="http://www.opengis.net/kml/2.2">
@@ -16,7 +26,7 @@ function main ($features) {
 ';
 
     if (SITETITLE) {
-        printf ('    <name>%s</name>', SITETITLE);
+        printf ('    <name>%s</name>', htmlspecialchars (SITETITLE));
     }
     foreach ($features as $feature) {
         $id = $feature->id;
@@ -64,12 +74,20 @@ function main ($features) {
     </kml>';
 }
 
+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 ()
 ?>