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&amp;ip={$ip['ipaddress']}\" title=\"" . $vbphrase['resolve_address'] . "\">{$ip['ipaddress']}</a> &nbsp; " . construct_link_code($vbphrase['find_more_users_with_this_ip_address'], "{$userscript}?" . vB::getCurrentSession()->get('sessionurl') . "do=doips&amp;ipaddress={$ip['ipaddress']}&amp;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>';
    }
}
Example #2
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'];
 }
Example #3
0
 /**
  * Sets the breadcrumbs for the route
  *
  * @return	array
  */
 protected function setBreadcrumbs()
 {
     $this->breadcrumbs = array();
     $phrase = 'create_new_topic';
     if (isset($this->arguments['nodeid']) && $this->arguments['nodeid']) {
         $onlyAddTopParent = false;
         $channelInfo = vB_Api::instanceInternal('Content_Channel')->fetchChannelById(intval($this->arguments['nodeid']));
         if ($channelInfo) {
             switch ($channelInfo['channeltype']) {
                 case 'blog':
                     $phrase = 'create_new_blog_entry';
                     break;
                 case 'group':
                     $phrase = 'create_new_topic';
                     break;
                 case 'article':
                     $phrase = 'create_new_article';
                     // when creating an article, the breadcrumb should
                     // always be home > articles > create article
                     // since you can choose the category when creating the article
                     $onlyAddTopParent = true;
                     break;
                 default:
                     break;
             }
         }
         $this->addParentNodeBreadcrumbs($this->arguments['nodeid'], $onlyAddTopParent);
     }
     $this->breadcrumbs[] = array('phrase' => $phrase);
 }
Example #4
0
 public function getCanonicalRoute()
 {
     if (!isset($this->canonicalRoute)) {
         if (empty($this->arguments['nodeid'])) {
             throw new vB_Exception_NodePermission();
         }
         $nodeApi = vB_Api::instanceInternal('node');
         try {
             // this method will return an error if the user does not have permission
             $node = $nodeApi->getNode($this->arguments['nodeid']);
         } catch (vB_Exception_Api $ex) {
             // throw the proper NodePermission exception to return a 403 status instead of a 500 internal error
             if ($ex->has_errors('no_permission')) {
                 throw new vB_Exception_NodePermission($this->arguments['nodeid']);
             } else {
                 // otherwise, just let the caller catch the exception
                 throw $ex;
             }
         }
         $contentApi = vB_Api_Content::getContentApi($node['contenttypeid']);
         if (!$contentApi->validate($node, vB_Api_Content::ACTION_VIEW, $node['nodeid'], array($node['nodeid'] => $node))) {
             throw new vB_Exception_NodePermission($node['nodeid']);
         }
         $parent = $nodeApi->getNode($node['starter']);
         $parent['innerPost'] = $this->arguments['nodeid'];
         $this->canonicalRoute = self::getRoute($node['routeid'], $parent, $this->queryParameters);
     }
     return $this->canonicalRoute;
 }
