Esempio n. 1
0
    if (Feeds::add($_POST['url'])) {
        $_SESSION['message'] = "Feed added.";
    } else {
        $_SESSION['message'] = "Failed to add feed to database.";
    }
    $f3->reroute("/feeds");
});
$f3->route('POST /feeds/edit', function ($f3) {
    global $db;
    admin_check();
    readonly_check();
    for ($i = 1; $i <= count($_POST["feed_url"]); $i++) {
        if (isset($_POST["delete"][$i])) {
            Feeds::delete($_POST["feed_url"][$i]);
        } else {
            Feeds::update($_POST["feed_url"][$i], $_POST["title"][$i], $_POST["site_url"][$i]);
        }
    }
    $_SESSION['message'] = 'Changes saved.';
    $f3->reroute("/feeds");
});
/******************************/
/**** Admin login & logout ****/
/******************************/
$f3->route('GET /admin', function ($f3) {
    admin_check();
    /** Retrieve event info **/
    $events_info = ["submitted" => 0, "approved" => 0, "old" => 0];
    $r = Events::$db->exec('SELECT count(*) AS count FROM events WHERE state IS "submitted" OR state IS "imported"');
    $events_info['submitted'] = $r[0]['count'];
    $r = Events::$db->exec('SELECT count(*) AS count FROM events WHERE state="approved"');