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;
 }
Beispiel #2
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();
 }
Beispiel #3
0
 protected function buildOutputFromItems($items, $options)
 {
     $xml = new vB_XML_Builder();
     $xml->add_group('source');
     $xml->add_tag('url', vB::getDatastore()->getOption('frontendurl') . '/');
     $items = $this->formatItems($items, $options);
     foreach ($items as $id => $item) {
         $item = $item['content'];
         $xml->add_group('thread', array('id' => $item['external_nodeid']));
         $xml->add_tag('title', $item['external_prefix_plain'] . vB_String::unHtmlSpecialChars($item['external_title']));
         $xml->add_tag('author', vB_String::unHtmlSpecialChars($item['authorname']));
         $xml->add_tag('date', $this->callvBDate(vB::getDatastore()->getOption('dateformat'), $item['publishdate']));
         $xml->add_tag('time', $this->callvBDate(vB::getDatastore()->getOption('timeformat'), $item['publishdate']));
         $xml->close_group('thread');
     }
     $xml->close_group('source');
     return $xml->fetch_xml();
 }
Beispiel #4
0
 protected function buildOutputFromItems($items, $options)
 {
     parent::buildOutputFromItems($items, $options);
     $xml = new vB_Xml_Builder();
     $xml->add_group('rss', array('version' => '2.0', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/'));
     $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_tag('lastBuildDate', gmdate('D, d M Y H:i:s') . ' GMT');
     $xml->add_tag('generator', 'vBulletin');
     $xml->add_tag('ttl', $this->rssinfo['ttl']);
     $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');
     // 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('pubDate', gmdate('D, d M Y H:i:s', $item['publishdate']) . ' GMT');
         $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('category', $channelsInfo[$item['channelid']]['htmltitle'], array('domain' => vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['channelid'])));
         $xml->add_tag('dc:creator', vB_String::unHtmlSpecialChars($item['authorname']));
         $xml->add_tag('guid', vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['external_nodeid']), array('isPermaLink' => 'true'));
         $xml->close_group('item');
     }
     $xml->close_group('channel');
     $xml->close_group('rss');
     return $xml->fetch_xml();
 }
     $userinfo = $getuserid;
     if (!$userinfo) {
         print_stop_message2('invalid_user_specified');
     }
 } else {
     if ($vbulletin->GPC['userid']) {
         $userid = $vbulletin->GPC['userid'];
         try {
             $userinfo = vB_Api::instanceInternal('user')->fetchUserInfo($vbulletin->GPC['userid']);
         } catch (vB_Exception_Api $ex) {
             $userinfo = false;
         }
         if (!$userinfo) {
             print_stop_message2('invalid_user_specified');
         }
         $vbulletin->GPC['username'] = vB_String::unHtmlSpecialChars($userinfo['username']);
     } else {
         $userid = 0;
     }
 }
 if ($vbulletin->GPC['ipaddress'] or $userid) {
     if ($vbulletin->GPC['ipaddress']) {
         print_form_header('', '');
         print_table_header(construct_phrase($vbphrase['ip_address_search_for_ip_address_x'], $vbulletin->GPC['ipaddress']));
         $hostname = @gethostbyaddr($vbulletin->GPC['ipaddress']);
         if (!$hostname or $hostname == $vbulletin->GPC['ipaddress']) {
             $hostname = $vbphrase['could_not_resolve_hostname'];
         }
         print_description_row("<div style=\"margin-" . vB_Template_Runtime::fetchStyleVar('left') . ":20px\"><a href=\"usertools.php?" . vB::getCurrentSession()->get('sessionurl') . "do=gethost&amp;ip=" . $vbulletin->GPC['ipaddress'] . "\">" . $vbulletin->GPC['ipaddress'] . "</a> : <b>{$hostname}</b></div>");
         $results = construct_ip_usage_table($vbulletin->GPC['ipaddress'], 0, $vbulletin->GPC['depth']);
         print_description_row($vbphrase['post_ip_addresses'], false, 2, 'thead');
Beispiel #6
0
 /**
  * Returns suggested usernames for the username autocomplete popup menu.
  *
  * @param  string Text to search for, must be at least 3 chars long.
  * @param  string Sort field, default 'username'
  * @param  string Sort order, default 'ASC'
  * @param  int    [Not used, always starts from 0] Offset to start searching from, default 0
  * @param  int    Max number of suggestions to return, default 15, max 15
  *
  * @return array  Array containing one element "suggestions" which is an array.
  *                Each element is an array containing:
  *                    'title' => username without html entities
  *                    'value' => username
  *                    'id' => userid
  */
 public function getAutocomplete($searchStr, $orderby = 'username', $direction = 'ASC', $limitstart = 0, $limitnumber = 15)
 {
     $cleaner = vB::getCleaner();
     $searchStr = $cleaner->clean($searchStr, vB_Cleaner::TYPE_STR);
     $orderby = $cleaner->clean($orderby, vB_Cleaner::TYPE_NOHTML);
     $direction = $cleaner->clean($direction, vB_Cleaner::TYPE_NOHTML);
     $limitstart = $cleaner->clean($limitstart, vB_Cleaner::TYPE_UINT);
     $limitnumber = $cleaner->clean($limitnumber, vB_Cleaner::TYPE_UINT);
     if (strlen($searchStr) < 3) {
         return array('suggestions' => array());
     }
     if ($limitnumber > 15) {
         $limitnumber = 15;
     }
     // always force $limitstart to be 0
     // I'm doing this because previously limitstart wasn't being respected
     // and I don't want to introduce a new problem by enabling it now.
     // if we actually need to use it, we just need to remove this line.
     $limitstart = 0;
     $direction = strtoupper($direction) === 'DESC' ? 'DESC' : 'ASC';
     $query = vB::getDbAssertor()->assertQuery('user', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'username', 'value' => "{$searchStr}", 'operator' => vB_dB_Query::OPERATOR_BEGINS)), vB_dB_Query::FIELDS_KEY => array('username', 'userid'), vB_dB_Query::PARAM_LIMITSTART => $limitstart, vB_dB_Query::PARAM_LIMIT => $limitnumber), array('field' => $orderby, 'direction' => $direction));
     $matching_users = array();
     if ($query and $query->valid()) {
         foreach ($query as $user) {
             $matching_users[] = array('title' => vB_String::unHtmlSpecialChars($user['username']), 'value' => $user['username'], 'id' => $user['userid']);
         }
     }
     return array('suggestions' => $matching_users);
 }
