Example #1
0
 /**
  * Receives either a template name or an array of template names to be fetched from the API
  * @param mixed $templateName
  */
 protected function fetchTemplate($templateName)
 {
     if (!is_array($templateName)) {
         $templateName = array($templateName);
     }
     $response = Api_InterfaceAbstract::instance()->callApi('template', 'getTemplateIds', array('template_names' => $templateName));
     $template_path = vB5_Template_Options::instance()->get('options.template_cache_path');
     if (isset($response['ids'])) {
         foreach ($response['ids'] as $name => $templateid) {
             $file_name = "template{$templateid}.php";
             //this matches the filename logic from template library saveTemplateToFileSystem and needs to
             //so that we come up with the same file in both cases.
             $real_path = realpath($template_path);
             if ($real_path === false) {
                 $real_path = realpath(vB5_Config::instance()->core_path . '/' . $template_path);
             }
             if ($real_path === false) {
                 $file = false;
             } else {
                 $file = $real_path . "/{$file_name}";
             }
             if ($templateid and $file and array_key_exists($templateid, $this->textOnlyTemplates)) {
                 $placeholder = $this->getPlaceholder($templateid, '_to');
                 $this->textOnlyReplace[$placeholder] = file_get_contents($file);
                 $this->cache[$name] = array('textonly' => 1, 'placeholder' => $placeholder);
             } else {
                 $this->cache[$name] = $file;
             }
         }
     }
 }
Example #2
0
 private function fetchOptions()
 {
     $response = Api_InterfaceAbstract::instance()->callApi('options', 'fetch');
     foreach ($response as $key => $value) {
         $this->cache[$key] = $value;
     }
 }
Example #3
0
 public function actionSaveGeneratedStyle()
 {
     //$scheme, $parentid, $title, $displayorder = 1, $userselect = false
     //, $_POST['type'], $_POST['id']
     $response = Api_InterfaceAbstract::instance()->callApi('style', 'generateStyle', array('scheme' => $_POST['scheme'], 'type' => $_POST['type'], 'parentid' => $_POST['parentid'], 'title' => $_POST['name'], 'displayorder' => empty($_POST['displayorder']) ? 1 : $_POST['displayorder'], 'userselect' => !empty($_POST['userselect'])));
     $this->sendAsJson($response);
 }
Example #4
0
 protected function ajaxPollData($nodeid)
 {
     $poll = Api_InterfaceAbstract::instance()->callApi('content_poll', 'getContent', array($nodeid));
     foreach ($poll as $v) {
         $this->sendAsJson(array('options' => $v['options'], 'poll_votes' => $v['poll_votes']));
         return;
     }
 }
Example #5
0
 /**
  * Reverses infraction for the specified nodeid
  *
  */
 public function actionReverse()
 {
     $nodeid = isset($_POST['nodeid']) ? trim(intval($_POST['nodeid'])) : 0;
     $reason = isset($_POST['reason']) ? trim(strval($_POST['reason'])) : '';
     $userInfraction = isset($_POST['userinfraction']) ? trim(intval($_POST['userinfraction'])) : 0;
     $api = Api_InterfaceAbstract::instance();
     $nodeId = $api->callApi('content_infraction', $userInfraction ? 'reverseInfraction' : 'reverseNodeInfraction', array($nodeid, $reason));
     $this->sendAsJson($nodeId);
 }
Example #6
0
 public function actionOutput()
 {
     $api = Api_InterfaceAbstract::instance();
     $response = $api->callApi('session', 'getGuestSession');
     if (is_array($response) and !empty($response['errors'])) {
         return '';
     }
     $type = !empty($_REQUEST['type']) ? $_REQUEST['type'] : '';
     // default rss2
     switch ($type) {
         case 'rss2':
         case 'rss1':
         case 'rss':
         case 'xml':
         case 'js':
             $type = $_REQUEST['type'];
             break;
         default:
             $type = 'rss2';
             break;
     }
     if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) and !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
         $response = $api->callApi('external', 'getCacheData', array('type' => $type, 'options' => $_REQUEST));
         if (is_array($response) and !empty($response['errors'])) {
             return '';
         }
         if ($_SERVER['HTTP_IF_NONE_MATCH'] == "\"{$response['cachehash']}\"") {
             $timediff = strtotime(gmdate('D, d M Y H:i:s') . ' GMT') - strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
             if ($timediff <= $response['cachetime']) {
                 if (SAPI_NAME == 'cgi' or SAPI_NAME == 'cgi-fcgi') {
                     header('Status: 304 Not Modified');
                 } else {
                     header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
                 }
                 exit;
             }
         }
     }
     // always disable nohtml
     $_REQUEST['nohtml'] = 0;
     $response = $api->callApi('external', 'createExternalOutput', array('type' => $type, 'options' => $_REQUEST));
     if (is_array($response) and !empty($response['errors'])) {
         return '';
     }
     $data = $_REQUEST + array('Pragma' => '', 'Content-Type' => vB5_String::getTempCharset());
     $headers = $api->callApi('external', 'getHeadersFromLastOutput', array('type' => $type, 'data' => $data));
     if (is_array($headers) and !empty($headers['errors'])) {
         return '';
     }
     foreach ($headers as $name => $value) {
         header("{$name}: {$value}");
     }
     return $response;
 }
Example #7
0
 public function actionRemove()
 {
     //Note that we shouldn't actually do anything here. If the filedata record isn't
     //used it will soon be deleted.
     if (!empty($_REQUEST['id']) && intval($_REQUEST['id'])) {
         $request = array('id' => $_REQUEST['id']);
         $api = Api_InterfaceAbstract::instance();
         // AFAIK, there is no "attach" api, and vb_api_content_attach doesn't have a removeAttachment().
         // TODO: Figure out where this going/supposed to be going.
         $api->callApi('attach', 'removeAttachment', $request);
     }
 }
Example #8
0
function do_version()
{
    global $fr_version, $fr_platform;
    if (file_exists(MCWD . '/sitekey.php')) {
        require_once MCWD . '/sitekey.php';
    } else {
        if (file_exists(MCWD . '/vb_sitekey.php')) {
            require_once MCWD . '/vb_sitekey.php';
        }
    }
    $push = Api_InterfaceAbstract::instance()->callApi('cron', 'fetchByVarName', array('forumrunnerpush'));
    $push_enabled = $push['active'] && $push['product'] == 'forumrunner';
    return array('version' => $fr_version, 'platform' => $fr_platform, 'push_enabled' => $push_enabled, 'charset' => get_local_charset(), 'sitekey_setup' => !$mykey || $mykey == '' ? false : true);
}
Example #9
0
 function actionGetvideodata()
 {
     $input = array('url' => trim($_POST['url']));
     $api = Api_InterfaceAbstract::instance();
     $video = $api->callApi('content_video', 'getVideoFromUrl', array($input['url']));
     if ($video) {
         $templater = new vB5_Template('video_edit');
         $templater->register('video', $video);
         $templater->register('existing', 0);
         $templater->register('editMode', 1);
         $results['template'] = $templater->render();
     } else {
         $results['error'] = 'Invalid URL.';
     }
     $this->sendAsJson($results);
     return;
 }
