Ejemplo n.º 1
0
 /**
  * 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'];
 }
Ejemplo n.º 2
0
 /**
  * Takes You to the first unread post of the thread or
  * if there are no unread posts it takes you to the last post
  * 
  * @param  [type] $threadid [The nodeid of the thread]
  * @return [array]          [return array from the showthread api method]
  */
 public function gotonewpost($threadid)
 {
     $assertor = vB::getDbAssertor();
     $userinfo = vB_Api::instance('user')->fetchUserinfo();
     $perpage = vB_Library::instance('vb4_functions')->getUsersPostPerPage(0);
     // Get readtime of the thread
     $lastRead = $assertor->getRow('vBForum:noderead', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'nodeid' => $threadid, 'userid' => $userinfo['userid']));
     if (!$lastRead) {
         // Thread has never been visited before, got to last page - as per comment on VBV-9310
         $nbReplies = $assertor->getRows('vBForum:node', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'parentid' => $threadid));
         $pageNumber = ceil((count($nbReplies) + 1) / $perpage);
         return vB_Api::instance('vb4_showthread')->call($threadid, $perpage, $pageNumber);
     } else {
         // Get the first unread reply after the threadmarking time
         $unreadpost = $assertor->getRow('vBForum:getFirstUnreadReply', array('nodeid' => $threadid, 'publishdate' => $lastRead['readtime']));
         if ($unreadpost and !empty($unreadpost['publishdate'])) {
             $lastvisit = $unreadpost['publishdate'];
         } else {
             $lastvisit = $lastRead['readtime'];
         }
         // All the replies before the lastunread reply
         $nbreplies = $assertor->getRow('vBForum:getNodeReplyNumber', array('nodeid' => $threadid, 'publishdate' => $lastvisit));
         // Increase the replies by 1 to count the starter (parentid)
         $pageNumber = ceil(($nbreplies['replies'] + 1) / $perpage);
         return vB_Api::instance('vb4_showthread')->call($threadid, $perpage, $pageNumber);
     }
 }
