-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrss.php
More file actions
58 lines (48 loc) · 1.58 KB
/
rss.php
File metadata and controls
58 lines (48 loc) · 1.58 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
include("classes.php");
if (!defined('INSTALLED')) {
header("Location: ./install/");
exit;
}
$sql = "SELECT * FROM ".$_qdbs['tpfx']."settings";
$r = $db->_sql($sql);
$row = $db->fetch_row($r);
$sitetitle = htmlentities($row['title'], ENT_XML1);
$urlscheme = (isset($_SERVER['HTTPS']) ? "https" : "http");
$urlhost = $_SERVER['HTTP_HOST'];
$urlport = "";
if (isset($_SERVER['SERVER_PORT'])) {
$ports = ["80", "443"];
if (!in_array($_SERVER['SERVER_PORT'], $ports)) {
$urlport = ":" . $_SERVER['SERVER_PORT'];
}
}
$baseurl = sprintf("%s://%s%s", $urlscheme, $urlhost, $urlport);
header("Content-Type: application/xml");
$date = date("r", time());
$content = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
<rss version=\"2.0\">
<channel>
<title>" . $sitetitle . " - Latest Quotes</title>
<link>" . $baseurl . "</link>
<description>" . $sitetitle . " - Latest Quotes</description>
<pubDate>".$date."</pubDate>
<lastBuildDate>".$date."</lastBuildDate>
<generator>QdbS ".QDBS_VERSION."</generator>
<ttl>30</ttl>";
$sql = "SELECT * FROM ".$_qdbs['tpfx']."quotes ORDER BY id DESC LIMIT ".intval($pgr->limit)." OFFSET 0";
$r = $db->_sql($sql);
while ($row = $db->fetch_row($r)) {
$content .="
<item>
<title>Quote: ".$row['id']."</title>
<link>" . $baseurl . "/?".$row['id']."</link>
<pubDate>".date("r", $row['time'])."</pubDate>
<description>".htmlentities($row['quote'], ENT_XML1)."</description>
<guid>" . $baseurl . "/?".$row['id']."</guid>
</item>";
}
$content .="
</channel>
</rss>";
echo $content;