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 header ("Cache-control: must-revalidate");
15 header (sprintf ("ETag: %s", $etag));
20 function main ($features) {
22 echo '<?xml version="1.0" encoding="UTF-8"?>
23 <kml xmlns="http://www.opengis.net/kml/2.2">
28 printf (' <name>%s</name>', htmlspecialchars (SITETITLE));
30 foreach ($features as $feature) {
32 $title = htmlspecialchars ($feature->title, ENT_QUOTES);
33 $description = htmlspecialchars ($feature->description, ENT_QUOTES);
34 $imgurl = ($feature->imgpath ?
35 image_url_from_imgpath ($feature->imgpath)
37 $thumburl = ($feature->imgpath ?
38 thumb_url_from_imgpath ($feature->imgpath)
42 $alt = (strlen ($title) > 60) ?
43 (substr ($title, 0, 57) . '...') :
47 $imgurlHTML = sprintf ('<a href="%s"><img alt="%s" src="%s"></a>', $imgurl, $alt, $thumburl);
53 $descriptionHTML = sprintf ('<p>%s</p>', $description) ;
55 $descriptionHTML = "";
61 <description><![CDATA[
66 <coordinates>%s,%s</coordinates>
69 ', $id, $title, $descriptionHTML, $imgurlHTML, $lon, $lat);
76 if (!@include_once ("./inc/settings.php")) {
77 exit ("server error");
79 require_once ("./inc/utils.php");
80 require_once ("./inc/db/mysql.php");
83 $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
84 $features = $connection->listfeatures ($_GET ['from_user']);
85 } catch (Exception $e) {
86 exit ("server error");
89 ob_start ("headers_callback");