2 /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
5 require_once ("./inc/settings.php");
6 require_once ("./inc/utils.php");
7 require_once ("./inc/db/mysql.php");
9 function headers_callback ($output) {
10 $etag = md5 ($output);
11 if ((isset ($_SERVER ["HTTP_IF_NONE_MATCH"])) &&
12 ($_SERVER ["HTTP_IF_NONE_MATCH"] == $etag)) {
13 header ("HTTP/1.1 304 Not Modified");
17 header ("Content-type: application/vnd.google-earth.kml+xml");
18 header ("Cache-control: must-revalidate");
19 header (sprintf ("ETag: %s", $etag));
24 function main ($features) {
26 echo '<?xml version="1.0" encoding="UTF-8"?>
27 <kml xmlns="http://www.opengis.net/kml/2.2">
32 printf (' <name>%s</name>', SITETITLE);
34 foreach ($features as $feature) {
36 $title = htmlspecialchars ($feature->title, ENT_QUOTES);
37 $description = htmlspecialchars ($feature->description, ENT_QUOTES);
38 $imgurl = ($feature->imgpath ?
39 image_url_from_imgpath ($feature->imgpath)
41 $thumburl = ($feature->imgpath ?
42 thumb_url_from_imgpath ($feature->imgpath)
46 $alt = (strlen ($title) > 60) ?
47 (substr ($title, 0, 57) . '...') :
51 $imgurlHTML = sprintf ('<a href="%s"><img alt="%s" src="%s"></a>', $imgurl, $alt, $thumburl);
57 $descriptionHTML = sprintf ('<p>%s</p>', $description) ;
59 $descriptionHTML = "";
65 <description><![CDATA[
70 <coordinates>%s,%s</coordinates>
73 ', $id, $title, $descriptionHTML, $imgurlHTML, $lon, $lat);
81 $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
82 $features = $connection->listfeatures ();
83 } catch (Exception $e) {
84 exit ("server error");
87 ob_start ("headers_callback");