Beispiel #7
0
 /**
  * Starts the process of sending an email - preps it so it's fully ready to send.
  * Call send() to actually send it.
  *
  * @param string	$toemail Destination email address
  * @param string	$subject Email message subject
  * @param string	$message Email message body
  * @param string	$from Optional name/email to use in 'From' header
  * @param string	$uheaders Additional headers
  * @param string	$username Username of person sending the email
  *
  * @return boolean True on success, false on failure
  */
 public function start($toemail, $subject, $message, $from = '', $uheaders = '', $username = '')
 {
     $toemail = $this->fetchFirstLine($toemail);
     if (empty($toemail)) {
         return false;
     }
     $delimiter =& $this->delimiter;
     $vboptions = vB::getDatastore()->getValue('options');
     $toemail = vB_String::unHtmlSpecialChars($toemail);
     $subject = $this->fetchFirstLine($subject);
     $message = preg_replace("#(\r\n|\r|\n)#s", $delimiter, trim($message));
     if ((strtolower(vB_Template_Runtime::fetchStyleVar('charset')) == 'iso-8859-1' or vB_Template_Runtime::fetchStyleVar('charset') == '') and preg_match('/&[a-z0-9#]+;/i', $message)) {
         $message = utf8_encode($message);
         $subject = utf8_encode($subject);
         $username = utf8_encode($username);
         $encoding = 'UTF-8';
         $unicode_decode = true;
     } else {
         if ($vboptions['utf8encode']) {
             $message = to_utf8($message, vB_Template_Runtime::fetchStyleVar('charset'));
             $subject = to_utf8($subject, vB_Template_Runtime::fetchStyleVar('charset'));
             $username = to_utf8($username, vB_Template_Runtime::fetchStyleVar('charset'));
             $encoding = 'UTF-8';
             $unicode_decode = true;
         } else {
             // we know nothing about the message's encoding in relation to UTF-8,
             // so we can't modify the message at all; just set the encoding
             $encoding = vB_Template_Runtime::fetchStyleVar('charset');
             $unicode_decode = false;
         }
     }
     // theses lines may need to call convert_int_to_utf8 directly
     $message = vB_String::unHtmlSpecialChars($message, $unicode_decode);
     $subject = $this->encodeEmailHeader(vB_String::unHtmlSpecialChars($subject, $unicode_decode), $encoding, false, false);
     $from = $this->fetchFirstLine($from);
     if (empty($from)) {
         $vbphrase = vB_Api::instanceInternal('phrase')->fetch(array('x_mailer'));
         if (isset($vbphrase['x_mailer'])) {
             $mailfromname = sprintf($this->fetchFirstLine($vbphrase['x_mailer']), $vboptions['bbtitle']);
         } else {
             $mailfromname = $vboptions['bbtitle'];
         }
         if ($unicode_decode == true) {
             $mailfromname = utf8_encode($mailfromname);
         }
         $mailfromname = $this->encodeEmailHeader(vB_String::unHtmlSpecialChars($mailfromname, $unicode_decode), $encoding);
         $headers = "From: {$mailfromname} <" . $vboptions['webmasteremail'] . '>' . $delimiter;
         $headers .= 'Auto-Submitted: auto-generated' . $delimiter;
         // Exchange (Oh Microsoft) doesn't respect auto-generated: http://www.vbulletin.com/forum/project.php?issueid=27687
         if ($vboptions['usebulkheader']) {
             $headers .= 'Precedence: bulk' . $delimiter;
         }
     } else {
         if ($username) {
             $mailfromname = "{$username} @ " . $vboptions['bbtitle'];
         } else {
             $mailfromname = $from;
         }
         if ($unicode_decode == true) {
             $mailfromname = utf8_encode($mailfromname);
         }
         $mailfromname = $this->encodeEmailHeader(vB_String::unHtmlSpecialChars($mailfromname, $unicode_decode), $encoding);
         $headers = "From: {$mailfromname} <{$from}>" . $delimiter;
         $headers .= "Sender: " . $vboptions['webmasteremail'] . $delimiter;
     }
     $fromemail = empty($vboptions['bounceemail']) ? $vboptions['webmasteremail'] : $vboptions['bounceemail'];
     $headers .= 'Return-Path: ' . $fromemail . $delimiter;
     $http_host = vB::getRequest()->getVbHttpHost();
     if (!$http_host) {
         $http_host = substr(md5($message), 12, 18) . '.vb_unknown.unknown';
     }
     $msgid = '<' . gmdate('YmdHis') . '.' . substr(md5($message . microtime()), 0, 12) . '@' . $http_host . '>';
     $headers .= 'Message-ID: ' . $msgid . $delimiter;
     $headers .= preg_replace("#(\r\n|\r|\n)#s", $delimiter, $uheaders);
     unset($uheaders);
     $headers .= 'MIME-Version: 1.0' . $delimiter;
     $headers .= 'Content-Type: text/plain' . iif($encoding, "; charset=\"{$encoding}\"") . $delimiter;
     $headers .= 'Content-Transfer-Encoding: 8bit' . $delimiter;
     $headers .= 'X-Priority: 3' . $delimiter;
     $headers .= 'X-Mailer: vBulletin Mail via PHP' . $delimiter;
     if (!empty($vboptions['extra_smtp_headers'])) {
         $headers .= preg_replace("#\r[^\n]|[^r]\n#", $delimiter, $vboptions['extra_smtp_headers']) . $delimiter;
     }
     $this->toemail = $toemail;
     $this->subject = $subject;
     $this->message = $message;
     $this->headers = $headers;
     $this->fromemail = $fromemail;
     return true;
 }
