root > potd > bin > potd-terse-rss.php

potd-terse-rss.php

application/x-php, 2699 bytes (load raw)
<?php
if (@$_SERVER['REQUEST_URI']) die("command line only");
require_once("potd-lib.php");

#$feedauthor = 'potd@tools.wikimedia.de';
$feedauthor = 'WikiPOTD';

$basedir = $argv[1];
$sz = $argv[2];

$pubdate = time();

$sources = array();
$timestamp = 0;
$html = '';
$dd = glob("$basedir/*", GLOB_ONLYDIR);
foreach ($dd as $dir) {
        if (!file_exists("$dir/potd.conf") || !file_exists("$dir/potd.meta.xml")) continue;

        $info = load_info($dir);

        $info['filemtime'] = filemtime("$dir/potd.name");
        $timestamp = max($timestamp, $info['filemtime']);

        $html.= '<p style="text-align:center">' . "\n";
        $html.= '<b>' . escape_xml($info['wiki']) . ':</b><br/>';
        $html.= image_html($info, $sz);
        $html.= '</p>';
        $html.= '<hr/>';

        $sources[] = home_url($info);
}

//NOTE: including dc:source for each element from $sources would be nice.
//      but the w3c validator complains about multiple source elements

if (!$html) exit();

function rssDate($timestamp) {
    return gmdate( 'D, d M Y H:i:s \G\M\T', $timestamp );
}

$guid = "http://tools.wikimedia.de/~daniel/potd/#*/$sz@" . gmdate( 'YmdHis', $pubdate) . ':' . gmdate( 'YmdHis', $timestamp);
$itemttl= "Pictures of the Day - " . gmdate( 'F d', $pubdate );

print '<?xml version="1.0" encoding="UTF-8"?>'."\n";
?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">

<channel>
<title>Pictures of the Day (<?= $sz ?>)</title>
<link>http://tools.wikimedia.de/~daniel/potd/potd.php</link>
<description>Wikimedia communities' pictures of the day</description>
<language>en-us</language><? /* FIXME */ ?>
<copyright>Feed: GNU Free Documentation License; Images: see description page</copyright>
<pubDate><?= rssDate( $pubdate ) ?></pubDate>
<lastBuildDate><?= rssDate( $pubdate ) ?></lastBuildDate>

<generator>WikiPOTD 0.5.5</generator>
<docs>http://meta.wikimedia.org/wiki/User:Duesentrieb/POTD</docs>

<image>
        <!-- Icon from http://commons.wikimedia.org/wiki/Image:Featured_envelope.svg,
             created by pfctdayelise. Licensed under GFDL-1.2 and CC-BY-SA-2.5 -->
        <url>http://tools.wikimedia.de/~daniel/potd/potd.png</url>
        <title>Pictures of the Day (<?= $sz ?>)</title>
        <link>http://tools.wikimedia.de/~daniel/potd/potd.php</link>
</image>

<item>
        <!-- core RSS -->
        <title><?= escape_xml($itemttl) ?></title>
        <pubDate><?= rssDate( $pubdate ) ?></pubDate>
        <link>http://tools.wikimedia.de/~daniel/potd/potd.php</link>
        <guid isPermaLink="false"><?= escape_xml($guid)?></guid>

        <dc:title><?= escape_xml($itemttl) ?></dc:title>
        <dc:publisher><?= escape_xml($feedauthor) ?></dc:publisher>
        <dc:identifier><?= escape_xml($guid)?></dc:identifier>

        <description>
                <?= escape_xml($html)?>
        </description>
</item>

</channel>
</rss>