Beispiel #1
0
require_once "lib/private/api.php";
require_once "lib/private/out.class.php";
Out::writeHeadersXML();
echo '<rss version="2.0">';
// Build RSS header
$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(DATE_RSS));
// 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"]));
Beispiel #2
0
// Generate response
$Out = Out::getInstance();
if (isset($_REQUEST['help'])) {
    api_help($_REQUEST);
} else {
    if (!isset($_REQUEST['query'])) {
        $Out->pushError('You must at least provide the parameter `query` and a `token`.');
        $Out->pushError('You can also pass `help` with a topic to see a list of available parameters.');
    } else {
        $Authenticated = false;
        $NormalizeFunc = 'api_args_' . strtolower($_REQUEST['query']);
        $Parameter = function_exists($NormalizeFunc) ? call_user_func($NormalizeFunc, $_REQUEST) : null;
        // Validate against public or private token
        // If no token is given, try to validate the currently logged in user.
        if (isset($_REQUEST['token'])) {
            $Authenticated = Api::testPrivateToken($_REQUEST['token']) || Api::testPublicToken($Parameter, $_REQUEST['token']);
        }
        // Only execute requests if validated
        if (!$Authenticated) {
            $Out->pushError('Validation failed.');
        } else {
            switch (strtolower($_REQUEST['query'])) {
                case 'location':
                    $Out->pushValue('result', api_query_location($Parameter));
                    break;
                case 'user':
                    $Out->pushValue('result', api_query_user($Parameter));
                    break;
                case 'raid':
                    $Out->pushValue('result', api_query_raid($Parameter));
                    break;