Example #10
0
 function actionGetlinkdata()
 {
     $input = array('url' => trim($_REQUEST['url']));
     $api = Api_InterfaceAbstract::instance();
     $video = $api->callApi('content_video', 'getVideoFromUrl', array($input['url']));
     $data = $api->callApi('content_link', 'parsePage', array($input['url']));
     if ($video and empty($video['errors'])) {
         $result = vB5_Template::staticRenderAjax('video_edit', array('video' => $video, 'existing' => 0, 'editMode' => 1, 'title' => $data['title'], 'url' => $input['url'], 'meta' => $data['meta']));
     } else {
         if ($data and empty($data['errors'])) {
             $result = vB5_Template::staticRenderAjax('link_edit', array('images' => $data['images'], 'title' => $data['title'], 'url' => $input['url'], 'meta' => $data['meta']));
         } else {
             $result = array('template' => array('error' => 'invalid_url'), 'css_links' => array());
         }
     }
     $this->sendAsJson($result);
     return;
 }
Example #11
0
 function actionReport()
 {
     $input = array('reason' => isset($_POST['reason']) ? trim(strval($_POST['reason'])) : '', 'reportnodeid' => isset($_POST['reportnodeid']) ? trim(intval($_POST['reportnodeid'])) : 0);
     if (!$input['reportnodeid']) {
         $results['error'] = 'invalid_nodeid';
         $this->sendAsJson($results);
         return;
     }
     $api = Api_InterfaceAbstract::instance();
     // get user info for the currently logged in user
     $user = $api->callApi('user', 'fetchCurrentUserinfo', array());
     $reportData = array('rawtext' => $input['reason'], 'reportnodeid' => $input['reportnodeid'], 'parentid' => $input['reportnodeid'], 'userid' => $user['userid'], 'authorname' => $user['username'], 'created' => time());
     $nodeId = $api->callApi('content_report', 'add', array($reportData));
     if (!empty($nodeId['errors'])) {
         $results['error'] = $nodeId['errors'][0];
     } else {
         $results = $nodeId;
     }
     $this->sendAsJson($results);
     return;
 }
 public static function getText($channelid)
 {
     if (empty($channelid)) {
         return false;
     }
     $cacheKey = "vB_Announcements_{$channelid}";
     // first try with cache
     $api = Api_InterfaceAbstract::instance();
     $cache = $api->cacheInstance(0);
     $found = $cache->read($cacheKey);
     if ($found !== false) {
         return $found;
     }
     $announcements = $api->callApi('announcement', 'fetch', array($channelid));
     $parser = new vB5_Template_BbCode();
     $bbCodeOptions = array('allowimages', 'allowimagebbcode', 'allowbbcode', 'allowhtml', 'allowsmilies');
     foreach ($announcements as $key => $announcement) {
         $announcements[$key]['pagetext'] = $parser->doParse($announcement['pagetext'], $announcement['dohtml'], $announcement['dosmilies'], $announcement['dobbcode'], $announcement['dobbimagecode']);
     }
     $events = array('nodeChg_' . $channelid, 'vB_AnnouncementChg');
     $cache->write($cacheKey, $announcements, 10080, $events);
     return $announcements;
 }
Example #13
0
 public function actionImage()
 {
     $api = Api_InterfaceAbstract::instance();
     $image = $api->callApi('hv', 'fetchHvImage', array('hash' => $_REQUEST['hash']));
     switch ($image['type']) {
         case 'gif':
             header('Content-transfer-encoding: binary');
             header('Content-disposition: inline; filename=image.gif');
             header('Content-type: image/gif');
             break;
         case 'png':
             header('Content-transfer-encoding: binary');
             header('Content-disposition: inline; filename=image.png');
             header('Content-type: image/png');
             break;
         case 'jpg':
             header('Content-transfer-encoding: binary');
             header('Content-disposition: inline; filename=image.jpg');
             header('Content-type: image/jpeg');
             break;
     }
     echo $image['data'];
 }