Ejemplo n.º 3
0
 /**
  * Perform verification of the payment, this is called from the payment gateway
  *
  * @return	bool	Whether the payment is valid
  */
 function verify_payment()
 {
     $this->registry->input->clean_array_gpc('r', array('callbackPW' => vB_Cleaner::TYPE_STR, 'desc' => vB_Cleaner::TYPE_STR, 'transStatus' => vB_Cleaner::TYPE_STR, 'authMode' => vB_Cleaner::TYPE_STR, 'cost' => vB_Cleaner::TYPE_NUM, 'currency' => vB_Cleaner::TYPE_STR, 'transId' => vB_Cleaner::TYPE_STR));
     if (!$this->test()) {
         $this->error = 'Payment processor not configured';
         return false;
     }
     $this->transaction_id = $this->registry->GPC['transId'];
     if ($this->registry->GPC['callbackPW'] == $this->settings['worldpay_password']) {
         $this->paymentinfo = vB::getDbAssertor()->getRow('vBForum:getPaymentinfo', array('hash' => $this->registry->GPC['item_number']));
         // lets check the values
         if (!empty($this->paymentinfo)) {
             $sub = vB::getDbAssertor()->getRow('vBForum:subscription', array('subscriptionid' => $this->paymentinfo['subscriptionid']));
             $cost = unserialize($sub['cost']);
             $this->paymentinfo['currency'] = strtolower($this->registry->GPC['currency']);
             $this->paymentinfo['amount'] = floatval($this->registry->GPC['cost']);
             if ($this->registry->GPC['transStatus'] == 'Y' and ($this->registry->GPC['authMode'] == 'A' or $this->registry->GPC['authMode'] == 'O')) {
                 if (doubleval($this->registry->GPC['cost']) == doubleval($cost["{$this->paymentinfo[subscriptionsubid]}"]['cost'][strtolower($this->registry->GPC['currency'])])) {
                     $this->type = 1;
                 }
             }
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 4
0
 /**
  * Perform verification of the payment, this is called from the payment gateway
  *
  * @return	bool	Whether the payment is valid
  */
 function verify_payment()
 {
     // Leave these values at vB_Cleaner::TYPE_STR since they need to be sent back to nochex just as they were received
     $this->registry->input->clean_array_gpc('p', array('order_id' => vB_Cleaner::TYPE_STR, 'amount' => vB_Cleaner::TYPE_STR, 'transaction_id' => vB_Cleaner::TYPE_STR, 'status' => vB_Cleaner::TYPE_STR));
     $this->transaction_id = $this->registry->GPC['transaction_id'];
     foreach ($_POST as $key => $val) {
         if (!empty($val)) {
             $query[] = $key . '=' . urlencode($val);
         }
     }
     $query = implode('&', $query);
     $used_curl = false;
     if (function_exists('curl_init') and $ch = curl_init()) {
         curl_setopt($ch, CURLOPT_URL, 'http://www.nochex.com/nochex.dll/apc/apc');
         curl_setopt($ch, CURLOPT_TIMEOUT, 15);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_USERAGENT, 'vBulletin via cURL/PHP');
         $result = curl_exec($ch);
         curl_close($ch);
         if ($result !== false) {
             $used_curl = true;
         }
     }
     if (!$used_curl) {
         $header = "POST /nochex.dll/apc/apc HTTP/1.0\r\n";
         $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
         $header .= "Content-Length: " . strlen($query) . "\r\n\r\n";
         if ($fp = fsockopen('www.nochex.com', 80, $errno, $errstr, 15)) {
             socket_set_timeout($fp, 15);
             fwrite($fp, $header . $query);
             while (!feof($fp)) {
                 $result = fgets($fp, 1024);
                 if (strcmp($result, 'AUTHORISED') == 0) {
                     break;
                 }
             }
             fclose($fp);
         }
     }
     if (!empty($this->settings['ncxemail']) and $result == 'AUTHORISED' and $vbulletin->GPC['status'] != 'test') {
         $this->paymentinfo = vB::getDbAssertor()->getRow('vBForum:getPaymentinfo', array('hash' => $this->registry->GPC['item_number']));
         // lets check the values
         if (!empty($this->paymentinfo)) {
             $sub = vB::getDbAssertor()->getRow('vBForum:subscription', array('subscriptionid' => $this->paymentinfo['subscriptionid']));
             $cost = unserialize($sub['cost']);
             $this->paymentinfo['currency'] = 'gbp';
             $this->paymentinfo['amount'] = floatval($this->registry->GPC['amount']);
             // Check if its a payment or if its a reversal
             if ($this->registry->GPC['amount'] == $cost["{$this->paymentinfo[subscriptionsubid]}"]['cost']['gbp']) {
                 $this->type = 1;
             }
         }
         return true;
     } else {
         $this->error = 'Invalid Request';
     }
     return false;
 }
 /**
  * Perform verification of the payment, this is called from the payment gateway
  *
  * @return	bool	Whether the payment is valid
  */
 function verify_payment()
 {
     $this->registry->input->clean_array_gpc('p', array('pay_to_email' => vB_Cleaner::TYPE_STR, 'merchant_id' => vB_Cleaner::TYPE_STR, 'transaction_id' => vB_Cleaner::TYPE_STR, 'mb_transaction_id' => vB_Cleaner::TYPE_UINT, 'status' => vB_Cleaner::TYPE_STR, 'md5sig' => vB_Cleaner::TYPE_STR, 'amount' => vB_Cleaner::TYPE_STR, 'currency' => vB_Cleaner::TYPE_STR, 'mb_amount' => vB_Cleaner::TYPE_STR, 'mb_currency' => vB_Cleaner::TYPE_STR));
     if (!$this->test()) {
         $this->error = 'Payment processor not configured';
         return false;
     }
     $this->transaction_id = $this->registry->GPC['mb_transaction_id'];
     $check_hash = strtoupper(md5($this->registry->GPC['merchant_id'] . $this->registry->GPC['transaction_id'] . strtoupper(md5(strtolower($this->settings['mbsecret']))) . $this->registry->GPC['mb_amount'] . $this->registry->GPC['mb_currency'] . $this->registry->GPC['status']));
     if ($check_hash == $this->registry->GPC['md5sig'] and strtolower($this->registry->GPC['pay_to_email']) == strtolower($this->settings['mbemail'])) {
         if (intval($this->registry->GPC['status']) == 2) {
             $this->paymentinfo = vB::getDbAssertor()->getRow('vBForum:getPaymentinfo', array('hash' => $this->registry->GPC['item_number']));
             // lets check the values
             if (!empty($this->paymentinfo)) {
                 $sub = vB::getDbAssertor()->getRow('vBForum:subscription', array('subscriptionid' => $this->paymentinfo['subscriptionid']));
                 $cost = unserialize($sub['cost']);
                 $this->paymentinfo['currency'] = strtolower($this->registry->GPC['currency']);
                 $this->paymentinfo['amount'] = floatval($this->registry->GPC['amount']);
                 if (doubleval($this->registry->GPC['amount']) == doubleval($cost["{$this->paymentinfo[subscriptionsubid]}"]['cost'][strtolower($this->registry->GPC['currency'])])) {
                     $this->type = 1;
                     return true;
                 }
             }
         }
     }
     return false;
 }
Ejemplo n.º 6
0
 /**
  * Handle update events. The required data in $eventData depends on the particular event.
  * Children may also handle their specific events.
  *
  * @param	String	$event			One of the event strings in static::$updateEvents
  * @param	Array	$eventData		When $event is 'read_topic'|'read_channel', expects:
  *										int 'nodeid'
  *										int 'userid'	(Optional)
  */
 public static function handleUpdateEvents($event, $eventData)
 {
     if (!static::validateUpdateEvent($event)) {
         return false;
     }
     $types = vB_Library::instance('Notification')->getNotificationTypes();
     $typeid = $types[static::TYPENAME]['typeid'];
     $assertor = vB::getDbAssertor();
     switch ($event) {
         case 'deleted_user':
             $userid = (int) $eventData['userid'];
             $check = $assertor->getRow('user', array('userid' => $userid));
             if (empty($check)) {
                 // remove any notification owned by deleted user.
                 $assertor->assertQuery('vBForum:notification', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_DELETE, 'recipient' => $userid, 'typeid' => $typeid));
                 // remove any userrelation notifications sent from now-deleted user.
                 $assertor->assertQuery('vBForum:notification', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_DELETE, 'sender' => $userid, 'typeid' => $typeid));
             }
             break;
         default:
             break;
     }
     // skip parent handler. Nothing valid there that isn't already handled here.
     return;
 }
