示例#1
0
 public function __construct($config, $log)
 {
     if (!is_a($config, '\\Sauce\\Object', true)) {
         $config = Ar($config);
     }
     // Set session hash function to SHA1
     ini_set('session.hash_function', 1);
     if (!isset($config['key'])) {
         throw new \Exception('No session key set, please place one in your config.');
     }
     $this->log = $log;
     $this->key = $config->key;
     if (isset($config->timeout)) {
         $this->timeout = intval($config->timeout);
     }
     if (isset($config->refresh_timeout)) {
         $this->refresh_timeout = intval($config->refresh_timeout);
     }
     if (isset($config->name)) {
         $this->name = $config->name;
     } else {
         $this->name .= $this->key;
     }
     if (!$this->created_at) {
         $this->start();
     }
     $this->regenerate();
     $this->refresh();
     $this->last_used_at = time();
 }
示例#2
0
 public function __construct($message = '', $code = 0, $previous = null)
 {
     if (is_an_array($message)) {
         $error = Ar($message);
         $this->column = $error->column;
         $this->message = $error->message;
     } else {
         $this->column = '(column not set)';
     }
     return parent::__construct($this->message, $code, $previous);
 }
示例#3
0
 public function __construct($session, $config, $log)
 {
     if (!$config instanceof \Sauce\Object) {
         $config = Ar($config);
     }
     $this->session = $session;
     $this->base_uri = $config->base_uri;
     $this->base_controller = $config->base_controller;
     $this->paths = $config->paths;
     $this->log = $log;
     $this->_request = Ar($_REQUEST);
     $this->_request->merge($_SERVER);
 }
示例#4
0
 public function __construct($config, $log)
 {
     if (!is_a($config, '\\Sauce\\Object', true)) {
         $config = Ar($config);
     }
     if (!isset($config['key'])) {
         throw new \Exception('No authcookie key set, please place one in your config.');
     }
     $this->log = $log;
     $this->key = base64_decode($config->key);
     if (isset($config->timeout)) {
         $this->timeout = intval($config->timeout);
     }
 }
示例#5
0
文件: Path.php 项目: brainsware/sauce
 public static function info($path)
 {
     return Ar(pathinfo($path));
 }
示例#6
0
 public function index()
 {
     if (!file_exists(\Sauce\Path::join(APP_ROOT, 'Views/NotFound/index.tpl'))) {
         return new \Bacon\Presenter\NotFoundHtml(null, Ar($this->params));
     }
 }
示例#7
0
文件: boot.php 项目: brainsware/bacon
    define('HTDOCS', APP_ROOT . '/htdocs/');
}
$log = new \Bacon\Log($config->logging);
Bacon\ORM\DatabaseSingleton::set_logger($log);
if (is_cli()) {
    $session = new \Sauce\Object();
} else {
    $session = new \Bacon\Session($config->session, $log);
}
$authcookie = new \Sauce\Object();
if (!empty(\Config\Base::$auth)) {
    $config->auth = \Config\Base::$auth;
    $authcookie = new \Bacon\AuthCookie($config->auth, $log);
}
$params = Ar($_REQUEST);
$env = Ar($_ENV);
$env->mergeF($_SERVER);
/* PHP's builtin webserver doesn't know FallbackResource. So we have to do it on our
 * own in this case.
 *
 * Check whether given URI maps to a file or is to be handled by us.
 */
if (is_cli_server()) {
    $path = $params->request_uri;
    if (empty($path) || $path === null) {
        $path = $env->request_uri;
    }
    /* Remove any GET parameters (<uri>?foo=bar) if present. */
    $question_mark = strpos($path, '?');
    if ($question_mark !== false) {
        $path = substr($path, 0, $question_mark);