Example #14
0
 /** gets a gallery and returns in json format for slideshow presentation.
  *
  ***/
 public function actionGallery()
 {
     //We need a nodeid
     if (!empty($_REQUEST['nodeid'])) {
         $nodeid = $_REQUEST['nodeid'];
     } else {
         if (!empty($_REQUEST['id'])) {
             $nodeid = $_REQUEST['id'];
         } else {
             return '';
         }
     }
     //get the raw data.
     $api = Api_InterfaceAbstract::instance();
     $config = vB5_Config::instance();
     $phraseApi = vB5_Template_Phrase::instance();
     $gallery = array('photos' => array());
     switch (intval($nodeid)) {
         case 0:
         case -1:
             //All Videos
             throw new vB_Exception_Api('invalid_request');
         case -2:
             //All non-Album photos and attachments
             if ((empty($_REQUEST['userid']) or !intval($_REQUEST['userid'])) and (empty($_REQUEST['channelid']) or !intval($_REQUEST['channelid']))) {
                 throw new vB_Exception_Api('invalid_request');
             }
             $galleryData = $api->callApi('profile', 'getSlideshow', array(array('userid' => isset($_REQUEST['userid']) ? intval($_REQUEST['userid']) : 0, 'channelid' => isset($_REQUEST['channelid']) ? intval($_REQUEST['channelid']) : 0, 'dateFilter' => isset($_REQUEST['dateFilter']) ? $_REQUEST['dateFilter'] : '', 'searchlimit' => isset($_REQUEST['perpage']) ? $_REQUEST['perpage'] : '', 'startIndex' => isset($_REQUEST['startIndex']) ? $_REQUEST['startIndex'] : '')));
             if (empty($galleryData)) {
                 return array();
             }
             foreach ($galleryData as $photo) {
                 $titleVm = !empty($photo['parenttitle']) ? $photo['parenttitle'] : $photo['startertitle'];
                 $route = $photo['routeid'];
                 if ($photo['parenttitle'] == 'No Title' and $photo['parentsetfor'] > 0) {
                     $titleVm = $phraseApi->getPhrase('visitor_message_from_x', array($photo['authorname']));
                     $route = 'visitormessage';
                 }
                 $userLink = vB5_Template_Options::instance()->get('options.frontendurl') . $api->callApi('route', 'getUrl', array('route' => 'profile', 'data' => array('userid' => $photo['userid'], 'username' => $photo['authorname']), 'extra' => array()));
                 $topicLink = vB5_Template_Options::instance()->get('options.frontendurl') . '/' . $api->callApi('route', 'getUrl', array('route' => $route, 'data' => array('title' => $titleVm, 'nodeid' => $photo['parentnode']), 'extra' => array()));
                 $title = $photo['title'] != null ? $photo['title'] : '';
                 $htmltitle = $photo['htmltitle'] != null ? $photo['htmltitle'] : '';
                 $photoTypeid = vB_Types::instance()->getContentTypeID('vBForum_Photo');
                 $attachTypeid = vB_Types::instance()->getContentTypeID('vBForum_Attach');
                 if ($photo['contenttypeid'] === $photoTypeid) {
                     $queryVar = 'photoid';
                 } else {
                     if ($photo['contenttypeid'] === $attachTypeid) {
                         $queryVar = 'id';
                     }
                 }
                 $gallery['photos'][] = array('title' => $title, 'htmltitle' => $htmltitle, 'url' => vB5_Template_Options::instance()->get('options.frontendurl') . '/filedata/fetch?' . $queryVar . '=' . intval($photo['nodeid']), 'thumb' => vB5_Template_Options::instance()->get('options.frontendurl') . '/filedata/fetch?' . $queryVar . '=' . intval($photo['nodeid']) . "&thumb=1", 'links' => $phraseApi->getPhrase('photos_by_x_in_y_linked', array($userLink, $photo['authorname'], $topicLink, htmlspecialchars($titleVm))) . "<br />\n");
             }
             $this->sendAsJson($gallery);
             return;
         default:
             $galleryData = $api->callApi('content_gallery', 'getContent', array('nodeid' => $nodeid));
             if (!empty($galleryData) and !empty($galleryData[$nodeid]['photo'])) {
                 foreach ($galleryData[$nodeid]['photo'] as $photo) {
                     $userLink = vB5_Template_Options::instance()->get('options.frontendurl') . $api->callApi('route', 'getUrl', array('route' => 'profile', 'data' => array('userid' => $photo['userid'], 'username' => $photo['authorname']), 'extra' => array()));
                     $gallery['photos'][] = array('title' => $photo['title'], 'htmltitle' => $photo['htmltitle'], 'url' => vB5_Template_Options::instance()->get('options.frontendurl') . '/filedata/fetch?photoid=' . intval($photo['nodeid']), 'thumb' => vB5_Template_Options::instance()->get('options.frontendurl') . '/filedata/fetch?photoid=' . intval($photo['nodeid']) . "&thumb=1", 'links' => $phraseApi->getPhrase('photos_by_x_in_y_linked', array($userLink, $photo['authorname'], 'javascript:$(\'#slideshow-dialog\').dialog(\'close\');void(0);', htmlspecialchars($photo['startertitle']))) . "<br />\n");
                 }
                 $this->sendAsJson($gallery);
             }
             return;
     }
 }