Ejemplo n.º 7
0
 protected function __construct()
 {
     parent::__construct();
     $this->storage = vB::getDatastore()->getOption('attachfile');
     $this->filePath = vB::getDatastore()->getOption('attachpath');
     $this->assertor = vB::getDbAssertor();
 }
Ejemplo n.º 8
0
 protected function getNewRouteInfo()
 {
     $arguments =& $this->arguments;
     $param =& $this->queryParameters;
     $keys = array_keys($param);
     $idkey = array('t', 'threadid');
     if (empty($param['do'])) {
         $param['do'] = 'showsmilies';
     }
     switch ($param['do']) {
         case 'bbcode':
             $this->anchor = 'bbcode_reference/bbcode_why';
             return 'help';
         case 'showrules':
             $this->anchor = 'community_overview/general_tos';
             return 'help';
         case 'showsmilies':
             $this->anchor = 'bbcode_reference/bbcode_smilies';
             return 'help';
         case 'whoposted':
             if ($set = array_intersect($keys, $idkey) and $pid = intval($param[reset($set)])) {
                 $oldid = $pid;
                 $oldcontenttypeid = vB_Types::instance()->getContentTypeID(array('package' => 'vBForum', 'class' => 'Thread'));
                 $node = vB::getDbAssertor()->getRow('vBForum:node', array('oldid' => $oldid, 'oldcontenttypeid' => $oldcontenttypeid));
                 if (!empty($node)) {
                     $arguments['nodeid'] = $node['nodeid'];
                     return $node['routeid'];
                 }
             }
         default:
             throw new vB_Exception_404('invalid_page');
     }
 }