Example #5
0
 protected function buildOutputFromItems($items, $options)
 {
     parent::buildOutputFromItems($items, $options);
     $xml = new vB_Xml_Builder();
     $xml->add_group('rss', array('version' => '0.91'));
     $xml->add_group('channel');
     $xml->add_tag('title', $this->rssinfo['title']);
     $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true);
     $xml->add_tag('description', $this->rssinfo['description']);
     $xml->add_tag('language', $this->defaultLang['languagecode']);
     $xml->add_group('image');
     $xml->add_tag('url', $this->rssinfo['icon']);
     $xml->add_tag('title', $this->rssinfo['title']);
     $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true);
     $xml->close_group('image');
     $dateformat = vB::getDatastore()->getOption('dateformat');
     $timeformat = vB::getDatastore()->getOption('timeformat');
     // gather channel info
     $channelsInfo = $this->getItemsChannelInfo($items);
     $items = $this->formatItems($items, $options);
     foreach ($items as $id => $item) {
         $item = $item['content'];
         $xml->add_group('item');
         $xml->add_tag('title', $item['external_prefix_plain'] . vB_String::htmlSpecialCharsUni($item['external_title']));
         $xml->add_tag('link', vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['external_nodeid']), array(), false, true);
         $xml->add_tag('description', vB_Phrase::fetchSinglePhrase('rss_91_forum_w_posted_by_x_post_time_y_at_z', array($channelsInfo[$item['channelid']]['htmltitle'], $item['authorname'], $this->callvBDate($dateformat, $item['publishdate']), $this->callvBDate($timeformat, $item['publishdate']))));
         $xml->close_group('item');
     }
     $xml->close_group('channel');
     $xml->close_group('rss');
     $output .= '<!DOCTYPE rss PUBLIC "-//RSS Advisory Board//DTD RSS 0.91//EN" "http://www.rssboard.org/rss-0.91.dtd">' . "\r\n";
     $output .= $xml->output();
     return $xml->fetch_xml_tag() . $output;
 }
 /**
  * Returns the phrased page title based on the GUID
  *
  * @param string Page GUID
  */
 public function getPageTitleByGuid($guid)
 {
     $phraseLib = vB_Library::instance('phrase');
     $phraseVarname = 'page_' . $phraseLib->cleanGuidForPhrase($guid) . '_title';
     $phrases = vB_Api::instanceInternal('phrase')->fetch(array($phraseVarname));
     return $phrases[$phraseVarname];
 }
 /**
  * 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;
     }
 }
Example #8
0
 /**
  * Loads information needed for RSS output
  *
  * @param 	array 	Options to be considered for feed.
  */
 protected function loadRssInfo($options)
 {
     $description = $this->getPhraseFromGuid(vB_Page::PAGE_HOME, 'metadesc');
     $stylevars = vB_Api::instanceInternal('style')->fetchStylevars(array(vB::getDatastore()->getOption('styleid')));
     $imgdir = (!empty($stylevars['imgdir_misc']) and !empty($stylevars['imgdir_misc']['imagedir'])) ? $stylevars['imgdir_misc']['imagedir'] : '';
     $this->rssinfo = array('title' => vB::getDatastore()->getOption('bbtitle'), 'link' => vB::getDatastore()->getOption('frontendurl'), 'icon' => vB::getDatastore()->getOption('bburl') . '/' . $imgdir . '/rss.png', 'description' => $description, 'ttl' => 60);
     $this->rssinfo = $this->applyRssOptions($options, $this->rssinfo);
 }