Beispiel #8
0
 /**
  * Handles an [img] tag.
  *
  * @param	string	The text to search for an image in.
  * @param	string	Whether to parse matching images into pictures or just links.
  *
  * @return	string	HTML representation of the tag.
  */
 function handle_bbcode_img($bbcode, $do_imgcode, $has_img_code = false, $fulltext = '', $forceShowImages = false)
 {
     $sessionurl = self::$sessionUrl;
     $showImages = (self::getUserValue('userid') == 0 or self::getUserValue('showimages') or $forceShowImages);
     /* Do search on $fulltext, which would be the entire article, not just a page of the article which would be in $page */
     if (!$fulltext) {
         $fulltext = $bbcode;
     }
     if ($has_img_code & self::BBCODE_HAS_ATTACH and preg_match_all('#\\[attach(?:=(right|left|config))?\\]([[:alnum:]]+)\\[/attach\\]#i', $fulltext, $matches)) {
         $legacyIds = $attachmentIds = array();
         foreach ($matches[2] as $key => $attachmentid) {
             $align = $matches[1]["{$key}"];
             $search[] = '#\\[attach(' . (!empty($align) ? '=' . $align : '') . ')\\](' . $attachmentid . ')\\[/attach\\]#i';
             // We need to decide whether it's a legacy attachment or a vB5 one
             if (preg_match('#^n(\\d+)$#', $attachmentid, $matches2)) {
                 // if the id has 'n' as prefix, it's a nodeid
                 $attachmentIds[] = intval($matches2[1]);
             } else {
                 // it's a legacy attachmentid
                 $legacyIds[] = intval($attachmentid);
             }
         }
         if (!empty($legacyIds)) {
             $this->oldAttachments = vB_Api::instanceInternal('filedata')->fetchLegacyAttachments($legacyIds);
             $attachmentIds += array_values($this->oldAttachments);
         }
         // we may already have the attachments (see vB5_Template_NodeText)
         if (!empty($this->attachments)) {
             $attachmentIds = array_diff(array_unique($attachmentIds), array_keys($this->attachments));
         }
         if (!empty($attachmentIds)) {
             $attachments = vB_Api::instanceInternal('filedata')->fetchFiledataByid($attachmentIds);
             $this->setAttachments($attachments);
         }
         $bbcode = preg_replace_callback($search, array($this, 'attachReplaceCallback'), $bbcode);
     }
     /*
     			VBV-12051 - Check for legacy [IMG] code using filedataid
     			Since we know that the filedata/fetch?filedataid URL only works for publicview
     			filedata (generally channel icons, forum logo, sigpics, theme icons and the like),
     			let's assume that any [IMG] tag with a filedataid that's used by any *remaining*
     			attachments (after above attachReplaceCallback) is an incorrect inline-inserted
     			attachment image, and replace them with the proper image tags.
     			This can cause some weirdness, like multiple [attach] bbcodes with the same nodeid,
     			but I think this is better than the current broken behavior (where filedataid img
     			will only show for the poster, and the attachment associated with the filedataid
     			is listed in the  bbcode_attachment_list)
     */
     $baseURL = vB5_Template_Options::instance()->get('options.frontendurl');
     /*
     $expectedPrefix = preg_quote($baseURL . '/filedata/fetch?filedataid=', '#');
     $regex = '#\[img\]\s*' . $expectedPrefix . '(?<filedataid>[0-9]+?)(?<extra>[&\#][^*\r\n]*|[a-z0-9/\\._\- !]*)\[/img\]#iU';
     */
     $expectedPrefix = preg_quote($baseURL . '/filedata/fetch?', '#');
     $regex = '#\\[img\\]\\s*' . $expectedPrefix . '(?<querystring>[^\\s]*filedataid=(?<filedataid>[0-9]+?)[^\\s]*)\\s*\\[/img\\]#iU';
     if ($has_img_code & self::BBCODE_HAS_IMG and preg_match_all($regex, $bbcode, $matches)) {
         if (!empty($matches['filedataid'])) {
             $searchForCallback = array();
             $searchForStrReplace = array();
             $replaceForStrReplace = array();
             $this->delayedUnsetAttachments = array();
             $oldUnsetattach = $this->unsetattach;
             $this->unsetattach = false;
             foreach ($matches['filedataid'] as $key => $filedataid) {
                 if (!empty($this->filedataidsToAttachmentids[$filedataid])) {
                     // There might be multiple attachments using the filedataid, but we just have
                     // no way of knowing which this one is supposed to be. Let's just walk through them.
                     $nodeid = current($this->filedataidsToAttachmentids[$filedataid]);
                     if (false === next($this->filedataidsToAttachmentids[$filedataid])) {
                         reset($this->filedataidsToAttachmentids[$filedataid]);
                     }
                     $searchForStrReplace[$key] = $matches[0][$key];
                     // 1 is align/config, 2 is "n{nodeid}"
                     $matchesForCallback = array(1 => '', 2 => "n{$nodeid}");
                     // grab size if provided in query string.
                     $querydata = array();
                     $querystring = vB_String::unHtmlSpecialChars($matches['querystring'][$key]);
                     parse_str($querystring, $querydata);
                     if (!empty($querydata['type'])) {
                         $matchesForCallback['settings'] = array('size' => $querydata['type']);
                     } elseif (!empty($querydata['thumb'])) {
                         $matchesForCallback['settings'] = array('size' => 'thumb');
                     }
                     $replaceForStrReplace[$key] = $this->attachReplaceCallback($matchesForCallback);
                 }
             }
             $this->unsetattach = $oldUnsetattach;
             /*
             					Temporarily turning off unsetattach & then doing the unset at the very end is required to
             					handle the edge case where multiple [img] bbcodes with the SAME filedataid exists.
             					If we don't turn off unsetattach, only the first instance will be replaced with an image tag.
             					If we turn off unsetattach and don't do this delayed unsetting, the attachment that was "used"
             					by the [img] matches will still remain to be listed in the attachments box.
             */
             if (!empty($this->delayedUnsetAttachments) and $this->unsetattach) {
                 foreach ($this->delayedUnsetAttachments as $arr) {
                     $attachmentid = $arr['attachmentid'];
                     $filedataid = $arr['filedataid'];
                     unset($this->attachments["{$attachmentid}"], $this->filedataidsToAttachmentids[$filedataid][$attachmentid]);
                 }
             }
             if (!empty($replaceForStrReplace)) {
                 $bbcode = str_replace($searchForStrReplace, $replaceForStrReplace, $bbcode);
             }
         }
     }
     if ($has_img_code & self::BBCODE_HAS_IMG) {
         if ($do_imgcode and $showImages) {
             // do [img]xxx[/img]
             $bbcode = preg_replace_callback('#\\[img\\]\\s*(https?://([^*\\r\\n]+|[a-z0-9/\\._\\- !]+))\\[/img\\]#iU', array($this, 'handleBbcodeImgMatchCallback'), $bbcode);
         } else {
             $bbcode = preg_replace_callback('#\\[img\\]\\s*(https?://([^*\\r\\n]+|[a-z0-9/\\._\\- !]+))\\[/img\\]#iU', array($this, 'handleBbcodeUrlCallback'), $bbcode);
         }
     }
     if ($has_img_code & self::BBCODE_HAS_SIGPIC) {
         $bbcode = preg_replace_callback('#\\[sigpic\\](.*)\\[/sigpic\\]#siU', array($this, 'handleBBCodeSicpicPregReplace'), $bbcode);
     }
     if ($has_img_code & self::BBCODE_HAS_RELPATH) {
         $bbcode = str_replace('[relpath][/relpath]', vB_String::htmlSpecialCharsUni(vB5_Request::get('vBUrlClean')), $bbcode);
     }
     return $bbcode;
 }
 function parseThreadInfo($node)
 {
     $info = array('title' => vB_String::unHtmlSpecialChars($node['title']), 'threadid' => $node['nodeid']);
     return $info;
 }
