Ejemplo n.º 1
0
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);
Ejemplo n.º 2
0
 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));
 }
Ejemplo n.º 3
0
<?php

namespace infrajs\infra;

use infrajs\access\Access;
use infrajs\event\Event;
use infrajs\ans\Ans;
use infrajs\session\Session;
if (!is_file('vendor/autoload.php')) {
    chdir('../../../../');
    require_once 'vendor/autoload.php';
}
Access::test(true);
$data = array();
if (!empty($_GET['id'])) {
    $id = (int) $_GET['id'];
} else {
    $id = Session::getId();
}
$db = Db::pdo();
$stmt = Db::stmt('select count(*) from ses_sessions');
$stmt->execute();
$data['count'] = $stmt->fetchColumn();
$data['id'] = $id;
$data['data'] = infra_session_user_get($id);
$data['data'] = print_r($data['data'], true);
$data['user'] = Session::getUser($id);
$data['user'] = print_r($data['user'], true);
echo Template::parse('-session/admin.tpl', $data);
Ejemplo n.º 4
0
<?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);