Пример #1
0
 public function start($ns = 'core')
 {
     $this->db = \Raw\Db::instance('session', $ns . '.' . forever());
     $this->ns = $ns;
     register_shutdown_function('session_write_close');
     $this->maxLifeTime = ini_get('session.gc_maxlifetime');
     session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc'));
 }
Пример #2
0
 public static function init($cli)
 {
     register_shutdown_function(['\\Thin\\Bootstrap', 'finish']);
     Timer::start();
     lib('app');
     forever();
     $storage_dir = STORAGE_PATH;
     if (!is_writable(STORAGE_PATH)) {
         die('Please give 0777 right to ' . STORAGE_PATH);
     }
     if (!is_dir(CACHE_PATH)) {
         File::mkdir(CACHE_PATH);
     }
     $dir = APPLICATION_PATH;
     Config::set('app.module.dir', APPLICATION_PATH);
     Config::set('mvc.dir', APPLICATION_PATH);
     Config::set('app.module.dirstorage', $dir . DS . 'storage');
     Config::set('app.module.assets', $dir . DS . 'assets');
     Config::set('app.module.config', $dir . DS . 'config');
     Config::set('dir.raw.store', $storage_dir . DS . 'db');
     Config::set('dir.ardb.store', $storage_dir . DS . 'db');
     Config::set('dir.ephemere', $storage_dir . DS . 'ephemere');
     Config::set('dir.flight.store', $storage_dir . DS . 'flight');
     Config::set('dir.flat.store', $storage_dir . DS . 'flat');
     Config::set('dir.cache.store', $storage_dir . DS . 'cache');
     Config::set('dir.nosql.store', $storage_dir . DS . 'nosql');
     Config::set('dir.module.logs', $storage_dir . DS . 'logs');
     path('module', $dir);
     path('pages', $dir . DS . 'app' . DS . 'pages');
     path('layouts', $dir . DS . 'app' . DS . 'layouts');
     path('store', $storage_dir);
     path('config', Config::get('app.module.config'));
     path('cache', CACHE_PATH);
     loaderProject('entity');
     loaderProject('system');
     Alias::facade('DB', 'EntityProject', 'Thin');
     Alias::facade('System', 'SystemProject', 'Thin');
     System::Db()->firstOrCreate(['name' => SITE_NAME]);
     require_once path('config') . DS . 'application.php';
     if (!$cli) {
         if (fnmatch('*/mytests', $_SERVER['REQUEST_URI'])) {
             self::tests();
         } else {
             self::router();
         }
     }
 }
Пример #3
0
 private static function init()
 {
     if (!isset(self::$store)) {
         self::$store = lib('ephemere', [forever()]);
     }
 }
Пример #4
0
/**
 * Thin is a swift Framework for PHP 5.4+
 *
 * @package    Thin
 * @version    1.0
 * @author     Gerald Plusquellec
 * @license    BSD License
 * @copyright  1996 - 2015 Gerald Plusquellec
 * @link       http://github.com/schpill/thin
 */
namespace Thin;

define('NL', "\n");
define('HTTPS', true);
define('THINSTART', microtime());
forever();
container();
$_SERVER['REQUEST_URI'] = isAke($_SERVER, 'REQUEST_URI', '/');
date_default_timezone_set(Config::get('application.timezone', 'Europe/Paris'));
setlocale(LC_ALL, Config::get('application.lc.all', 'fr_FR.UTF-8'));
require_once __DIR__ . DS . 'helpers/functions.php';
require_once __DIR__ . DS . 'helpers.php';
require_once __DIR__ . DS . 'facades.php';
if (Arrays::exists('SERVER_NAME', $_SERVER)) {
    $protocol = 'http';
    if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
        $protocol .= 's';
    }
    container()->setProtocol($protocol);
    $urlSite = "{$protocol}://" . $_SERVER["SERVER_NAME"] . "/";
    if (strstr($urlSite, '//')) {
Пример #5
0
 public function session($k, $v = 'dummyget', $field = '', $e = null)
 {
     $user = session('front')->getUser();
     $isLogged = !is_null($user);
     $key = $isLogged ? sha1(lng() . '.' . forever() . '1.' . $k) : sha1(lng() . '.' . forever() . '0.' . $k);
     return 'dummyget' == $v ? $this->get($key) : $this->set($key, $v, $e);
 }