2 /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
5 function headers_callback ($output) {
7 if ((isset ($_SERVER ["HTTP_IF_NONE_MATCH"])) &&
8 ($_SERVER ["HTTP_IF_NONE_MATCH"] == $etag)) {
9 header ("HTTP/1.1 304 Not Modified");
13 header ("Content-type: application/vnd.google-earth.kml+xml");
14 // no-cache is needed otherwise IE does not try to get new version.
15 header ("Cache-control: no-cache, must-revalidate");
16 header (sprintf ("ETag: %s", $etag));
21 function main ($features) {
23 echo '<?xml version="1.0" encoding="UTF-8"?>
24 <kml xmlns="http://www.opengis.net/kml/2.2">
29 printf (' <name>%s</name>', htmlspecialchars (SITETITLE));
31 foreach ($features as $feature) {
33 $title = htmlspecialchars ($feature->title, ENT_QUOTES);
34 $description = htmlspecialchars ($feature->description, ENT_QUOTES);
35 $imgurl = ($feature->imgpath ?
36 image_url_from_imgpath ($feature->imgpath)
38 $thumburl = ($feature->imgpath ?
39 thumb_url_from_imgpath ($feature->imgpath)
43 $alt = (strlen ($title) > 60) ?
44 (substr ($title, 0, 57) . '...') :
48 $imgurlHTML = sprintf ('<a href="%s"><img alt="%s" src="%s"></a>', $imgurl, $alt, $thumburl);
54 $descriptionHTML = sprintf ('<p>%s</p>', $description) ;
56 $descriptionHTML = "";
62 <description><![CDATA[
67 <coordinates>%s,%s</coordinates>
70 ', $id, $title, $descriptionHTML, $imgurlHTML, $lon, $lat);
77 if (!@include_once ("./inc/settings.php")) {
78 exit ("server error");
80 require_once ("./inc/utils.php");
81 require_once ("./inc/db/" . (defined ("DBTYPE")? DBTYPE: "mysql") . ".php");
84 $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
85 $features = $connection->listfeatures ($_GET ['from_user']);
86 } catch (Exception $e) {
87 exit ("server error");
90 ob_start ("headers_callback");