本文整理汇总了PHP中vB::getCurrentSession方法的典型用法代码示例。如果您正苦于以下问题:PHP vB::getCurrentSession方法的具体用法?PHP vB::getCurrentSession怎么用?PHP vB::getCurrentSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vB
的用法示例。
在下文中一共展示了vB::getCurrentSession方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTmpFileName
/**
* Generates a valid path and filename for a temp file. In the case
* of safe upload, this generates the filename, but not the file. In
* the case of tempnam(), the temp file is actually created.
*
* @param string|int Optional extra "entropy" for the md5 call, this would typically be an ID such as userid or avatarid, etc *for the current record* of whatever is being processed. If empty, it uses the *current user's* userid.
* @param string An optional prefix for the file name. Depending on OS and if tempnam is used, only the first 3 chars of this will be used.
* @param string An optional suffix for the file name, can be used to add a file extension if needed.
*
* @return string|false The path and filename of the temp file, or bool false if it failed.
*/
public static function getTmpFileName($entropy = '', $prefix = 'vb_', $suffix = '')
{
$options = vB::getDatastore()->getValue('options');
if ($options['safeupload']) {
if (empty($entropy)) {
$entropy = vB::getCurrentSession()->get('userid');
}
//it *usually* doesn't matter if we use the slash instead of the local OS seperator, but
//if we pass the value to exec things can't go a bit wierd.
$filename = $options['tmppath'] . DIRECTORY_SEPARATOR . $prefix . md5(uniqid(microtime()) . $entropy) . $suffix;
} else {
if (vB::getUserContext()->hasPermission('adminpermissions', 'cancontrolpanel')) {
$filename = tempnam(self::getTmpDir(), $prefix);
} else {
$filename = @tempnam(self::getTmpDir(), $prefix);
}
if ($filename and $suffix) {
// tempnam doesn't support specifying a suffix
unlink($filename);
$filename = $filename . $suffix;
touch($filename);
}
}
return $filename;
}
示例2: createChannel
/**
* Create a blog channel.
*
* @param array $input
* @param int $channelid
* @param int $channelConvTemplateid
* @param int $channelPgTemplateId
* @param int $ownerSystemGroupId
*
* @return int The nodeid of the new blog channel
*/
public function createChannel($input, $channelid, $channelConvTemplateid, $channelPgTemplateId, $ownerSystemGroupId)
{
$input['parentid'] = $channelid;
$input['inlist'] = 1;
// we don't want it to be shown in channel list, but we want to move them
$input['protected'] = 0;
if (empty($input['userid'])) {
$input['userid'] = vB::getCurrentSession()->get('userid');
}
if (!isset($input['publishdate'])) {
$input['publishdate'] = vB::getRequest()->getTimeNow();
}
$input['templates']['vB5_Route_Channel'] = $channelPgTemplateId;
$input['templates']['vB5_Route_Conversation'] = $channelConvTemplateid;
// add channel node
$channelLib = vB_Library::instance('content_channel');
$input['page_parentid'] = 0;
$result = $channelLib->add($input, array('skipFloodCheck' => true, 'skipDupCheck' => true));
//Make the current user the channel owner.
$userApi = vB_Api::instanceInternal('user');
$usergroup = vB::getDbAssertor()->getRow('usergroup', array('systemgroupid' => $ownerSystemGroupId));
if (empty($usergroup) or !empty($usergroup['errors'])) {
//This should never happen. It would mean an invalid parameter was passed
throw new vB_Exception_Api('invalid_request');
}
vB_User::setGroupInTopic($input['userid'], $result['nodeid'], $usergroup['usergroupid']);
vB_Cache::allCacheEvent(array('nodeChg_' . $this->blogChannel, "nodeChg_{$channelid}"));
vB::getUserContext()->rebuildGroupAccess();
vB_Channel::rebuildChannelTypes();
// clear follow cache
vB_Api::instanceInternal('follow')->clearFollowCache(array($input['userid']));
return $result['nodeid'];
}
示例3: createChannel
/**
* Create an article category channel. This function works basically like the blog library's version
*
* @param array $input data array, should have standard channel data like title, parentid,
* @param int $channelid parentid that the new channel should fall under.
* @param int $channelConvTemplateid "Conversation" level pagetemplate to use. Typically vB_Page::getArticleConversPageTemplate()
* @param int $channelPgTemplateId "Channel" level pagetemplate to use. Typically vB_Page::getArticleChannelPageTemplate()
* @param int $ownerSystemGroupId
*
* @return int The nodeid of the new blog channel
*/
public function createChannel($input, $channelid, $channelConvTemplateid, $channelPgTemplateId, $ownerSystemGroupId)
{
if (!isset($input['parentid']) or intval($input['parentid']) < 1) {
$input['parentid'] = $channelid;
}
$input['inlist'] = 1;
// we don't want it to be shown in channel list, but we want to move them
$input['protected'] = 0;
if (empty($input['userid'])) {
$input['userid'] = vB::getCurrentSession()->get('userid');
}
if (!isset($input['publishdate'])) {
$input['publishdate'] = vB::getRequest()->getTimeNow();
}
$input['templates']['vB5_Route_Channel'] = $channelPgTemplateId;
$input['templates']['vB5_Route_Article'] = $channelConvTemplateid;
$input['childroute'] = 'vB5_Route_Article';
// add channel node
$channelLib = vB_Library::instance('content_channel');
$input['page_parentid'] = 0;
$result = $channelLib->add($input, array('skipNotifications' => true, 'skipFloodCheck' => true, 'skipDupCheck' => true));
//Make the current user the channel owner.
$userApi = vB_Api::instanceInternal('user');
$usergroup = vB::getDbAssertor()->getRow('usergroup', array('systemgroupid' => $ownerSystemGroupId));
vB_Cache::allCacheEvent(array('nodeChg_' . $this->articleHomeChannel, "nodeChg_{$channelid}"));
vB::getUserContext()->rebuildGroupAccess();
vB_Channel::rebuildChannelTypes();
// clear follow cache
vB_Api::instanceInternal('follow')->clearFollowCache(array($input['userid']));
return $result['nodeid'];
}
示例4: get_admin_detail_chat
public function get_admin_detail_chat()
{
global $vbulletin;
// Get the settings options and the user's info
$options = vB::getDatastore()->getValue('options');
$userinfo = vB::getCurrentSession()->fetch_userinfo();
// Api Key and Secret
$api = $options['chat_cat_messenger_api'];
$secret = $options['chat_cat_messenger_secret'];
$login_url = $options['chat_cat_messenger_login_url'];
$register_url = $options['chat_cat_messenger_register_url'];
$primary_domain = $options['chat_cat_messenger_primary_url'];
// echo $primary_domain;
// die();
// User info
$uname = $userinfo['username'];
$uid = $userinfo['userid'];
$desc = $userinfo['field1'];
$src = '';
$home = $options['bburl'] . '/member/' . $uid;
//echo $home;die;
$location = $userinfo['field2'];
$bod = $userinfo['birthday'];
if (!empty($bod)) {
$year = explode("-", $bod);
$bod = $year['2'];
}
$profilepic = $vbulletin->db->query_first("\n\t\t\tSELECT userid, dateline, height, width\n\t\t\tFROM " . TABLE_PREFIX . "customavatar\n\t\t\tWHERE userid = " . $uid);
if ($profilepic['dateline']) {
$img = $options['bburl'] . '/image.php?userid=' . $uid . '&thumb=1&dateline=' . $profilepic[dateline] . '&type=avtar';
} else {
$img = null;
}
$src = urlencode($img);
$home = urlencode($home);
//$src = urldecode($img);
$chatdata = array();
$chatdata['sinonurl'] = '';
if (isset($api) && $api != '') {
$chatdata['sinonurl'] = '/ajaxchat.php?uid=' . $uid . '&api=' . $api . '&secret=' . $secret . '&uname=' . $uname . '&desc=' . $desc . '&src=' . $src . '&home=' . $home . '&birthday=' . $bod . '&location=' . $location;
}
$chatdata['primaryurl'] = $primary_domain;
if ($login_url != '') {
$chatdata['loginurl'] = $login_url;
if (!preg_match("@^[hf]tt?ps?://@", $chatdata['loginurl'])) {
$chatdata['loginurl'] = "http://" . $chatdata['loginurl'];
}
} else {
$chatdata['loginurl'] = '';
}
if ($register_url != '') {
$chatdata['registerurl'] = $register_url;
if (!preg_match("@^[hf]tt?ps?://@", $chatdata['registerurl'])) {
$chatdata['registerurl'] = "http://" . $chatdata['registerurl'];
}
} else {
$chatdata['registerurl'] = $options['frontendurl'] . '/register';
}
return $chatdata;
}
示例5: construct_user_ip_table
function construct_user_ip_table($userid, $previpaddress, $depth = 2)
{
global $vbulletin, $vbphrase;
if (VB_AREA == 'AdminCP') {
$userscript = 'usertools.php';
} else {
$userscript = 'user.php';
}
$depth--;
$ips = vB_Api::instanceInternal('user')->searchIP($userid, $depth);
$retdata = '';
// @TODO user api currently returns only 1 IP per user.
$result = array('ipaddress' => $ips['regip']);
foreach ($result as $ip) {
$retdata .= '<li>' . "<a href=\"{$userscript}?" . vB::getCurrentSession()->get('sessionurl') . "do=gethost&ip={$ip['ipaddress']}\" title=\"" . $vbphrase['resolve_address'] . "\">{$ip['ipaddress']}</a> " . construct_link_code($vbphrase['find_more_users_with_this_ip_address'], "{$userscript}?" . vB::getCurrentSession()->get('sessionurl') . "do=doips&ipaddress={$ip['ipaddress']}&hash=" . CP_SESSIONHASH) . "</li>\n";
if ($depth > 0) {
$retdata .= construct_ip_usage_table($ip['ipaddress'], $userid, $depth);
}
}
if (empty($retdata)) {
return '';
} else {
return '<ul>' . $retdata . '</ul>';
}
}
示例6: checkRoutePermissions
protected function checkRoutePermissions()
{
$currentUser = vB::getUserContext();
if (!$currentUser->hasPermission('genericpermissions', 'canviewmembers') and $this->arguments['userid'] != vB::getCurrentSession()->get('userid')) {
throw new vB_Exception_NodePermission('profile');
}
}
示例7: __construct
public function __construct(&$routeInfo, &$matches, &$queryString = '')
{
if (isset($matches['params']) and !empty($matches['params'])) {
$paramString = strpos($matches['params'], '/') === 0 ? substr($matches['params'], 1) : $matches['params'];
$params = explode('/', $paramString);
if (count($params) >= 2) {
$this->pagenum = $params[1];
$this->folderid = $params[0];
} else {
if (!empty($params)) {
$this->pagenum = $params[1];
}
}
}
if (!empty($matches['pagenum']) and intval($matches['pagenum'])) {
$this->pagenum = $matches['pagenum'];
}
if (!empty($matches['folderid']) and intval($matches['folderid'])) {
$this->folderid = $matches['folderid'];
}
$routeInfo['arguments']['subtemplate'] = $this->subtemplate;
$userid = vB::getCurrentSession()->get('userid');
$pmquota = vB::getUserContext($userid)->getLimit('pmquota');
$vboptions = vB::getDatastore($userid)->getValue('options');
$canUsePmSystem = ($vboptions['enablepms'] and $pmquota);
if (!$canUsePmSystem and !$this->overrideDisable) {
throw new vB_Exception_NodePermission('privatemessage');
}
}
示例8: fetch_online_status
/**
* Fetches the online states for the user, taking into account the browsing
* user's viewing permissions. Also modifies the user to include [buddymark]
* and [invisiblemark]
*
* @param array Array of userinfo to fetch online status for
* @param boolean True if you want to set $user[onlinestatus] with template results
*
* @return integer 0 = offline, 1 = online, 2 = online but invisible (if permissions allow)
*/
function fetch_online_status(&$user)
{
static $buddylist, $datecut;
$session = vB::getCurrentSession();
if (empty($session)) {
$currentUserId = 0;
} else {
$currentUserId = vB::getCurrentSession()->get('userid');
}
// get variables used by this function
if (!isset($buddylist) and !empty($currentUserId)) {
$buddylist = array();
//If we are asking for the current user's status we can skip the fetch
if ($currentUserId == $user['userid']) {
$currentUser =& $user;
} else {
$currentUser = vB_Api::instanceInternal('user')->fetchCurrentUserInfo();
}
if (isset($currentUser['buddylist']) and $currentUser['buddylist'] = trim($currentUser['buddylist'])) {
$buddylist = preg_split('/\\s+/', $currentUser['buddylist'], -1, PREG_SPLIT_NO_EMPTY);
}
}
if (!isset($datecut)) {
$datecut = vB::getRequest()->getTimeNow() - vB::getDatastore()->getOption('cookietimeout');
}
// is the user on bbuser's buddylist?
if (isset($buddylist) and is_array($buddylist) and in_array($user['userid'], $buddylist)) {
$user['buddymark'] = '+';
} else {
$user['buddymark'] = '';
}
// set the invisible mark to nothing by default
$user['invisiblemark'] = '';
$onlinestatus = 0;
$user['online'] = 'offline';
// now decide if we can see the user or not
if ($user['lastactivity'] > $datecut and $user['lastvisit'] != $user['lastactivity']) {
$bf_misc_useroptions = vB::getDatastore()->getValue('bf_misc_useroptions');
if ($user['options'] & $bf_misc_useroptions['invisible']) {
if (!isset($userContext)) {
$userContext = vB::getUserContext();
}
if ($currentUserId == $user['userid'] or $userContext and $userContext->hasPermission('genericpermissions', 'canseehidden')) {
// user is online and invisible BUT bbuser can see them
$user['invisiblemark'] = '*';
$user['online'] = 'invisible';
$onlinestatus = 2;
}
} else {
// user is online and visible
$onlinestatus = 1;
$user['online'] = 'online';
}
}
return $onlinestatus;
}
示例9: __construct
public function __construct(&$routeInfo, &$matches, &$queryString = '')
{
$userid = vB::getCurrentSession()->get('userid');
$pmquota = vB::getUserContext($userid)->getLimit('pmquota');
$vboptions = vB::getDatastore($userid)->getValue('options');
$canUsePmSystem = ($vboptions['enablepms'] and $pmquota);
if (!$canUsePmSystem) {
throw new vB_Exception_NodePermission('privatemessage');
}
parent::__construct($routeInfo, $matches, $queryString);
}
示例10: fetch_faq_parents
function fetch_faq_parents($faqname)
{
global $ifaqcache, $faqcache, $parents, $vbulletin;
static $i = 0;
$faq = $faqcache["{$faqname}"];
if (is_array($ifaqcache["{$faq['faqparent']}"])) {
$key = iif($i++, 'faq.php?' . vB::getCurrentSession()->get('sessionurl') . "faq={$faq['faqname']}");
$parents["{$key}"] = $faq['title'];
fetch_faq_parents($faq['faqparent']);
}
}
示例11: show_inline_mod_login
/**
* Shows the form for inline mod authentication.
*/
function show_inline_mod_login($showerror = false)
{
global $vbulletin, $vbphrase, $show;
$show['inlinemod_form'] = true;
$show['passworderror'] = $showerror;
if (!$showerror) {
$vbulletin->url = SCRIPTPATH;
}
$forumHome = vB_Library::instance('content_channel')->getForumHomeChannel();
eval(standard_error(fetch_error('nopermission_loggedin', $vbulletin->userinfo['username'], vB_Template_Runtime::fetchStyleVar('right'), vB::getCurrentSession()->get('sessionurl'), $vbulletin->userinfo['securitytoken'], vB5_Route::buildUrl($forumHome['routeid'] . 'home|fullurl'))));
}
示例12: getNewRouteInfo
protected function getNewRouteInfo()
{
if ($session = vB::getCurrentSession()) {
$userid = $session->get('userid');
}
if (empty($userid)) {
throw new vB_Exception_404('invalid_page');
}
$this->arguments['userid'] = $userid;
$this->arguments['tab'] = 'subscriptions';
return 'subscription';
}
示例13: init
public static function init($configFile)
{
parent::init($configFile);
self::$instance = new vB5_Frontend_Application();
self::$instance->router = new vB5_Frontend_Routing();
self::$instance->router->setRoutes();
$styleid = vB5_Template_Stylevar::instance()->getPreferredStyleId();
if ($styleid) {
vB::getCurrentSession()->set('styleid', $styleid);
}
self::ajaxCharsetConvert();
self::setHeaders();
return self::$instance;
}
示例14: __construct
/**
* Create a taggable content item.
*
* @param int id for the content item to be tagged. Can be 0 if it is used only for validating tags
* @param array content info -- database record for item to be tagged, values vary by
* specific content item. For performance reasons this can be included, otherwise the
* data will be fetched if needed from the provided id.
*/
public function __construct($nodeid = 0, $contentinfo = false)
{
$this->nodeid = $nodeid;
$this->assertor = vB::getDbAssertor();
$this->currentUserId = vB::getCurrentSession()->get('userid');
// If this is node related fetch the required info
if ($this->nodeid) {
$this->owner = $this->getNodeOwner($this->nodeid);
if ($contentinfo) {
$this->contentinfo = $contentinfo;
} else {
$this->loadContentInfo();
}
}
}
示例15: fetch_dismissed_notices
/**
* Fetches the IDs of the dismissed notices so we do not display them for the user.
*
*/
function fetch_dismissed_notices()
{
static $dismissed_notices = null;
if ($dismissed_notices === null) {
$userinfo = vB::getCurrentSession()->fetch_userinfo();
$dismissed_notices = array();
if (!$userinfo['userid']) {
return $dismissed_notices;
}
$noticeids = vB::getDbAssertor()->assertQuery('vBForum:fetchdismissednotices', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'userid' => $userinfo['userid']));
foreach ($noticeids as $noticeid) {
$dismissed_notices[] = $noticeid['noticeid'];
}
}
return $dismissed_notices;
}