Example #15
0
 protected function attachReplaceCallback($matches)
 {
     $align = $matches[1];
     $showOldImage = false;
     $tempid = false;
     // used if this attachment hasn't been saved yet (ex. going back & forth between source mode & wysiwyg on a new content)
     $filedataid = false;
     $attachmentid = false;
     // Same as before: are we looking at a legacy attachment?
     if (preg_match('#^n(\\d+)$#', $matches[2], $matches2)) {
         // if the id has 'n' as prefix, it's a nodeid
         $attachmentid = intval($matches2[1]);
     } else {
         if (preg_match('#^temp_(\\d+)_(\\d+)_(\\d+)$#', $matches[2], $matches2)) {
             // if the id is in the form temp_##_###_###, it's a temporary id that links to hidden inputs that contain
             // the stored settings that will be saved when it becomes a new attachment @ post save.
             $tempid = $matches2[0];
             $filedataid = intval($matches2[1]);
         } else {
             // it's a legacy attachmentid, get the new id
             if (isset($this->oldAttachments[intval($matches[2])])) {
                 // key should be nodeid, not filedataid.
                 $attachmentid = $this->oldAttachments[intval($matches[2])]['nodeid'];
                 $showOldImage = $this->oldAttachments[intval($matches[2])]['cangetattachment'];
             }
         }
     }
     $cangetattachment = $this->options['do_imgcode'];
     $canseethumbnails = true;
     if ($attachmentid === false and $tempid === false) {
         // No data match was found for the attachment, so just return nothing
         return '';
     } else {
         if (!empty($this->attachments["{$attachmentid}"])) {
             // attachment specified by [attach] tag belongs to this post
             $attachment =& $this->attachments["{$attachmentid}"];
             $filedataid = $attachment['filedataid'];
             // remove attachment from array
             if ($this->unsetattach) {
                 unset($this->attachments["{$attachmentid}"]);
                 unset($this->filedataidsToAttachmentids[$filedataid][$attachmentid]);
             } else {
                 $this->delayedUnsetAttachments[$attachmentid] = array('attachmentid' => $attachmentid, 'filedataid' => $filedataid);
             }
             if (!empty($attachment['settings']) and strtolower($align) == 'config') {
                 $settings = unserialize($attachment['settings']);
             } elseif (!empty($matches['settings'])) {
                 $settings = array();
                 // Currently strictly used by VBV-12051, replacing [IMG]...?filedataid=...[/IMG] with corresponding attachment image
                 // when &amp;type=[a-z]+ or &amp;thumb=1 is part of the image url, that size is passed into us as settings from handle_bbcode_img()
                 // Nothing else AFAIK should be able to pass in the settings, but if we do add this as a main feature,
                 // we should be sure to scrub this well (either via the regex pattern or actual cleaning) to prevent xss.
                 if (isset($matches['settings']['size'])) {
                     // This cleaning is not strictly necessary since the switch-case below that uses this restricts the string to a small set, so xss is not possible.
                     $size = Api_InterfaceAbstract::instance()->callApi('filedata', 'sanitizeFiletype', array($matches['settings']['size']));
                     $settings['size'] = $size;
                 }
             } else {
                 $settings = '';
             }
             if (!$attachment['visible'] and $attachment['userid'] != self::getUserValue('userid')) {
                 // Don't show inline unless the poster is viewing the post (post preview)
                 return '';
             }
             $forceimage = false;
             if ($cangetattachment and $canseethumbnails and $attachment['resize_filesize'] == $attachment['filesize']) {
                 $attachment['hasthumbnail'] = false;
                 $forceimage = self::$viewAttachedImages;
             } else {
                 if (!$canseethumbnails) {
                     $attachment['hasthumbnail'] = false;
                 }
             }
             if (empty($attachment['extension'])) {
                 $attachment['filename'] = $this->fetchCensoredText(vB_String::htmlSpecialCharsUni($attachment['filename']));
                 $attachment['extension'] = strtolower(file_extension($attachment['filename']));
             }
             $attachment['filesize'] = vb_number_format($attachment['filesize'], 1, true);
             $lightbox_extensions = array('gif', 'jpg', 'jpeg', 'jpe', 'png', 'bmp');
             $fullsize = false;
             $imgSrcSuffix = '';
             switch ($attachment['extension']) {
                 case 'gif':
                 case 'jpg':
                 case 'jpeg':
                 case 'jpe':
                 case 'png':
                 case 'bmp':
                 case 'tiff':
                 case 'tif':
                 case 'psd':
                 case 'pdf':
                     $imgclass = array();
                     $alt_text = $title_text = $caption_tag = $styles = '';
                     if ($settings) {
                         if ($settings['alignment']) {
                             switch ($settings['alignment']) {
                                 case 'left':
                                     $imgclass[] = 'align_left';
                                     break;
                                 case 'center':
                                     $imgclass[] = 'align_center';
                                     break;
                                 case 'right':
                                     $imgclass[] = 'align_right';
                                     break;
                             }
                         }
                         if (isset($settings['size'])) {
                             switch ($settings['size']) {
                                 case 'icon':
                                     // AFAIK vB4 didn't have this size, but vB5 does.
                                     $imgSrcSuffix = '&amp;type=icon';
                                     break;
                                 case 'thumb':
                                     // I think 'thumbnail' was used mostly in vB4. We lean towards the usage of 'thumb' instead in vB5.
                                 // I think 'thumbnail' was used mostly in vB4. We lean towards the usage of 'thumb' instead in vB5.
                                 case 'thumbnail':
                                     $imgSrcSuffix = '&amp;type=thumb';
                                     $imgclass[] = 'size_thumbnail';
                                     break;
                                 case 'small':
                                     // AFAIK vB4 didn't have this size, but vB5 does.
                                     $imgSrcSuffix = '&amp;type=small';
                                     break;
                                 case 'medium':
                                     $imgSrcSuffix = '&amp;type=medium';
                                     $imgclass[] = 'size_medium';
                                     break;
                                 case 'large':
                                     $imgSrcSuffix = '&amp;type=large';
                                     $imgclass[] = 'size_large';
                                     break;
                                 case 'full':
                                     // I think 'fullsize' was used mostly in vB4. We lean towards the usage of 'full' instead in vB5.
                                 // I think 'fullsize' was used mostly in vB4. We lean towards the usage of 'full' instead in vB5.
                                 case 'fullsize':
                                     $imgSrcSuffix = '&amp;type=full';
                                     $fullsize = true;
                                     break;
                                 default:
                                     break;
                             }
                         }
                         //						if ($settings['caption'])
                         //						{
                         //							$caption_tag = "<p class=\"caption $size_class\">$settings[caption]</p>";
                         //						}
                         $alt_text = $settings['title'];
                         $description_text = $settings['description'];
                         $title_text = $settings['title'];
                         $styles = $settings['styles'];
                     }
                     if (($settings or self::$viewAttachedImages == 1 and $attachment['hasthumbnail']) and self::getUserValue('showimages') and $cangetattachment) {
                         $suffixAlreadyAppended = false;
                         if (empty($link)) {
                             $link = vB_String::htmlSpecialCharsUni($this->getAttachmentLink($attachment));
                             $suffixAlreadyAppended = true;
                         }
                         if (!empty($attachment['nodeid'])) {
                             $id = 'attachment' . $attachment['nodeid'];
                         } else {
                             $id = 'filedata' . $attachment['filedataid'];
                         }
                         $link .= $imgSrcSuffix;
                         if (!empty($this->sessionSuffix) and !$suffixAlreadyAppended) {
                             // This is going into src/href attributes in HTML
                             $link .= vB_String::htmlSpecialCharsUni($this->sessionSuffix);
                         }
                         $lightbox = (!$fullsize and $cangetattachment and in_array($attachment['extension'], $lightbox_extensions));
                         $hrefbits = array('href' => "{$link}&amp;d={$attachment['dateline']}", 'id' => $id, 'class' => 'bbcode-attachment');
                         if ($lightbox) {
                             $hrefbits["rel"] = 'Lightbox_' . $this->containerid;
                         } else {
                             $hrefbits["rel"] = "nofollow";
                         }
                         //						if ($addnewwindow)
                         //						{
                         //							$hrefbits['target'] = '_blank';
                         //						}
                         $atag = '';
                         foreach ($hrefbits as $tag => $value) {
                             $atag .= "{$tag}=\"{$value}\" ";
                         }
                         $imgbits = array('src' => "{$link}&amp;d={$attachment['resize_dateline']}", 'border' => '0', 'alt' => $alt_text ? $alt_text : $this->getPhrase('image_larger_version_x_y_z', $attachment['filename'], $attachment['counter'], $attachment['filesize'], $attachment['filedataid']));
                         if (!$settings and !$this->displayimage) {
                             $imgbits['src'] .= '&amp;thumb=1';
                         }
                         if (!empty($imgclass)) {
                             $imgbits['class'] = implode(' ', $imgclass);
                         } else {
                             $imgbits['class'] = 'thumbnail';
                         }
                         if ($title_text) {
                             $imgbits['title'] = $title_text;
                         } else {
                             if (isset($description_text) and !empty($description_text)) {
                                 $imgbits['title'] = $description_text;
                             }
                         }
                         if (isset($description_text) and !empty($description_text)) {
                             $imgbits['description'] = $description_text;
                         }
                         if ($styles) {
                             $imgbits['style'] = $styles;
                         } else {
                             if (!$settings and $align and $align != '=CONFIG') {
                                 $imgbits['style'] = "float:{$align}";
                             }
                         }
                         $imgtag = '';
                         foreach ($imgbits as $tag => $value) {
                             $imgtag .= "{$tag}=\"{$value}\" ";
                         }
                         if ($fullsize) {
                             return ($fullsize ? '<div class="size_fullsize">' : '') . "<img {$imgtag}/>" . ($fullsize ? '</div>' : '');
                         } else {
                             if (isset($settings['alignment']) && $settings['alignment'] == 'center') {
                                 return "<div class=\"img_align_center " . ($fullsize ? 'size_fullsize' : '') . "\"><a {$atag}><img {$imgtag}/></a></div>";
                             } else {
                                 return ($fullsize ? '<div class="size_fullsize">' : '') . "<a {$atag}><img {$imgtag}/></a>" . ($fullsize ? '</div>' : '');
                             }
                         }
                     } else {
                         if (self::getUserValue('showimages') and ($forceimage or self::$viewAttachedImages == 3) and !in_array($attachment['extension'], array('tiff', 'tif', 'psd', 'pdf')) and $cangetattachment) {
                             $link = vB_String::htmlSpecialCharsUni($this->getAttachmentLink($attachment));
                             return ($fullsize ? '<div class="size_fullsize">' : '') . "<img src=\"" . $link . "&amp;d={$attachment['dateline']}\" border=\"0\" alt=\"" . $this->getPhrase('image_x_y_z', $attachment['filename'], $attachment['counter'], $attachment['filesize']) . "\" " . (!empty($align) ? " style=\"float: {$align}\"" : '') . " />";
                             $fullsize ? '</div>' : '';
                         } else {
                             $link = vB_String::htmlSpecialCharsUni($this->getAttachmentLink($attachment));
                             return ($fullsize ? '<div class="size_fullsize">' : '') . "<a href=\"" . $link . "&amp;d={$attachment['dateline']}\" title=\"" . $this->getPhrase('image_x_y_z', $attachment['filename'], $attachment['counter'], $attachment['filesize']) . "\">{$attachment['filename']}</a>" . ($fullsize ? '</div>' : '');
                         }
                     }
                     break;
                 default:
                     $link = vB_String::htmlSpecialCharsUni($this->getAttachmentLink($attachment));
                     return ($fullsize ? '<div class="size_fullsize">' : '') . "<a href=\"" . $link . "&amp;d={$attachment['dateline']}\" title=\"" . $this->getPhrase('image_x_y_z', $attachment['filename'], $attachment['counter'], $attachment['filesize']) . "\">{$attachment['filename']}</a>" . ($fullsize ? '</div>' : '');
             }
         } else {
             // if we have a temporaryid, then we're probably editing a post with a new attachment that doesn't have
             // a node created for the attachment yet. Let's return a basic image tag and let JS handle fixing it.
             if ($tempid and $filedataid) {
                 return "<img class=\"bbcode-attachment js-need-data-att-update\" src=\"" . self::$frontendurl . "/filedata/fetch?filedataid={$filedataid}\" data-tempid=\"" . $tempid . "\" />";
             } else {
                 // Belongs to another post so we know nothing about it ... or we are not displying images so always show a link
                 return "<a href=\"" . self::$frontendurl . "/filedata/fetch?filedataid={$attachmentid}\">" . $this->getPhrase('attachment') . " </a>";
             }
         }
     }
 }
 /**
  * Handles a [thread] tag. Creates a link to another thread.
  *
  * @param	string	If tag has option, the displayable name. Else, the threadid.
  * @param	string	If tag has option, the threadid.
  *
  * @return	string	HTML representation of the tag.
  */
 function handle_bbcode_thread($text, $threadId)
 {
     $threadId = intval($threadId);
     if (empty($threadId)) {
         // no option -- use param
         $threadId = intval($text);
         unset($text);
     }
     $url = Api_InterfaceAbstract::instance()->callApi('route', 'fetchLegacyThreadUrl', array($threadId));
     if (!isset($text)) {
         $text = $url;
     }
     // standard URL hyperlink
     return "<a href=\"{$url}\" target=\"_blank\">{$text}</a>";
 }
 /**
  * This sets a return url when creating new content and sets if the created content
  * is a visitor message
  *
  */
 protected function getReturnUrl(&$result, $channelid, $parentid, $nodeid)
 {
     $api = Api_InterfaceAbstract::instance();
     $returnUrl = '';
     // ensure we have a channelid for the redirect
     if (!$channelid && $parentid) {
         try {
             $channel = $api->callApi('content_channel', 'fetchChannelById', array($parentid));
             if ($channel && isset($channel['nodeid']) && $channel['nodeid']) {
                 $channelid = $channel['nodeid'];
             }
         } catch (Exception $e) {
         }
     }
     //Get the conversation detail page of the newly created post if we are creating a starter
     if ($channelid == $parentid) {
         if (isset($result['moderateNode'])) {
             $nodeid = $parentid;
         }
         $node = $api->callApi('node', 'getNode', array($nodeid));
         if ($node and empty($node['errors'])) {
             $url = $api->callApi('route', 'getUrl', array('route' => $node['routeid'], 'data' => $node, 'extra' => array()));
             if (is_string($url)) {
                 $returnUrl = vB5_Template_Options::instance()->get('options.frontendurl') . $url;
             } else {
                 // if the user can't view the item they just created, return to the channel.
                 $channel = $api->callApi('content_channel', 'fetchChannelById', array($channelid));
                 $url = $api->callApi('route', 'getUrl', array('route' => $channel['routeid'], 'data' => $channel, 'extra' => array()));
                 if (is_string($url)) {
                     $returnUrl = vB5_Template_Options::instance()->get('options.frontendurl') . $url;
                 }
             }
         }
     }
     if (!empty($returnUrl)) {
         $result['retUrl'] = $returnUrl;
     }
 }