Example #9
0
 /**
  * Sets the breadcrumbs for the route
  */
 protected function setBreadcrumbs()
 {
     //if we are coming in for a route (instead of generating a URL) then the $this->arguments['username'] is the
     //url slug, which we don't want.  The API call is cached and will be called later anyway to generate the
     //profile page so its not a bit performance hit to load this way.
     $userInfo = vB_Api::instanceInternal('user')->fetchProfileInfo($this->arguments['userid']);
     $this->breadcrumbs = array(0 => array('title' => $userInfo['username'], 'url' => ''));
 }
 public function call($forumid, $perpage = 20, $pagenumber = 1)
 {
     $contenttype = vB_Api::instance('contenttype')->fetchContentTypeIdFromClass('Channel');
     $forum = vB_Api::instance('node')->getNodeFullContent($forumid);
     if (empty($forum) or isset($forum['errors'])) {
         return array("response" => array("errormessage" => array("invalidid")));
     }
     $forum = $forum[$forumid];
     $modPerms = vB::getUserContext()->getModeratorPerms($forum);
     $foruminfo = array('forumid' => $forum['nodeid'], 'title' => vB_String::unHtmlSpecialChars($forum['title']), 'description' => $forum['description'], 'title_clean' => $forum['htmltitle'], 'description_clean' => strip_tags($forum['description']), 'prefixrequired' => 0);
     $nodes = vB_Api::instance('node')->fetchChannelNodeTree($forumid, 3);
     $channels = array();
     if (!empty($nodes) and empty($nodes['errors']) and isset($nodes['channels']) and !empty($nodes['channels'])) {
         foreach ($nodes['channels'] as $node) {
             $channels[] = vB_Library::instance('vb4_functions')->parseForum($node);
         }
     }
     $forumbits = $channels;
     $topics = array();
     $topics_sticky = array();
     $page_nav = vB_Library::instance('vb4_functions')->pageNav(1, $perpage, 1);
     $search = array("channel" => $forumid);
     $search['view'] = vB_Api_Search::FILTER_VIEW_TOPIC;
     $search['depth'] = 1;
     $search['include_sticky'] = true;
     $search['sort']['lastcontent'] = 'desc';
     $search['nolimit'] = 1;
     $topic_search = vB_Api::instanceInternal('search')->getInitialResults($search, $perpage, $pagenumber, true);
     if (!isset($topic_search['errors']) and !empty($topic_search['results'])) {
         $topic_search['results'] = vB_Api::instance('node')->mergeNodeviewsForTopics($topic_search['results']);
         foreach ($topic_search['results'] as $key => $node) {
             if ($node['content']['contenttypeclass'] == 'Channel' or $node['content']['starter'] != $node['content']['nodeid']) {
                 unset($topic_search['results'][$key]);
             } else {
                 $topic = vB_Library::instance('vb4_functions')->parseThread($node);
                 if ($topic['thread']['sticky']) {
                     $topics_sticky[] = $topic;
                 } else {
                     $topics[] = $topic;
                 }
             }
         }
         $page_nav = vB_Library::instance('vb4_functions')->pageNav($topic_search['pagenumber'], $perpage, $topic_search['totalRecords']);
     }
     $inlinemod = $forum['canmoderate'] ? 1 : 0;
     $subscribed = vB_Api::instance('follow')->isFollowingContent($forum['nodeid']);
     $subscribed = $subscribed ? 1 : 0;
     $forumsearch = vB::getUserContext()->hasPermission('forumpermissions', 'cansearch');
     $response = array();
     $response['response']['forumbits'] = $forumbits;
     $response['response']['foruminfo'] = $foruminfo;
     $response['response']['threadbits'] = $topics;
     $response['response']['threadbits_sticky'] = $topics_sticky;
     $response['response']['pagenav'] = $page_nav;
     $response['response']['pagenumber'] = intval($pagenumber);
     $response['show'] = array('subscribed_to_forum' => $subscribed, 'inlinemod' => $inlinemod, 'spamctrls' => $modPerms['candeleteposts'] > 0 ? 1 : 0, 'openthread' => $modPerms['canopenclose'] > 0 ? 1 : 0, 'approvethread' => $modPerms['canmoderateposts'] > 0 ? 1 : 0, 'movethread' => $modPerms['canmassmove'] > 0 ? 1 : 0, 'forumsearch' => $forumsearch, 'stickies' => count($topics_sticky) > 0 ? 1 : 0);
     return $response;
 }
 /**
  * Fetch all subscriptions that an user can join and already joined
  * It also fetches active payment APIs
  *
  * @param bool $isreg Whether to fetch subscriptions for signup page
  * @return array Paid subscriptions info for the user.
  */
 public function fetchAll($isreg = false)
 {
     try {
         $this->checkStatus();
     } catch (vB_Exception_Api $e) {
         return array();
     }
     $userinfo = vB::getCurrentSession()->fetch_userinfo();
     $usercontext = vB::getUserContext();
     $membergroupids = fetch_membergroupids_array($userinfo);
     $allow_secondary_groups = $usercontext->hasPermission('genericoptions', 'allowmembergroups');
     $subscribed = $this->fetchSubscribed();
     $vbphrase = vB_Api::instanceInternal('phrase')->fetch(array('day', 'week', 'month', 'year', 'days', 'weeks', 'months', 'years', 'length_x_units_y_recurring_z', 'recurring'));
     $lengths = array('D' => $vbphrase['day'], 'W' => $vbphrase['week'], 'M' => $vbphrase['month'], 'Y' => $vbphrase['year'], 'Ds' => $vbphrase['days'], 'Ws' => $vbphrase['weeks'], 'Ms' => $vbphrase['months'], 'Ys' => $vbphrase['years']);
     $cansubscribesubscriptions = array();
     $subscribedsubscriptions = array();
     foreach ($this->subobj->subscriptioncache as $subscription) {
         $subscriptionid =& $subscription['subscriptionid'];
         $subscription['cost'] = unserialize($subscription['cost']);
         $subscription['newoptions'] = @unserialize($subscription['newoptions']);
         foreach ($subscription['cost'] as $key => $currentsub) {
             if ($currentsub['length'] == 1) {
                 $currentsub['units'] = $lengths["{$currentsub['units']}"];
             } else {
                 $currentsub['units'] = $lengths[$currentsub['units'] . 's'];
             }
             $subscription['cost'][$key]['subscription_length'] = construct_phrase($vbphrase['length_x_units_y_recurring_z'], $currentsub['length'], $currentsub['units'], $currentsub['recurring'] ? " ({$vbphrase['recurring']})" : '');
         }
         if (isset($subscribed["{$subscription['subscriptionid']}"])) {
             // This subscription has been subscribed by the user
             $subscribedsubscriptions[$subscriptionid] = $subscription;
             $subscribedsubscriptions[$subscriptionid]['subscribed'] = $subscribed["{$subscription['subscriptionid']}"];
         }
         if ($subscription['active']) {
             if ($isreg and empty($subscription['newoptions']['regshow'])) {
                 // Display paid subscription during registration is set to false
                 continue;
             }
             // Check whether to show the subscription to the user.
             if (!empty($subscription['deniedgroups']) and ($allow_secondary_groups and !count(array_diff($membergroupids, $subscription['deniedgroups'])) or !$allow_secondary_groups and in_array($userinfo['usergroupid'], $subscription['deniedgroups']))) {
                 continue;
             }
             // List allowed payment apis
             $allowedapis = array();
             foreach ((array) $subscription['newoptions']['api'] as $api => $options) {
                 if (!empty($options['show'])) {
                     $allowedapis[] = $api;
                 }
             }
             $subscription['allowedapis'] = json_encode($allowedapis);
             $cansubscribesubscriptions[$subscriptionid] = $subscription;
         }
     }
     if (!$cansubscribesubscriptions and !$subscribedsubscriptions) {
         return array();
     }
     return array('subscribed' => $subscribedsubscriptions, 'cansubscribe' => $cansubscribesubscriptions, 'paymentapis' => $this->apicache, 'currencysymbols' => $this->subobj->_CURRENCYSYMBOLS);
 }
