summaryrefslogtreecommitdiffstats
path: root/apis/news.inc.php
blob: 2c7e265489539ae9be4b110d756246e6b780d3c9 (plain) (blame)
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
<?php

header('Content-Type: application/xml; charset=utf-8');

// Fetch news from DB
$row = Database::queryFirst('SELECT title, content, dateline FROM news ORDER BY dateline DESC LIMIT 1');
if ($row !== false ) {

	echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
	echo "<news>" . "\n";
	echo "\t" . '<headline>' . "\n";
	echo "\t\t" . $row['title'] . "\n";
	echo "\t" . '</headline>' . "\n";
	echo "\t" . "<content>" . "\n";
	echo "\t\t" . $row['content'] . "\n";
	echo "\t" . '</content>' . "\n";
	echo "\t" . "<date>" . "\n";
	echo "\t\t" . $row['dateline'] . "\n";
	echo "\t" . "</date>" . "\n";
	echo "</news>";

} else {
	// no news in DB, output a 'null' news xml
	echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
	echo "<news>null</news>";
}