Exemple #1
0
 public static function _init()
 {
     static::$crypter = new Crypt_AES();
     static::$hasher = new Crypt_Hash('sha256');
     // load the config
     \Config::load('crypt', true);
     static::$config = \Config::get('crypt', array());
     // generate random crypto keys if we don't have them or they are incorrect length
     $update = false;
     foreach (array('crypto_key', 'crypto_iv', 'crypto_hmac') as $key) {
         if (empty(static::$config[$key]) or strlen(static::$config[$key]) % 4 != 0) {
             $crypto = '';
             for ($i = 0; $i < 8; $i++) {
                 $crypto .= static::safe_b64encode(pack('n', mt_rand(0, 0xffff)));
             }
             static::$config[$key] = $crypto;
             $update = true;
         }
     }
     // update the config if needed
     if ($update === true) {
         // load the file config
         \Config::load('file', true);
         try {
             \Config::save('crypt', static::$config);
             chmod(APPPATH . 'config' . DS . 'crypt.php', \Config::get('file.chmod.files', 0666));
         } catch (\FileAccessException $e) {
             // failed to write the config file, inform the user
             echo \View::forge('errors/crypt_keys', array('keys' => static::$config));
             die;
         }
     }
     static::$crypter->enableContinuousBuffer();
     static::$hasher->setKey(static::safe_b64decode(static::$config['crypto_hmac']));
 }
Exemple #2
0
 /**
  * initialisation and auto configuration
  */
 public static function _init()
 {
     $crypter = new Crypt_AES();
     $hasher = new Crypt_Hash('sha256');
     // load the config
     \Config::load('crypt', true);
     static::$defaults = \Config::get('crypt', array());
     // generate random crypto keys if we don't have them or they are incorrect length
     $update = false;
     foreach (array('crypto_key', 'crypto_iv', 'crypto_hmac') as $key) {
         if (empty(static::$defaults[$key]) or strlen(static::$defaults[$key]) % 4 != 0) {
             $crypto = '';
             for ($i = 0; $i < 8; $i++) {
                 $crypto .= static::safe_b64encode(pack('n', mt_rand(0, 0xffff)));
             }
             static::$defaults[$key] = $crypto;
             $update = true;
         }
     }
     // update the config if needed
     if ($update === true) {
         try {
             \Config::save('crypt', static::$defaults);
         } catch (\FileAccessException $e) {
             // failed to write the config file, inform the user
             echo \View::forge('errors/crypt_keys', array('keys' => static::$defaults));
             die;
         }
     }
 }
Exemple #3
0
 public function __construct()
 {
     Package::load('curl_http_client');
     Config::load('eventbrite');
     $this->curl_http_client = new \curl_http_client(array('debug' => true));
     $this->baseUrl = Config::get('eventbrite_base_url');
 }
Exemple #4
0
 public static function _init()
 {
     static::$crypter = new Crypt_AES();
     static::$hasher = new Crypt_Hash('sha256');
     // load the config
     \Config::load('crypt', true);
     static::$config = \Config::get('crypt', array());
     // generate random crypto keys if we don't have them or they are incorrect length
     $update = false;
     foreach (array('crypto_key', 'crypto_iv', 'crypto_hmac') as $key) {
         if (empty(static::$config[$key]) || strlen(static::$config[$key]) % 4 != 0) {
             $crypto = '';
             for ($i = 0; $i < 8; $i++) {
                 $crypto .= static::safe_b64encode(pack('n', mt_rand(0, 0xffff)));
             }
             static::$config[$key] = $crypto;
             $update = true;
         }
     }
     // update the config if needed
     if ($update === true) {
         try {
             \Config::save('crypt', static::$config);
         } catch (\File_Exception $e) {
             throw new \Exception('Crypt keys are invalid or missing, and app/config/crypt.php could not be written.');
         }
     }
     static::$crypter->enableContinuousBuffer();
     static::$hasher->setKey(static::safe_b64decode(static::$config['crypto_hmac']));
 }
 public function __construct()
 {
     Package::load('curl_http_client');
     Config::load('foursquare');
     $this->curl_http_client = new \curl_http_client(array('debug' => true));
     $this->baseUrl = Config::get('foursquare_base_url');
     $this->authUrl = Config::get('foursquare_auth_url');
 }