/**
* 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;
}
 /**
  * Verifies that the specified nodeid is valid
  *
  * @param	integer	Forum ID (allow -1 = all forums)
  *
  * @return	boolean
  */
 function verify_nodeid(&$forumid)
 {
     $channels = vB_Api::instanceInternal('search')->getChannels(true);
     if ($forumid == -1 or isset($channels["{$forumid}"])) {
         return true;
     } else {
         $this->error('invalid_forum_specified');
         return false;
     }
 }
function build_bbcode_video($checktable = false)
{
    if ($checktable) {
        try {
            vB::getDbAssertor()->assertQuery('bbcode_video', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT));
        } catch (Exception $e) {
            return false;
        }
    }
    require_once DIR . '/includes/class_xml.php';
    $xmlobj = new vB_XML_Parser(false, DIR . '/includes/xml/bbcode_video_vbulletin.xml');
    $data = $xmlobj->parse();
    if (is_array($data['provider'])) {
        $insert = array();
        foreach ($data['provider'] as $provider) {
            $items = array();
            $items['tagoption'] = $provider['tagoption'];
            $items['provider'] = $provider['title'];
            $items['url'] = $provider['url'];
            $items['regex_url'] = $provider['regex_url'];
            $items['regex_scrape'] = $provider['regex_scrape'];
            $items['embed'] = $provider['embed'];
            $insert[] = $items;
        }
        if (!empty($insert)) {
            vB::getDbAssertor()->assertQuery('truncateTable', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_METHOD, 'table' => 'bbcode_video'));
            vB::getDbAssertor()->assertQuery('bbcode_video', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_MULTIPLEINSERT, vB_dB_Query::FIELDS_KEY => array('tagoption', 'provider', 'url', 'regex_url', 'regex_scrape', 'embed'), vB_dB_Query::VALUES_KEY => $insert));
        }
    }
    $firsttag = '<vb:if condition="$provider == \'%1$s\'">';
    $secondtag = '<vb:elseif condition="$provider == \'%1$s\'" />';
    $template = array();
    $bbcodes = vB::getDbAssertor()->assertQuery('bbcode_video', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT), array('field' => array('priority'), 'direction' => array(vB_dB_Query::SORT_ASC)));
    foreach ($bbcodes as $bbcode) {
        if (empty($template)) {
            $template[] = sprintf($firsttag, $bbcode['tagoption']);
        } else {
            $template[] = sprintf($secondtag, $bbcode['tagoption']);
        }
        $template[] = $bbcode['embed'];
    }
    $template[] = "</vb:if>";
    $final = implode("\r\n", $template);
    $exists = vB::getDbAssertor()->getRow('template', array(vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'title', 'value' => 'bbcode_video', 'operator' => vB_dB_Query::OPERATOR_EQ), array('field' => 'product', 'value' => array('', 'vbulletin'), 'operator' => vB_dB_Query::OPERATOR_EQ), array('field' => 'styleid', 'value' => -1, 'operator' => vB_dB_Query::OPERATOR_EQ))));
    if ($exists) {
        try {
            vB_Api::instanceInternal('template')->update($exists['templateid'], 'bbcode_video', $final, 'vbulletin', false, false, '');
        } catch (Exception $e) {
            return false;
        }
    } else {
        vB_Api::instanceInternal('template')->insert(-1, 'bbcode_video', $final, 'vbulletin');
    }
    return true;
}
Example #15
0
 function appendAttachments($nodeid, $posthash)
 {
     if (!empty($posthash) and !empty($nodeid)) {
         $filedataids = vB_Library::instance('vb4_posthash')->getFiledataids($posthash);
         foreach ($filedataids as $filedataid) {
             $result = vB_Api::instance('node')->addAttachment($nodeid, array('filedataid' => $filedataid['filedataid']));
             if (empty($result) || !empty($result['errors'])) {
                 // Ignore attachment errors
             }
         }
     }
 }
