function is_session($f3) { if (!isset($_COOKIE["Girudatsu_api"]) && $f3->get('PARAMS')[0] != '/session') { $f3->reroute('/session'); } if (!isset($_SESSION['api'])) { if (isset($_COOKIE["Girudatsu_api"]) && verif_session($_COOKIE["Girudatsu_api"]) == 'true') { $_SESSION['api'] = $_COOKIE["Girudatsu_api"]; $f3->reroute('/'); } } if (isset($_SESSION['api']) && isset($_COOKIE["Girudatsu_api"]) && $f3->get('PARAMS')[0] == '/session') { $f3->reroute('/'); } }
exit; } $f3->route('GET /', function ($f3) { is_session($f3); include 'app/controllers/index.php'; }); $f3->route('GET /session', function ($f3) { is_session($f3); include 'app/controllers/session.php'; }); $f3->route('GET /logout', function ($f3) { end_session($f3); $f3->reroute('/session'); }); $f3->route('POST /session', function ($f3) { if (verif_session($f3->get('POST.api')) == 'true') { $f3->reroute('/'); } else { $f3->set('ESCAPE', FALSE); $f3->set('message', '<div class="alert alert-danger">Invalid <a class="alert-link" href="#">Girudatsu API Key</a>.'); include 'app/controllers/session.php'; } }); $f3->route('GET /api/stripe', function ($f3) { is_session($f3); include 'app/controllers/api.stripe.php'; }); $f3->route('GET /api/paypal', function ($f3) { is_session($f3); //include 'app/controllers/api.paypal.php'; echo 'maintenance';