Example #18
0
 protected function getApi()
 {
     return Api_InterfaceAbstract::instance();
 }
Example #19
0
 protected function fetchStyleVars()
 {
     $res = Api_InterfaceAbstract::instance()->callApi('style', 'fetchStyleVars', array($this->stylePreference));
     // api method returns unserealized stylevars
     if (empty($res) or !empty($res['errors'])) {
         return;
     }
     $user = vB5_User::instance();
     if (is_null($user['lang_options']) or isset($user['lang_options']) and is_array($user['lang_options']) and !empty($user['lang_options']['direction'])) {
         // if user has a LTR language selected
         $res['textdirection'] = array('datatype' => 'string', 'string' => 'ltr');
         $res['left'] = array('datatype' => 'string', 'string' => 'left');
         $res['right'] = array('datatype' => 'string', 'string' => 'right');
     } else {
         // if user has a RTL language selected
         $res['textdirection'] = array('datatype' => 'string', 'string' => 'rtl');
         $res['left'] = array('datatype' => 'string', 'string' => 'right');
         $res['right'] = array('datatype' => 'string', 'string' => 'left');
     }
     foreach ($res as $key => $value) {
         $this->cache[$key] = $value;
     }
 }
 public function actionKillActivation()
 {
     $data = array('u' => !empty($_GET['u']) ? intval($_GET['u']) : 0, 'i' => !empty($_GET['i']) ? trim($_GET['i']) : '');
     $api = Api_InterfaceAbstract::instance();
     $result = $api->callApi('user', 'killActivation', array('userid' => $data['u'], 'activateid' => $data['i']));
     $phraseController = vB5_Template_Phrase::instance();
     $phraseController->register('registration');
     if (!empty($result['errors']) and is_array($result['errors'])) {
         $phraseArgs = is_array($result['errors'][0]) ? $result['errors'][0] : array($result['errors'][0]);
     } else {
         $phraseArgs = is_array($result) ? $result : array($result);
     }
     $messagevar = call_user_func_array(array($phraseController, 'getPhrase'), $phraseArgs);
     vB5_ApplicationAbstract::showMsgPage($phraseController->getPhrase('registration'), $messagevar);
 }
