本文整理汇总了PHP中vB::getRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP vB::getRequest方法的具体用法?PHP vB::getRequest怎么用?PHP vB::getRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vB
的用法示例。
在下文中一共展示了vB::getRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'];
}
示例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: execSend
/**
* Inserts the message into the queue instead of sending it.
*
* @return string True on success, false on failure
*/
protected function execSend()
{
if (!$this->toemail) {
return false;
}
$data = array('dateline' => vB::getRequest()->getTimeNow(), 'toemail' => $this->toemail, 'fromemail' => $this->fromemail, 'subject' => $this->subject, 'message' => $this->message, 'header' => $this->headers);
if ($this->bulk) {
$this->mailsql[] = $data;
$this->mailcounter++;
// current insert exceeds half megabyte, insert it and start over
if ($this->arraySize($this->mailsql) > 524288) {
$this->setBulk(false);
$this->setBulk(true);
}
} else {
/*insert query*/
vB::getDbAssertor()->insert('mailqueue', $data);
vB::getDbAssertor()->assertQuery('mailqueue_updatecount', array('counter' => 1));
// if we're using a alternate datastore, we need to give it an integer value
// this may not be atomic
$mailqueue_db = vB::getDbAssertor()->getRow('datastore', array('title' => 'mailqueue'));
vB::getDatastore()->build('mailqueue', intval($mailqueue_db['data']));
}
return true;
}
示例4: do_mark_read
function do_mark_read()
{
$vbulletin = vB::get_registry();
$userinfo = vB_Api::instance('user')->fetchUserInfo();
$cleaned = vB::getCleaner()->cleanArray($_REQUEST, array('forumid' => vB_Cleaner::TYPE_INT));
$forumid = $cleaned['forumid'];
if ($forumid == 0) {
return json_error(ERR_INVALID_FORUM);
}
$foruminfo = vB_Api::instance('node')->getFullContentforNodes(array($forumid));
if (empty($foruminfo) or $foruminfo[0]['contenttypeclass'] != 'Channel') {
return json_error(ERR_INVALID_FORUM);
}
if (!$userinfo['userid']) {
return json_error(ERR_INVALID_LOGGEDIN, RV_NOT_LOGGED_IN);
}
$forums_marked = vB_Api::instance('node')->markChannelsRead($forumid > 0 ? $forumid : 0);
$tableinfo = $vbulletin->db->query_first("\n\t\tSHOW TABLES LIKE '" . TABLE_PREFIX . "forumrunner_push_data'\n\t\t");
if ($tableinfo) {
if ($forumid > 0) {
$vbulletin->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "forumrunner_push_data AS forumrunner_push_data\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "node AS thread\n\t\t\t\tON thread.nodeid = forumrunner_push_data.vb_threadid\n\t\t\t\tSET forumrunner_push_data.vb_subsent = 0, forumrunner_push_data.vb_threadread = " . vB::getRequest()->getTimeNow() . "\n\t\t\t\tWHERE forumrunner_push_data.vb_userid = {$userinfo['userid']} AND thread.parentid IN (" . join(',', $forums_marked) . ")\n\t\t\t\t");
} else {
$vbulletin->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "forumrunner_push_data\n\t\t\t\tSET vb_subsent = 0, vb_threadread = " . vB::getRequest()->getTimeNow() . "\n\t\t\t\tWHERE vb_userid = {$userinfo['userid']} AND vb_threadid > 0\n\t\t\t\t");
}
}
return true;
}
示例5: startSessionLight
/**
* starts a new lightweight (no shutdown) session
*
* @param string session hash
*
* @return mixed array of permissions,
*/
public static function startSessionLight($sessionHash = false, $cphash = false, $languageid = 0, $checkTimeout = false)
{
if (!empty($sessionHash)) {
if ($checkTimeout) {
$timenow = vB::getRequest()->getTimeNow();
$timeout = vB::getDatastore()->getOption('cookietimeout');
if ($timenow > $timeout) {
$cutoff = $timenow - $timeout;
} else {
$cutoff = 0;
}
$sessionInfo = vB::getDbAssertor()->getRow('session', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'sessionhash', 'value' => $sessionHash, 'operator' => vB_dB_Query::OPERATOR_EQ), array('field' => 'lastactivity', 'value' => $cutoff, 'operator' => vB_dB_Query::OPERATOR_GT))));
} else {
$sessionInfo = vB::getDbAssertor()->getRow('session', array('sessionhash' => $sessionHash));
}
if (!empty($sessionInfo) and empty($sessionInfo['errors'])) {
$session = vB_Session_Web::getSession($sessionInfo['userid'], $sessionHash);
if (!empty($cphash)) {
$session->setCpsessionHash($cphash);
}
}
}
if (empty($session)) {
//constructor is now private
$session = vB_Session_Web::getSession(0, '');
}
$session->set('languageid', $languageid);
vB::skipShutdown(true);
vB::setCurrentSession($session);
return $session;
}
示例6: __call
public function __call($method, $arguments)
{
try {
$logger = vB::getLogger('api.' . $this->controller . '.' . $method);
//check so that we don't var_export large variables when we don't have to
if ($logger->isInfoEnabled()) {
if (!($ip = vB::getRequest()->getAltIp())) {
$ip = vB::getRequest()->getIpAddress();
}
$message = str_repeat('=', 80) . "\ncalled {$method} on {$this->controller} from ip {$ip} \n\$arguments = " . var_export($arguments, true) . "\n" . str_repeat('=', 80) . "\n";
$logger->info($message);
$logger->info("time: " . microtime(true));
}
if ($logger->isTraceEnabled()) {
$message = str_repeat('=', 80) . "\n " . $this->getTrace() . str_repeat('=', 80) . "\n";
$logger->trace($message);
}
$c = $this->api;
// This is a hack to prevent method parameter reference error. See VBV-5546
$hackedarguments = array();
foreach ($arguments as $k => &$arg) {
$hackedarguments[$k] =& $arg;
}
$return = call_user_func_array(array(&$c, $method), $hackedarguments);
//check so that we don't var_export large variables when we don't have to
if ($logger->isDebugEnabled()) {
$message = str_repeat('=', 80) . "\ncalled {$method} on {$this->controller}\n\$return = " . var_export($return, true) . "\n" . str_repeat('=', 80) . "\n";
$logger->debug($message);
}
return $return;
} catch (vB_Exception_Api $e) {
$errors = $e->get_errors();
$config = vB::getConfig();
if (!empty($config['Misc']['debug'])) {
$trace = '## ' . $e->getFile() . '(' . $e->getLine() . ") Exception Thrown \n" . $e->getTraceAsString();
$errors[] = array("exception_trace", $trace);
}
return array('errors' => $errors);
} catch (vB_Exception_Database $e) {
$config = vB::getConfig();
if (!empty($config['Misc']['debug']) or vB::getUserContext()->hasAdminPermission('cancontrolpanel')) {
$errors = array('Error ' . $e->getMessage());
$trace = '## ' . $e->getFile() . '(' . $e->getLine() . ") Exception Thrown \n" . $e->getTraceAsString();
$errors[] = array("exception_trace", $trace);
return array('errors' => $errors);
} else {
// This text is purposely hard-coded since we don't have
// access to the database to get a phrase
return array('errors' => array(array('There has been a database error, and the current page cannot be displayed. Site staff have been notified.')));
}
} catch (Exception $e) {
$errors = array(array('unexpected_error', $e->getMessage()));
$config = vB::getConfig();
if (!empty($config['Misc']['debug'])) {
$trace = '## ' . $e->getFile() . '(' . $e->getLine() . ") Exception Thrown \n" . $e->getTraceAsString();
$errors[] = array("exception_trace", $trace);
}
return array('errors' => $errors);
}
}
示例7: save_default
/**
* Saves the stylevars specified in the array as default style for the whole site
*
* @param array $stylevars - associative array
*/
function save_default($stylevars)
{
$result = array();
if (!$this->canSaveDefault()) {
$result['error'][] = 'no_permission_styles';
}
if (!$this->hasPermissions()) {
$result['error'][] = 'no_permission';
}
if (!isset($result['error'])) {
$values = array();
$now = vB::getRequest()->getTimeNow();
$styleid = vB::getDatastore()->getOption('styleid');
foreach ($stylevars as $stylevarname => $stylevarvalue) {
$values[] = array('stylevarid' => $stylevarname, 'styleid' => $styleid, 'value' => serialize($stylevarvalue), 'dateline' => $now);
}
vB::getDbAssertor()->assertQuery('replaceValues', array('table' => 'stylevar', 'values' => $values));
$style_lib = vB_Library::instance('Style');
$style_lib->buildStyleDatastore();
require_once DIR . '/includes/adminfunctions_template.php';
$style_lib->buildStyle($styleid, '', array('docss' => 1, 'dostylevars' => 1), true);
}
vB_Library::instance('Style')->setCssDate();
return $result;
}
示例8: fetch
/**
* Fetches announcements by channel ID
*
* @param int $channelid (optional) Channel ID
* @param int $announcementid (optional) Announcement ID
*
* @throws vB_Exception_Api no_permission if the user doesn't have permission to view the announcements
*
* @return array Announcements, each element is an array containing all the fields
* in the announcement table and username, avatarurl, and the individual
* options from the announcementoptions bitfield-- dohtml, donl2br,
* dobbcode, dobbimagecode, dosmilies.
*/
public function fetch($channelid = 0, $announcementid = 0)
{
$usercontext = vB::getUserContext();
$userapi = vB_Api::instanceInternal('user');
$channelapi = vB_Api::instanceInternal('content_channel');
$parentids = array();
// Check channel permission
if ($channelid) {
// This is to verify $channelid
$channelapi->fetchChannelById($channelid);
if (!$usercontext->getChannelPermission('forumpermissions', 'canview', $channelid)) {
throw new vB_Exception_Api('no_permission');
}
$parents = vB_Library::instance('node')->getParents($channelid);
foreach ($parents as $parent) {
if ($parent['nodeid'] != 1) {
$parentids[] = $parent['nodeid'];
}
}
}
$data = array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'startdate', 'value' => vB::getRequest()->getTimeNow(), 'operator' => vB_dB_Query::OPERATOR_LTE), array('field' => 'enddate', 'value' => vB::getRequest()->getTimeNow(), 'operator' => vB_dB_Query::OPERATOR_GTE)));
if ($parentids) {
$parentids[] = -1;
// We should always include -1 for global announcements
$data[vB_dB_Query::CONDITIONS_KEY][] = array('field' => 'nodeid', 'value' => $parentids);
} elseif ($channelid) {
$channelid = array($channelid, -1);
// We should always include -1 for global announcements
$data[vB_dB_Query::CONDITIONS_KEY][] = array('field' => 'nodeid', 'value' => $channelid);
} else {
$data[vB_dB_Query::CONDITIONS_KEY][] = array('field' => 'nodeid', 'value' => '-1');
}
$announcements = $this->assertor->getRows('vBForum:announcement', $data, array('field' => array('startdate', 'announcementid'), 'direction' => array(vB_dB_Query::SORT_DESC, vB_dB_Query::SORT_DESC)));
if (!$announcements) {
return array();
} else {
$results = array();
$bf_misc_announcementoptions = vB::getDatastore()->getValue('bf_misc_announcementoptions');
foreach ($announcements as $k => $post) {
$userinfo = $userapi->fetchUserinfo($post['userid'], array(vB_Api_User::USERINFO_AVATAR, vB_Api_User::USERINFO_SIGNPIC));
$announcements[$k]['username'] = $userinfo['username'];
$announcements[$k]['avatarurl'] = $userapi->fetchAvatar($post['userid']);
$announcements[$k]['dohtml'] = $post['announcementoptions'] & $bf_misc_announcementoptions['allowhtml'];
if ($announcements[$k]['dohtml']) {
$announcements[$k]['donl2br'] = false;
} else {
$announcements[$k]['donl2br'] = true;
}
$announcements[$k]['dobbcode'] = $post['announcementoptions'] & $bf_misc_announcementoptions['allowbbcode'];
$announcements[$k]['dobbimagecode'] = $post['announcementoptions'] & $bf_misc_announcementoptions['allowbbcode'];
$announcements[$k]['dosmilies'] = $post['announcementoptions'] & $bf_misc_announcementoptions['allowsmilies'];
if ($announcements[$k]['dobbcode'] and $post['announcementoptions'] & $bf_misc_announcementoptions['parseurl']) {
require_once DIR . '/includes/functions_newpost.php';
$announcements[$k]['pagetext'] = convert_url_to_bbcode($post['pagetext']);
}
}
return $announcements;
}
}
示例9: getRequestInfo
/**
* Returns an array of request information
*
* @return array The request info
*/
public function getRequestInfo()
{
$request = vB::getRequest();
$items = array('sessionClass' => 'getSessionClass', 'timeNow' => 'getTimeNow', 'ipAddress' => 'getIpAddress', 'altIp' => 'getAltIp', 'sessionHost' => 'getSessionHost', 'userAgent' => 'getUserAgent', 'useEarlyFlush' => 'getUseEarlyFlush', 'cachePageForGuestTime' => 'getCachePageForGuestTime', 'referrer' => 'getReferrer', 'vBHttpHost' => 'getVbHttpHost', 'vBUrlScheme' => 'getVbUrlScheme', 'vBUrlPath' => 'getVbUrlPath', 'vBUrlQuery' => 'getVbUrlQuery', 'vBUrlQueryRaw' => 'getVbUrlQueryRaw', 'vBUrlClean' => 'getVbUrlClean', 'vBUrlWebroot' => 'getVbUrlWebroot', 'scriptPath' => 'getScriptPath');
$values = array();
foreach ($items as $varName => $methodName) {
$values[$varName] = $request->{$methodName}();
}
return $values;
}
示例10: vote
/**
* Vote a node
*
* @param int $nodeid Node ID.
* @return array New Node info.
* @see vB_Api_Node::getNode()
* @throws vB_Exception_Api
*/
public function vote($nodeid)
{
$node = vB_Api::instanceInternal('node')->getNodeFullContent($nodeid);
$node = $node[$nodeid];
$this->checkCanUseRep($node);
$loginuser =& vB::getCurrentSession()->fetch_userinfo();
if ($node['userid'] == $loginuser['userid']) {
// Can't vote own node
throw new vB_Exception_Api('reputationownpost');
}
$score = $this->fetchReppower($loginuser['userid']);
// Check if the user has already reputation this node
$check = $this->assertor->getRow('vBForum:reputation', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'nodeid' => $node['nodeid'], 'whoadded' => $loginuser['userid']));
if (!empty($check)) {
throw new vB_Exception_Api('reputationsamepost');
}
$userinfo = vB_Api::instanceInternal('user')->fetchUserinfo($node['userid']);
if (!$userinfo['userid']) {
throw new vB_Exception_Api('invalidid', 'User');
}
$usergroupcache = vB::getDatastore()->getValue('usergroupcache');
$bf_ugp_genericoptions = vB::getDatastore()->getValue('bf_ugp_genericoptions');
if (!($usergroupcache["{$userinfo['usergroupid']}"]['genericoptions'] & $bf_ugp_genericoptions['isnotbannedgroup'])) {
throw new vB_Exception_Api('reputationbanned');
}
$usercontext =& vB::getUserContext($loginuser['userid']);
$vboptions = vB::getDatastore()->getValue('options');
$userinfo['reputation'] += $score;
// Determine this user's reputationlevelid.
$reputationlevelid = $this->assertor->getField('vBForum:reputation_userreputationlevel', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'reputation' => $userinfo['reputation']));
// init user data manager
$userdata = new vB_Datamanager_User(NULL, vB_DataManager_Constants::ERRTYPE_STANDARD);
$userdata->set_existing($userinfo);
$userdata->set('reputation', $userinfo['reputation']);
$userdata->set('reputationlevelid', intval($reputationlevelid));
$userdata->pre_save();
/*insert query*/
$this->assertor->assertQuery('vBForum:reputation', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_INSERTIGNORE, 'nodeid' => $node['nodeid'], 'reputation' => $score, 'userid' => $userinfo['userid'], 'whoadded' => $loginuser['userid'], 'dateline' => vB::getRequest()->getTimeNow()));
if ($this->assertor->affected_rows() == 0) {
// attempt Zat a flood!
throw new vB_Exception_Api('reputationsamepost');
}
$userdata->save();
$condition = array('nodeid' => $nodeid);
$this->assertor->assertQuery('vBForum:updateNodeVotes', $condition);
// Send notification
$recipients = array($node['userid']);
$contextData = array('sentbynodeid' => $nodeid, 'sender' => vB::getUserContext()->fetchUserId());
vB_Library::instance('notification')->triggerNotificationEvent('node-reputation-vote', $contextData, $recipients);
vB_Library::instance('notification')->insertNotificationsToDB();
// Expire node cache so this like displays correctly
vB_Cache::instance()->allCacheEvent('nodeChg_' . $nodeid);
$votesCount = $this->assertor->getField('vBForum:node', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::COLUMNS_KEY => array('votes'), vB_dB_Query::CONDITIONS_KEY => $condition));
return array('nodeid' => $nodeid, 'votes' => $votesCount);
}
示例11: deleteExpiredRedirects
/**
* Deletes all expired redirects
*
*/
public function deleteExpiredRedirects()
{
$timenow = vB::getRequest()->getTimeNow();
$contenttypeid = vB_Types::instance()->getContentTypeId($this->contenttype);
$assertor = vB::getDbAssertor();
$expiredRedirects = $assertor->getRows('vBForum:node', array(vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'contenttypeid', 'value' => $contenttypeid, vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_EQ), array('field' => 'unpublishdate', 'value' => $timenow, vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_LTE))));
$redirectids = array();
foreach ($expiredRedirects as $redirect) {
$redirectids[] = $redirect['nodeid'];
}
$assertor->delete('vBForum:redirect', array(array('field' => 'nodeid', 'value' => $redirectids, vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_EQ)));
$assertor->delete('vBForum:node', array(array('field' => 'nodeid', 'value' => $redirectids, vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_EQ)));
}
示例12: sendemail
public function sendemail($postid, $reason)
{
$cleaner = vB::getCleaner();
$postid = $cleaner->clean($postid, vB_Cleaner::TYPE_UINT);
$reason = $cleaner->clean($reason, vB_Cleaner::TYPE_STR);
if (empty($postid)) {
return array('response' => array('errormessage' => array('invalidid')));
}
if (empty($reason)) {
return array('response' => array('errormessage' => array('invalidid')));
}
$userinfo = vB_Api::instance('user')->fetchUserinfo();
$data = array('reportnodeid' => $postid, 'rawtext' => $reason, 'created' => vB::getRequest()->getTimeNow(), 'userid' => $userinfo['userid'], 'authorname' => $userinfo['username']);
$result = vB_Api::instance('content_report')->add($data, array('wysiwyg' => false));
if ($result === null || isset($result['errors'])) {
return vB_Library::instance('vb4_functions')->getErrorResponse($result);
}
return array('response' => array('errormessage' => array('redirect_reportthanks')));
}
示例13: __construct
/**
* Constructor protected to enforce singleton use.
* @see instance()
*/
protected function __construct($cachetype)
{
parent::__construct($cachetype);
$this->memcached = vB_Memcache::instance();
$check = $this->memcached->connect();
if ($check === 3) {
trigger_error('Unable to connect to memcache server', E_USER_ERROR);
}
$this->expiration = 48 * 60 * 60;
// two days
$this->timeNow = vB::getRequest()->getTimeNow();
//get the memcache prefix.
$config = vB::getConfig();
if (empty($config['Cache']['memcacheprefix'])) {
$this->prefix = $config['Database']['tableprefix'];
} else {
$this->prefix = $config['Cache']['memcacheprefix'];
}
}
示例14: newthread
public function newthread($forumid)
{
$cleaner = vB::getCleaner();
$forumid = $cleaner->clean($forumid, vB_Cleaner::TYPE_UINT);
$forum = vB_Api::instance('node')->getFullContentforNodes(array($forumid));
if (empty($forum)) {
return array("response" => array("errormessage" => array("invalidid")));
}
$forum = $forum[0];
$foruminfo = vB_Library::instance('vb4_functions')->parseForumInfo($forum);
$prefixes = vB_Library::instance('vb4_functions')->getPrefixes($forumid);
$options = vB::getDatastore()->getValue('options');
$postattachment = $forum['content']['createpermissions']['vbforum_attach'];
$postattachment = empty($postattachment) ? 0 : intval($postattachment);
$usercontext = vB::getUserContext($this->currentUserId);
$maxtags = $usercontext->getChannelLimits($forumid, 'maxstartertags');
$out = array('show' => array('tag_option' => 1), 'vboptions' => array('postminchars' => $options['postminchars'], 'titlemaxchars' => $options['titlemaxchars'], 'maxtags' => $maxtags), 'response' => array('forumrules' => array('can' => array('postattachment' => $postattachment)), 'prefix_options' => $prefixes, 'foruminfo' => $foruminfo, 'poststarttime' => vB::getRequest()->getTimeNow(), 'posthash' => vB_Library::instance('vb4_posthash')->getNewPosthash()));
return $out;
}
示例15: postreply
public function postreply($threadid, $message, $posthash = null, $subject = null)
{
$cleaner = vB::getCleaner();
$threadid = $cleaner->clean($threadid, vB_Cleaner::TYPE_UINT);
$message = $cleaner->clean($message, vB_Cleaner::TYPE_STR);
$subject = $cleaner->clean($subject, vB_Cleaner::TYPE_STR);
$posthash = $cleaner->clean($posthash, vB_Cleaner::TYPE_STR);
if (empty($threadid) || empty($message)) {
return array("response" => array("errormessage" => array("invalidid")));
}
$hv = vB_Library::instance('vb4_functions')->getHVToken();
$data = array('parentid' => $threadid, 'title' => !empty($subject) ? $subject : '(Untitled)', 'rawtext' => $message, 'created' => vB::getRequest()->getTimeNow(), 'hvinput' => $hv);
$result = vB_Api::instance('content_text')->add($data, array('nl2br' => true, 'wysiwyg' => false));
if (empty($result) || !empty($result['errors'])) {
return vB_Library::instance('vb4_functions')->getErrorResponse($result);
}
vB_Library::instance('vb4_posthash')->appendAttachments($result, $posthash);
return array('response' => array('errormessage' => 'redirect_postthanks', 'show' => array('threadid' => $result, 'postid' => $result)));
}