Ejemplo n.º 9
0
 public function fetchHistoryComparison($nodeid, $oldpost, $newpost)
 {
     if (!$this->canViewPostHistory($nodeid)) {
         throw new Exception('no_permission');
     }
     $_posthistory = vB::getDbAssertor()->getRows('vBForum:postedithistory', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::CONDITIONS_KEY => array('nodeid' => $nodeid, 'postedithistoryid' => array($oldpost, $newpost)), vB_dB_Query::COLUMNS_KEY => array('postedithistoryid', 'reason', 'dateline', 'username', 'original', 'pagetext')), array('field' => 'postedithistoryid', 'direction' => vB_dB_Query::SORT_ASC));
     if (!$_posthistory) {
         throw new Exception('no_permission');
     }
     $posthistory = array();
     $key = 1;
     foreach ($_posthistory as $info) {
         $posthistory['post' . $key] = $info;
         $key++;
     }
     require_once DIR . '/includes/class_diff.php';
     if ($posthistory['post2']) {
         $textdiff_obj = new vB_Text_Diff($posthistory['post1']['pagetext'], $posthistory['post2']['pagetext']);
     } else {
         $textdiff_obj = new vB_Text_Diff($posthistory['post1']['pagetext'], $posthistory['post1']['pagetext']);
     }
     $results = array();
     $diff = $textdiff_obj->fetch_diff();
     foreach ($diff as $diffrow) {
         $compare_show = array();
         if ($diffrow->old_class == 'unchanged' and $diffrow->new_class == 'unchanged') {
             // no change
             $results[] = array('unchanged_olddata' => vB_String::fetchWordWrappedString(nl2br(vB_String::htmlSpecialCharsUni(implode("\n", $diffrow->fetch_data_old())))));
         } else {
             // something has changed
             $results[] = array('changed_olddata' => vB_String::fetchWordWrappedString(nl2br(vB_String::htmlSpecialCharsUni(implode("\n", $diffrow->fetch_data_old())))), 'changed_newdata' => vB_String::fetchWordWrappedString(nl2br(vB_String::htmlSpecialCharsUni(implode("\n", $diffrow->fetch_data_new())))));
         }
     }
     return $results;
 }