Example #16
0
 protected function buildOutputFromItems($items, $options)
 {
     parent::buildOutputFromItems($items, $options);
     if ($this->rssinfo['ttl'] <= 60) {
         $updateperiod = 'hourly';
         $updatefrequency = round(60 / $this->rssinfo['ttl']);
     } else {
         $updateperiod = 'daily';
         $updatefrequency = round(1440 / $this->rssinfo['ttl']);
     }
     $xml = new vB_Xml_Builder();
     $xml->add_group('rdf:RDF', array('xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:syn' => 'http://purl.org/rss/1.0/modules/syndication/', 'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/', 'xmlns' => 'http://purl.org/rss/1.0/'));
     $xml->add_group('channel', array('rdf:about' => $this->rssinfo['link']));
     $xml->add_tag('title', $this->rssinfo['title']);
     $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true);
     $xml->add_tag('description', $this->rssinfo['description']);
     $xml->add_tag('syn:updatePeriod', $updateperiod);
     $xml->add_tag('syn:updateFrequency', $updatefrequency);
     $xml->add_tag('syn:updateBase', '1970-01-01T00:00Z');
     $xml->add_tag('dc:language', $this->defaultLang['languagecode']);
     $xml->add_tag('dc:creator', 'vBulletin');
     $xml->add_tag('dc:date', gmdate('Y-m-d\\TH:i:s') . 'Z');
     $xml->add_group('items');
     $xml->add_group('rdf:Seq');
     $xml->add_tag('rdf:li', '', array('rdf:resource' => $this->rssinfo['link'] . '/'));
     $xml->close_group('rdf:Seq');
     $xml->close_group('items');
     $xml->add_group('image');
     $xml->add_tag('url', $this->rssinfo['icon']);
     $xml->add_tag('title', $this->rssinfo['title']);
     $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true);
     $xml->close_group('image');
     $xml->close_group('channel');
     // gather channel info
     $channelsInfo = $this->getItemsChannelInfo($items);
     $items = $this->formatItems($items, $options);
     foreach ($items as $id => $item) {
         $item = $item['content'];
         $xml->add_group('item', array('rdf:about' => vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['external_nodeid'])));
         $xml->add_tag('title', $item['external_prefix_plain'] . vB_String::htmlSpecialCharsUni($item['external_title']));
         $xml->add_tag('link', vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['external_nodeid']), array(), false, true);
         $xml->add_tag('description', $this->getItemDescription($item['rawtext'], $options));
         if (empty($options['nohtml'])) {
             $xml->add_tag('content:encoded', vB_Library::instance('bbcode')->doParse($item['rawtext']));
         }
         $xml->add_tag('dc:date', gmdate('Y-m-d\\TH:i:s', $item['publishdate']) . 'Z');
         $xml->add_tag('dc:creator', vB_String::unHtmlSpecialChars($item['authorname']));
         $xml->add_tag('dc:subject', $channelsInfo[$item['channelid']]['htmltitle']);
         $xml->close_group('item');
     }
     $xml->close_group('rdf:RDF');
     return $xml->fetch_xml();
 }