Example #21
0
 public function legacy($file)
 {
     $api = Api_InterfaceAbstract::instance();
     $api->relay($file);
 }
Example #22
0
<?php

/*
 * Forum Runner
 *
 * Copyright (c) 2010-2011 to End of Time Studios, LLC
 *
 * This file may not be redistributed in whole or significant part.
 *
 * http://www.forumrunner.com
 */
define('CSRF_PROTECTION', false);
chdir('../');
require_once 'includes/vb5/autoloader.php';
vB5_Autoloader::register(getcwd());
vB5_Frontend_Application::init('config.php');
$return = Api_InterfaceAbstract::instance()->callApi('site', 'forumrunner_request');
if (!is_string($return)) {
    $config = vB::getConfig();
    if (!empty($config['Misc']['debug'])) {
        error_log(var_export($return, true));
    }
    $return = json_encode(array('success' => false, 'message' => 'Unknown error.'));
}
echo $return;
Example #23
0
 /**
  * Fetch node's preview
  *
  */
 public function actionFetchNodePreview()
 {
     $preview = '';
     $nodeid = isset($_REQUEST['nodeid']) ? intval($_REQUEST['nodeid']) : array();
     if (!empty($nodeid)) {
         if (!vb::getUserContext()->getChannelPermission('forumpermissions', 'canviewthreads', $nodeid)) {
             return '';
         }
         $contenttypes = vB_Types::instance()->getContentTypes();
         $typelist = array();
         foreach ($contenttypes as $key => $type) {
             $typelist[$type['id']] = $key;
         }
         $api = Api_InterfaceAbstract::instance();
         $contentTypes = array('vBForum_Text', 'vBForum_Gallery', 'vBForum_Poll', 'vBForum_Video', 'vBForum_Link');
         $nodes = $api->callApi('node', 'getNodeContent', array($nodeid));
         $node = $nodes[$nodeid];
         $contentType = $typelist[$node['contenttypeid']];
         if (in_array($contentType, $contentTypes)) {
             $preview = vB5_Template_NodeText::instance()->fetchOneNodePreview($nodeid, $api);
         }
         $previewLength = vB5_Template_Options::instance()->get('options.threadpreview');
         if (strlen($preview) > $previewLength) {
             $preview = substr($preview, 0, $previewLength);
         }
     }
     return $preview;
 }
Example #24
0
 private function loadJsBundles()
 {
     $jsfilelist = Api_InterfaceAbstract::instance()->callApi('product', 'loadProductXmlListParsed', array('type' => 'jsrollup', 'typekey' => true));
     if (empty($jsfilelist['vbulletin'])) {
         return false;
     } else {
         $data = $jsfilelist['vbulletin'];
     }
     if (!is_array($data['rollup'][0])) {
         $data['rollup'] = array($data['rollup']);
     }
     foreach ($data['rollup'] as $file) {
         if (!is_array($file['template'])) {
             $file['template'] = array($file['template']);
         }
         foreach ($file['template'] as $name) {
             $vbdefaultjs["{$file['name']}"] = $file['template'];
         }
     }
     $this->jsbundles = $vbdefaultjs;
     // TODO: Add product xml handling here if we need it.
     return true;
 }
 /**
  * This gets phrase data from an ajax request.
  */
 protected function fetchImage()
 {
     $config = vB5_Config::instance();
     //first see if we have a php session
     //Check cookies
     $cookiePrefix = $config->cookie_prefix;
     //Need to instantiate a session.
     if (!empty($_COOKIE[$cookiePrefix . 'sessionhash'])) {
         $sessionHash = $_COOKIE[$cookiePrefix . 'sessionhash'];
     } else {
         $sessionHash = false;
     }
     $api = Api_InterfaceAbstract::instance('light');
     $request = array('id' => 0, 'type' => '', 'includeData' => true);
     if (isset($_REQUEST['type']) and !empty($_REQUEST['type'])) {
         $request['type'] = $_REQUEST['type'];
     } else {
         if (!empty($_REQUEST['thumb']) and intval($_REQUEST['thumb'])) {
             $request['type'] = 'thumb';
         }
     }
     if (!empty($_REQUEST['id']) and intval($_REQUEST['id'])) {
         $request['id'] = $_REQUEST['id'];
         try {
             set_error_handler(array($this, 'handleImageError'), E_ALL | E_STRICT);
             $fileInfo = $api->callApi('content_attach', 'fetchImage', $request);
         } catch (Exception $e) {
             //just end quietly
             return '';
         }
     } else {
         if (!empty($_REQUEST['filedataid']) and intval($_REQUEST['filedataid'])) {
             $request['id'] = $_REQUEST['filedataid'];
             try {
                 set_error_handler(array($this, 'handleImageError'), E_ALL | E_STRICT);
                 $fileInfo = $api->callApi('filedata', 'fetchImageByFiledataid', $request);
             } catch (Exception $e) {
                 //just end quietly
                 return '';
             }
         } else {
             if (!empty($_REQUEST['photoid']) and intval($_REQUEST['photoid'])) {
                 $request['id'] = $_REQUEST['photoid'];
                 $fileInfo = $api->callApi('content_photo', 'fetchImageByPhotoid', $request);
             } else {
                 if (!empty($_REQUEST['linkid']) and intval($_REQUEST['linkid'])) {
                     $request['id'] = $_REQUEST['linkid'];
                     $request['includeData'] = false;
                     try {
                         set_error_handler(array($this, 'handleImageError'), E_ALL | E_STRICT);
                         $fileInfo = $api->callApi('content_link', 'fetchImageByLinkId', $request);
                     } catch (Exception $e) {
                         //just end quietly
                         return '';
                     }
                 } else {
                     if (!empty($_REQUEST['attachid']) and intval($_REQUEST['attachid'])) {
                         $request['id'] = $_REQUEST['attachid'];
                         try {
                             set_error_handler(array($this, 'handleImageError'), E_ALL | E_STRICT);
                             $fileInfo = $api->callApi('content_attach', 'fetchImage', $request);
                         } catch (Exception $e) {
                             //just end quietly
                             return '';
                         }
                     } else {
                         if (!empty($_REQUEST['channelid']) and intval($_REQUEST['channelid'])) {
                             $request['id'] = $_REQUEST['channelid'];
                             try {
                                 set_error_handler(array($this, 'handleImageError'), E_ALL | E_STRICT);
                                 $fileInfo = $api->callApi('content_channel', 'fetchChannelIcon', $request);
                             } catch (Exception $e) {
                                 //just end quietly
                                 return '';
                             }
                         } else {
                             return '';
                         }
                     }
                 }
             }
         }
     }
     if (!empty($fileInfo['filedata'])) {
         header('ETag: "' . $fileInfo['filedataid'] . '"');
         header('Accept-Ranges: bytes');
         header('Content-transfer-encoding: binary');
         header("Content-Length: " . $fileInfo['filesize']);
         $fileInfo['extension'] = strtolower($fileInfo['extension']);
         if (in_array($fileInfo['extension'], array('jpg', 'jpe', 'jpeg', 'gif', 'png'))) {
             header("Content-Disposition: inline; filename=\"image_" . $fileInfo['filedataid'] . "." . $fileInfo['extension'] . "\"");
             header('Content-transfer-encoding: binary');
         } else {
             $attachInfo = $api->callApi('content_attach', 'fetchAttachByFiledataids', array('filedataids' => array($fileInfo['filedataid'])));
             // force files to be downloaded because of a possible XSS issue in IE
             header("Content-disposition: attachment; filename=\"" . $attachInfo[$fileInfo['filedataid']]['filename'] . "\"");
         }
         header('Cache-control: max-age=31536000, private');
         header('Expires: ' . gmdate("D, d M Y H:i:s", time() + 31536000) . ' GMT');
         header('Pragma:');
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $fileInfo['dateline']) . ' GMT');
         foreach ($fileInfo['headers'] as $header) {
             header($header);
         }
         echo $fileInfo['filedata'];
     }
 }