Ejemplo n.º 10
0
 /**
  * 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'];
 }
Ejemplo n.º 11
0
 public function createSession($userid = 1)
 {
     //$this->session = vB_Session_Web::getSession(1);
     $this->session = new vB_Session_Cli(vB::getDbAssertor(), vB::getDatastore(), vB::getConfig(), $userid);
     vB::setCurrentSession($this->session);
     $this->timeNow = time();
 }
Ejemplo n.º 12
0
 public function __construct($routeInfo = array(), $matches = array(), $queryString = '', $anchor = '')
 {
     /* Depending on the friendliness setting, we can have four different url formats.  Like:
     		   content.php?280-Accu-Sim-In-General/view/2
     		   content.php?r=280-Accu-Sim-In-General/view/2
     		   content.php/280-Accu-Sim-In-General/view/2
     		   content/280-Accu-Sim-In-General/view/2
     		*/
     parent::__construct($routeInfo, $matches, $queryString, $anchor);
     if (!empty($queryString) and (empty($this->arguments['oldid']) or !is_numeric($this->arguments['oldid']) or empty($this->arguments['oldpage']) or !is_numeric($this->arguments['oldpage']))) {
         $queryMatches = array();
         if (preg_match('#[^0-9]*(?P<oldid>[0-9]+)?(-)?(?P<urlident>[^%2F]*)?(%2Fview%2F)?(?P<oldpage>[0-9]+)?#i', $queryString, $queryMatches)) {
             if (!empty($queryMatches['oldid'])) {
                 $this->arguments['oldid'] = $queryMatches['oldid'];
             }
             if (!empty($queryMatches['oldpage'])) {
                 $this->arguments['contentpage'] = $queryMatches['oldpage'];
             }
         }
     }
     if (!empty($this->arguments['oldid']) and is_numeric($this->arguments['oldid'])) {
         $node = vB::getDbAssertor()->getRow('vBForum:node', array('oldid' => $this->arguments['oldid'], 'oldcontenttypeid' => array(vB_Api_ContentType::OLDTYPE_CMS_STATICPAGE, vB_Api_ContentType::OLDTYPE_CMS_ARTICLE)));
         if (!empty($node) and empty($node['errors'])) {
             $this->arguments['nodeid'] = $node['nodeid'];
             $this->arguments['contenttypeid'] = $node['contenttypeid'];
             $this->arguments['routeid'] = $node['routeid'];
         }
     }
     // I'm leaving this bit of comment here to remind ourselves that we need to actually ensure that articles have a meta description.
     // Meta Description
     /*
        $this->arguments['metadescription'] = ;
     */
 }
Ejemplo n.º 13
0
 /**
  * 
  * @param mixed $languageIds - Language id or array of language ids
  * @return array - Array of languages including:
  *					- languageid
  *					- dateoverride
  *					- timeoverride
  *					- locale
  *					- charset
  */
 public function fetchLanguages($languageIds)
 {
     $result = array();
     if (empty($languageIds)) {
         return $result;
     } else {
         if (is_array($languageIds)) {
             array_walk($languageIds, 'intval');
         } else {
             $languageIds = array(intval($languageIds));
         }
     }
     $missing = array();
     foreach ($languageIds as $languageId) {
         if (isset($this->languages[$languageId])) {
             $result[$languageId] = $this->languages[$languageId];
         } else {
             $missing[$languageId] = $languageId;
         }
     }
     if (!empty($missing)) {
         $query = array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::COLUMNS_KEY => array('languageid', 'dateoverride', 'timeoverride', 'locale', 'charset'), vB_dB_Query::CONDITIONS_KEY => array('languageid' => $missing));
         $dbLanguages = vB::getDbAssertor()->assertQuery('language', $query);
         foreach ($dbLanguages as $lang) {
             $this->languages[$lang['languageid']] = $lang;
             $result[$lang['languageid']] = $lang;
         }
     }
     return $result;
 }