Example #17
0
function do_upload_avatar()
{
    $cleaned = vB::getCleaner()->cleanArray($_REQUEST, array('upload' => vB_Cleaner::TYPE_FILE));
    if (empty($cleaned['upload'])) {
        return json_error(ERR_NO_PERMISSION);
    }
    $upload_result = vB_Api::instance('profile')->upload($cleaned['upload']);
    if (!empty($upload_result['errors'])) {
        return json_error(ERR_NO_PERMISSION);
    }
    return true;
}
Example #18
0
 protected function getNewRouteInfo()
 {
     // go to home page if path is exactly like prefix
     if (count($this->matches) == 1 and empty($this->queryParameters)) {
         $blogHomeChannelId = vB_Api::instance('blog')->getBlogChannel();
         $blogHomeChannel = vB_Library::instance('content_channel')->getBareContent($blogHomeChannelId);
         $blogHomeChannel = $blogHomeChannel[$blogHomeChannelId];
         return $blogHomeChannel['routeid'];
     }
     $this->oldcontenttypeid = vB_Api_ContentType::OLDTYPE_BLOGCHANNEL;
     return parent::getNewRouteInfo();
 }
Example #19
0
 public function buddylist()
 {
     $followers = vB_Api::instance('follow')->getFollowers($userid, array('page' => $pagenumber, 'perpage' => $perpage));
     if ($followers === null || isset($followers['errors'])) {
         return vB_Library::instance('vb4_functions')->getErrorResponse($followers);
     }
     $friends = array();
     foreach ($followers['results'] as $friend) {
         $friends[] = array('buddy' => array('userid' => $friend['userid'], 'username' => $friend['username']));
     }
     return array('response' => array('offlineusers' => $friends));
 }
Example #20
0
 public function checkApiState($method)
 {
     if (in_array($method, $this->disableFalseReturnOnly)) {
         return false;
     } else {
         if (!in_array($method, $this->disableWhiteList)) {
             // we need to fetch options even without a session to verify
             parent::checkApiState($method);
         }
     }
     return true;
 }
 public function message($message, $userid)
 {
     $cleaner = vB::getCleaner();
     $message = $cleaner->clean($message, vB_Cleaner::TYPE_STR);
     $userid = $cleaner->clean($userid, vB_Cleaner::TYPE_STR);
     $parentid = vB_Api::instanceInternal('node')->fetchVMChannel();
     $data = array('title' => '(Untitled)', 'parentid' => $parentid, 'channelid' => '', 'nodeid' => '', 'setfor' => $userid, 'rawtext' => $message);
     $result = vB_Api::instanceInternal('content_text')->add($data, array('wysiwyg' => false));
     if (!empty($result['errors'])) {
         return array('response' => array('postpreview' => array('invalidid')));
     }
     return array('response' => array('errormessage' => array('visitormessagethanks')));
 }
Example #22
0
 protected function getNewRouteInfo()
 {
     $param =& $this->queryParameters;
     if (!empty($param['faq'])) {
         try {
             $section = $param['faq'];
             $answer = vB_Api::instanceInternal('help')->getAnswer($section);
             $this->anchor = $answer['firstItem']['path'];
         } catch (Exception $e) {
         }
     }
     return 'help';
 }
 /**
  * Returns the HTML to be displayed to the user for Human Verification
  *
  * @param	string	Passed to template
  *
  * @return 	string	HTML to output
  *
  */
 function output_token($var_prefix = 'humanverify')
 {
     global $vbphrase, $show;
     $vbulletin =& $this->registry;
     $humanverify = $this->generate_token();
     $phraseAux = vB_Api::instanceInternal('phrase')->fetch(array('question' . $humanverify['answer']));
     $humanverify['question'] = $phraseAux['question' . $humanverify['answer']];
     $templater = vB_Template::create('humanverify_question');
     $templater->register('humanverify', $humanverify);
     $templater->register('var_prefix', $var_prefix);
     $output = $templater->render();
     return $output;
 }
