Beispiel #1
0
 public static function forceLogin($user = null, $remember = false)
 {
     if ($user->exists()) {
         DB::instance()->delete("user_sessions", array("", "hash", "=", Cookie::get(Config::get('remember/cookie_name'))));
         Session::put(Config::get('session/loggedId'), $user->id());
         if ($remember) {
             $hash = Hash::hashUnique();
             DB::instance()->insert("user_sessions", array('user_id' => $user->id(), 'hash' => $hash, 'expiry' => DateFormat::sql(time() + Config::get('remember/cookie_expiry'))));
             Cookie::put(Config::get('remember/cookie_name'), $hash, Config::get('remember/cookie_expiry'));
         }
         self::$_currentUser = new User();
     }
 }
Beispiel #2
0
<?php

require_once 'app/core/init.php';
require_once 'main.php';
if (isset($_GET['page']) && !empty($_GET['page'])) {
    $smarty = new Smarty();
    $smarty->debugging = Config::get('debug/smartyDebug');
    $smarty->caching = Config::get('smarty/caching');
    $smarty->cache_lifetime = Config::get('smarty/cache_lifetime');
    $cache_id = md5(json_encode($_GET) . json_encode($_POST) . Notifications::getAsJson());
    $pageFile = 'app/pages/' . $_GET['page'] . '.php';
    $templateFile = 'templates/pages/' . $_GET['page'] . '.tpl';
    if (file_exists($pageFile) && file_exists($templateFile)) {
        require $pageFile;
        if (!$allowCaching) {
            $cache_id = md5($cache_id . Hash::hashUnique());
        }
        if (!$smarty->isCached($templateFile, $cache_id)) {
            $smarty = createPage($smarty);
            $smarty = pageAddMain($smarty);
        }
        $smarty = pageAddMessages($smarty);
        $smarty->loadFilter("output", "trimwhitespace");
        $smarty->display($templateFile, $cache_id);
    } else {
        Redirect::error(404);
    }
} else {
    Redirect::to('?page=home');
}
Beispiel #3
0
 public static function generate()
 {
     return Session::put(Config::get('session/token_name'), md5(Hash::hashUnique()));
 }