示例#1
0
 /**
  * Save a session.
  *
  * @param  array  $session
  * @return void
  */
 public function save($session)
 {
     if (!headers_sent()) {
         extract(Config::get('session'));
         $payload = $this->crypter->encrypt(serialize($session));
         \System\Cookie::put('session_payload', $payload, $lifetime, $path, $domain, $https, $http_only);
     }
 }
示例#2
0
 public static function getConnection($connection = null)
 {
     $connection = $connection ?: self::$currentConnection ?: Config::get('db.default');
     if (!isset(self::$connections[$connection])) {
         $config = Config::get('db.connections.' . $connection);
         self::$connections[$connection] = new PDO($config['driver'] . ':host=' . $config['host'] . ';dbname=' . $config['database'], $config['username'], $config['password']);
         if ($config['driver'] == 'mysql') {
             self::$connections[$connection]->exec('set names utf8');
         }
         self::$connections[$connection]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     }
     $return =& self::$connections[$connection];
     return $return;
 }
示例#3
0
 /**
  * Delete an item from the cache.
  *
  * @param  string  $key
  * @return void
  */
 public function forget($key)
 {
     \System\Memcached::instance()->delete(Config::get('cache.key') . $key);
 }
示例#4
0
 /**
  * Delete an item from the cache.
  *
  * @param  string  $key
  * @return void
  */
 public function forget($key)
 {
     apc_delete(Config::get('cache.key') . $key);
 }
示例#5
0
 /**
  * Get all of the routes for the application.
  *
  * To improve performance, this operation will only be performed once. The routes
  * will be cached and returned on every subsequent call.
  *
  * @param  bool    $reload
  * @param  string  $path
  * @return array
  */
 public static function all($reload = false, $path = APP_PATH)
 {
     if (!is_null(static::$routes) and !$reload) {
         return static::$routes;
     }
     // Merge all of the module paths in with the specified path so that all
     // active module routes will also be loaded. So, by default, this method
     // will search the application path and all active module paths for routes.
     $paths = array_merge(array($path), array_map(function ($module) {
         return MODULE_PATH . $module . '/';
     }, Config::get('application.modules')));
     $routes = array();
     foreach ($paths as $path) {
         if (file_exists($path . 'routes' . EXT)) {
             $routes = array_merge($routes, require $path . 'routes' . EXT);
         }
         if (is_dir($path . 'routes')) {
             // Since route files can be nested deep within the route directory, we need to
             // recursively spin through the directory to find every file.
             $directoryIterator = new \RecursiveDirectoryIterator($path . 'routes');
             $recursiveIterator = new \RecursiveIteratorIterator($directoryIterator, \RecursiveIteratorIterator::SELF_FIRST);
             foreach ($recursiveIterator as $file) {
                 if (filetype($file) === 'file' and strpos($file, EXT) !== false) {
                     $routes = array_merge($routes, require $file);
                 }
             }
         }
     }
     return static::$routes = $routes;
 }
示例#6
0
文件: db.php 项目: hpaul/Google-short
 /**
  * Get a session database query.
  *
  * @return Query
  */
 private function table()
 {
     return \System\DB::connection()->table(Config::get('session.table'));
 }
示例#7
0
 /**
  * Save a session.
  *
  * @param  array  $session
  * @return void
  */
 public function save($session)
 {
     Cache::driver('memcached')->put($session['id'], $session, Config::get('session.lifetime'));
 }
示例#8
0
 public static function middleware()
 {
     $config = Config::get('App', 'Middleware');
     $global = $config['Global'];
     if (count($global) == 0) {
         $result = call_user_func_array([Request::$controller, Request::$function], Request::$parameters);
         print_r($result);
         return;
     }
     $controller = Request::$controller;
     Request::$middleware = array_merge($global, $controller->getMiddleware(), Request::$middleware);
     $middleware = 'App\\Middleware\\' . Request::$middleware[0];
     if (!class_exists($middleware)) {
         trigger_error("Middleware with the name '" . Request::$middleware[0] . "' not found", E_USER_ERROR);
     }
     array_shift(Request::$middleware);
     $middle = new $middleware();
     $middle();
 }
示例#9
0
 /**
  * Menghapus seluruh cache
  */
 public static function flush()
 {
     $cache = Config::get("Cache", "Cache");
     $config = Config::get("Cache", "Configuration");
     switch ($cache) {
         case 'File':
             return FileCache::flush();
             break;
         default:
             # code...
             break;
     }
 }
示例#10
0
 /**
  * Log the exception using the logger closure specified in the error configuration.
  *
  * @return void
  */
 private function log()
 {
     $parameters = array($this->exception->severity(), $this->exception->message(), $this->exception->getTraceAsString());
     call_user_func_array(Config::get('error.logger'), $parameters);
 }
示例#11
0
 /**
  * Mendapatkan file dan juga path cache
  * @param string $key
  */
 private static function getCacheFile($key)
 {
     $config = Config::get("Cache", "Configuration");
     $directory = removeMultiple($config['File']['Path']);
     $fileName = $config['File']['EncryptFileName'] ? md5($key) : $key;
     return removeMultiple($directory . "/" . $fileName . ".cache");
 }