예제 #1
0
 public function get(&$layer, $name = '', $def = null)
 {
     if (@is_null($layer['autosavename'])) {
         return $def;
     }
     $val = Session::get($layer['autosavename'] . '.' . $name);
     if (@is_null($val)) {
         return $def;
     }
     return $val;
 }
예제 #2
0
파일: index.php 프로젝트: infrajs/session
namespace infrajs\infra;

use infrajs\access\Access;
use infrajs\event\Event;
use infrajs\ans\Ans;
use infrajs\path\Path;
use infrajs\session\Session;
if (!is_file('vendor/autoload.php')) {
    chdir(explode('vendor/', __DIR__)[0]);
    require_once 'vendor/autoload.php';
}
Access::admin(true);
$ans = array();
if (isset($_GET['get'])) {
    $name = Ans::REQ('name');
    $ans['id'] = Session::getId();
    $ans['data'] = Session::get($name);
} else {
    if (isset($_GET['clear'])) {
        Session::clear();
    } else {
        if (isset($_GET['set'])) {
            $ans = array();
            $name = Path::toutf($_REQUEST['name']);
            $val = Path::toutf($_REQUEST['val']);
            Session::set($name, $val);
        }
    }
}
return Ans::ret($ans);
예제 #3
0
파일: Session.php 프로젝트: infrajs/session
 public static function &user_init($email)
 {
     $user = Session::getUser($email);
     $session_id = $user['session_id'];
     $nowsession_id = Session::getId();
     if ($session_id == $nowsession_id) {
         return Session::get();
     }
     return Once::exec(__FILE__ . 'user_init', function ($session_id) {
         $sql = 'select name, value, unix_timestamp(time) as time from ses_records where session_id=? order by time,rec_id';
         $db = Db::pdo();
         $stmt = $db->prepare($sql);
         $stmt->execute(array($session_id));
         $news = $stmt->fetchAll();
         if (!$news) {
             $news = array();
         }
         $obj = array();
         Each::forr($news, function &(&$v) use(&$obj) {
             $r = null;
             if ($v['value'] == 'null') {
                 $value = null;
             } else {
                 $value = Load::json_decode($v['value']);
             }
             $right = Sequence::right($v['name']);
             $obj = Sequence::set($obj, $right, $value);
             return $r;
         });
         return $obj;
     }, array($session_id));
 }
예제 #4
0
파일: tester.php 프로젝트: infrajs/session
<?php

use infrajs\ans\Ans;
use infrajs\session\Session;
use infrajs\router\Router;
use infrajs\once\Once;
use infrajs\access\Access;
if (!is_file('vendor/autoload.php')) {
    chdir('../../../');
    require_once 'vendor/autoload.php';
    Router::init();
    //Нужен чтобы работал конфиг .infra.json
}
Access::test(true);
Session::get();
$ans = array();
return Ans::ret($ans);
예제 #5
0
파일: infra.php 프로젝트: infrajs/session
<?php

namespace infrajs\crumb;

use infrajs\controller\Controller;
use infrajs\each\Each;
use infrajs\controller\Run;
use infrajs\controller\Layer;
use infrajs\path\Path;
use infrajs\event\Event;
use infrajs\sequence\Sequence;
use infrajs\template\Template;
use infrajs\session\Session;
use infrajs\controller\External;
Path::reqif('-controller/infra.php');
$cl = function ($name, $def = null) {
    return Session::get($name, $def);
};
Sequence::set(Template::$scope, Sequence::right('infra.session.get'), $cl);
$cl = function () {
    return Session::getLink();
};
Sequence::set(Template::$scope, Sequence::right('infra.session.getLink'), $cl);
$cl = function () {
    return Session::getTime();
};
Sequence::set(Template::$scope, Sequence::right('infra.session.getTime'), $cl);
$cl = function () {
    return Session::getId();
};
Sequence::set(Template::$scope, Sequence::right('infra.session.getId'), $cl);