xref: /web-php/releases/feed.php (revision 59c070f5)
1<?php
2
3header("Content-Type: application/atom+xml");
4
5include __DIR__ . "/../include/version.inc";
6
7echo <<<XML
8<?xml version="1.0" encoding="UTF-8"?>
9<feed xmlns="http://www.w3.org/2005/Atom" xmlns:php="http://php.net/ns/releases">
10    <title>PHP.net releases</title>
11    <link href="/releases.atom" rel="self"/>
12    <icon>/images/news/php-logo.gif</icon>
13    <author>
14        <name>Webmaster</name>
15        <uri>http://php.net/contact</uri>
16        <email>php-webmaster@lists.php.net</email>
17    </author>
18    <id>http://php.net/releases/index.php</id>
19
20XML;
21
22ob_start();
23
24// Flatten major versions out of RELEASES.
25$RELEASED_VERSIONS = array_reduce($RELEASES, 'array_merge', []);
26$FEED_UPDATED = 0;
27krsort($RELEASED_VERSIONS);
28foreach ($RELEASED_VERSIONS as $version => $release) {
29    $published = date(DATE_ATOM, strtotime($release["source"][0]["date"]));
30    if ($release["announcement"]) {
31        $id = "http://php.net/releases/" . str_replace(".", "_", $version) . ".php";
32    } else {
33        $id = "http://qa.php.net/#$version";
34    }
35
36    echo <<<XML
37    <entry>
38        <title>PHP {$version} released!</title>
39        <id>{$id}</id>
40        <php:version>{$version}</php:version>
41        <published>{$published}</published>
42        <summary type="html">There is a new PHP release in town!</summary>
43
44XML;
45    $maxtime = [];
46    foreach ($release["source"] as $source) {
47        if (!isset($source["date"])) {
48            continue;
49        }
50        $maxtime[] = $time = strtotime($source["date"]);
51        $released = date(DATE_ATOM, $time);
52
53        echo "        <link rel=\"enclosure\" title=\"{$source["name"]}\" href=\"/distributions/{$source["filename"]}\">\n";
54        foreach (['md5', 'sha256'] as $hashAlgo) {
55            if (isset($source[$hashAlgo])) {
56                echo "            <php:{$hashAlgo}>{$source[$hashAlgo]}</php:{$hashAlgo}>\n";
57            }
58        }
59
60        echo <<<XML
61            <php:releaseDate>{$released}</php:releaseDate>
62        </link>
63
64XML;
65
66    }
67
68    $updated = date(DATE_ATOM, max($maxtime));
69
70    if (isset($release['tags'])) {
71        foreach ($release['tags'] as $tag) {
72            echo '        <php:tag>', htmlspecialchars($tag), "</php:tag>\n";
73        }
74    }
75
76    echo <<<XML
77        <updated>{$updated}</updated>
78        <content src="{$id}" type="application/xhtml+xml"/>
79    </entry>
80
81XML;
82
83    $FEED_UPDATED = max($maxtime, $FEED_UPDATED);
84}
85
86$entries = ob_get_clean();
87
88$FEED_UPDATED = date(DATE_ATOM, max($FEED_UPDATED));
89
90echo "    <updated>{$FEED_UPDATED}</updated>\n";
91echo $entries;
92echo "</feed>";
93