Ejemplo n.º 14
0
 /**
  * This function updates specified settings
  * @param array $values
  *	'varname' => $vbulletin->GPC['varname'],
  *	'grouptitle' => $vbulletin->GPC['grouptitle'],
  *	'optioncode' => $vbulletin->GPC['optioncode'],
  *	'defaultvalue' => $vbulletin->GPC['defaultvalue'],
  *	'displayorder' => $vbulletin->GPC['displayorder'],
  *	'volatile' => $vbulletin->GPC['volatile'],
  *	'datatype' => $vbulletin->GPC['datatype'],
  *	'validationcode' => $vbulletin->GPC['validationcode'],
  *	'product' => $vbulletin->GPC['product'],
  *	'blacklist' => $vbulletin->GPC['blacklist'],
  *	'title' => $vbulletin->GPC['title'],
  *	'username' => $vbulletin->userinfo['username'],
  *	'description' => $vbulletin->GPC['description']
  * @return array, $response
  */
 public function updateSetting($values)
 {
     require_once DIR . '/includes/class_xml.php';
     require_once DIR . '/includes/functions_file.php';
     require_once DIR . '/includes/adminfunctions_options.php';
     require_once DIR . '/includes/adminfunctions.php';
     $response = array();
     $langid = $values['volatile'] ? -1 : 0;
     if (defined('DEV_AUTOEXPORT') and DEV_AUTOEXPORT) {
         $old_setting = vB::getDbAssertor()->getRow('setting', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'varname' => $values['varname']));
     }
     vB::getDbAssertor()->assertQuery('setting', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, 'grouptitle' => $values['grouptitle'], 'optioncode' => $values['optioncode'], 'defaultvalue' => $values['defaultvalue'], 'displayorder' => $values['displayorder'], 'volatile' => $values['volatile'], 'datatype' => $values['datatype'], 'validationcode' => $values['validationcode'], 'product' => $values['product'], 'blacklist' => $values['blacklist'], 'ispublic' => $values['ispublic'], 'adminperm' => isset($values['adminperm']) ? $values['adminperm'] : '', vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'varname', 'value' => $values['varname'], 'operator' => vB_dB_Query::OPERATOR_EQ))));
     $phrases = vB::getDbAssertor()->assertQuery('vBForum:phrase', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'languageid' => array(-1, 0), 'fieldname' => 'vbsettings', 'varname' => array("setting_" . $values['varname'] . "_title", "setting_" . $values['varname'] . "_desc")));
     $full_product_info = fetch_product_list(true);
     $product_version = $full_product_info[$values['product']]['version'];
     if ($phrases and $phrases->valid()) {
         foreach ($phrases as $phrase) {
             if ($phrase['varname'] == "setting_" . $values['varname'] . "_title") {
                 vB::getDbAssertor()->assertQuery('vBForum:phrase', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, 'languageid' => $langid, 'text' => $values['title'], 'product' => $values['product'], 'username' => $values['username'], 'dateline' => TIMENOW, 'version' => $product_version, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'languageid', 'value' => $phrase['languageid'], 'operator' => vB_dB_Query::OPERATOR_EQ), array('field' => 'varname', 'value' => "setting_" . $values['varname'] . "_title", 'operator' => vB_dB_Query::OPERATOR_EQ))));
             } else {
                 if ($phrase['varname'] == "setting_" . $values['varname'] . "_desc") {
                     vB::getDbAssertor()->assertQuery('vBForum:phrase', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, 'languageid' => $langid, 'text' => $values['description'], 'product' => $values['product'], 'username' => $values['username'], 'dateline' => TIMENOW, 'version' => $product_version, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'languageid', 'value' => $phrase['languageid'], 'operator' => vB_dB_Query::OPERATOR_EQ), array('field' => 'varname', 'value' => "setting_" . $values['varname'] . "_desc", 'operator' => vB_dB_Query::OPERATOR_EQ))));
                 }
             }
         }
     }
     vB::getDatastore()->build_options();
     $response['update'] = true;
     return $response;
 }
Ejemplo n.º 15
0
 protected static function getInstance($type, $value)
 {
     $dbType = vB::getDbAssertor()->getDbType();
     $className = "vB_dB_{$dbType}_Type_" . $type;
     if (class_exists($className)) {
         return new $className($value);
     }
 }
Ejemplo n.º 16
0
 /**
  * Constructor
  *
  * @param string Directory where the XML files are located
  */
 public function __construct($xmldir)
 {
     $this->xmldir = (string) $xmldir;
     $this->assertor = vB::getDbAssertor();
     $items = array('page', 'route', 'pagetemplate');
     foreach ($items as $item) {
         $this->xml[$item] = $this->loadXmlFile($item);
     }
 }
