当前位置: 首页>>代码示例>>PHP>>正文


PHP SessionHandler::getInstance方法代码示例

本文整理汇总了PHP中SessionHandler::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionHandler::getInstance方法的具体用法?PHP SessionHandler::getInstance怎么用?PHP SessionHandler::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SessionHandler的用法示例。


在下文中一共展示了SessionHandler::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 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');
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:7,代码来源:SessionStorageHandler.php

示例2: remove

 /**
  *
  * @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);
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:14,代码来源:Bookmark.php

示例3: send

 /**
  * 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();
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:13,代码来源:Poke.php

示例4: markHandled

 /**
  * 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();
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:13,代码来源:Feedback.php

示例5: editHandler

 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');
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:11,代码来源:faq.php

示例6: send

 /**
  * @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();
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:14,代码来源:Message.php

示例7: init

 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/>");' . '}' . '});');
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:11,代码来源:ChatRoomUpdater.php

示例8: loginHandler

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;
}
开发者ID:martinlindhe,项目名称:core_dev,代码行数:12,代码来源:login.php

示例9: createHandler

 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');
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:12,代码来源:blogs.php

示例10: generate

 /**
  * 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;
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:16,代码来源:Token.php

示例11: getUsersOnline

 /**
  * @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');
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:15,代码来源:UserList.php

示例12: add

 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;
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:12,代码来源:ModerationObject.php

示例13: render

 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);
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:13,代码来源:WikiViewer.php

示例14: editHandler

 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');
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:13,代码来源:chatroom.php

示例15: addVote

 /** 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;
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:14,代码来源:Rating.php


注:本文中的SessionHandler::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。