Beispiel #1
0
function prepareHome($dbh)
{
    if ($_SESSION['userType'] === "hunter") {
        $template_array["username"] = $_SESSION['userLogin'];
        $template_array['preferredBounties'] = getPreferredBounties($dbh);
        $template_array['messageOfDay'] = getMessageOfDayHunter($dbh);
        $args[':username'] = $_SESSION['userLogin'];
        $template_array['trackBounties'] = getBountiesFromUsernameRecentReports($dbh, $args);
        $template_array['subscriptions'] = getRSSSubscription($dbh);
        return $template_array;
    } else {
        if ($_SESSION['userType'] === "marshal") {
            $template_array['username'] = $_SESSION['userLogin'];
            $template_array['rssExists'] = rssExists($dbh);
            $template_array['subscriptions'] = getRSSSubscription($dbh);
            $dummy = getMessageOfDayMarshal($dbh);
            $template_array["messageOfDay"] = getMessageOfDayMarshal($dbh);
            $args[':username'] = $_SESSION['userLogin'];
            $template_array['activeBounties'] = getActiveBounties($dbh, $args);
            $template_array['subscriptions'] = getRSSSubscription($dbh);
            return $template_array;
        } else {
            $template_array = getPreferredBounties($dbh);
            return $template_array;
        }
    }
}
Beispiel #2
0
    echo json_encode(getReportsFromMarshal($dbh, $args));
});
/*
getBountiesFromUsername
Inputs:
Username: username to find results for
Outputs: an array of all bounties which the user has submitted reports for
Errors:
0: success
1: statements failed
*/
$app->get('/api/getBountiesFromUsername/:username', function ($username) use($dbh) {
    $args[':username'] = $username;
    echo json_encode(getBountiesFromUsername($dbh, $args));
});
/*
Michael Gilbert
basicSearch
Inputs:
Query: A simple string search term
Outputs: An array of up to 5 bounties whose name includes the search term
Errors:
0: success
1: Statement execution failed
*/
$app->get('/api/basicSearch/:query', function ($query) use($dbh) {
    $args[':query'] = '%' . $query . '%';
});
$app->get('/api/getRSSSubscription/', function () use($dbh) {
    echo json_encode(getRSSSubscription($dbh));
});