Ejemplo n.º 17
0
 public static function getChannelTypes()
 {
     $types = array();
     $vBChannelTypes = vB::getDbAssertor()->assertQuery('vBForum:channel', array('guid' => array_keys(self::$channelTypes)));
     foreach ($vBChannelTypes as $channel) {
         $types[$channel['nodeid']] = array('type' => self::$channelTypes[$channel['guid']], 'GUID' => $channel['guid'], 'label' => self::$channelLabels[self::$channelTypes[$channel['guid']]]);
     }
     return $types;
 }
 /**
  * Constructor
  *
  * @param	vBulletin database Instance
  */
 function vB_UserChangeLog(&$registry)
 {
     // the db object need for the execute and for the escape string
     if (is_object($registry)) {
         $this->registry =& $registry;
     } else {
         $this->registry =& vB::get_registry();
     }
     $this->assertor =& vB::getDbAssertor();
 }
Ejemplo n.º 19
0
 public static function createSession($vbApiParamsToVerify, $vBApiRequests)
 {
     self::$vBApiParamsToVerify = $vbApiParamsToVerify;
     self::$vBApiRequests = $vBApiRequests;
     $assertor = vB::getDbAssertor();
     $datastore = vB::getDatastore();
     $config = vB::getConfig();
     $session = new vB_Session_Api($assertor, $datastore, $config, '', $vbApiParamsToVerify, $vBApiRequests);
     return $session;
 }
Ejemplo n.º 20
0
 /**
  *	Create a session for this page load
  *
  *	Should only be called from the Request code.
  *	Will use a reexisting session that matches the session hash
  *
  *	@param string $sessionhash -- the token given to the client for session handling.  If the client has this token they
  *		can use the session.
  *	@param array $restoreSessionInfo -- Information to handle "remember me" logic.
  *		* remembermetoken -- Token value for "remember me".  Stored in the "password" cookie for legacy reasons.  There are
  *			so special values to indicate that we should reauthentic via a method other than the internal vB remember me
  *			system.
  *		* userid -- user we are remembering
  *		* fbsr_{appid} (optional) -- Only valid if facebook is enabled, and only used if "remembermetoken" is "facebook".
  */
 public static function createSessionNew($sessionhash, $restoreSessionInfo = array())
 {
     $assertor = vB::getDbAssertor();
     $datastore = vB::getDatastore();
     $config = vB::getConfig();
     //this looks weird but its valid.  Will create the an instance of whatever session class this was called
     //on.  So vB_Session_Web::createSessionNew() will do the expected thing.
     $session = new vB_Session_WebApi($assertor, $datastore, $config, $sessionhash, $restoreSessionInfo);
     return $session;
 }
Ejemplo n.º 21
0
 /**
  * get the actual node after captured old id
  * set route arguments for building new URL
  * return new routeid
  */
 protected function getNewRouteInfo()
 {
     $oldid = $this->captureOldId();
     $node = vB::getDbAssertor()->getRow('vBForum:node', array('oldid' => $oldid, 'oldcontenttypeid' => $this->oldcontenttypeid));
     if (empty($node)) {
         throw new vB_Exception_404('invalid_page');
     }
     $this->arguments['nodeid'] = $node['nodeid'];
     return $node['routeid'];
 }
Ejemplo n.º 22
0
 public static function getSession($userId, $sessionHash = '', &$dBAssertor = null, &$datastore = null, &$config = null)
 {
     $dBAssertor = $dBAssertor ? $dBAssertor : vB::getDbAssertor();
     $datastore = $datastore ? $datastore : vB::getDatastore();
     $config = $config ? $config : vB::getConfig();
     $restoreSessionInfo = array('userid' => $userId);
     $session = new vB_Session_Web($dBAssertor, $datastore, $config, $sessionHash, $restoreSessionInfo);
     $session->set('userid', $userId);
     $session->fetch_userinfo();
     return $session;
 }
