-
Notifications
You must be signed in to change notification settings - Fork 16
/
viewrssrecent.php
79 lines (72 loc) · 3.01 KB
/
viewrssrecent.php
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
# This view generates an RSS feed ("Really Simple Syndication")
# listing the calendar events that have been altered recently.
include("include/common.php");
header("Content-type: text/xml");
header("Cache-control: private");
print "<"."?xml version=\"1.0\" encoding=\"iso-8859-1\" ?".">\r\n";
# Compute $today and $tomorrow. This is slightly complicated by the
# fact that Thinkhost uses the Eastern timezone, not Pacific.
$today = date("Y-m-d", time() - 3600 * TZTWEAK);
$tomorrow = date("Y-m-d", time() + 3600 * (24 - TZTWEAK));
?>
<rss version="2.0">
<channel>
<title>Shift Recent</title>
<link><?php
print CALURL;
?></link>
<description>Bike events that have been modified recently.</description>
<language>en-us</language>
<generator>Shift Calendar</generator>
<?php
print " <lastBuildDate>".substr(date("r"), 0, 26)."GMT</lastBuildDate>\r\n";
$conn = mysql_connect(DBHOST, DBUSER, DBPASSWORD) or die(mysql_error());
mysql_select_db(DBDATABASE, $conn);
function datelink($sqldate) {
if ($sqldate >= PPSTART && $sqldate <= PPEND)
$view = PPURL;
else
$view = "view3week.php";
$date = strtotime($sqldate);
return CALURL."$view#".date("Fj", $date);
}
function eventlink($sqldate, $id) {
if ($sqldate >= PPSTART && $sqldate <= PPEND)
$view = PPURL;
else
$view = "view3week.php";
return CALURL."$view#".substr($sqldate, 8, 2)."-$id";
}
function pubdate($sqldate) {
$date = strtotime($sqldate);
return date("D, d M Y", $date)." 00:00:00 GMT";
}
# Generate the XML for all recent entries.
$result = mysql_query("SELECT calevent.id as id, newsflash, tinytitle, eventdate, eventtime, timedetails, locname, address, locdetails, printdescr FROM calevent, caldaily WHERE caldaily.id = calevent.id AND eventstatus != \"C\" AND eventstatus != \"E\" AND eventstatus != \"S\" ORDER BY calevent.modified DESC LIMIT 1, 10", $conn) or die(mysql_error());
$date = "";
while ($record = mysql_fetch_array($result)) {
# Output an event
print " <item>\r\n";
print " <title>".date("D, M d ", strtotime($record['eventdate'])).hmmpm($record["eventtime"])." ".($record["newsflash"] ? "[!] " : "").htmlspecialchars($record["tinytitle"])."</title>\r\n";
print " <link>".eventlink($record["eventdate"], $record["id"])."</link>\r\n";
print " <pubDate>".pubdate($record["eventdate"])."</pubDate>\r\n";
print " <description>";
date("D, d M Y ", strtotime($record['eventdate']));
print hmmpm($record["eventtime"]);
if ($record["timedetails"])
print ' ('.htmlspecialchars($record[timedetails]).')';
print "\r\n ";
if ($record["locname"])
print htmlspecialchars($record["locname"]).", ";
print htmlspecialchars($record["address"]);
if ($record["locdetails"])
print " (".htmlspecialchars($record["locdetails"]).")";
print "\r\n ";
print htmlspecialchars($record["printdescr"]);
print "</description>\r\n";
print " </item>\r\n";
}
?>
</channel>
</rss>