2 /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
5 require ("./inc/settings.php");
6 require ("./inc/errors.php");
7 require ("./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) {
20 $title = htmlspecialchars ($feature->title, ENT_QUOTES);
21 $description = htmlspecialchars ($feature->description, ENT_QUOTES);
22 if (strpos ($feature->imgurl, "http://") === 0) {
23 $imgurl = "http://" . rawurlencode (substr($feature->imgurl, 7));
24 } else if (strpos ($feature->imgurl, "https://") === 0) {
25 $imgurl = "https://" . rawurlencode (substr ($feature->imgurl, 8));
27 $imgurl = rawurlencode ($feature->imgurl);
29 $imgurl = str_replace ('%2F', '/', $imgurl);
32 $alt = (strlen ($title) > 60) ?
33 (substr ($title, 0, 57) . '...') :
39 <description><![CDATA[
41 <img alt="%s" src="%s">
44 <coordinates>%s,%s</coordinates>
47 ', $title, $description, $alt, $imgurl, $lon, $lat);
55 $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
56 $features = $connection->listfeatures ();
57 } catch (Exception $e) {
60 header ("Content-type: application/vnd.google-earth.kml+xml");