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 echo '<?xml version="1.0" encoding="UTF-8"?>
12 <kml xmlns="http://www.opengis.net/kml/2.2">
17 printf (' <name>%s</name>', SITETITLE);
19 foreach ($features as $feature) {
21 $title = htmlspecialchars ($feature->title, ENT_QUOTES);
22 $description = htmlspecialchars ($feature->description, ENT_QUOTES);
23 $imgurl = ($feature->imgpath ?
24 full_url_from_filename ($feature->imgpath)
28 $alt = (strlen ($title) > 60) ?
29 (substr ($title, 0, 57) . '...') :
33 $imgurlHTML = sprintf ('<img alt="%s" src="%s">', $alt, $imgurl);
39 $descriptionHTML = sprintf ('<p>%s</p>', $description) ;
41 $descriptionHTML = "";
47 <description><![CDATA[
52 <coordinates>%s,%s</coordinates>
55 ', $id, $title, $descriptionHTML, $imgurlHTML, $lon, $lat);
63 $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
64 $features = $connection->listfeatures ();
65 } catch (Exception $e) {
66 exit ("server error");
68 header ("Content-type: application/vnd.google-earth.kml+xml");