Beispiel #10
0
 /**
  * Handles an [img] tag.
  *
  * @param	string	The text to search for an image in.
  * @param	string	Whether to parse matching images into pictures or just links.
  *
  * @return	string	HTML representation of the tag.
  */
 function handle_bbcode_img($bbcode, $do_imgcode, $has_img_code = false, $fulltext = '', $forceShowImages = false)
 {
     $sessionurl = self::$sessionUrl;
     $showImages = (vB5_User::get('userid') == 0 or vB5_User::get('showimages') or $forceShowImages);
     /* Do search on $fulltext, which would be the entire article, not just a page of the article which would be in $page */
     if (!$fulltext) {
         $fulltext = $bbcode;
     }
     // Skip checking if inside a [QUOTE] or [NOPARSE] tag.
     $find = array('#\\[QUOTE[^\\]]*\\].*\\[/QUOTE\\]#siU', '#\\[NOPARSE\\].*\\[/NOPARSE\\]#siU');
     $replace = '';
     $fulltext_omit_noparse = preg_replace($find, $replace, $fulltext);
     // Prevent inline attachments from showing up in the attachments list
     $this->skipAttachmentList = array();
     // keep the regex roughly in sync with the one in text library's fixAttachBBCode()
     $attachRegex = '#\\[attach(?:=(?<align>[a-z]+))?\\](?<type>n|temp_)?(?<id>[0-9]+)(?<tempsuffix>[0-9_]+)?\\[/attach\\]#i';
     if ($has_img_code & self::BBCODE_HAS_ATTACH and preg_match_all($attachRegex, $fulltext_omit_noparse, $matches)) {
         if (!empty($matches['id'])) {
             $legacyIds = array();
             $searchForStrReplace = array();
             $replaceForStrReplace = array();
             $matchesForCallback = array();
             foreach ($matches['id'] as $key => $id) {
                 // full original, replace this with $replaceForStrReplace
                 $searchForStrReplace[$key] = $matches[0][$key];
                 // 0 is the full match, 1 is align/config, 2 is "n{nodeid}"
                 $matchesForCallback[$key] = array(0 => $matches[0][$key], 1 => !empty($matches['align'][$key]) ? $matches['align'][$key] : '', 2 => $matches['type'][$key] . $id . $matches['tempsuffix'][$key]);
                 switch ($matches['type'][$key]) {
                     case 'n':
                         $nodeid = 0;
                         // either a nodeid or a bugged filedataid.
                         if (!empty($this->attachments[$id])) {
                             // This is a normal one with an attachmentid
                             $nodeid = $id;
                             $filedataid = $this->attachments[$id]['filedataid'];
                         } else {
                             if (!empty($this->filedataidsToAttachmentids[$id])) {
                                 /*
                                  * VBV-10556  -  In addition to [IMG] bbcodes using filedataid URLs, there might be some old [ATTACH] bbcodes with
                                  * n{filedataid} instead of n{attachid}.
                                  * $id is a probably a filedataid, or just bogus. Since we can't tell the difference at this point, assume it's bugged not bogus.
                                  * There might be multiple attachments using the filedataid, but we just have
                                  * no way of knowing which this one is supposed to be. Let's just walk through them.
                                  */
                                 $filedataid = $id;
                                 $nodeid = current($this->filedataidsToAttachmentids[$id]);
                                 if (false === next($this->filedataidsToAttachmentids[$id])) {
                                     reset($this->filedataidsToAttachmentids[$id]);
                                 }
                             }
                         }
                         if (!empty($nodeid)) {
                             $matchesForCallback[$key][2] = "n{$nodeid}";
                             // Flag attachment for removal from array
                             if ($this->unsetattach) {
                                 $this->skipAttachmentList[$nodeid] = array('attachmentid' => $nodeid, 'filedataid' => $filedataid);
                             }
                         }
                         break;
                         // end case 'n'
                     // end case 'n'
                     case 'temp_':
                         // temporary id.
                         break;
                         // end case 'temp_'
                     // end case 'temp_'
                     default:
                         // most likely a legacy id.
                         $legacyIds[$key] = intval($id);
                         // The legacy attachments are set later, meaning it will fail the "filedataid" interpolation fixes
                         // but AFAIK that's okay, because those are vB5 bugs and shouldn't be using legacy ids.
                         break;
                         // end default case
                 }
             }
             // grab and set any legacy attachments.
             if (!empty($legacyIds)) {
                 $this->oldAttachments = Api_InterfaceAbstract::instance()->callApi('filedata', 'fetchLegacyAttachments', array($legacyIds));
                 if (!empty($this->oldAttachments)) {
                     $this->setAttachments($this->oldAttachments, true);
                 }
             }
             // Use attachReplaceCallback() to construct the replacements.
             foreach ($matchesForCallback as $key => $matchesArr) {
                 $replaceForStrReplace[$key] = $this->attachReplaceCallback($matchesArr);
                 if ($searchForStrReplace[$key] == $replaceForStrReplace[$key]) {
                     // No idea if PHP already optimizes this, but don't bother str_replace with the same value.
                     unset($searchForStrReplace[$key], $replaceForStrReplace[$key]);
                 }
             }
             if (!empty($replaceForStrReplace)) {
                 $bbcode = str_replace($searchForStrReplace, $replaceForStrReplace, $bbcode);
             }
         }
     }
     /*
     			VBV-12051 - Check for legacy [IMG] code using filedataid
     			Since we know that the filedata/fetch?filedataid URL only works for publicview
     			filedata (generally channel icons, forum logo, sigpics, theme icons and the like),
     			let's assume that any [IMG] tag with a filedataid that's used by any *remaining*
     			attachments (after above attachReplaceCallback) is an incorrect inline-inserted
     			attachment image, and replace them with the proper image tags.
     			This can cause some weirdness, like multiple [attach] bbcodes with the same nodeid,
     			but I think this is better than the current broken behavior (where filedataid img
     			will only show for the poster, and the attachment associated with the filedataid
     			is listed in the  bbcode_attachment_list)
     */
     $baseURL = vB5_Template_Options::instance()->get('options.frontendurl');
     /*
     $expectedPrefix = preg_quote($baseURL . '/filedata/fetch?filedataid=', '#');
     $regex = '#\[img\]\s*' . $expectedPrefix . '(?<filedataid>[0-9]+?)(?<extra>[&\#][^*\r\n]*|[a-z0-9/\\._\- !]*)\[/img\]#iU';
     */
     $expectedPrefix = preg_quote($baseURL . '/filedata/fetch?', '#');
     $regex = '#\\[img\\]\\s*' . $expectedPrefix . '(?<querystring>[^\\s]*filedataid=(?<filedataid>[0-9]+?)[^\\s]*)\\s*\\[/img\\]#iU';
     if ($has_img_code & self::BBCODE_HAS_IMG and preg_match_all($regex, $fulltext_omit_noparse, $matches)) {
         if (!empty($matches['filedataid'])) {
             $searchForStrReplace = array();
             $replaceForStrReplace = array();
             $matchesForCallback = array();
             foreach ($matches['filedataid'] as $key => $filedataid) {
                 if (!empty($this->filedataidsToAttachmentids[$filedataid])) {
                     // There might be multiple attachments using the filedataid, but we just have
                     // no way of knowing which this one is supposed to be. Let's just walk through them.
                     $nodeid = current($this->filedataidsToAttachmentids[$filedataid]);
                     if (false === next($this->filedataidsToAttachmentids[$filedataid])) {
                         reset($this->filedataidsToAttachmentids[$filedataid]);
                     }
                     $searchForStrReplace[$key] = $matches[0][$key];
                     // 0 is the full match, 1 is align/config, 2 is "n{nodeid}"
                     $matchesForCallback = array(0 => $matches[0][$key], 1 => '', 2 => "n{$nodeid}");
                     // grab size if provided in query string.
                     $querydata = array();
                     $querystring = vB_String::unHtmlSpecialChars($matches['querystring'][$key]);
                     parse_str($querystring, $querydata);
                     if (!empty($querydata['type'])) {
                         $matchesForCallback['settings'] = array('size' => $querydata['type']);
                     } elseif (!empty($querydata['thumb'])) {
                         $matchesForCallback['settings'] = array('size' => 'thumb');
                     }
                     $replaceForStrReplace[$key] = $this->attachReplaceCallback($matchesForCallback);
                     if ($searchForStrReplace[$key] == $replaceForStrReplace[$key]) {
                         // No idea if PHP already optimizes this, but don't bother str_replace with the same value.
                         unset($searchForStrReplace[$key], $replaceForStrReplace[$key]);
                     }
                     if ($this->unsetattach) {
                         $this->skipAttachmentList[$nodeid] = array('attachmentid' => $nodeid, 'filedataid' => $filedataid);
                     }
                 }
             }
             if (!empty($replaceForStrReplace)) {
                 $bbcode = str_replace($searchForStrReplace, $replaceForStrReplace, $bbcode);
             }
         }
     }
     // Now handle everything that was left behind. These are ones we just don't know how to "fix" because we
     // couldn't find an existing, remaining attachment that we can interpolate to.
     if ($has_img_code & self::BBCODE_HAS_ATTACH and !empty($search)) {
         $bbcode = preg_replace_callback($search, array($this, 'attachReplaceCallbackFinal'), $bbcode);
     }
     if ($has_img_code & self::BBCODE_HAS_IMG) {
         if ($do_imgcode and $showImages) {
             // do [img]xxx[/img]
             $bbcode = preg_replace_callback('#\\[img\\]\\s*(https?://([^*\\r\\n]+|[a-z0-9/\\._\\- !]+))\\[/img\\]#iU', array($this, 'handleBbcodeImgMatchCallback'), $bbcode);
         } else {
             $bbcode = preg_replace_callback('#\\[img\\]\\s*(https?://([^*\\r\\n]+|[a-z0-9/\\._\\- !]+))\\[/img\\]#iU', array($this, 'handleBbcodeUrlCallback'), $bbcode);
         }
     }
     if ($has_img_code & self::BBCODE_HAS_SIGPIC) {
         $bbcode = preg_replace_callback('#\\[sigpic\\](.*)\\[/sigpic\\]#siU', array($this, 'handleBBCodeSigPicCallback'), $bbcode);
     }
     if ($has_img_code & self::BBCODE_HAS_RELPATH) {
         $bbcode = str_replace('[relpath][/relpath]', vB5_String::htmlSpecialCharsUni(vB5_Request::get('vBUrlClean')), $bbcode);
     }
     return $bbcode;
 }
