本文整理汇总了PHP中SessionHandler类的典型用法代码示例。如果您正苦于以下问题:PHP SessionHandler类的具体用法?PHP SessionHandler怎么用?PHP SessionHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SessionHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: tagFullname
/**
* Outputs the current users full name (if any)
*/
protected function tagFullname()
{
$user = SessionHandler::user();
if ($user) {
return $user->getFullName();
}
}
开发者ID:hofmeister,项目名称:Pimple,代码行数:10,代码来源:UserTagLib.php
示例2: get
public static function get($name)
{
if (!SessionHandler::instance()->hasSession()) {
return null;
}
return self::instance()->getSession()->get($name);
}
开发者ID:hofmeister,项目名称:Pimple,代码行数:7,代码来源:SessionHandler.php
示例3: __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
示例4: save
public function save()
{
if (count($this->messages) > 0) {
$this->flash = array_merge($this->flash, $this->messages);
$this->clear();
}
SessionHandler::set('PIMPLE_FLASH', $this->flash);
}
开发者ID:hofmeister,项目名称:Pimple,代码行数:8,代码来源:MessageHandler.php
示例5: 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
示例6: 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
示例7: hasAccess
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);
}
开发者ID:hofmeister,项目名称:Pimple,代码行数:9,代码来源:AccessHandler.php
示例8: save
public static function save()
{
try {
MessageHandler::instance()->save();
SessionHandler::instance()->save();
} catch (Exception $e) {
//Do nothing...
}
}
开发者ID:hofmeister,项目名称:Pimple,代码行数:9,代码来源:Pimple.php
示例9: 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
示例10: delete
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;
}
开发者ID:hofmeister,项目名称:ScrumBanana.com,代码行数:10,代码来源:ProjectService.php
示例11: 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
示例12: 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("] ");' . '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
示例13: 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
示例14: 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
示例15: 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
示例16: 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
示例17: 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
示例18: 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
示例19: fbHandler
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
}
开发者ID:martinlindhe,项目名称:core_dev,代码行数:13,代码来源:feedback.php
示例20: 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
注:本文中的SessionHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论