rendered paste body### FeedWriter.php<?phprequire_once 'FeedWriterItem.php';require_once 'FeedWriterTitle.php';abstract class FeedWriter { /** * Write feed. Needs subclass to work. * * @param Array of FeedWriter Item instances * @param FeedWriterTitle instance */ public function main(&$arrItems, &$title) { // Send headers if (headers_sent() === false) { header("Last-Modified: " . date("D, M j Y G:i:s O", $title->lastUpdated)); $this->sendHeader(); } $this->printTitle($title); foreach($arrItems as $item) { $this->printItem($item); } $this->printEnd(); } protected function sendHeader() { header("Content-Type: text/xml"); } abstract protected function printItem($item); abstract protected function printTitle($title); abstract protected function printEnd();}### FeedWriterRssWriter.php <?phprequire_once 'FeedWriter.php';class FeedWriterRssWriter extends FeedWriter { protected function sendHeader() { header("Content-Type: text/xml"); } protected function printItem($item) { ?> <item> <title><?php print $item->title; ?></title> <link><?php print $item->link; ?></link> <description><?php print $item->description; ?></description> <content:encoded><?php print $item->content; ?></content:encoded> <pubDate><?php print date(DATE_RFC822, $item->pubDate); ?></pubDate> <guid isPermaLink="true"><?php print $item->guid; ?></guid> <author><?php print $item->author; ?></author> </item> <?php } protected function printTitle($title) { print '<?xml version="1.0" encoding="' . $title->encoding . '"?>'; ?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" > <channel> <title><?php print $title->title; ?></title> <link><?php print $title->link; ?></link> <description><?php print $title->description; ?></description> <language>de</language> <pubDate><?php print date(DATE_RFC822, $title->lastUpdated); ?></pubDate> <generator><?php print $title->generator; ?></generator> <image> <title><?php print $title->title; ?></title> <link><?php print $title->link; ?></link> <url><?php print $title->imageURL; ?></url> </image> <?php } protected function printEnd() { ?> </channel> </rss> <?php }}### FeedWriterItem.php <?php /*** Simple Date Structure holding feed item data*/class FeedWriterItem { public $description = ''; public $title = ''; public $link = ''; public $pubDate = ''; // this is a date, no string! public $guid = ''; public $author = ''; public $content = '';}### FeedWriterTitle.php <?php /** * Simple Date Structure holding feed data */class FeedWriterTitle { public $title = ''; public $lastUpdated = ''; // this is a date, no string! public $description = ''; public $link = ''; public $imageURL = ''; public $generator = ''; public $encoding = 'Utf-8';}## usage#<?phperror_reporting(E_ALL);require_once 'FeedWriter/FeedWriterRssWriter.php';define('NUMBEROFPOSTS', 6);define('GENERATOR', 'Sommerzeit Benachrichtigung');//get RSS get parmif (isset($_GET['rss'])) { $rss = (boolean) $_GET['rss']; header('Content-type: application/rss+xml; charset=UTF-8');}else { $rss = false; header('Content-type: text/plain; charset=UTF-8');}//get date GETif (isset($_GET['date'])) { $now = (int) $_GET['date']; $numberOfPosts = 1;}else { $now = gmmktime(); $numberOfPosts = NUMBEROFPOSTS;}//get prepublish GETif (isset($_GET['prepublish'])) { $prePublish = (int) $_GET['prepublish']; $prePublish *= 60 * 60 * 24;}else { $prePublish = 0;}$locales = array('de_DE@euro', 'de_DE', 'en_EN');$timezones = array(-1, -1, 0);//get timezone GETif (isset($_GET['locale']) && ($key = array_search($_GET['locale'], $locales)) !== false) { $locale = setlocale(LC_ALL, $locales[$key]); $timezone = $timezones[$key];}else { $locale = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge'); $timezone = -1;}//make timezone calculationsdefine('URL', 'http://userp.uni-koblenz.de/~hrehfeld/time/time.php?timezone=' . $timezone);//calculate current time$now += $prePublish;$currentYear = gmdate('Y', $now);$currentMonth = gmdate('m', $now);//caculate if the last change was a MESZ -> normal time change$back = (boolean) ($currentMonth - 3) / 6;$items = array();for ($i = 0; $i < $numberOfPosts; ++$i) { $year = (int) ($currentYear - ( $i / 2)); $lastChangeTime = getMeszShiftTime($year, $back); if (!$back) { $season = 'vor auf Sommer'; } else { $season = 'zurück auf Normal'; } $description = 'Zeitumstellung ' . $season . 'zeit am ' . readableDate($lastChangeTime, $timezone); if ($rss) { $item = new FeedWriterItem(); $pubdate = $lastChangeTime - $prePublish; $item->pubDate = $pubdate; $item->description = $description; $item->title = $item->description; $item->content = $item->description; $item->guid = URL . '&date=' . $lastChangeTime; $item->link = URL; $items[] = $item; } else { echo $description, "\n"; } $back = !$back;}if ($rss) { $title = new FeedWriterTitle(); $title->generator = GENERATOR; $title->lastUpdated = getMeszShiftTime($currentYear, $back) - $timezone; $title->description = 'Sommer-/Normalzeitumstellungsbenachrichtigung'; $title->title = $title->description; $title->link = URL; $writer = new FeedWriterRssWriter(); $writer->main($items, $title);}function getMeszShiftTime($year, $back = false) { if ($back) { $month = 10; } else { $month = 3; } //find last sunday in month $lastDay = gmdate('w', gmmktime(0, 0, 0, $month, 31, $year, 0)); $day = 31 - $lastDay; // in oct time changes at 3 oclock, not 2 $hours = 1 + (int) $back; //return a timestamp return gmmktime($hours, 00, 0, $month, $day, $year);} function readableDate($time, $timezone = -1) { $time -= $timezone * 60 * 60; return mb_convert_encoding(strftime('%A, dem %e. %B %Y', $time), 'utf-8') . ' um ' . gmdate('G:i', $time);}