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 full_url_from_imgpath ($feature->imgpath)
30 $alt = (strlen ($title) > 60) ?
31 (substr ($title, 0, 57) . '...') :
35 $imgurlHTML = sprintf ('<img alt="%s" src="%s">', $alt, $imgurl);
41 $descriptionHTML = sprintf ('<p>%s</p>', $description) ;
43 $descriptionHTML = "";
49 <description><![CDATA[
54 <coordinates>%s,%s</coordinates>
57 ', $id, $title, $descriptionHTML, $imgurlHTML, $lon, $lat);
65 $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
66 $features = $connection->listfeatures ();
67 } catch (Exception $e) {
68 exit ("server error");
70 header ("Content-type: application/vnd.google-earth.kml+xml");