Example #26
0
 /**
  * Forgot password form action
  * Reset url = /auth/lostpw/?action=pwreset&userid=<n>&activationid=<xxxxx>
  */
 public function actionLostpw()
 {
     $input = array('email' => isset($_POST['email']) ? trim(strval($_POST['email'])) : '', 'hvinput' => isset($_POST['humanverify']) ? (array) $_POST['humanverify'] : array(), 'action' => isset($_REQUEST['action']) ? trim($_REQUEST['action']) : '', 'userid' => isset($_REQUEST['userid']) ? trim(strval($_REQUEST['userid'])) : '', 'activationid' => isset($_REQUEST['activationid']) ? trim($_REQUEST['activationid']) : '');
     if (isset($_POST['recaptcha_challenge_field']) and $_POST['recaptcha_challenge_field']) {
         $input['hvinput']['recaptcha_challenge_field'] = $_POST['recaptcha_challenge_field'];
     }
     if (isset($_POST['recaptcha_response_field']) and $_POST['recaptcha_response_field']) {
         $input['hvinput']['recaptcha_response_field'] = $_POST['recaptcha_response_field'];
     }
     $api = Api_InterfaceAbstract::instance();
     if ($input['action'] == 'pwreset') {
         $response = $api->callApi('user', 'resetPassword', array('userid' => $input['userid'], 'activationid' => $input['activationid']));
         if (isset($response['errors'])) {
             $phraseController = vB5_Template_Phrase::instance();
             $phraseController->register('error');
             //call message first so that we pull both phrases at the same time
             $message = call_user_func_array(array($phraseController, 'getPhrase'), $response['errors'][0]);
             $title = $phraseController->getPhrase('error');
         } else {
             $title = $response['password_reset'];
             $message = $response['resetpw_message'];
         }
         vB5_ApplicationAbstract::showMsgPage($title, $message);
     } else {
         $response = $api->callApi('user', 'emailPassword', array('userid' => 0, 'email' => $input['email'], 'hvinput' => $input['hvinput']));
         $this->sendAsJson(array('response' => $response));
     }
 }
Example #27
0
<?php

/*
 * Forum Runner
 *
 * Copyright (c) 2010-2011 to End of Time Studios, LLC
 *
 * This file may not be redistributed in whole or significant part.
 *
 * http://www.forumrunner.com
 */
chdir('../');
require_once 'includes/vb5/autoloader.php';
vB5_Autoloader::register(getcwd());
vB5_Frontend_Application::init('config.php');
Api_InterfaceAbstract::instance()->callApi('site', 'forumrunner_image');
Example #28
0
 /**
  * This gets the charset based on the current language
  *
  * @return string, stylevar charset value
  */
 public static function getCharset()
 {
     // first check for user info
     $encoding = vB5_User::get('lang_charset');
     if (!$encoding) {
         $encoding = Api_InterfaceAbstract::instance()->callApi('phrase', 'getLanguageid', array('getCharset' => true));
         if (empty($encoding['charset'])) {
             return 'UTF-8';
         }
         $encoding = $encoding['charset'];
     }
     return strtoupper($encoding);
 }
Example #29
0
 /**
  * Constructor
  */
 protected function __construct()
 {
     $this->data = Api_InterfaceAbstract::instance()->callApi('user', 'fetchCurrentUserinfo', array());
 }
