예제 #1
0
 public function run()
 {
     //this part is to test Admin cookies only - start.
     $params = ['uuid' => 'fake_uuid', 'username' => '*****@*****.**', 'password' => 'fake password', 'name' => 'fake name', 'created' => ''];
     $adminUserDto = new AdminUserDto($params);
     $this->sessionHandler->setAdminUserCookie($adminUserDto);
     //this part is to test Admin cookies only - end.
     $this->pipeFilter->run();
     $controller = $this->request->controller;
     $controllerMethod = strtolower($this->request->request_method());
     $controller->{$controllerMethod}();
     echo "<br><br>" . __METHOD__;
 }
예제 #2
0
 /**
  * Outputs the current users full name (if any)
  */
 protected function tagFullname()
 {
     $user = SessionHandler::user();
     if ($user) {
         return $user->getFullName();
     }
 }
예제 #3
0
 public function close()
 {
     parent::close();
     if ($this->isCurrentSessionExceeded()) {
         $this->log->error(sprintf("[SessionLock] Session lock was held for %s seconds which is longer than the maximum of %s seconds. Request details: \n                SERVER_NAME     | %s \n                SERVER_ADDR     | %s \n                SCRIPT_FILENAME | %s \n                REQUEST_METHOD  | %s \n                SCRIPT_NAME     | %s \n                REQUEST_URI     | %s \n                QUERY_STRING    | %s ", $this->session_time, $this->max_session_time, $_SERVER['SERVER_NAME'], $_SERVER['SERVER_ADDR'], $_SERVER['SCRIPT_FILENAME'], $_SERVER['REQUEST_METHOD'], $_SERVER['SCRIPT_NAME'], $_SERVER['REQUEST_URI'], $_SERVER['QUERY_STRING']));
     }
 }
예제 #4
0
 public static function get($name)
 {
     if (!SessionHandler::instance()->hasSession()) {
         return null;
     }
     return self::instance()->getSession()->get($name);
 }
 public function __construct()
 {
     $session = SessionHandler::getInstance();
     $this->expire_time = $session->getTimeout();
     session_set_save_handler(array($this, "open"), array($this, "close"), array($this, "read"), array($this, "write"), array($this, "destroy"), array($this, "gc"));
     register_shutdown_function('session_write_close');
 }
예제 #6
0
 public function save()
 {
     if (count($this->messages) > 0) {
         $this->flash = array_merge($this->flash, $this->messages);
         $this->clear();
     }
     SessionHandler::set('PIMPLE_FLASH', $this->flash);
 }
예제 #7
0
 function __construct($request)
 {
     parent::__construct($request);
     global $project_datapath;
     global $project_webroot;
     $this->projectpath = $project_webroot;
     $this->userdata = new Userdata($request);
 }
예제 #8
0
 public static function open()
 {
     if (self::$_sess_db = mysqli_connect(DATABASE1_HOST, DATABASE1_USER, DATABASE1_PASS, DATABASE1_NAME)) {
         mysqli_set_charset(self::$_sess_db, utf8);
         return true;
     }
     return false;
 }
예제 #9
0
 /**
  * Mark feedback item as handled
  * @param $message_id optionally refer to a response message
  */
 public static function markHandled($id, $message_id = 0)
 {
     $session = SessionHandler::getInstance();
     $i = self::get($id);
     $i->time_answered = sql_datetime(time());
     $i->answered_by = $session->id;
     $i->message = $message_id;
     $i->store();
 }
예제 #10
0
 /**
  * Creates a new poke
  * @param $to
  */
 public static function send($to)
 {
     $session = SessionHandler::getInstance();
     $o = new Poke();
     $o->from = $session->id;
     $o->to = $to;
     $o->time = sql_datetime(time());
     $o->store();
 }
예제 #11
0
 public function destroy($id)
 {
     if ($id === '') {
         return false;
     }
     setcookie($this->s_session_name, null, time() - 42000);
     parent::destroy($id);
     return true;
 }
예제 #12
0
 public function hasAccess($tag)
 {
     $entry = $this->tagRoles[strtoupper($tag)];
     if (!$entry) {
         return true;
     }
     $user = SessionHandler::instance()->getUser();
     return $entry->isValid($user ? $user->getRole() : self::R_GUEST);
 }
 public function updateTimestamp($key, $data)
 {
     ++$this->i;
     echo 'Update Timestamp ', session_id(), "\n";
     return parent::write($key, $data);
     // User must implement their own method and
     // cannot call parent as follows
     // return parent::updateTimestamp($key, $data);
 }
예제 #14
0
 public static function save()
 {
     try {
         MessageHandler::instance()->save();
         SessionHandler::instance()->save();
     } catch (Exception $e) {
         //Do nothing...
     }
 }
