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 main ($features) {
11 header ("Cache-control: no-cache");
13 echo '<?xml version="1.0" encoding="UTF-8"?>
14 <kml xmlns="http://www.opengis.net/kml/2.2">
19 printf (' <name>%s</name>', SITETITLE);
21 foreach ($features as $feature) {
23 $title = htmlspecialchars ($feature->title, ENT_QUOTES);
24 $description = htmlspecialchars ($feature->description, ENT_QUOTES);
25 $imgurl = ($feature->imgpath ?
26 image_url_from_imgpath ($feature->imgpath)
28 $thumburl = ($feature->imgpath ?
29 thumb_url_from_imgpath ($feature->imgpath)
33 $alt = (strlen ($title) > 60) ?
34 (substr ($title, 0, 57) . '...') :
38 $imgurlHTML = sprintf ('<a href="%s"><img alt="%s" src="%s"></a>', $imgurl, $alt, $thumburl);
44 $descriptionHTML = sprintf ('<p>%s</p>', $description) ;
46 $descriptionHTML = "";
52 <description><![CDATA[
57 <coordinates>%s,%s</coordinates>
60 ', $id, $title, $descriptionHTML, $imgurlHTML, $lon, $lat);
68 $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
69 $features = $connection->listfeatures ();
70 } catch (Exception $e) {
71 exit ("server error");
73 header ("Content-type: application/vnd.google-earth.kml+xml");