Esempio n. 1
0
 public static function response($http_code, $message = '')
 {
     //send a response to the client
     if (!is_null(json_decode($message))) {
         $message = json_decode($message);
     }
     $message = self::json_string_response($http_code, $message);
     //die('DIE : '.$message);
     //if(DEBUG) $message .= self::$db->last_query();
     Flight::halt($http_code, $message);
     Flight::stop();
 }
Esempio n. 2
0
Flight::route('/', function () {
    return Flight::view()->display('index.php', Flight::get('config')->getTemplateData());
});
// ! --- ROUTE: About ---------------------------
Flight::route('/we', function () {
    return Flight::get('config')->renderPage('about');
});
// ! --- ROUTE: Sitemap -------------------------
/**
 * Publishes all routes in the /sitemap.xml
 */
Flight::route('/sitemap.xml', function () {
    $items = Flight::get('navigation.loader')->getNavigationItems();
    $sitemap = array();
    foreach ($items as $item) {
        $sitemap[] = array('Url' => $item->get('Url'), 'DateTime' => $item->get('DateTime'));
    }
    Flight::response()->header('Content-Type', 'application/xml');
    Flight::view()->display('sitemap.php', array('Sitemap' => $sitemap));
});
// ! --- ROUTE: Project -------------------------
Flight::route('/@name', function ($name) {
    return Flight::get('config')->renderPage($name);
});
// ! --- ROUTE: 404 - Not Found -----------------
Flight::map('notFound', function () {
    Flight::view()->display('404.php', Flight::get('config')->getTemplateData());
    Flight::stop(404);
});
// ! --- Kick things off! -----------------------
Flight::start();
Esempio n. 3
0
function handle_checkin()
{
    render_boilerplate();
    // This happens if we unset the nonce below.
    // Or if the nonce was never set, in which case the user
    // shouldn't be here.
    $msg1 = _('It looks like you accidentally hit the refresh button or got here by accident.');
    $msg2 = _('We prevented a double post of your message.');
    if (!array_key_exists('FB_CHECKIN_NONCE', $_SESSION)) {
        Flight::render('denied_fb', array('msg' => $msg1 . ' ' . $msg2));
        Flight::stop();
    }
    $nonce = $_SESSION['FB_CHECKIN_NONCE'];
    if (empty($nonce)) {
        Flight::render('denied_fb', array('msg' => $msg1 . ' ' . $msg2));
        Flight::stop();
    }
    $submitted_nonce = Flight::request()->query->nonce;
    if (empty($submitted_nonce)) {
        Flight::error(new Exception('No nonce in form submission!'));
    }
    if ($nonce !== $submitted_nonce) {
        Flight::error(new Exception('Nonces don\'t match!'));
    }
    // Now, make double submissions impossible by discarding the
    // nonce
    unset($_SESSION['FB_CHECKIN_NONCE']);
    $token = $_SESSION['FBTOKEN'];
    if (empty($token)) {
        Flight::error(new Exception('No FB token in session!'));
    }
    $session = new FacebookSession($token);
    $message = Flight::request()->query->message;
    $config = array(place => PAGE_ID);
    if (!empty($message)) {
        $config['message'] = $message;
    }
    $request = new FacebookRequest($session, 'POST', '/me/feed', $config);
    // Some exceptions can be caught and handled sanely,
    // e.g. Duplicate status message (506)
    try {
        $response = $request->execute()->getGraphObject();
    } catch (FacebookRequestException $ex) {
        Flight::error($ex);
    } catch (\Exception $ex) {
        Flight::error($ex);
    }
    $postid = $response->asArray()['id'];
    $posturl = 'https://www.facebook.com/' . $postid;
    Flight::render('checkin', array('loginurl' => login_success(False), 'posturl' => $posturl));
}
Esempio n. 4
0
 public static function response($http_code, $message = '')
 {
     //send a response to the client
     if (!is_null(json_decode($message))) {
         $message = json_decode($message);
     }
     //HACK for WLS
     $content = self::json_string_response($http_code, $message);
     //HACK for WLS
     $http_code = 200;
     //200 HACK FLASH WLS
     Flight::halt($http_code, $content);
     Flight::stop();
 }
Esempio n. 5
0
<?php

require 'flight/Flight.php';
require "config.php";
require "handler.php";
include 'jwt/BeforeValidException.php';
include 'jwt/ExpiredException.php';
include 'jwt/SignatureInvalidException.php';
include 'jwt/JWT.php';
include "jwt/jwthelper.php";
Flight::route('/', function () {
    echo Flight::get("dbname");
});
Flight::route("POST /user/register", array("Handler", "reg"));
Flight::route("POST /user/login", array("Handler", "log"));
Flight::route("POST /snippets", array("Handler", "snippets"));
Flight::route("POST /snippet", array("Handler", "snippet"));
Flight::route("POST /key/valid", array("Handler", "validate"));
Flight::register("db", "PDO", array("mysql:host=" . Flight::get("dbhost") . ";dbname=" . Flight::get("dbname") . ";charset=utf8;", Flight::get("dbuser"), Flight::get("dbpass")));
Flight::map("error", function ($err = "error") {
    Flight::halt(404, $err);
    Flight::stop();
});
Flight::start();