예제 #15
0
 /**
  *
  * @param $type
  * @param $object_id   the object who owns the bookmark
  */
 public static function remove($type, $object_id, $owner = 0)
 {
     if (!is_numeric($type) || !is_numeric($object_id) || !is_numeric($owner)) {
         throw new \Exception('noo');
     }
     $session = SessionHandler::getInstance();
     $q = 'DELETE FROM ' . self::$tbl_name . ' WHERE owner = ?' . ' AND value = ?' . ' AND type = ?';
     return Sql::pDelete($q, 'iii', $owner ? $owner : $session->id, $object_id, $type);
 }
예제 #16
0
 public static function delete($projectId)
 {
     $projectDoc = self::get($projectId);
     $userId = SessionHandler::user()->getUserId();
     if ($projectDoc->type == 'project' && in_array($projectDoc->users, $userId)) {
         CouchDB::client()->deleteDoc($projectDoc);
         return true;
     }
     return false;
 }
 public function close()
 {
     $id = session_id();
     if ($this->destroyed) {
         echo "(#{$this->num}) destroyed, cannot write\n";
     } else {
         echo "(#{$this->num}) closing {$id}\n";
     }
     return parent::close();
 }
 /**
  * This function is automatically called after the "open" function
  * Use the PHP default "read" function, then save the data and close the session if the session has not to be locked
  *
  * @param string $session_id
  *
  * @return string
  */
 public function read($session_id)
 {
     $data = parent::read($session_id);
     $this->session = $this->unserialize_session_data($data);
     if (!$this->lock) {
         $_SESSION = $this->session;
         session_write_close();
     }
     return $data;
 }
예제 #19
0
 function editHandler($p)
 {
     $session = SessionHandler::getInstance();
     $o = FaqItem::get($p['id']);
     $o->question = $p['q'];
     $o->answer = $p['a'];
     $o->creator = $session->id;
     $o->time_created = sql_datetime(time());
     $o->store();
     js_redirect('a/faq');
 }
예제 #20
0
 public static function init($room_id, $div_name, $form_id)
 {
     $header = XhtmlHeader::getInstance();
     $header->includeJs('http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js');
     $session = SessionHandler::getInstance();
     $interval = 1000 * parse_duration('1s');
     // milliseconds
     $locale = 'sv-SE';
     $header->registerJsFunction('function scroll_to_bottom(div)' . '{' . 'var elm = get_el(div);' . 'try {' . 'elm.scrollTop = elm.scrollHeight;' . '} catch(e) {' . 'var f = document.createElement("input");' . 'if (f.setAttribute) f.setAttribute("type","text");' . 'if (elm.appendChild) elm.appendChild(f);' . 'f.style.width = "0px";' . 'f.style.height = "0px";' . 'if (f.focus) f.focus();' . 'if (elm.removeChild) elm.removeChild(f);' . '}' . '}');
     $header->embedJs('YUI({lang:"' . $locale . '"}).use("io-form","node","json-parse","datatype-date", function(Y)' . '{' . 'Y.on("load", function() {' . 'Init();' . '});' . 'function Init(ts)' . '{' . 'var latest;' . 'if (typeof ts === "undefined") {' . 'var uri = "/u/chatroom/update/" + ' . $room_id . ';' . '} else {' . 'var uri = "/u/chatroom/update/" + ' . $room_id . ' + "?ts=" + ts;' . '}' . 'function complete(id, o)' . '{' . 'var data = o.responseText;' . 'var node = Y.one("#' . $div_name . '");' . 'try {' . 'var data = Y.JSON.parse(data);' . '} catch (e) {' . 'console.log("invalid data from " + uri);' . 'return;' . '}' . 'if (typeof ts === "undefined")' . 'node.setContent("");' . 'for (var i = data.length-1; i >= 0; --i) {' . 'var p = data[i];' . 'if ((typeof ts === "undefined") || p.from != ' . $session->id . ')' . 'msg_render(p,node);' . '}' . 'if (data.length)' . 'scroll_to_bottom("' . $div_name . '");' . 'latest = data[0] ? data[0].ts : ts;' . 'setTimeout(Init,' . $interval . ',latest);' . '};' . 'Y.once("io:complete",complete,Y);' . 'var request = Y.io(uri);' . '}' . 'Y.one("#' . $form_id . '").on("submit", function(e)' . '{' . 'e.preventDefault();' . 'e.stopPropagation();' . 'frm = get_el( this.get("id") );' . 'if (!frm.msg.value)' . 'return false;' . 'var uri = "/u/chatroom/send/" + ' . $room_id . ' + "?m=" + frm.msg.value;' . 'var request = Y.io(uri);' . 'var node = Y.one("#' . $div_name . '");' . 'var p = {' . '"name":"' . $session->username . '",' . '"from":' . $session->id . ',' . '"msg":frm.msg.value,' . '"ts":new Date().getTime()/1000' . '};' . 'msg_render(p,node);' . 'scroll_to_bottom("' . $div_name . '");' . 'frm.msg.value = "";' . 'return false;' . '});' . 'function msg_render(p,node)' . '{' . 'var d = new Date(p.ts*1000);' . 'var today = new Date( new Date().getFullYear(), new Date().getMonth(), new Date().getDate(),0,0,0);' . 'node.append("[");' . 'if (d >= today) {' . 'node.append( Y.DataType.Date.format(d, {format:"%H:%M"}) );' . '} else {' . 'node.append( Y.DataType.Date.format(d, {format:"%a %d %b %H:%M"}) );' . '}' . 'node.append("]&nbsp;");' . 'var who = Y.Node.create("<span class=\\"yui3-hastooltip\\" id=\\"tt_usr_"+p.from+"\\">"+p.name+"</span>");' . 'who.addClass("yui3-hastooltip");' . 'node.append(who);' . 'node.append(": "+p.msg+"<br/>");' . '}' . '});');
 }
