Example #1
1
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'flight/flight/Flight.php';
require_once 'ipsp-php/autoload.php';
Flight::set('flight.views.path', 'templates');
Flight::set('layout', 'layout/default');
Flight::set('appname', 'IPSP PHP Examples');
Flight::set('apptitle', 'Api');
Flight::register('ipsp', 'Ipsp_Api', array(new Ipsp_Client(1000, 'test', 'api.oplata.com')));
Flight::map('output', function ($content = NULL) {
    Flight::view()->set('ipsp', Flight::ipsp());
    Flight::render($content, array(), 'content');
    Flight::render(Flight::get('layout'));
});
Flight::route('/', function () {
    Flight::output('pages/frontpage');
});
Flight::route('/page/@page(/@order_id)', function ($page = 'notfound', $order_id = NULL) {
    Flight::view()->set('order_id', $order_id);
    Flight::output(sprintf('pages/%s', $page));
});
Flight::route('/modal/@page', function ($page = 'notfound') {
    Flight::view()->set('ipsp', Flight::ipsp());
    Flight::render(sprintf('modal/%s', $page));
});
Flight::route('/api/checkout', function () {
    $data = Flight::request()->data;
});
Flight::start();
Example #2
1
<?php

require 'flight/Flight.php';
//Registre enllaç a base de dades per a realitzar les connexions
Flight::register('db', 'PDO', array('mysql:host=hostingmysql299.nominalia.com;dbname=budainteractiu', 'F538317_budafilm', '@Buda#Int2015'), function ($db) {
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
});
Flight::route('POST /savevideo', function () {
    $db = Flight::db();
    $savevideo = $db->prepare("INSERT INTO videos (usuari,video,llegenda) VALUES (:user, :video, :desc)");
    $savevideo->bindParam(':user', $_POST['user'], PDO::PARAM_INT);
    $savevideo->bindParam(':video', $_POST['video']);
    $savevideo->bindParam(':desc', $_POST['desc']);
    $return = $savevideo->execute();
    $db = NULL;
    if ($return) {
        echo TRUE;
    } else {
        echo FALSE;
    }
});
Flight::route('POST /savefoto', function () {
    $db = Flight::db();
    $savefoto = $db->prepare("INSERT INTO fotos (usuari,foto,llegenda) VALUES (:user, :foto, :desc)");
    $savefoto->bindParam(':user', $_POST['user'], PDO::PARAM_INT);
    $savefoto->bindParam(':foto', $_POST['foto']);
    $savefoto->bindParam(':desc', $_POST['desc']);
    $return = $savefoto->execute();
    $db = NULL;
    if ($return) {
        echo TRUE;
Example #3
1
define('APP_ROOT', dirname(getcwd()));
require APP_ROOT . '/vendor/autoload.php';
/*
 * We're using Flight for this project as it's quick to get up and running and allows
 * us some neat features like views, layouts and globaly registering objects for access
 * later (like the database)
 */
try {
    // Set Flight view path param and config options
    Flight::set('flight.views.path', APP_ROOT . '/views');
    Flight::set('config', require_once APP_ROOT . '/config.php');
    $config = Flight::get('config');
    // Register the PDO DB object in Flight
    $dbOptions = ['mysql:host=' . $config['db']['host'] . ';dbname=' . $config['db']['name'], $config['db']['user'], $config['db']['pass']];
    Flight::register('db', 'PDO', $dbOptions, function ($db) {
        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    });
    // Register routes for loading registration page
    Flight::route('GET /register', array('Register\\Controller', 'getRegister'));
    Flight::route('POST /register', array('Register\\Controller', 'postRegister'));
    // Thanks page
    Flight::route('/thanks', array('Register\\Controller', 'getThanks'));
    // Default route to redirect to registration page
    Flight::route('/', function () {
        Flight::redirect('/register');
    });
    // Start Flight
    Flight::start();
} catch (Exception $e) {
    // Some (very) lazy error handling
    print_r($e);
Example #4
0
 /**
  * Register service.
  *
  * @param array $services
  */
 public function registerService($services)
 {
     if (is_array($services)) {
         foreach ($services as $k => $v) {
             \Flight::register($k, $v);
         }
     }
 }
Example #5
0
 function testRegister()
 {
     Flight::path(__DIR__ . '/classes');
     Flight::register('user', 'User');
     $user = Flight::user();
     $loaders = spl_autoload_functions();
     $this->assertTrue(sizeof($loaders) > 0);
     $this->assertTrue(is_object($user));
     $this->assertEquals('User', get_class($user));
 }
 function testRegister()
 {
     Flight::path(__DIR__ . '/classes');
     Flight::register('test', 'TestClass');
     $test = Flight::test();
     $loaders = spl_autoload_functions();
     $this->assertTrue(sizeof($loaders) > 0);
     $this->assertTrue(is_object($test));
     $this->assertEquals('TestClass', get_class($test));
 }
Example #7
0
 public static function init()
 {
     $host = 'ubuntu';
     $database = 'bmslink';
     $user = '******';
     $pass = '';
     $PDO = ['mysql:host=' . $host . ';dbname=' . $database, $user, $pass];
     \Flight::register('db', 'PDO', $PDO, function ($db) {
         $db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     });
 }
Example #8
0
if (is_file($path . '/initflight.php')) {
    require_once $path . '/initflight.php';
}
if (is_file($path . '/config.php')) {
    require_once $path . '/config.php';
} elseif (is_file($path . '/../config.php')) {
    require_once $path . '/../config.php';
} else {
    echo "Invalid config file.";
    die;
}
// Register classes with Flight
Flight::register('artmoiController', 'ArtMoi_Controller');
Flight::register('artmoiRequest', 'ArtMoi_Request');
Flight::register('artmoiResponse', 'ArtMoi_Response');
Flight::register('artmoiContact', 'ArtMoi_Controller_Contact');
// 404 Error page
Flight::map('notFound', function () {
    Flight::view()->set('errorCode', "404");
    Flight::view()->set('message', "Sorry! 404 Page not Found");
    Flight::view()->set('pageTitle', "404 Page not Found");
    Flight::render('404');
});
// Contact Page
Flight::route('/contact', function () {
    // TODO:: We will need to include the form validation as optional because anyone downloading this project will need to obtain thier own license...
    $js = array("https://v1.artmoi.me/vendor/formvalidation/dist/js/formValidation.min.js", "https://v1.artmoi.me/vendor/formvalidation/dist/js/framework/bootstrap.min.js", "//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js", "/scripts/contact.js");
    $css = array("https://v1.artmoi.me/vendor/formvalidation/dist/css/formValidation.min.css", "//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css");
    $contact = Flight::artmoiContact()->action_contactPoints();
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        if (MANDRILL_API_KEY != null) {
Example #9
0
<?php

/********************************************
 * 说明:
*********************************************/
/*注册类*/
Flight::register("user", "Models\\UserModel");
Flight::register("read", "Models\\ReadModel");
<?php

# Site name to appear in the <title> tags and footer copyright text
define('SITE_NAME', 'Your Name');
# Database connection information
Flight::register('db', 'PDO', array('sqlite:../db.sqlite3'));
# The directory to look for views in
Flight::set('flight.views.path', '../views');
# The file extension of view files
Flight::set('flight.views.extension', '.phtml');
Example #11
0
<?php

/********************************************
 * 说明:工具调用函数,用于对公共函数的调用
*********************************************/
/*引入配置文件*/
$db_config = parse_ini_file("configs/database.ini");
/*注册工具*/
Flight::register("db", "Tools\\MysqlTool", array($db_config['host'], $db_config['username'], $db_config['password'], $db_config['database']));
Example #12
0
<?php

// Includes
require 'flight/Flight.php';
require 'classes/auth.class.php';
require 'classes/config.class.php';
require 'languages/en.php';
require 'database.php';
// Settings
Flight::set('lang', $lang);
Flight::set('flight.log_errors', true);
Flight::set('flight.views.path', 'views/');
// Register classes
Flight::register('db', 'PDO', array("mysql:host={$db_host};dbname={$db_name}", $db_user, $db_pass));
Flight::register('config', 'Config', array(Flight::db()));
Flight::register('auth', 'Auth', array(Flight::db(), Flight::config()));
// Set Timezone
date_default_timezone_set(Flight::config()->site_timezone);
// Check if user is logged in
if (Flight::request()->cookies->{Flight::config()->cookie_name} == false) {
    Flight::set('loggedin', false);
} else {
    if (Flight::auth()->checkSession(Flight::request()->cookies->{Flight::config()->cookie_name})) {
        Flight::set('loggedin', true);
        $uid = Flight::auth()->getSessionUID(Flight::request()->cookies->{Flight::config()->cookie_name});
        Flight::set('userdata', Flight::auth()->getUser($uid));
    } else {
        Flight::set('loggedin', false);
        setcookie(Flight::config()->cookie_name, "", time() - 3600, Flight::config()->cookie_path, Flight::config()->cookie_domain, Flight::config()->cookie_secure, Flight::config()->cookie_http);
    }
}
Example #13
0
<?php

date_default_timezone_set('UTC');
//Database
Flight::register('dbMain', 'PDO', array('mysql:host=184.107.179.178;dbname=app_main', 'admin', 'admin'), function ($dbMain) {
    $dbMain->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $dbMain->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
});
Flight::register('dbData', 'PDO', array('mysql:host=184.107.179.178;dbname=app_data_2016', 'admin', 'admin'), function ($dbData) {
    $dbData->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $dbData->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
});
//Api
$keys = array('49xSgp6MDZFV3wb2' => 'Testing', 'CjXSJrGje33Njj4G' => 'Reserve');
//Api Version
Flight::set('api_key', $keys);
Flight::set('api_version', 'v1');
?>
	
Example #14
0
<?php

require "lib/flight/Flight.php";
require "lib/organizer/settings.php";
Flight::load_settings();
require "lib/organizer/explorer.php";
Flight::register("explorer", "organizer\\Explorer", array(Flight::setting("from.folders"), Flight::setting("from.pattern")));
Flight::route("/", function () {
    Flight::render("index", array(), "content");
    Flight::render("layout");
});
Flight::route("POST /", function () {
    require "lib/organizer/organizer.php";
    $files = array();
    for ($i = 0; $i < count($_POST["paths"]); $i++) {
        $files[$_POST["paths"][$i]] = array("name" => $_POST["names"][$i], "type" => $_POST["types"][$i]);
    }
    $settings = Flight::get("organizer.settings");
    $organizer = new organizer\Organizer($settings);
    $result = $organizer->organize($files);
    header("Content-type: application/json");
    echo json_encode($result);
});
Flight::route("/entries", function () {
    Flight::render("_entries", array("paths" => Flight::explorer()->get_entries()));
});
Flight::route("/settings", function () {
    if (($settings = Flight::get("organizer.settings")) == null) {
        $settings = array("paths" => array());
    }
    Flight::render("settings", array("settings" => $settings), "content");
Example #15
0
    require $filename;
}
// Including all Routing files
foreach (glob(__DIR__ . '/../src' . '/Router/*.php') as $filename) {
    require $filename;
}
// Including values from config.yml
$config = Spyc::YAMLLoad(__DIR__ . '/../app/config/config.yml');
// Flight
array_walk_recursive($config['flight'], function ($value, $key) {
    Flight::set($key, eval('return ' . $value . ';'));
});
// Registering Smarty as template engine
Flight::register('view', 'Smarty', array(), function ($smarty) {
    $smarty->template_dir = Flight::get('flight.views.path') . '/';
    $smarty->compile_dir = __DIR__ . '/../app/cache/smarty_compile/';
    $smarty->config_dir = __DIR__ . '/../app/config/smarty/';
    $smarty->cache_dir = __DIR__ . '/../app/cache/smarty_cache/';
});
Flight::map('render', function ($template, $data) {
    Flight::view()->assign($data);
    Flight::view()->display($template);
});
//personnalizing errors
Flight::map('notFound', function () {
    if (file_exists(Flight::get('flight.views.path') . '/Errors/404.tpl')) {
        Flight::render('Errors/404.tpl', array());
    } else {
        Flight::_notFound();
    }
});
Flight::map('error', function (\Exception $e) {
Example #16
0
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation in version 3.
 *
 * FBWLAN is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
require_once 'include/flight/flight/Flight.php';
require_once 'config.php';
Flight::register('db', 'PDO', array('mysql:host=' . DB_HOST . ';port=' . DB_PORT . ';dbname=' . DB_NAME, DB_USER, DB_PASS), function ($db) {
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
});
function init_token_db()
{
    $db = Flight::db();
    // TODO: add index on date column
    $db->exec('CREATE TABLE IF NOT EXISTS tokens (id INT AUTO_INCREMENT PRIMARY KEY, token CHAR(40) NOT NULL UNIQUE, date timestamp NOT NULL)');
}
function generate_token()
{
    // Taken from wifidog Token.php, but use sha1 instead of md5sum
    return sha1(uniqid(rand(), 1));
}
function make_token()
{
    // Temporary: purge tokens more often
Example #17
0
<?php

if (!function_exists('avg')) {
    function avg(array $data)
    {
        return array_sum($data) / count($data);
    }
}
/**
 * Registers a class and set a variable to framework method.
 *
 * @param string $name Method name
 * @param string $class Class name
 * @param array $params Class initialization parameters
 * @param callback $callback Function to call after object instantiation
 * @throws \Exception If trying to map over a framework method
 */
Flight::map('instance', function ($name, $class, array $params = array(), $callback = null) {
    Flight::register($name, $class, $params, $callback);
    Flight::set($name, Flight::$name());
});
Example #18
0
<?php

require 'flight/Flight.php';
require 'jsonindent.php';
Flight::register('db', 'Database', array('automobilidb'));
$json_podaci = file_get_contents("php://input");
Flight::set('json_podaci', $json_podaci);
Flight::route('/', function () {
    echo 'hello world!';
});
Flight::route('GET /automobili', function () {
    header("Content-Type: application/json; charset=utf-8");
    $db = Flight::db();
    $db->select();
    $niz = array();
    while ($red = $db->getResult()->fetch_object()) {
        $niz[] = $red;
    }
    $json_niz = json_encode($niz, JSON_UNESCAPED_UNICODE);
    echo indent($json_niz);
    return false;
});
Flight::route('GET /autoplac', function () {
    header("Content-Type: application/json; charset=utf-8");
    $db = Flight::db();
    $db->select2();
    $niz = array();
    while ($red = $db->getResult()->fetch_object()) {
        $niz[] = $red;
    }
    $json_niz = json_encode($niz, JSON_UNESCAPED_UNICODE);
Example #19
0
    FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
    COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
    IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
    CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
require 'lib/flight/Flight.php';
require 'app/Tokens.php';
require 'app/TokensCollection.php';
require 'app/Utils.php';
require 'app/Delta.php';
require 'app/Logger.php';
// Map for shared memcached:
// 1) [incrementalno] = array(device, channel, fullpathnameofota.zip)
// 2) [fullpathnameofota.zip] = array(device, api_level, incremental, timestamp, md5sum)
Flight::register('mc', 'Memcached', array(), function ($mc) {
    $mc->addServer('localhost', 11211);
});
// Root dir
Flight::route('/', function () {
    Flight::redirect('/_builds');
});
// All builds
Flight::route('/api', function () {
    $ret = array('id' => null, 'result' => array(), 'error' => null);
    $req = Flight::request();
    $postJson = json_decode($req->body);
    $log = new Logger();
    $log->logWrite($req->ip . ' ' . $postJson->params->device . ' ' . $postJson->params->source_incremental);
    if ($postJson != NULL && !empty($postJson->params) && !empty($postJson->params->device)) {
        $device = $postJson->params->device;
        $devicePath = realpath('./_builds/' . $device);
Example #20
0
<?php

require 'flight/Flight.php';
require 'sendMail.php';
require 'lang.php';
Flight::register('db', 'PDO', array('pgsql:host=localhost;port=5432;dbname=osm;user=osm;'));
Flight::route('/about', function () {
    checkLang();
    Flight::render('about.php', array('baseUrl' => Flight::request()->base, 'pTitle' => 'About'));
});
Flight::route('GET /contact', function () {
    checkLang();
    Flight::render('contact.php', array('baseUrl' => Flight::request()->base, 'pTitle' => 'Contact'));
});
Flight::route('POST /contact', function () {
    $result = sendMail();
    Flight::render('contact.php', array('baseUrl' => Flight::request()->base, 'pTitle' => 'Contact', 'mailResult' => $result));
});
Flight::route('/', function () {
    checkLang();
    $db = Flight::db();
    $query = "SELECT osm_id,cod_istat,name,safe_name FROM it_regioni reg ORDER BY safe_name";
    $res = $db->query($query)->fetchAll(PDO::FETCH_ASSOC);
    Flight::render('list.php', array('baseUrl' => Flight::request()->base, 'pTitle' => 'Italy', 'list' => $res));
});
Flight::route('/@region', function ($region) {
    checkLang();
    $db = Flight::db();
    $query = "SELECT reg.osm_id,reg.cod_istat,reg.name,reg.safe_name,reg.bbox,ST_AsGeoJSON(ST_Simplify(reg.geom,0.0001),5)";
    $query .= " FROM it_regioni reg WHERE reg.safe_name=" . $db->quote($region);
    $res = $db->query($query);
Example #21
0
//Flight::set('google_analytics_site_id', 'UA-XXXXX-X');
// Now do classes
// Register db class with constructor parameters
Flight::register('db', 'PDO', array('sqlite:data/flightgeoip.sqlite3'), function ($db) {
    // after construct callback (with new object passed in)
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    // now create tables if needed
    $db->exec('CREATE TABLE IF NOT EXISTS geo (
                    id INTEGER PRIMARY KEY,
                    ip TEXT UNIQUE,
                    geoplugin_city TEXT,
                    geoplugin_region TEXT,
                    geoplugin_areaCode TEXT,
                    geoplugin_dmaCode TEXT,
                    geoplugin_countryCode TEXT,
                    geoplugin_countryName TEXT,
                    geoplugin_continentCode TEXT,
                    geoplugin_latitude TEXT,
                    geoplugin_longitude TEXT,
                    geoplugin_regionCode TEXT,
                    geoplugin_regionName TEXT)');
    $db->exec('CREATE TABLE IF NOT EXISTS requests (
                    id INTEGER PRIMARY KEY,
                    path TEXT,
                    ip TEXT,
                    uastring TEXT,
                    time INTEGER)');
});
//$db = Flight::db();
// Now extend Flight with your methods
/**
Example #22
0
<?php

require 'vendor/autoload.php';
require 'EasyBlogDBInterface.php';
include 'MyFuncs.php';
Flight::register('db', 'MyDBInterface', array('localhost', 'EasyBlog', 'root', 'root'));
session_start();
//главная страница
Flight::route('/(\\?p=@p)', function ($p) {
    $s_login = SetLogin();
    //gettin page index
    $page = 1;
    if ($p > 1) {
        $page = $p;
    }
    $postselector = ($page - 1) * 5;
    $posts = Flight::db()->GetPosts($postselector, 5);
    $postscount = Flight::db()->CountPosts();
    $pages_count = ceil($postscount / 5);
    Flight::render('home.php', array('headertext' => 'Мой летучий блог', 'authorname' => $s_login, 'footertext' => '@ProgForce forever'), 'home_page_content');
    Flight::render('post.php', array('posts' => $posts), 'posts_block');
    Flight::render('page_hyperlinks.php', array('pages_count' => $pages_count, 'current_page' => $page), 'pages_n_links');
    Flight::render('auth_view.php', null, 'auth_view');
    Flight::render('home_layout.php', null);
});
Flight::route('/exit', function () {
    session_destroy();
    Flight::redirect('/');
});
Flight::route('/auth/', function () {
    Flight::render('auth.php', null);
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
include dirname(__FILE__) . '/vendor/autoload.php';
/**
 * Initiate Twig, and register to Flight
 */
$loader = new Twig_Loader_Filesystem(dirname(__FILE__) . '/views');
$twigConfig = array('debug' => true);
Flight::register('view', 'Twig_Environment', array($loader, $twigConfig), function ($twig) {
    $twig->addExtension(new Twig_Extension_Debug());
    // Add the debug extension
});
/**
 * Initiate ActiveRecord
 */
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory('./models');
    $cfg->set_connections(array('development' => 'mysql://*****:*****@localhost/test'));
    $cfg->set_default_connection('development');
});
/**
 * Add /controllers to the include-path
 */
Flight::path(dirname(__FILE__) . '/controllers');
Flight::route('/', array('IndexController', 'index'));
Flight::route('/test', function () {
    echo "hello!";
});
Flight::route('/test-user', function () {
Example #24
0
 * Apply AppConfig and global settings to Flight.
 */
Flight::set('config', new MyAppConfig());
Flight::set('flight.log_errors', Flight::get('config')->get('logErrors'));
if (Flight::get('config')->get('showErrors')) {
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
}
/**
 * Initiate Twig, and register to Flight
 */
$twigLoader = new Twig_Loader_Filesystem('../templates');
$twigConfig = array('cache' => Flight::get('config')->get('cache.enabled') ? Flight::get('config')->get('cache.path') . 'twig/' : false, 'debug' => Flight::get('config')->get('debug'));
Flight::register('view', 'Twig_Environment', array($twigLoader, $twigConfig), function ($twig) {
    $twig->addExtension(new Twig_Extension_Debug());
    // Add the debug extension
    $currentUrl = sprintf("%s://%s%s", isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http', $_SERVER['SERVER_NAME'], $_SERVER['REQUEST_URI']);
    $twig->addGlobal('CurrentUrl', $currentUrl);
});
/**
 * Add navigation hook on start, get all links and store them in config -> 'app.navigation'
 */
Flight::before('start', function (&$params, &$output) {
    if (Flight::has('navigation.loader')) {
        return;
    }
    Flight::get('config')->initNavigation(Flight::request()->url);
});
// ! --- ROUTE: Index ---------------------------
Flight::route('/', function () {
    return Flight::view()->display('index.php', Flight::get('config')->getTemplateData());
});
Example #25
0
<?php

$time_start = microtime(true);
include 'app/config.php';
require 'app/flight/Flight.php';
require 'app/jsonRPCClient.php';
require 'app/controller.php';
date_default_timezone_set(TIMEZONE);
session_start();
Flight::register('reddcoin', 'jsonRPCClient', array("{$wallet['protocol']}://{$wallet['user']}:{$wallet['pass']}@{$wallet['host']}:{$wallet['port']}"));
Flight::register('controller', 'Controller');
if (USE_AUTHENTICATION == 1 && !isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_USER'] != USERNAME || $_SERVER['PHP_AUTH_PW'] != PASSWORD) {
    header('WWW-Authenticate: Basic realm="StakeUI"');
    header('HTTP/1.0 401 Unauthorized');
    exit;
}
switch (CURRENCY) {
    case "BTC":
        Flight::set('currency', 'average');
        Flight::set('currencySym', 'BTC');
        break;
    case "USD":
        Flight::set('currency', 'averageUSD');
        Flight::set('currencySym', 'USD');
        break;
    case "LTC":
        Flight::set('currency', 'averageLTC');
        Flight::set('currencySym', 'LTC');
        break;
    case "DOGE":
        Flight::set('currency', 'averageDOGE');
Example #26
0
        preg_match("/(.*).-.*/", $pickup, $matched);
        if (isset($matched[1])) {
            return $matched[1];
        } else {
            return $pickup;
        }
    }
    private function splitName($name)
    {
        $parts = explode(" ", $name);
        $last = array_pop($parts);
        $first = implode(" ", $parts);
        return array("First" => $first, "Last" => $last);
    }
}
Flight::register('Lists', 'Lists');
Flight::route('/save/data', function () {
    $list = Flight::Lists();
    $list->saveData();
});
Flight::route('/save/walkon', function () {
    $list = Flight::Lists();
    $list->saveWalkOn();
});
Flight::route('/walkon/delete/@tripId', function ($tripId) {
    $list = Flight::Lists();
    $list->deleteOrder($tripId);
});
Flight::route('/dropdown/destination', function () {
    $list = Flight::Lists();
    echo $list->destinationDropdown();
Example #27
0
<?php

Flight::path("model/");
Flight::path("controller/");
Flight::register('db', 'mysqli', [$config['db']['host'], $config['db']['username'], $config['db']['password'], $config['db']['databasename']]);
Flight::register("util", "util");
Flight::register("auth", "authController");
Flight::register("posts", "postController");
Flight::register("users", "userController");
Flight::set("flight.base_url", $config['web']['base_url']);
Flight::map('link', function ($url) {
    echo Flight::get('flight.base_url') . $url;
});
Example #28
0
require_once 'flight/Flight.php';
require_once 'vendor/github/GitHubClient.php';
// Autoload models and controllers
Flight::path('models');
Flight::path('controllers');
Flight::path('models/division_structures');
// Set views path and environment
Flight::set('flight.views.path', 'views');
Flight::set('root_dir', dirname(__FILE__));
Flight::set('base_url', '/Division-Tracker/');
// Set database credentials
define('DB_HOST', '');
define('DB_USER', '');
define('DB_PASS', '');
define('ARCH_PASS', '');
Flight::register('aod', 'Database', array('aod'));
// defines for website URLs
define('CLANAOD', 'http://www.clanaod.net/forums/member.php?u=');
define('BATTLELOG', 'http://battlelog.battlefield.com/bfh/agent/');
define('BATTLEREPORT', 'http://battlelog.battlefield.com/bf4/battlereport/show/1/');
define('BF4DB', 'http://bf4db.com/players/');
define('PRIVMSG', 'http://www.clanaod.net/forums/private.php?do=newpm&u=');
define('EMAIL', 'http://www.clanaod.net/forums/sendmessage.php?do=mailmember&u=');
define('REMOVE', 'http://www.clanaod.net/forums/modcp/aodmember.php?do=remaod&u=');
// defines for BF4 division activity status display
define('PERCENTAGE_CUTOFF_GREEN', 75);
define('PERCENTAGE_CUTOFF_AMBER', 50);
define('INACTIVE_MIN', 0);
define('INACTIVE_MAX', 25);
// global settings
define('MAX_GAMES_ON_PROFILE', 25);
Example #29
0
<?php

require 'flight/Flight.php';
require 'extensions/Bcrypt.php';
// Register Bcrypt class to use later on
Flight::register('bcrypt', 'Bcrypt');
Flight::route('GET /', function () {
    Flight::render('index.php', array('hashResult' => 'Waiting...'));
});
Flight::route('POST /', function () {
    $bcrypt = Flight::bcrypt();
    $hashResult = '';
    $hashMatches = '';
    $hashCheck = false;
    switch ($_POST['method']) {
        case 'hash':
            $hashResult = $bcrypt->hash($_POST['stringToHash']);
            break;
        case 'check':
            $hashMatches = $bcrypt->check($_POST['plainText'], $_POST['hashText']);
            $hashCheck = true;
            break;
    }
    Flight::render('index.php', array('hashResult' => $hashResult, 'hashMatches' => $hashMatches, 'hashCheck' => $hashCheck));
});
Flight::start();
Example #30
-1
<?php

session_start();
require 'vendor/autoload.php';
use predictionio\EventClient;
Flight::register('mdb', 'Mongo', array('mongodb://localhost'));
//Flight::register('prediction', 'predictionio\EventClient');
Flight::register('guzzle', 'GuzzleHttp\\Client');
Flight::map('prediction_client', function () {
    //$accessKey = 'GJBuFYODWTwFBVQ2D2nbBFW5C0iKClNLEMbYGGhDGoZGEtLre62BLwLJlioTEeJP';
    //$client = new EventClient($accessKey, 'http://localhost:7070');
    $predictionio_appkey = "sD13KDmvVn8RVWaxlkuVUS0wxropKJTdUPbm6vWD7BvheZsqmrW0FJHdZa2y7wR2";
    $predictionio_eventserver = "http://127.0.0.1:7070";
    $client = new EventClient($predictionio_appkey, $predictionio_eventserver);
    return $client;
});
Flight::route('GET /', array('Home', 'index'));
Flight::route('GET /movies/recommended', array('Home', 'recommended'));
Flight::route('POST /movie/random', array('Home', 'random'));
Flight::route('/movies/import', array('Admin', 'import'));
Flight::route('/test', function () {
    $accessKey = 'sD13KDmvVn8RVWaxlkuVUS0wxropKJTdUPbm6vWD7BvheZsqmrW0FJHdZa2y7wR2';
    $client = new EventClient($accessKey, 'http://127.0.0.1:7070');
    $response = $client->setUser(2);
    echo 'a';
    print_r($response);
});
Flight::start();