<?php
include('functions.php');
$title 'TUM Diskrete Strukturen Uebungen';
$url 'http://www14.in.tum.de/lehre/2007WS/ds/uebung/';
$description '';
$lang 'de';

$file implode(''file($url));

if ( !
preg_match('#<h4 align=center>&Uuml;bungsbl&auml;tter</h4>\s+<table align=center>\s+<tr>\s+<td>\s+<ul>(.+?)</ul>\s+</td>\s+</tr>\s+</table>#is'$file$regs) )
    die(
'No match!');
$block $regs[1];
$block remove_comments($block);
if ( !
preg_match_all('#<li>\s+(&Uuml;bungsblatt [0-9]+) \((.+?)\) \[<a href="(ue[0-9]+\.pdf)">PDF</a>\](?:\s+- Ergebnisse \[<a href="(lo[0-9]+\.pdf)">PDF</a>\])?\s+</li>#is'$block$regs))
    die(
'No entry matches!');

header('Content-Type: application/rss+xml; charset=utf-8');
echo 
'<?xml version="1.0"?>
<rss version="2.0">
    <channel>
        <title>' 
$title '</title>
        <link>' 
$url '</link>
        <description>' 
$description '</description>
        <language>' 
$lang '</language>
        <pubDate>' 
date('r') . '</pubDate>
'

/* <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate> */
for ( $i count($regs[0])-1$i >= 0$i-- )
{
    
$regs[1][$i] = str_replace('&Uuml;''Ue'$regs[1][$i]);
    if ( !empty(
$regs[4][$i]) )
    {
        echo 
'
        <item>
            <title>' 
$regs[1][$i] . ' - Loesung</title>
            <link>' 
$url $regs[4][$i] . '</link>
            <description>Loesung der Aufgaben vom ' 
$regs[2][$i]  . '</description>' /*
            <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>*/ 
'
            <guid>' 
$url $regs[4][$i] . '</guid>
            <enclosure url="' 
$url $regs[4][$i] . '" length="1" type="application/pdf" />
        </item>'
;
    }

    echo 
'
        <item>
            <title>' 
$regs[1][$i] . '</title>
            <link>' 
$url $regs[3][$i] . '</link>
            <description>Abgabe: ' 
$regs[2][$i]  . '</description>' /*
            <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>*/ 
'
            <guid>' 
$url $regs[3][$i] . '</guid>
            <enclosure url="' 
$url $regs[3][$i] . '" length="1" type="application/pdf" />
        </item>'
;
}
echo 
'
    </channel>
</rss>
'
;
?>