X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=items.php;h=c36318379964d0790564a47587ccf7b4416ef27a;hp=f816cfbeb25f1f8b060779ea105bef8afed77095;hb=9acc365249b5e630da6b5cdd23e3a8015f39ddc7;hpb=7282fabcfef34ef95b8c6bd414f34d77037451e1 diff --git a/items.php b/items.php index f816cfb..c363183 100644 --- a/items.php +++ b/items.php @@ -2,12 +2,14 @@ /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD license. */ -require ("./inc/settings.php"); -require ("./inc/errors.php"); -require ("./inc/db/mysql.php"); +require_once ("./inc/settings.php"); +require_once ("./inc/utils.php"); +require_once ("./inc/db/mysql.php"); function main ($features) { + header ("Cache-control: no-cache"); + echo ' @@ -17,34 +19,45 @@ function main ($features) { printf (' %s', SITETITLE); } foreach ($features as $feature) { + $id = $feature->id; $title = htmlspecialchars ($feature->title, ENT_QUOTES); $description = htmlspecialchars ($feature->description, ENT_QUOTES); - if (strpos ($feature->imgurl, "http://") === 0) { - $imgurl = "http://" . rawurlencode (substr($feature->imgurl, 7)); - } else if (strpos ($feature->imgurl, "https://") === 0) { - $imgurl = "https://" . rawurlencode (substr ($feature->imgurl, 8)); - } else { - $imgurl = rawurlencode ($feature->imgurl); - } - $imgurl = str_replace ('%2F', '/', $imgurl); + $imgurl = ($feature->imgpath ? + image_url_from_imgpath ($feature->imgpath) + : ""); + $thumburl = ($feature->imgpath ? + thumb_url_from_imgpath ($feature->imgpath) + : ""); $lon = $feature->lon; $lat = $feature->lat; $alt = (strlen ($title) > 60) ? (substr ($title, 0, 57) . '...') : $title; + if ($imgurl) { + $imgurlHTML = sprintf ('%s', $imgurl, $alt, $thumburl); + } else { + $imgurlHTML = ""; + } + + if ($description) { + $descriptionHTML = sprintf ('

%s

', $description) ; + } else { + $descriptionHTML = ""; + } + printf (' - + %s %s

- %s + %s + %s ]]>
%s,%s
-', $title, $description, $alt, $imgurl, $lon, $lat); +', $id, $title, $descriptionHTML, $imgurlHTML, $lon, $lat); } echo'
@@ -55,7 +68,7 @@ try { $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX); $features = $connection->listfeatures (); } catch (Exception $e) { - server_error (); + exit ("server error"); } header ("Content-type: application/vnd.google-earth.kml+xml"); main ($features);