X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=news.php;fp=news.php;h=615989f0fb3d00318808ecea45fe3487b02c2ae6;hp=0000000000000000000000000000000000000000;hb=e4a4e5149d55cf01a86f26392c52fdca803654ce;hpb=de485fbe85dc15d416ed08a51d6561fc8db0e078 diff --git a/news.php b/news.php new file mode 100644 index 0000000..615989f --- /dev/null +++ b/news.php @@ -0,0 +1,111 @@ +date); + + $matches = array(); + if (preg_match ('/^([\-+])(\d{2})(\d{2})$/', + date ('O', $feature->date), $matches)) { + $date .= $matches [1] . $matches [2] . ':' . $matches [3]; + } else { + $date .= 'Z'; + } + return $date; +} + +function unique_id_from_feature ($feature) { + // method from http://diveintomark.org/archives/2004/05/28/howto-atom-id#other + $date = date('Y-m-d', $feature->date); + $res = sprintf("tag:%s,%s:%d", gethost(), $date, $feature->id); + return $res; +} + +function unique_id_from_site () { + $id = md5 (full_url_from_path ("")); + $res = sprintf("tag:%s,1970-01-01:%d", gethost, $id); + return $res; +} + +function main ($features) { + print " +\n"; + + printf(" \n", + full_url_from_path ("")); + printf(" \n", + full_url_from_path (basename ($_SERVER ["PHP_SELF"]))); + printf(" %s\n", unique_id_from_site()); + + if (count ($features) > 0) { + printf(" %s\n", date3339 ($features[0])); + } + + if (SITETITLE) { + printf (" %s\n", SITETITLE); + } + + if (WEBMASTERMAIL) { + printf (" \n"); + printf (" %s\n", WEBMASTERMAIL); + printf(" \n"); + } + + print "\n"; + + foreach ($features as $feature) { + print (" \n"); + + if ($feature->title) { + $title = htmlspecialchars ($feature->title, ENT_QUOTES); + } else { + $title = $feature->id; + } + printf (" %s\n", $title); + + $rel_url = sprintf ("index.php?lat=%.18F&lon=%.18F&zoom=12", + $feature->lat, $feature->lon); + $link = htmlspecialchars (full_url_from_path ($rel_url), ENT_QUOTES); + printf (" \n", $link); + + printf (" %s\n", unique_id_from_feature ($feature)); + + printf (" %s\n", date3339 ($feature)); + + if ($feature->description) { + $contentHTML = sprintf ("

%s

", htmlspecialchars ($feature->description, ENT_QUOTES)); + } else { + $contentHTML = sprintf ("

%s

", htmlspecialchars ($feature->title, ENT_QUOTES)); + } + + if (strlen ($contentHTML) != 0) { + printf(" + %s + \n", htmlspecialchars ($contentHTML)); + } + + printf(" %.18F %.18F\n", + $feature->lat, $feature->lon); + + printf("
\n\n"); + } + print '
'; +} + +try { + $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX); + $features = $connection->mostrecentfeatures (10); +} catch (Exception $e) { + exit ("server error"); +} +main ($features); +?>