Ejemplo n.º 23
0
 protected function getNewRouteInfo()
 {
     $oldid = $this->captureOldId();
     $node = vB::getDbAssertor()->getRow('vBForum:fetchLegacyPostIds', array('oldids' => $oldid, 'postContentTypeId' => vB_Types::instance()->getContentTypeID('vBForum_Post')));
     if (empty($node)) {
         throw new vB_Exception_404('invalid_page');
     }
     $this->arguments['nodeid'] = $node['starter'];
     $this->arguments['innerPost'] = $node['nodeid'];
     return $node['routeid'];
 }
Ejemplo n.º 24
0
 public static function importArguments($arguments)
 {
     $data = unserialize($arguments);
     $page = vB::getDbAssertor()->getRow('page', array('guid' => $data['pageGuid']));
     if (empty($page)) {
         throw new Exception('Couldn\'t find page');
     }
     $data['pageid'] = $page['pageid'];
     unset($data['pageGuid']);
     return serialize($data);
 }
Ejemplo n.º 25
0
 /**
  * Returns the array of post icons
  *
  * @param array $orderby Sort orders
  * @return    array    The icons
  */
 public function fetchAll($orderby = array())
 {
     $result = vB::getDbAssertor()->assertQuery('icon', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT), $orderby);
     $icons = array();
     if ($result->valid()) {
         foreach ($result as $icon) {
             $icons[$icon['iconid']] = $icon;
         }
     }
     return $icons;
 }
Ejemplo n.º 26
0
 function __construct($masterstyleid = -1)
 {
     // Set initial stuff
     $this->dateline = time();
     $this->assertor = vB::getDbAssertor();
     $this->productlist = vB::get_datastore()->get_value('products');
     $this->masterstyleid = $masterstyleid;
     $this->styles[] = $this->masterstyleid;
     $styles = $this->assertor->getRows('getStylesForMaster', array('masterid' => $this->masterstyleid));
     foreach ($styles as $style) {
         $this->styles[] = $style['styleid'];
     }
 }
Ejemplo n.º 27
0
 /**
  * Returns a list of all screen layouts.
  *
  * @param	bool	Force reload
  * @return	array
  */
 public function fetchScreenLayoutList($skipcache = false)
 {
     if (!is_array($this->cache) or $skipcache) {
         $db = vB::getDbAssertor();
         $screenLayouts = $db->getRows('screenlayout', array(), array('displayorder', 'title'));
         if ($screenLayouts) {
             $this->cache = $screenLayouts;
         } else {
             $this->cache = array();
         }
     }
     return $this->cache;
 }
Ejemplo n.º 28
0
 /**
  * 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)));
 }
Ejemplo n.º 29
0
 public function getCanonicalRoute()
 {
     if (!isset($this->canonicalRoute)) {
         if (!empty($this->arguments['pageid'])) {
             $page = vB::getDbAssertor()->getRow('page', array('pageid' => $this->arguments['pageid']));
         }
         if (!empty($page['routeid'])) {
             $this->canonicalRoute = self::getRoute($page['routeid'], array(), $this->queryParameters);
         } else {
             return $this;
         }
     }
     return $this->canonicalRoute;
 }
Ejemplo n.º 30
0
 /**
  * Returns list of vbUser info about the list of facebook user ids
  * @param  [string] $facebookidList [Comma separated list of Facebook user ids]
  * @return [array]  $usersArray     [Array of the userInfo for the required userids]
  */
 public function getVbfromfacebook($facebookidList)
 {
     $cleaner = vB::getCleaner();
     $facebookidList = $cleaner->clean($facebookidList, vB_Cleaner::TYPE_STR);
     $usersArray = array();
     $listIds = explode(',', $facebookidList);
     $users = vB::getDbAssertor()->getRows('user', array('fbuserid' => $listIds));
     if (!empty($users) || !isset($users['errors'])) {
         foreach ($users as $user) {
             $usersArray[] = array('userid' => $user['userid'], 'username' => $user['username'], 'fbuserid' => $user['fbuserid']);
         }
     }
     return $usersArray;
 }