Example #24
0
 /**
  * Moves all blog channels from the old blog channel parent to the new one.
  * @param int $oldChannelId
  * @param int $newChannelId
  */
 public static function moveBlogChannels($oldChannelId, $newChannelId)
 {
     if (empty($oldChannelId)) {
         $oldChannelId = vB::getDbAssertor()->getField('vBForum:channel', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'guid' => self::DEFAULT_BLOG_PARENT));
     }
     $children = vB::getDbAssertor()->assertQuery('vBForum:closure', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'parent' => $oldChannelId, 'depth' => 1));
     $childrenIds = array();
     foreach ($children as $child) {
         $childrenIds[] = $child['child'];
     }
     if (!empty($childrenIds)) {
         vB_Api::instanceInternal('node')->moveNodes($childrenIds, $newChannelId);
     }
 }
Example #25
0
 public function editpost($postid)
 {
     $cleaner = vB::getCleaner();
     $postid = $cleaner->clean($postid, vB_Cleaner::TYPE_UINT);
     $post = vB_Api::instance('node')->getFullContentforNodes(array($postid));
     if (empty($post)) {
         return array("response" => array("errormessage" => array("invalidid")));
     }
     $post = $post[0];
     $prefixes = vB_Library::instance('vb4_functions')->getPrefixes($postid);
     $options = vB::getDatastore()->getValue('options');
     $out = array('show' => array('tag_option' => 1), 'vboptions' => array('postminchars' => $options['postminchars'], 'titlemaxchars' => $options['titlemaxchars']), 'response' => array('prefix_options' => $prefixes, 'poststarttime' => 0, 'posthash' => vB_Library::instance('vb4_posthash')->getNewPosthash()));
     return $out;
 }
 protected function addAdditionalRecipients()
 {
     $skipUsers = array();
     /*
     			TODO: if we get ignore list caching in memory, add them to the skip list.
     */
     if (!empty($this->notificationData['sender'])) {
         $skipUsers[$this->notificationData['sender']] = (int) $this->notificationData['sender'];
     }
     $apiResult = vB_Api::instanceInternal('follow')->getSubscribersForNotifications($this->notificationData['sentbynodeid'], $skipUsers);
     $subscribers = $apiResult['subscribers'];
     // Subscribers should be an array keyed by userids.
     return array_keys($subscribers);
 }
Example #27
0
 /**
  * Login with fabecook logged user
  *
  * @param  [string] $signed_request [fb info]
  * @return [array]                  [response -> errormessage and session params]
  */
 public function facebook($signed_request)
 {
     $cleaner = vB::getCleaner();
     $signed_request = $cleaner->clean($signed_request, vB_Cleaner::TYPE_STR);
     $user_api = vB_Api::instance('user');
     $loginInfo = $user_api->loginExternal('facebook', array('signedrequest' => $signed_request));
     if (empty($loginInfo) || isset($loginInfo['errors'])) {
         //the api doesn't allow us to be that specific about our errors here.
         //and the app gets very cranky if the login returns an unexpected error code
         return array('response' => array('errormessage' => array('badlogin_facebook')));
     }
     $result = array('session' => array('dbsessionhash' => $loginInfo['login']['sessionhash'], 'userid' => $loginInfo['login']['userid']), 'response' => array('errormessage' => array('redirect_login')));
     return $result;
 }