Example #30
0
 /**
  * @param $textDataArray
  * @param $nodeId
  * @param $bbcodeOptions
  * @return array
  */
 protected function parseNode($textDataArray, $nodeId, $bbcodeOptions)
 {
     $textData = $textDataArray[$nodeId];
     $skipBbCodeParsing = $textData['disable_bbcode'];
     // if disable_bbcode is set (static pages), just use the rawtext
     $parser = new vB5_Template_BbCode();
     $parser->setRenderImmediate(true);
     $parser->setMultiPageRender($textData['channeltype'] == 'article');
     if (isset($textData['attachments'])) {
         $parser->setAttachments($textData['attachments']);
     }
     if (isset($textData['attachments']) and empty($textData['attachments'])) {
         $parser->getAndSetAttachments($nodeId);
     }
     //make sure we have values for all the necessary options
     foreach (array('allowimages', 'allowimagebbcode', 'allowbbcode', 'allowsmilies') as $option) {
         if (!empty($bbcodeOptions) and isset($bbcodeOptions[$option])) {
             $textData['bbcodeoptions'][$option] = $bbcodeOptions[$option];
         } else {
             if (!isset($textData['bbcodeoptions'][$option])) {
                 $textData['bbcodeoptions'][$option] = false;
             }
         }
     }
     /*
     	bbcodeOptions['allowhtml'] comes from channel.options & 256 (bf_misc_forumoptions.allowhtml),
     	except for public_preview > 0 articles that the user can't view... (see function vB_Api_Content_Text->getDataForParse() & queryef vBForum:getDataForParse)
     	so we should actually be ignoring that, and using htmlstate only.
     	Unfortunately, we can't just ignore it in the parser's doParse() function, because there is at least 1 other thing that seems to use allowhtml: announcements. I'm placing
     	the change here instead of the parser in order to minimize risk.
     	Alternatively, we could just make sure that every single channel is created with allowhtml set, but that'd also mean we're keeping this option, and adding
     	an upgrade step to fix all old channels that may have been created with allowhtml unset.
     */
     $textData['bbcodeoptions']['allowhtml'] = in_array($textData['htmlstate'], array('on', 'on_nl2br'));
     $allowimages = false;
     if (!empty($bbcodeOptions) and !empty($bbcodeOptions['allowimages'])) {
         $allowimages = $bbcodeOptions['allowimages'];
     } else {
         if (!empty($bbcodeOptions['cangetimgattachment'])) {
             $allowimages = $bbcodeOptions['cangetimgattachment'];
         } else {
             if (!empty($textData['bbcodeoptions']['allowimages'])) {
                 $allowimages = $textData['bbcodeoptions']['allowimages'];
             } else {
                 if (!empty($textData['bbcodeoptions']['allowimagecode'])) {
                     $allowimages = $textData['bbcodeoptions']['allowimagecode'];
                 }
             }
         }
     }
     if ($textData['channeltype'] == 'article') {
         if (!$skipBbCodeParsing) {
             //If it's paginated we parse it here.
             $matches = array();
             $check = preg_match_all('#\\[page\\].*\\[\\/page\\]#siU', $textData['rawtext'], $matches, PREG_OFFSET_CAPTURE);
             $start = 0;
             $title = $textData['title'];
             $parsed = array();
             // If [page] is at the beginning of the text, use it for the first page title
             // instead of using the article title for the first one.
             $hasFirstPageTitle = (bool) preg_match('#^\\s*\\[PAGE\\]#siU', $textData['rawtext']);
             if (!empty($matches[0])) {
                 foreach ($matches[0] as $match) {
                     if ($hasFirstPageTitle) {
                         $hasFirstPageTitle = false;
                         $start = strlen($match[0]) + $match[1];
                         $title = vB_String::stripBbcode($match[0]);
                         continue;
                     }
                     $rawtext = substr($textData['rawtext'], $start, $match[1] - $start);
                     $currentText = $parser->doParse($rawtext, $textData['bbcodeoptions']['allowhtml'], $textData['bbcodeoptions']['allowsmilies'], $textData['bbcodeoptions']['allowbbcode'], $allowimages, true, false, $textData['htmlstate'], false, $textData['rawtext']);
                     $parsed[] = array('title' => $title, 'pageText' => $currentText);
                     $start = strlen($match[0]) + $match[1];
                     $title = vB_String::stripBbcode($match[0]);
                 }
                 if (!empty($start) and $start < strlen($textData['rawtext'])) {
                     $rawtext = substr($textData['rawtext'], $start);
                     $currentText = $parser->doParse($rawtext, $textData['bbcodeoptions']['allowhtml'], $textData['bbcodeoptions']['allowsmilies'], $textData['bbcodeoptions']['allowbbcode'], $allowimages, true, false, $textData['htmlstate'], false, $textData['rawtext']);
                     $parsed[] = array('title' => $title, 'pageText' => $currentText);
                 }
             }
             $paging = array();
             $pageNo = 1;
             $phrases = vB5_Template_Phrase::instance();
             foreach ($parsed as $page) {
                 if (empty($page['title'])) {
                     $page['title'] = $phrases->getPhrase('page_x', $pageNo);
                 }
                 $paging[$pageNo] = $page['title'];
                 $pageNo++;
             }
             Api_InterfaceAbstract::instance()->cacheInstance(0)->write($this->getPagingCacheKey($nodeId), $paging, 1440, 'nodeChg_' . $nodeId);
         } else {
             $parsed = $textData['rawtext'];
             $matches[0] = 1;
             // skip re-parsing below.
         }
     }
     if (empty($matches[0])) {
         // Get full text
         $parsed = $parser->doParse($textData['rawtext'], $textData['bbcodeoptions']['allowhtml'], $textData['bbcodeoptions']['allowsmilies'], $textData['bbcodeoptions']['allowbbcode'], $allowimages, true, false, $textData['htmlstate']);
     }
     // Get preview text
     if (empty($this->previewLength)) {
         if (isset($textData['previewLength'])) {
             $this->previewLength = $textData['previewLength'];
         } else {
             $options = Api_InterfaceAbstract::instance()->callApiStatic('options', 'fetchStatic', array('previewLength'));
             $this->previewLength = $options['previewLength'];
         }
     }
     // if textData has previewLength set, we always want to use it (articles)
     if (isset($textData['previewLength'])) {
         $previewLength = $textData['previewLength'];
     } else {
         $previewLength = $this->previewLength;
     }
     if ($skipBbCodeParsing) {
         // static pages from vb4 should always have text.previewtext set, taken from cms_nodeconfig.value where name = 'previewtext'
         // As such, we should always set the previewtext for static pages created in vB5.
         $previewText = $textData['previewtext'];
     } else {
         $previewText = $parser->get_preview($textData['rawtext'], $previewLength, $textData['bbcodeoptions']['allowhtml'], true, $textData['htmlstate'], array('do_smilies' => $textData['bbcodeoptions']['allowsmilies'], 'allowPRBREAK' => !empty($textData['disableBBCodes']['prbreak'])));
     }
     if (is_array($parsed)) {
         // for multi-paged articles, $parsed is an array, let's check the length
         // of the first page of that article for purposes of appending the ellipsis
         $parsedLength = strlen($parsed[0]['pageText']);
     } else {
         $parsedLength = strlen($parsed);
     }
     // Append ellipsis if preview text is shorter than parsed full text.
     // One special case to note is if previewText has 0 length. This could happen if the previewText is entirely composed of bbcodes that are stripped via parsing
     // If we want special behavior, we should check for that case here and not append the ellipsis
     if ($parsedLength > strlen($previewText)) {
         $previewText .= '...';
     }
     return array($previewText, $parsed);
 }