2012-12-26 20:39:54 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// publically available page to feed the news to feedreaders
|
|
|
|
function user_atom() {
|
|
|
|
global $ical_shifts, $user, $DISPLAY_NEWS;
|
|
|
|
|
|
|
|
if (isset ($_REQUEST['key']) && preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key']))
|
|
|
|
$key = $_REQUEST['key'];
|
|
|
|
else
|
|
|
|
die("Missing key.");
|
|
|
|
|
2013-09-10 14:27:31 +02:00
|
|
|
$user = User_by_api_key($key);
|
|
|
|
if($user === false)
|
|
|
|
die("Unable to find user.");
|
|
|
|
if($user == null)
|
2012-12-26 20:39:54 +01:00
|
|
|
die("Key invalid.");
|
2013-09-10 14:27:31 +02:00
|
|
|
if(!in_array('atom', privileges_for_user($user['UID'])))
|
|
|
|
die("No privilege for atom.");
|
2012-12-26 20:39:54 +01:00
|
|
|
|
|
|
|
$news = sql_select("SELECT * FROM `News` " . (empty($_REQUEST['meetings'])? '' : 'WHERE `Treffen` = 1 ') . "ORDER BY `ID` DESC LIMIT " . sql_escape($DISPLAY_NEWS));
|
|
|
|
|
|
|
|
header('Content-Type: application/atom+xml; charset=utf-8');
|
|
|
|
$html = '<?xml version="1.0" encoding="utf-8"?>
|
2013-09-10 14:27:31 +02:00
|
|
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
2012-12-26 20:39:54 +01:00
|
|
|
<title>Engelsystem</title>
|
|
|
|
<id>' . $_SERVER['HTTP_HOST'] . htmlspecialchars(preg_replace('#[&?]key=[a-f0-9]{32}#', '', $_SERVER['REQUEST_URI'])) . '</id>
|
|
|
|
<updated>' . date('Y-m-d\TH:i:sP', $news[0]['Datum']) . "</updated>\n";
|
|
|
|
foreach ($news as $news_entry) {
|
|
|
|
$html .= " <entry>
|
|
|
|
<title>" . htmlspecialchars($news_entry['Betreff']) . "</title>
|
|
|
|
<link href=\"" . page_link_to_absolute("news_comments&nid=") . "${news_entry['ID']}\"/>
|
|
|
|
<id>" . preg_replace('#^https?://#', '', page_link_to_absolute("news")) . "-${news_entry['ID']}</id>
|
|
|
|
<updated>" . date('Y-m-d\TH:i:sP', $news_entry['Datum']) . "</updated>
|
|
|
|
<summary type=\"html\">" . htmlspecialchars($news_entry['Text']) . "</summary>
|
2013-09-10 14:27:31 +02:00
|
|
|
</entry>\n";
|
|
|
|
}
|
|
|
|
$html .= "</feed>";
|
|
|
|
header("Content-Length: " . strlen($html));
|
|
|
|
echo $html;
|
|
|
|
die();
|
2012-12-26 20:39:54 +01:00
|
|
|
}
|
|
|
|
?>
|