start() static public method

Starts a new session
static public start ( )
Exemplo n.º 1
0
 function __construct()
 {
     s::start();
     c::set('home.keepurl', true);
     // auto-detect the url if it is not set
     if (!c::get('url')) {
         c::set('url', c::get('scheme') . server::get('http_host'));
     }
     // setup the thumb plugin
     c::set('thumb.cache.root', c::get('root') . '/thumbs');
     c::set('thumb.cache.url', c::get('url') . '/thumbs');
     c::set('url', c::get('url') . '/' . c::get('panel.folder'));
     // remove the panel folder name from the uri
     c::set('subfolder', ltrim(c::get('subfolder') . '/' . c::get('panel.folder'), '/'));
     // attach the uri after caching
     $this->uri = new paneluri();
     if (c::get('lang.support')) {
         $path = $this->uri->path->toArray();
         $first = array_shift($path);
         if (!in_array($first, c::get('lang.available', array()))) {
             $first = c::get('lang.default');
         }
         // set the current language
         c::set('lang.current', $first);
         $this->uri->path = new uriPath($path);
     }
     // get the first set of pages
     $this->rootPages();
     // get the additional site info from content/site.txt
     $this->siteInfo();
 }
Exemplo n.º 2
0
 /**
  * Remove old values from the Session’s flash data.
  */
 public static function flush()
 {
     // Make sure the session is started
     s::start();
     // Retrieve the flash data
     $registry = s::get(self::$namespace);
     // Clean up registry
     if (!empty($registry)) {
         foreach ($registry as $key => $expiry) {
             $expiry++;
             // Remove all old values from the session
             if ($expiry > 1) {
                 s::remove($key);
                 unset($registry[$key]);
             } else {
                 $registry[$key] = $expiry;
             }
         }
         // Write registry back to session
         if (!empty($registry)) {
             s::set(self::$namespace, $registry);
         } else {
             s::remove(self::$namespace);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Make sure the session is started within the constructor
  */
 public function __construct()
 {
     s::start();
     if (!isset($_SESSION['_cache'])) {
         $_SESSION['_cache'] = array();
     }
 }
Exemplo n.º 4
0
 public function __construct()
 {
     $roots = array('tests' => dirname(__DIR__), 'panel' => dirname(dirname(__DIR__)), 'index' => dirname(dirname(dirname(__DIR__))), 'kirby' => dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'kirby', 'dummy' => dirname(__DIR__) . DIRECTORY_SEPARATOR . 'dummy');
     // load kirby
     require_once $roots['kirby'] . DIRECTORY_SEPARATOR . 'bootstrap.php';
     // make sure to start a session
     s::start();
     // create the dummy content directory
     dir::make($roots['dummy'] . DS . 'content');
     // create the roots object
     $this->roots = new Obj($roots);
     // load the panel
     require_once $roots['panel'] . DS . 'app' . DS . 'bootstrap.php';
     // initiate kirby
     $this->kirby = new Kirby();
     $this->kirby->roots->content = $this->roots->dummy . DS . 'content';
     $this->kirby->roots->site = $this->roots->dummy . DS . 'site';
     // initiate the panel
     $this->panel = new Panel($this->kirby, $this->roots->panel);
     // store the site instance
     $this->site = $this->panel->site();
 }
Exemplo n.º 5
0
 function __construct()
 {
     s::start();
     $this->urlSetup();
     // setup the thumb plugin
     c::set('thumb.cache.root', c::get('root') . '/thumbs');
     c::set('thumb.cache.url', dirname(c::get('url')) . '/thumbs');
     // set the rewrite mode
     $rewrite = c::get('rewrite');
     $config = c::get();
     if (isset($config['panel.rewrite'])) {
         $rewrite = $config['panel.rewrite'];
     }
     c::set('panel.rewrite', $rewrite);
     // attach the uri after caching
     $this->uri = new paneluri();
     if (c::get('lang.support')) {
         $path = $this->uri->path->toArray();
         $first = array_shift($path);
         if (!in_array($first, c::get('lang.available', array()))) {
             if (empty($first)) {
                 $first = c::get('lang.default');
             } else {
                 go(c::get('panel.url'));
             }
         }
         // set the current language
         c::set('lang.current', $first);
         $this->uri->path = new uriPath($path);
         // mark if this is a translated version or the default version
         c::get('lang.current') != c::get('lang.default') ? c::set('lang.translated', true) : c::set('lang.translated', false);
     }
     // get the first set of pages
     $this->rootPages();
     // get the additional site info from content/site.txt
     $this->info();
 }
Exemplo n.º 6
0
/**
 * Checks / returns a csrf token
 *
 * @param string $check Pass a token here to compare it to the one in the session
 * @return mixed Either the token or a boolean check result
 */
function csrf($check = null)
{
    // make sure a session is started
    s::start();
    if (is_null($check)) {
        $token = str::random(64);
        s::set('csrf', $token);
        return $token;
    }
    return $check === s::get('csrf') ? true : false;
}
Exemplo n.º 7
0
 public static function getCart()
 {
     s::start();
     $data = s::get('cart', []);
     return new self($data);
 }
Exemplo n.º 8
0
<?php

if (!defined('KIRBY')) {
    define('KIRBY', true);
}
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}
// load the kirby toolkit
include_once __DIR__ . DS . 'toolkit' . DS . 'bootstrap.php';
// start a session
s::start();
// load all core classes
load(array('kirby' => __DIR__ . DS . 'kirby.php', 'kirby\\roots' => __DIR__ . DS . 'kirby' . DS . 'roots.php', 'kirby\\urls' => __DIR__ . DS . 'kirby' . DS . 'urls.php', 'kirby\\component' => __DIR__ . DS . 'kirby' . DS . 'component.php', 'kirby\\registry' => __DIR__ . DS . 'kirby' . DS . 'registry.php', 'kirby\\request' => __DIR__ . DS . 'kirby' . DS . 'request.php', 'kirby\\request\\params' => __DIR__ . DS . 'kirby' . DS . 'request' . DS . 'params.php', 'kirby\\request\\query' => __DIR__ . DS . 'kirby' . DS . 'request' . DS . 'query.php', 'kirby\\request\\path' => __DIR__ . DS . 'kirby' . DS . 'request' . DS . 'path.php', 'kirby\\component\\template' => __DIR__ . DS . 'kirby' . DS . 'component' . DS . 'template.php', 'kirby\\component\\thumb' => __DIR__ . DS . 'kirby' . DS . 'component' . DS . 'thumb.php', 'kirby\\component\\markdown' => __DIR__ . DS . 'kirby' . DS . 'component' . DS . 'markdown.php', 'kirby\\component\\smartypants' => __DIR__ . DS . 'kirby' . DS . 'component' . DS . 'smartypants.php', 'kirby\\component\\snippet' => __DIR__ . DS . 'kirby' . DS . 'component' . DS . 'snippet.php', 'kirby\\component\\css' => __DIR__ . DS . 'kirby' . DS . 'component' . DS . 'css.php', 'kirby\\component\\js' => __DIR__ . DS . 'kirby' . DS . 'component' . DS . 'js.php', 'kirby\\component\\tinyurl' => __DIR__ . DS . 'kirby' . DS . 'component' . DS . 'tinyurl.php', 'kirby\\component\\response' => __DIR__ . DS . 'kirby' . DS . 'component' . DS . 'response.php', 'kirby\\traits\\image' => __DIR__ . DS . 'kirby' . DS . 'traits' . DS . 'image.php', 'assetabstract' => __DIR__ . DS . 'core' . DS . 'asset.php', 'avatarabstract' => __DIR__ . DS . 'core' . DS . 'avatar.php', 'pagesabstract' => __DIR__ . DS . 'core' . DS . 'pages.php', 'childrenabstract' => __DIR__ . DS . 'core' . DS . 'children.php', 'contentabstract' => __DIR__ . DS . 'core' . DS . 'content.php', 'fieldabstract' => __DIR__ . DS . 'core' . DS . 'field.php', 'fileabstract' => __DIR__ . DS . 'core' . DS . 'file.php', 'filesabstract' => __DIR__ . DS . 'core' . DS . 'files.php', 'kirbytextabstract' => __DIR__ . DS . 'core' . DS . 'kirbytext.php', 'kirbytagabstract' => __DIR__ . DS . 'core' . DS . 'kirbytag.php', 'pageabstract' => __DIR__ . DS . 'core' . DS . 'page.php', 'roleabstract' => __DIR__ . DS . 'core' . DS . 'role.php', 'rolesabstract' => __DIR__ . DS . 'core' . DS . 'roles.php', 'siteabstract' => __DIR__ . DS . 'core' . DS . 'site.php', 'usersabstract' => __DIR__ . DS . 'core' . DS . 'users.php', 'userabstract' => __DIR__ . DS . 'core' . DS . 'user.php', 'pageextension' => __DIR__ . DS . 'lib' . DS . 'pageextension.php', 'structure' => __DIR__ . DS . 'lib' . DS . 'structure.php', 'parsedown' => __DIR__ . DS . 'vendors' . DS . 'parsedown.php', 'parsedownextra' => __DIR__ . DS . 'vendors' . DS . 'parsedownextra.php', 'smartypantstypographer_parser' => __DIR__ . DS . 'vendors' . DS . 'smartypants.php'));
// load all helper functions
include __DIR__ . DS . 'helpers.php';
Exemplo n.º 9
0
 function setUp()
 {
     s::start();
     s::set('key', 'value');
 }
Exemplo n.º 10
0
 public function session()
 {
     // setup the session
     s::$timeout = $this->kirby->option('panel.session.timeout', 120);
     s::$cookie['lifetime'] = $this->kirby->option('panel.session.lifetime', 0);
     // start the session
     s::start();
 }
Exemplo n.º 11
0
function get_cart()
{
    s::start();
    $cart = s::get('cart', array());
    return $cart;
}