forked from arnecls/raidplaner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeed.php
88 lines (68 loc) · 2.75 KB
/
feed.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
80
81
82
83
84
85
86
87
88
<?php
// Raidplaner RSS Feed
// This is a demo implementation of an RSS feed, but it can be used as is, too.
//
// Usage:
// feed.php?token=<private token>&timezone=<timezone>
//
// Timezone is optional and has to be compatible to date_default_timezone_set().
require_once("lib/private/api.php");
require_once("lib/private/out.class.php");
header("Content-type: application/xml");
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<rss version="2.0">';
// Build RSS header
$RFC2822 = "D, d M Y H:i:s O";
$BaseURL = getBaseURL();
$Out = new Out();
$Out->pushValue("title", "Raidplaner RSS feed");
$Out->pushValue("link", $BaseURL."index.php");
$Out->pushValue("description", "Upcoming raids for the next 2 weeks.");
$Out->pushValue("language", "en-en");
$Out->pushValue("copyright", "packedpixel");
$Out->pushValue("pubDate", date($RFC2822));
// Requires private token to be visible
$Token = (isset($_REQUEST["token"]))
? $_REQUEST["token"]
: null;
if (Api::testPrivateToken($Token))
{
// Setting the correct timezones
$Timezone = (isset($_REQUEST["timezone"]))
? $_REQUEST["timezone"]
: date_default_timezone_get();
// Query API
date_default_timezone_set("UTC");
$Parameters = Array(
"start" => time() - 24 * 60 * 60,
"end" => time() + 14 * 24 * 60 * 60,
"limit" => 0,
"closed" => true,
"canceled" => true,
);
$Locations = Api::queryLocation(null);
$Raids = Api::queryRaid($Parameters);
$LocationName = Array();
foreach($Locations as $Location)
{
$LocationName[$Location["Id"]] = $Location["Name"];
}
// Generate RSS content
date_default_timezone_set($Timezone);
foreach($Raids as $Raid)
{
$Start = date("H:i", intval($Raid["Start"]));
$End = date("H:i", intval($Raid["End"]));
$Out->pushValue("item", Array(
"title" => $LocationName[$Raid["LocationId"]]. " (".$Raid["Size"].")",
"description" => "Status: ".$Raid["Status"]."\nFrom ".$Start." to ".$End."\n".$Raid["Description"],
"link" => $BaseURL."index.php#raid,".$Raid["RaidId"],
"author" => "Raidplaner",
"guid" => $Raid["RaidId"],
"pubDate" => date($RFC2822, intval($Raid["Start"]))
));
}
}
$Out->flushXML("channel");
echo '</rss>';
?>