-
-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathrss.php
More file actions
37 lines (30 loc) · 1.06 KB
/
Copy pathrss.php
File metadata and controls
37 lines (30 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
date_default_timezone_set( 'UTC' );
require_once(__DIR__ . '/../vendor/autoload.php');
/* Find files */
$d = glob( "../data/news/*html" );
sort($d);
$d = array_reverse( $d );
$latest = preg_replace( '@^../data/news/(.*).html$@', '\1', (string) $d[0] );
$feed = new ezcFeed();
$feed->title = 'Xdebug.org announcements';
$feed->description = 'This is a feed showing the latest announcements from xdebug.org.';
$feed->published = new DateTime( "$latest 09:00" );
$author = $feed->add( 'author' );
$author->name = 'Derick Rethans';
$author->email = 'derick@xdebug.org';
$link = $feed->add( 'link' );
$link->href = 'http://xdebug.org';
foreach ( $d as $item )
{
$date = preg_replace( '@^../data/news/(.*).html$@', '\1', (string) $item );
$file = file( $item );
$title = array_shift( $file );
$item = $feed->add( 'item' );
$item->title = trim( (string) $title );
$item->description = join( '', $file );
$item->published = new DateTime( "$date 09:00" );
}
$xml = $feed->generate( 'rss2' );
header( 'Content-Type: ' . $feed->getContentType() . '; charset=utf-8' );
echo $xml;