/** * PRedis constructor. * * @param array $conf * @param $options */ public function __construct($conf = [], $options = null) { if (!$conf) { $conf = \Flight::get('config')->get('redis'); } parent::__construct($conf, $options); }
/** * Constructor */ public function __construct($install) { parent::__construct($install); if (F::has('pageinfos')) { F::view()->assign(array('pageinfos' => Files::getPageInfos(F::get('pageinfos')['cat'], F::get('pageinfos')['page']))); } }
/** * Gets fields/columns from specified tables and generates dropdown options */ public function getselectfields() { $tablesJSON = $_POST['tables']; if ($tablesJSON) { $html = ''; $tables = json_decode($tablesJSON, true); foreach ($tables as $table) { // table columns $stmt = Flight::get('db')->query("DESCRIBE {$table}"); $columns = $stmt->fetchAll(PDO::FETCH_ASSOC); //pretty_print($columns); $fields = array(); foreach ($columns as $values) { if (isset($values['Field'])) { $fields[] = $values['Field']; } } //pretty_print($fields); $html .= '<optgroup label="' . $table . '">' . "\n"; $html .= getOptions($fields, false, $table); $html .= '</optgroup>' . "\n"; } echo $html; } }
function render_boilerplate() { Flight::render('head', array('my_url' => MY_URL, 'title' => _('WLAN at ') . PAGE_NAME), 'head'); Flight::render('foot', array('privacy_url' => MY_URL . 'privacy/', 'imprint_url' => IMPRINT_URL), 'foot'); Flight::render('back_to_code_widget', array('retry_url' => Flight::get('retry_url')), 'back_to_code_widget'); Flight::render('access_code_widget', array('codeurl' => MY_URL . 'access_code/'), 'access_code_widget'); }
public function __construct() { new Model_Test(); include "test.html"; $tmp = Flight::get('test'); echo "Controller_Test" . $tmp; }
/** * AssetsManager constructor. * @param array $conf */ public function __construct($conf = []) { if (!$conf) { $conf = \Flight::get('config')->get('assets'); } $this->loadConfig($conf); }
public function get($key) { if ($val = parent::get($key)) { return $val; } return Flight::has($key) ? Flight::get($key) : null; }
/** * Save properties of the user profile * @return [JSON] Success or error message */ public static function saveProfile() { if (!Flight::has('currentUser')) { Flight::json(['Error' => 'No Access']); } $currentUser = Flight::get('currentUser'); if (isset(Flight::request()->query->bio)) { $currentUser->bio = Flight::request()->data->bio; } else { if (isset(Flight::request()->query->password)) { if (!isset(Flight::request()->data->passwordold) || !isset(Flight::request()->data->passwordnew1) || !isset(Flight::request()->data->passwordnew2)) { Flight::json(['success' => false, 'exception' => 'Empty fields']); } if ($currentUser->password === hash("sha256", Flight::request()->data->passwordold)) { if (Flight::request()->data->passwordnew1 == Flight::request()->data->passwordnew2) { $currentUser->password = hash("sha256", Flight::request()->data->passwordnew1); } else { Flight::json(['success' => false, 'exception' => 'New passwords are not the same']); } } else { Flight::json(['success' => false, 'exception' => 'Old password is not correct ']); } } } $result = $currentUser->update(); if ($result != false) { $_SESSION['user'] = Flight::users()->getUserWithId(Flight::get('currentUser')->id); Flight::json(['success' => true]); } else { Flight::json(['sucess' => false, 'exception' => 'An error']); } }
/** * Login POST verification (authentication) */ public function access() { $pass = F::request()->data->password; # captcha if (!empty(F::get('config')['recaptcha']['public'])) { $captcha = F::request()->data['g-recaptcha-response']; if (!Verif::okCaptcha($captcha)) { $_SESSION['flashbag'] = '<div class="alert alert-danger">Wrong security captcha.</div>'; $this->index(); exit; } } # password if (Verif::okPassword($pass)) { $_SESSION['admin'] = 1; $_SESSION['flashbag'] = ' <div class="alert alert-success alert-dismissible"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> You are now logged in. </div>'; F::redirect('/'); } else { $_SESSION['flashbag'] = '<div class="alert alert-danger">Wrong password.</div>'; } $this->index(); }
function smarty_function_res($params, &$smarty) { if (empty($params['path'])) { return "[plugin:res] missing parameter."; } return \Flight::get('root') . 'web/' . $params['path']; }
public function __construct() { try { $this->pdo = new PDO('mysql:host=' . Flight::get('DBhost') . ';dbname=' . Flight::get('DBname'), Flight::get('DBlogin'), Flight::get('DBpassword')); } catch (PDOException $e) { echo 'Po³¹czenie nie mog³o zostaæ utworzone.<br />'; } }
/** * DataPool constructor. * @param array $conf */ public function __construct($conf = []) { if (!$conf) { $conf = \Flight::get('config')->get('datapool'); $conf['debug'] = isDebug(); } $this->dataPool = new DefaultDataPool($conf, ROOT); }
/** * Create a post */ public static function createPost() { if (!Flight::has('currentUser')) { Flight::redirect('/'); } $post = new post(['user' => Flight::get('currentUser')->id, 'title' => Flight::request()->data->title, 'content' => Flight::request()->data->content]); $post->store(); }
/** * Timer constructor. * @param array $conf */ public function __construct($conf = []) { if (!$conf) { $tz = \Flight::get('config')->get('timezone'); $conf = ['timezone' => $tz]; } $this->loadConfig($conf); }
public function __construct($paths, $pattern) { $this->paths = $paths; $this->pattern = $pattern; $this->ignores = $this->update_ignores(\Flight::setting("ignores")); $settings = \Flight::get("organizer.settings"); $settings["ignores"] = $this->ignores; \Flight::write_settings($settings); }
/** * MedooDB constructor. * @param array $conf */ public function __construct($conf = []) { if (!$conf) { $conf = \Flight::get('config')->get('database'); } if (!isset($conf['charset'])) { $conf['charset'] = 'utf8'; } parent::__construct($conf); }
function real_remote_addr() { $ip = Flight::request()->ip; $proxy = Flight::request()->proxy_ip; if ('' != $proxy && Flight::get('proxies')->match($ip)) { return $proxy; } else { return $ip; } }
/** * check if the install process have been done */ private function checkInstall($install) { if (F::has('password')) { if (!$install && empty(F::get('password'))) { F::redirect('/install'); } elseif ($install && !empty(F::get('password'))) { F::redirect('/login'); } } }
function getLang() { if (!isset($_COOKIE["extractLang"])) { setLang('it'); } if (Flight::has('lang')) { return Flight::get('lang'); } return $_COOKIE["extractLang"]; }
/** * SessionUtil constructor. * @param array $conf */ public function __construct($conf = []) { if (!$conf) { $conf = \Flight::get('config')->get('storage'); } $this->prefix = isset($conf['prefix']) ? $conf['prefix'] . '_' : ''; $enabled = isset($conf['session']) ? $conf['session'] : ''; if ($enabled) { $this->enabled = true; $this->session =& $_SESSION; } }
public static function listTables(array $array) { $html = ''; $base = Flight::get('base'); $counter = 0; foreach ($array as $arrayitem) { $counter++; $html .= <<<HTML <li><a href="{$base}/table/{$arrayitem}">{$arrayitem}</a></li> HTML; } return $html; }
function get_users($user, $password) { $nbUser = Flight::get('db')->count(Flight::get('dbtables')['user'], ['AND' => ['name' => $user, 'password' => $password]]); if ($nbUser != 1) { Flight::halt(403, 'Bad user/password.'); } $nowtime = time(); $endtime = $nowtime + Flight::get('tokenEndAfter') * 60; // now + 20min $token = sha1($user . $nowtime); $res = Flight::get('db')->insert(Flight::get('dbtables')['usertoken'], ['token' => $token, 'end_of_validity' => date(BDD_DATETIME_FORMAT, $endtime)]); echo $token; }
public static function author($id = null) { if ($id == null) { if (Flight::has('currentUser')) { $user = Flight::get('currentUser'); } else { Flight::redirect("/"); } } else { $user = Flight::users()->getUserWithId($id); } Flight::util()->render('profile', ['user' => $user]); }
/** * CookieUtil constructor. * @param array $conf */ public function __construct($conf = []) { if (!$conf) { $conf = \Flight::get('config')->get('storage'); } $this->prefix = isset($conf['prefix']) ? $conf['prefix'] . '_' : ''; $this->path = isset($conf['cookie_path']) ? $conf['cookie_path'] : '/'; $this->domain = isset($conf['domain']) ? $conf['domain'] : null; $enabled = isset($conf['cookie']) ? $conf['cookie'] : false; if ($enabled) { $this->enabled = true; $this->cookies =& $_COOKIE; } }
function testGetAndSet() { Flight::set('a', 1); $var = Flight::get('a'); $this->assertEquals(1, $var); Flight::clear(); $vars = Flight::get(); $this->assertEquals(0, count($vars)); Flight::set('a', 1); Flight::set('b', 2); $vars = Flight::get(); $this->assertEquals(2, count($vars)); $this->assertEquals(1, $vars['a']); $this->assertEquals(2, $vars['b']); }
/** * Monolog constructor. * @param array $conf */ function __construct($conf = []) { if (!$conf) { $conf = \Flight::get('config')->get('log'); } if (is_array($conf)) { $this->logDir = isset($conf['directory']) ? FormatUtils::formatPath($conf['directory']) : STORAGE . 'log'; if (!file_exists($this->logDir)) { mkdir($this->logDir, 0777, true); } if (isset($conf['loggers'])) { foreach ($conf['loggers'] as $d => $con) { $this->registerLogger($d, $con); } } } }
public static function getMyWages() { $req = Flight::request()->query; $limit = $req['limit'] ? $req['limit'] : 10; $offset = $req['offset'] ? $req['offset'] : 0; $search = $req['search'] ? $req['search'] : ''; $ser_id = Session::get('ser_id'); $db = Flight::get('db'); $cond = array("ORDER" => "add_time DESC", "LIMIT" => array($offset, $limit)); if ($search) { $cond['AND'] = array("ser_name" => $search); } $cond['AND']['ser_id'] = $ser_id; $data = $db->select("wages", array("[>]services" => "ser_id"), "*", $cond); $total = $db->count("wages"); Flight::json(array("total" => $total, 'rows' => $data)); }
/** * Get, and store for the session, location data for the current visitor * * @return object IP location data. */ function sd_location_data() { $key = 'sd.location'; $data = Flight::get($key); if (empty($data)) { if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; } if ('dev' == ENV) { $_SERVER['REMOTE_ADDR'] = ''; } $path = 'https://freegeoip.net/json/' . $_SERVER['REMOTE_ADDR']; $data = file_get_contents($path); Flight::set($key, $data); } return json_decode($data); }
/** * Attempt to login user based on credentials specified in config file. */ public function loginuser() { $username_ok = false; $password_ok = false; $username = $_POST['username']; $password = $_POST['password']; // get user login details from config file $config = Flight::get('config'); // go through array and match username and password foreach ($config as $key => $value) { if ($key === 'username') { if (is_array($value)) { foreach ($value as $value2) { if ($username === $value2) { $username_ok = true; } } } else { if ($username === $value) { $username_ok = true; } } } elseif ($key === 'password') { if (is_array($value)) { foreach ($value as $value2) { if ($password === $value2) { $password_ok = true; } } } else { if ($password === $value) { $password_ok = true; } } } } if ($username_ok && $password_ok) { $_SESSION['logged'] = true; Flight::redirect('./home'); } else { setFlashMessage('Error: Invalid username or password!'); Flight::redirect('./login'); } }
/** * SymTrans constructor. * @param array $conf */ function __construct($conf = []) { if (!$conf) { $conf = \Flight::get('config')->get('locale'); } $path = isset($conf['directory']) ? $conf['directory'] : CONFIG . 'lang'; $this->setPath($path); $locale = null; if (function_exists('getOValue')) { $ov = getOValue(); $locale = $ov ? $ov->getOld('language') : ''; } if (!$locale) { $locale = $conf['language']; } $this->translator = new Translator($locale); $this->translator->addLoader('array', new ArrayLoader()); $this->setLocale($locale); }