Example #28
0
function getFullCategoryList(&$channelInfoArray = array(), $tabsize = 1, $tabchar = "--", $tabspace = " ")
{
    $cache = vB_Cache::instance(vB_Cache::CACHE_STD);
    $cacheKey = "vBAdminCP_CMS_Categories";
    $categories = $cache->read($cacheKey);
    $writeCache = false;
    $cacheEvents = array();
    if (empty($categories)) {
        $categories = vB::getDbAssertor()->getRows('vBAdminCP:getCMSChannels', array('articleChannelId' => vB_Api::instanceInternal('node')->fetchArticleChannel(), 'channelcontenttype' => vB_Api::instanceInternal('ContentType')->fetchContentTypeIdFromClass('Channel')));
        $writeCache = true;
    }
    $categoriesList = array();
    // The query result is sorted by depth first. We have to group/sort into a hierarchical order, such that
    // children come immediately after a parent.
    $parent_position = array();
    // parentid => position
    $nodeid_index = array();
    // nodeid => search result index
    foreach ($categories as $index => $category) {
        $cacheEvents[] = 'nodeChg_' . $category['nodeid'];
        $parentid = $category['parentid'];
        $nodeid_index[$category['nodeid']] = $index;
        if (empty($parent_position)) {
            $parent_position[$category['nodeid']] = 0;
        } else {
            $position = $parent_position[$parentid] + 1;
            // increment positions of parents whose positions are after $position
            foreach ($parent_position as $pid => $pos) {
                if ($pos >= $position) {
                    $parent_position[$pid]++;
                }
            }
            // node will be positioned after its parent, but above any siblings. This is why all but the depth is sort order DESC in the query.
            $parent_position[$category['nodeid']] = $position;
        }
    }
    // sort parent_position by position
    asort($parent_position);
    foreach ($parent_position as $nodeid => $position) {
        $category = $categories[$nodeid_index[$nodeid]];
        $channelInfoArray[$category['nodeid']] = array("title" => $category['htmltitle'], "parentid" => $category['parentid'], "showpublished" => $category['showpublished'], "textcount" => $category['textcount'], "displayorder" => $category['displayorder'], "description" => $category['description']);
        $tab = str_repeat($tabchar, $category['depth'] * $tabsize) . $tabspace;
        $categoriesList[$category['nodeid']] = $tab . $category['htmltitle'];
    }
    if ($writeCache) {
        $cache->write($cacheKey, $categories, 1440, $cacheEvents);
    }
    return $categoriesList;
}
Example #29
0
 public function docopythread($threadid, $destforumid)
 {
     $cleaner = vB::getCleaner();
     $threadid = $cleaner->clean($threadid, vB_Cleaner::TYPE_UINT);
     $destforumid = $cleaner->clean($destforumid, vB_Cleaner::TYPE_UINT);
     if (empty($threadid) || empty($destforumid)) {
         return array('response' => array('errormessage' => 'invalidid'));
     }
     $result = vB_Api::instance('node')->cloneNodes(array($threadid), $destforumid);
     if ($result === null || isset($result['errors'])) {
         return vB_Library::instance('vb4_functions')->getErrorResponse($result);
     } else {
         return array('response' => array('errormessage' => array('redirect_movethread')));
     }
 }
Example #30
0
 public function getXmlHooks()
 {
     if (!$this->hasPermission()) {
         return false;
     }
     $typelist = array();
     $hooklocations = array();
     require_once DIR . '/includes/class_xml.php';
     $types = $this->assertor->getRows('getHooktypePhrases');
     $hookfiles = vB_Api_Product::loadProductXmlList('hooks');
     foreach ($types as $type) {
         $typelist[] = $type['varname'];
     }
     $vbphrase = vB_Api::instanceInternal('phrase')->fetch($typelist);
     foreach ($hookfiles as $file) {
         if (!preg_match('#hooks_(.*).xml$#i', $file, $matches)) {
             continue;
         }
         $product = $matches[1];
         $phrased_product = $products[$product ? $product : 'vbulletin'];
         if (!$phrased_product) {
             $phrased_product = $product;
         }
         $xmlobj = new vB_XML_Parser(false, $location . $file);
         $xml = $xmlobj->parse();
         if (!is_array($xml['hooktype'][0])) {
             $xml['hooktype'] = array($xml['hooktype']);
         }
         foreach ($xml['hooktype'] as $key => $hooks) {
             if (!is_numeric($key)) {
                 continue;
             }
             $phrased_type = isset($vbphrase["hooktype_{$hooks['type']}"]) ? $vbphrase["hooktype_{$hooks['type']}"] : $hooks['type'];
             $hooktype = $phrased_type;
             $hooklocations["#{$hooktype}#"] = $hooktype;
             if (!is_array($hooks['hook'])) {
                 $hooks['hook'] = array($hooks['hook']);
             }
             foreach ($hooks['hook'] as $hook) {
                 $hookid = trim(is_string($hook) ? $hook : $hook['value']);
                 if ($hookid !== '') {
                     $hooklocations[$hookid] = '--- ' . $hookid . ($product != 'vbulletin' ? " ({$phrased_product})" : '');
                 }
             }
         }
     }
     return $hooklocations;
 }