Exemple #6
0
 public static function getQRCodeUrl($name, $secret)
 {
     $config = \Fuel\Core\Config::load('g2fa', true);
     $urlencoded_str = urlencode('otpauth://totp/' . $name . '?secret=' . $secret);
     if (isset($config['title'])) {
         $urlencoded_str .= urlencode('&issuer=' . urlencode($config['title']));
     }
     return 'https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=' . $urlencoded_str;
 }
Exemple #7
0
 public static function bootstrap()
 {
     //Make sure orm is loaded first as we need this
     \Fuel\Core\Package::load('orm');
     //For fuel v1 add to the finder path
     if (class_exists('\\Fuel\\Core\\Finder')) {
         \Fuel\Core\Finder::instance()->add_path(__DIR__ . DS . '..' . DS . '..');
     }
     \Fuel\Core\Config::load('ethanol', true);
     \Fuel\Core\Config::load('ethanol_permissions', true);
     \Fuel\Core\Lang::load('ethanol', 'ethanol');
     Auth::instance()->register_driver(array('database', 'facebook'));
 }
 public static function routes()
 {
     $route = '_status';
     Router::add($route, new Route($route, function ($request) {
         // ignore this transaction
         Transaction::ignore();
         // load a config
         $conf = Config::load('newrelic-ping');
         // ping the urls
         $pinger = new Pinger($conf['urls'], $conf['base_host']);
         $res = $pinger->ping();
         // add path to lookup view
         Finder::instance()->add_path(realpath(rtrim(__DIR__, '/') . '/../'));
         // build a response and return it
         return new Response(View::forge('_newrelic-status', ['result' => $res]), $res->getResultStatusCode());
     }));
 }
Exemple #9
0
 /**
  * Display article-list of category - Img-list
  *
  * params array $arts articles
  * params object $cat Category
  * return void
  *
  * @version 1.0
  * @since 1.0
  * @access protected
  * @author Nguyen Van Hiep
  */
 protected function ds_sanpham($arts, $cat)
 {
     $custom_config = \Fuel\Core\Config::load('custom');
     $view = View::forge('customer/cat/ds_sanpham_4col');
     $view->cat = $cat;
     $view->arts = $arts;
     $view->lang = $this->lang;
     $view->show_arts = Model_Article::articles_of_cat_limit($cat->id, $this->lang, null, 8);
     $this->template->title = Security::strip_tags($cat->name);
     $this->template->content = $view;
 }
Exemple #10
0
 /**
  * Initializes the default dsn and option values from the predefined configuration values.
  *
  * @throws \Fuel\Core\FuelException
  */
 public static function _init()
 {
     Config::load('db', true);
     $config = Config::get('db.monga');
     static::setup_default($config);
 }
Exemple #11
0
<?php

//Make sure orm is loaded first as we need this
\Fuel\Core\Package::load('orm');
//For fuel v1 add to the finder path
if (class_exists('\\Finder')) {
    \Fuel\Core\Finder::instance()->add_path(__DIR__ . DS . '..' . DS . '..');
}
\Fuel\Core\Config::load('ethanol', true);
\Fuel\Core\Config::load('ethanol_permissions', true);
\Fuel\Core\Lang::load('ethanol', 'ethanol');
Ethanol\Auth::instance()->register_driver(array('database', 'facebook'));
Exemple #12
0
 public static function _init()
 {
     \Fuel\Core\Config::load('evernote', true);
 }
 public function __construct()
 {
     Config::load('facebook');
     FacebookSession::setDefaultApplication(Config::get('appId'), Config::get('appSecret'));
     $this->helper = new FacebookRedirectLoginHelper(Config::get('login_url'));
 }