예제 #21
0
 /**
  * @return message id
  */
 public static function send($to, $msg, $type = PRIV_MSG)
 {
     $session = SessionHandler::getInstance();
     $m = new Message();
     $m->to = $to;
     $m->from = $session->id;
     $m->body = $msg;
     $m->type = $type;
     $m->time_sent = sql_datetime(time());
     return $m->store();
 }
예제 #22
0
function loginHandler($p)
{
    $session = SessionHandler::getInstance();
    if ($session->id) {
        dp('HACK user ' . $session->name . ' (' . $session->id . ') tried to login user ' . $p['usr']);
        return false;
    }
    if ($session->login($p['usr'], $p['pwd'])) {
        $session->showStartPage();
    }
    return true;
}
예제 #23
0
 /**
  * @return array of User objects for all users online
  */
 public static function getUsersOnline($filter = '')
 {
     $session = SessionHandler::getInstance();
     $db = SqlHandler::getInstance();
     $q = 'SELECT * FROM ' . self::$tbl_name . ' WHERE time_deleted IS NULL';
     if ($filter) {
         $q .= ' AND userName LIKE "%' . $db->escape($filter) . '%"';
     }
     $q .= ' AND time_last_active >= DATE_SUB(NOW(),INTERVAL ' . $session->online_timeout . ' SECOND)' . ' ORDER BY time_last_active DESC';
     $list = $db->getArray($q);
     return SqlObject::loadObjects($list, 'User');
 }
예제 #24
0
 function createHandler($p)
 {
     $session = SessionHandler::getInstance();
     $o = new BlogEntry();
     $o->owner = $session->id;
     $o->subject = trim($p['subject']);
     $o->body = trim($p['body']);
     $o->time_created = sql_datetime(time());
     $o->time_published = sql_datetime(time());
     $o->id = $o->store();
     js_redirect('a/blogs/overview');
 }
예제 #25
0
 /**
  * Creates a new token for specified $name
  * @return newly created token
  */
 public static function generate($owner, $name)
 {
     $session = SessionHandler::getInstance();
     do {
         $val = sha1('pOwplopw' . $session->id . mt_rand() . $session->name . 'LAZER!!');
         if (!Setting::getOwner(TOKEN, $name, $val)) {
             break;
         }
     } while (1);
     Setting::set(TOKEN, $owner, $name, $val);
     return $val;
 }
예제 #26
0
 public static function add($type, $reference = 0, $data = '')
 {
     $session = SessionHandler::getInstance();
     $c = new ModerationObject();
     $c->type = $type;
     $c->owner = $session->id;
     $c->time_created = sql_datetime(time());
     $c->data = $data;
     $c->reference = $reference;
     $c->id = $c->store();
     return $c->id;
 }
예제 #27
0
function fbHandler($p)
{
    $session = SessionHandler::getInstance();
    $o = new Feedback();
    $o->type = USER;
    $o->subject = $p['subj'];
    $o->body = $p['body'];
    $o->from = $session->id;
    $o->time_created = sql_datetime(time());
    $o->store();
    js_redirect('');
    // jump to start page
}
예제 #28
0
 function editHandler($p)
 {
     $o = new ChatRoom();
     $o->id = $p['roomid'];
     $o->name = trim($p['name']);
     if ($p['locked']) {
         $session = SessionHandler::getInstance();
         $o->locked_by = $session->id;
         $o->time_locked = sql_datetime(time());
     }
     $o->store();
     js_redirect('a/chatroom/list');
 }
예제 #29
0
 public static function render($name)
 {
     $wiki = self::getByName($name);
     $session = SessionHandler::getInstance();
     if (empty($wiki->text)) {
         $res = t('The wiki') . ' "' . $name . '" ' . t('does not yet exist') . '!<br/>';
         if ($session->isWebmaster) {
             $res .= ahref('u/wiki/edit/' . $name, 'Create') . '<br/>';
         }
         return $res;
     }
     return self::renderText($wiki->text);
 }
예제 #30
0
 /** Votes for a poll */
 static function addVote($type, $id, $value)
 {
     $session = SessionHandler::getInstance();
     if (!$session->id) {
         return false;
     }
     if (self::hasAnswered($type, $id)) {
         return false;
     }
     $q = 'INSERT INTO ' . self::$tbl_name . ' SET type = ?, owner = ?, userId = ?, value = ?, timestamp = NOW()';
     Sql::pInsert($q, 'iiii', $type, $id, $session->id, $value);
     return true;
 }