2 header("Content-Type: application/atom+xml");
4 $url = 'http://www.ssps.cz/pages/rozvrhy/index.php';
8 $croom = trim($_GET['q']);
10 function atomPrintItem($title, $id, $update, $link, $desc='') {
12 echo("\t<id>$id</id>\n");
13 echo("\t<updated>" . strftime("%Y-%m-%dT%H:%M:%SZ", $update) . "</updated>\n");
14 echo("\t<title>$title</title>\n");
15 echo("\t<link href=\"$link\" />\n");
16 echo("\t<content>$desc</content>\n");
19 echo('<?xml'); ?
> version
="1.0" encoding
="UTF-8"?
>
20 <feed xmlns
="http://www.w3.org/2005/Atom" xml
:lang
="cs">
21 <title
>Změny v rozvrhu SSPŠ
</title
>
22 <subtitle
>Aktuální změny v rozvrhu SSPŠ
</subtitle
>
23 <link href
="<?php echo($url); ?>" />
24 <icon
>http
://www.ssps.cz/favicon.ico</icon>
25 <id
>tag
:ssps
.cz
,2008:</id
>
30 $croom = str_replace('.', '\.', $croom);
31 $feed = split('<[^>]+>', iconv('WINDOWS-1250', 'UTF-8', file_get_contents($url)));
38 foreach($feed as $line) {
40 if($line == '' ||
eregi('rozvrhy', $line)) continue;
43 if (eregi("^Aktualizováno: (..)\.(..)\.(....) (..:..:..)$", $line, $r))
45 $update = strtotime("{$r[3]}-{$r[2]}-{$r[1]} {$r[4]}");
47 # This is the last update of the whole feed
48 if ($lastUpdate < $update)
49 $lastUpdate = $update;
53 # What day are we reading?
54 if (eregi("^[^ ]+ (..)\.(..)\.(....)$", $line, $r))
56 $date = strtotime("{$r[3]}-{$r[2]}-{$r[1]}");
60 # Found a line about our class
61 if ($date && eregi($croom, $line))
63 $days = array('Ne', 'Po', 'Út', 'St', 'Čt', 'Pá', 'So');
64 $wday = localtime($date, TRUE);
65 $wday = $days[$wday['tm_wday']];
66 atomPrintItem($wday . strftime(" %d.%m. ", $date) . $line,
67 "tag:ssps.cz," . strftime("%Y-%m-%d:", $date) . md5($line),
68 $update, $url, $line);
71 $feed = ob_get_contents();
73 # Must appear before the items
74 echo ("\t<updated>" . strftime("%Y-%m-%dT%H:%M:%SZ", $lastUpdate) . "</updated>\n");