Beispiel #11
0
 /**
  * Attempts to do a character-based strlen on data that might contain HTML entities.
  * By default, it only converts numeric entities but can optional convert &quot;,
  * &lt;, etc. Uses a multi-byte aware function to do the counting if available.
  *
  * @param	string	String to be measured
  * @param	boolean	If true, run unhtmlspecialchars on string to count &quot; as one, etc.
  *
  * @return	integer	Length of string
  */
 public static function vbStrlen($string, $unHtmlSpecialChars = false)
 {
     $string = preg_replace('#&\\#([0-9]+);#', '_', $string);
     if ($unHtmlSpecialChars) {
         // don't try to translate unicode entities ever, as we want them to count as 1 (above)
         $string = vB_String::unHtmlSpecialChars($string, false);
     }
     //for some reason the original version of this -- without the extra parans around the
     //second half of the and caused an ajax failure in the installer. I have no explanation
     //and it only appears to happen in really specific environments, but since adding the
     //extra parens seems to work and is harmless I'm going with it.
     if (function_exists('mb_strlen') and $length = @mb_strlen($string, self::getCharSet())) {
         return $length;
     } else {
         return strlen($string);
     }
 }
Beispiel #12
0
 /**
  * Structuring the result data for output
  *
  * @param  [Array]  $result [Array with the search result]
  * @param  [String] $show   [See constant FILTER_SHOW_*. Only when it has value 'photos' it changes the output structure]
  *
  * @return [array]			[Formatted structure for output]
  */
 private function prepareSearchData($result, $show)
 {
     $bbcodeParserInstance = new vB_Library_BbCode(true, true);
     $activitybits = array();
     $result['results'] = vB_Api::instance('node')->mergeNodeviewsForTopics($result['results']);
     foreach ($result['results'] as $node) {
         $activitybit = array();
         if (empty($node['content'])) {
             $conversation = $node;
         } else {
             $conversation = $node['content'];
         }
         $itemSection = $this->getSection($node);
         if (empty($itemSection)) {
             // This might be some weird node under the special channel or some other node
             // that shouldn't have ended up here. Just skip it.
             continue;
         }
         // Socialgroup not handled in the apps
         // TODO: Need to look into this.
         if ($itemSection == 'socialgroup') {
             continue;
         }
         $activityType = $this->getActivityType($itemSection, $node);
         $activitybit['activity'] = array('posttime' => vbdate('h:i A', $conversation['publishdate']), 'postdate' => vbdate('m-d-Y', $conversation['publishdate']), 'section' => $itemSection, 'type' => $activityType, 'score' => 0.0);
         if ($show == self::FILTER_SHOW_PHOTOS) {
             // TODO: TEST THIS
             $activitybit['attachmentinfo'] = array('attachmentid' => -intval($conversation['nodeid']), 'dateline' => $conversation['publishdate'], 'thumbnail_width' => '', 'thumbnail_height' => '');
             if ($itemSection == 'socialgroup') {
                 $activitybit['groupinfo'] = array('albumid' => $conversation['parentid']);
             } else {
                 $activitybit['albuminfo'] = array('albumid' => $conversation['parentid']);
             }
         } else {
             // Section specific info
             switch ($itemSection) {
                 case 'forum':
                     // @TODO: This is inside the special channel and not here, but at this moment the search api doesn't even return vm's.
                     // Need to set up a filter for those or just a flag of ijf we should include or not.
                     if (!empty($node['setfor'])) {
                         $activitybit['messageinfo'] = array('vmid' => $node['nodeid'], 'preview' => $node['preview']);
                         $activitybit['userinfo2'] = array('userid' => $node['setfor'], 'username' => vB_Library::instance('user')->fetchUserName($node['setfor']));
                     } else {
                         $isPost = false;
                         if ($node['nodeid'] == $node['starter']) {
                             $forumInfo = vB_Library::instance('node')->getNodeBare($node['parentid']);
                             $threadInfo = $node;
                             $forumid = (int) $node['parentid'];
                             $threadid = $postid = (int) $node['nodeid'];
                             $threadPreview = $postPreview = $node['content']['rawtext'];
                         } else {
                             $threadInfo = vB_Library::instance('node')->getNode($node['starter']);
                             $forumInfo = vB_Library::instance('node')->getNodeBare($threadInfo['parentid']);
                             $forumid = (int) $forumInfo['nodeid'];
                             $threadid = (int) $threadInfo['nodeid'];
                             $postid = (int) $node['nodeid'];
                             $threadPreview = $threadInfo['content']['rawtext'];
                             $postPreview = $node['content']['rawtext'];
                             $isPost = true;
                         }
                         $activitybit['foruminfo'] = array('forumid' => $forumid, 'title' => vB_String::unHtmlSpecialChars($forumInfo['title']));
                         $activitybit['threadinfo'] = array('title' => vB_String::unHtmlSpecialChars($threadInfo['title']), 'forumid' => $forumid, 'replycount' => $threadInfo['totalcount'], 'views' => isset($threadInfo['content']['views']) ? $threadInfo['content']['views'] : 0, 'preview' => vB_Library::instance('vb4_functions')->getPreview($threadPreview));
                         if ($node['contenttypeid'] == vB_Types::instance()->getContentTypeID('vBForum_Poll')) {
                             $activitybit['threadinfo']['pollid'] = $node['nodeid'];
                         } else {
                             $activitybit['threadinfo']['threadid'] = $threadid;
                         }
                         if ($isPost) {
                             $activitybit['postinfo'] = array('postid' => $postid, 'threadid' => $threadid, 'preview' => vB_Library::instance('vb4_functions')->getPreview($postPreview));
                         }
                         $activitybit['show'] = array('threadcontent' => true);
                     }
                     break;
                 case 'blog':
                     $topChannels = $this->getTopChannels();
                     $blogComment = false;
                     if ($node['parentid'] == $topChannels['blogs']) {
                         // if it is a blog dont include it
                         break;
                     } elseif ($node['nodeid'] == $node['starter']) {
                         // blog entry
                         $blogentryInfo = $node;
                         $blogInfo = vB_Library::instance('node')->getNodeBare($node['parentid']);
                     } else {
                         // blog comment
                         $blogentryInfo = vB_Library::instance('node')->getNode($node['parentid']);
                         $blogInfo = vB_Library::instance('node')->getNodeBare($blogentryInfo['parentid']);
                         $blogComment = true;
                     }
                     $activitybit['bloginfo'] = array('blogid' => $blogentryInfo['nodeid'], 'title' => vB_String::unHtmlSpecialChars($blogentryInfo['title']), 'blog_title' => vB_String::unHtmlSpecialChars($blogInfo['title']), 'comments_visible' => $blogInfo['textcount'], 'views' => isset($blogentryInfo['content']['views']) ? $blogentryInfo['content']['views'] : 0, 'preview' => vB_Library::instance('vb4_functions')->getPreview($blogentryInfo['content']['rawtext']));
                     if ($blogComment) {
                         $activitybit['blogtextinfo'] = array('blogtextid' => $node['nodeid'], 'preview' => vB_Library::instance('vb4_functions')->getPreview($node['content']['rawtext']));
                     }
                     break;
                 case 'socialgroup':
                     $topChannels = $this->getTopChannels();
                     $discussionInfo = false;
                     $messageinfo = false;
                     if ($node['parentid'] == $topChannels['groups']) {
                         // group
                         $groupInfo = $node;
                     } elseif ($node['nodeid'] == $node['starter']) {
                         // group discussion
                         $discussionInfo = $node;
                         $groupInfo = vB_Library::instance('node')->getNodeBare($node['parentid']);
                     } else {
                         // group message
                         $discussionInfo = vB_Library::instance('node')->getNodeBare($node['parentid']);
                         $groupInfo = vB_Library::instance('node')->getNodeBare($discussionInfo['parentid']);
                         $messageInfo = $node;
                     }
                     $activitybit['groupinfo'] = array('groupid' => $groupInfo['nodeid'], 'name' => $groupInfo['title']);
                     if ($discussionInfo) {
                         $activitybit['discussioninfo'] = array('discussionid' => $discussionInfo['nodeid'], 'title' => $discussionInfo['title'], 'preview' => vB_Library::instance('vb4_functions')->getPreview($discussionInfo['content']['rawtext']), 'visible' => 1);
                     }
                     if ($messageInfo) {
                         $activitybit['messageinfo'] = array('gmid' => $messageInfo['nodeid'], 'preview' => vB_Library::instance('vb4_functions')->getPreview($discussionInfo['content']['rawtext']));
                     }
                     break;
                 case 'album':
                     // Only show albums, not individual photos in albums.
                     // For some reason, the search can return individual photos
                     // added later to the album.
                     if (!($node['nodeid'] == $node['starter'])) {
                         $album = vB_Library::instance('node')->getNodeFullContent($node['starter']);
                         if (empty($album[$node['starter']])) {
                             // This shouldn't happen AFAIK. Maybe if there's data corruption/incomplete cleanup?
                             continue 2;
                         }
                         $album = vB_Api::instance('node')->mergeNodeviewsForTopics($album);
                         $album = $album[$node['starter']];
                     } else {
                         $album = $node;
                     }
                     // There are some serious inconsistencies between getNodeFullContent() and
                     // returned node array from search results...
                     if (!isset($album['photo']) and isset($album['content']['photo'])) {
                         $album['photo'] = $album['content']['photo'];
                     }
                     if (!isset($album['photopreview']) and isset($album['content']['photopreview'])) {
                         $album['photopreview'] = $album['content']['photopreview'];
                     }
                     if (!isset($album['photocount']) and isset($album['content']['photocount'])) {
                         $album['photocount'] = $album['content']['photocount'];
                     }
                     // Use actual thumbnail size if thumbnail is found.
                     // TODO: include this as part of the regular 'photo' array info?
                     $filedataids = array();
                     foreach ($album['photopreview'] as $key => $photo) {
                         $filedataids[$photo['filedataid']] = $photo['filedataid'];
                     }
                     $thumbInfoQuery = vB::getDbAssertor()->getRows('vBForum:filedataresize', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::COLUMNS_KEY => array('filedataid', 'resize_width', 'resize_height'), vB_dB_Query::CONDITIONS_KEY => array('resize_type' => vB_Api_Filedata::SIZE_THUMB, 'filedataid' => $filedataids)));
                     $thumbInfo = array();
                     foreach ($thumbInfoQuery as $row) {
                         $thumbInfo[$row['filedataid']] = $row;
                     }
                     /*
                     	Since this is an "album", let's just ignore any attachments that
                     	the user might've added to the post. Especially since clicking on
                     	an album doesn't show the post, just the photos in the gallery.
                     	vB4 didn't have a "gallery", so it didn't have this issue.
                     */
                     $activitybit['albuminfo'] = array('albumid' => $album['nodeid'], 'title' => $album['title'], 'picturecount' => $album['photocount'], 'views' => isset($album['content']['views']) ? $album['content']['views'] : 0);
                     $activitybit['photocount'] = $album['photocount'];
                     $activitybit['attach'] = array();
                     // Let's just use the photo preview for this view. It never shows more than 3 photos anyways.
                     foreach ($album['photopreview'] as $photo) {
                         $thumburl = $bbcodeParserInstance->getAttachmentLink($photo, vB_Api_Filedata::SIZE_THUMB);
                         $filedataid = $photo['filedataid'];
                         if (isset($thumbInfo[$filedataid])) {
                             $thumbwidth = $thumbInfo[$filedataid]['resize_width'];
                             $thumbheight = $thumbInfo[$filedataid]['resize_height'];
                         } else {
                             $thumbwidth = $photo['width'];
                             $thumbheight = $photo['height'];
                         }
                         $activitybit['attach'][] = array('attachmentid' => -intval($photo['nodeid']), 'thumburl' => $thumburl, 'dateline' => $photo['dateline'], 'thumbnail_width' => $thumbwidth, 'thumbnail_height' => $thumbheight);
                     }
                     break;
                 default:
                     break;
             }
         }
         $userInfo = vB_Library::instance('user')->fetchUserinfo($node['userid'], array('avatar'));
         $activitybit['userinfo'] = array('userid' => $userInfo['userid'], 'username' => $userInfo['username'], 'avatarurl' => vB_Library::instance('vb4_functions')->avatarUrl($userInfo['userid']), 'showavatar' => $userInfo['showavatars']);
         $activitybits[] = $activitybit;
     }
     return $activitybits;
 }
 private function nodeToApiFormat($node)
 {
     $thread = array('thread' => array('threadid' => $node['nodeid'], 'threadtitle' => vB_String::unHtmlSpecialChars($node['title']), 'postusername' => $node['authorname'], 'postuserid' => $node['userid'], 'status' => array('dot' => 'dot'), 'moderatedprefix' => '', 'realthreadid' => $node['nodeid'], 'rating' => 0, 'preview' => vB_Library::instance('vb4_functions')->getPreview($node['rawtext']), 'dot_count' => 0, 'dot_lastpost' => 0, 'threadiconpath' => $node['iconpath'], 'threadicontitle' => '', 'typeprefix' => '', 'prefix_rich' => $node['prefix_rich'], 'starttime' => $node['lastcontent'], 'attach' => count($node['attach']), 'forumid' => $node['channelid'], 'forumtitle' => $node['channeltitle'], 'replycount' => $node['textcount'], 'views' => $node['views'], 'lastposttime' => $node['lastcontent'], 'lastpostid' => $node['lastcontentid'], 'lastposter' => $node['lastcontentauthor'], 'lastposterid' => $node['lastauthorid']), 'avatar' => array('hascustom' => $node['avatar']['hascustom'], '0' => $node['avatar']['avatarpath'], '1' => ''), 'show' => array('rexpires' => 0, 'rmanage' => 0, 'threadmoved' => 0, 'paperclip' => count($node['attach']) ? 1 : 0, 'unsubscribe' => 0, 'sticky' => $node['sticky'], 'threadicon' => $node['iconid'] ? 1 : 0, 'gotonewpost' => 0, 'subscribed' => 0, 'pagenav' => 0, 'guestuser' => 0, 'threadrating' => 0, 'threadcount' => 1, 'taglist' => 0, 'avatar' => 1));
     return $thread;
 }
Beispiel #14
0
 private function parseMessage($message)
 {
     return array('pm' => array('pmid' => $message['nodeid'], 'sendtime' => $message['publishdate'], 'title' => vB_String::unHtmlSpecialChars($message['title'] ? $message['title'] : $message['previewtext']), 'statusicon' => $message['msgread'] ? 'old' : 'new'), 'userbit' => array('userinfo' => array('userid' => $message['userid'], 'username' => $message['username'])), 'show' => array('unread' => $message['msgread'] ? 0 : 1));
 }