Esempio n. 1
0
function do_get_cms_article()
{
    global $vbulletin, $db, $contenttype;
    $vbulletin->input->clean_array_gpc('r', array('articleid' => TYPE_UINT, 'page' => TYPE_UINT, 'perpage' => TYPE_UINT));
    if (!$vbulletin->GPC['articleid']) {
        json_error(ERR_NO_PERMISSION);
    }
    $page = 1;
    if ($vbulletin->GPC['page']) {
        $page = $vbulletin->GPC['page'];
    }
    $perpage = 10;
    if ($vbulletin->GPC['perpage']) {
        $perpage = $vbulletin->GPC['perpage'];
    }
    if ($perpage > 50 || $perpage < 5) {
        $perpage = 10;
    }
    if ($page < 1) {
        $page = 1;
    }
    $articleid = $vbulletin->GPC['articleid'];
    $article = new vBCms_Item_Content_Article($articleid, vBCms_Item_Content::INFO_CONTENT);
    $associated_thread_id = $article->getAssociatedThreadId();
    if (!$associated_thread_id) {
        $associated_thread_id = create_associated_thread($article);
        if ($associated_thread_id) {
            $article->setAssociatedThread($associated_thread_id);
        }
    }
    $posts_out = array();
    $fr_images = array();
    // Display article if on first page of comments
    if ($page == 1) {
        // First, the article
        $postdate = vbdate($vbulletin->options['dateformat'], $article->getPublishDate(), 1);
        $posttime = vbdate($vbulletin->options['timeformat'], $article->getPublishDate());
        // Parse the post for quotes and inline images
        $contenttype = vB_Types::instance()->getContentTypeID("vBCms_Article");
        // Attachments (images).
        if (count($post['attachments']) > 0) {
            foreach ($post['attachments'] as $attachment) {
                $lfilename = strtolower($attachment['filename']);
                if (strpos($lfilename, '.jpe') !== false || strpos($lfilename, '.png') !== false || strpos($lfilename, '.gif') !== false || strpos($lfilename, '.jpg') !== false || strpos($lfilename, '.jpeg') !== false) {
                    $fr_images[] = array('img' => $vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid'], 'tmb' => $vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid'] . '&stc=1&thumb=1');
                }
            }
        }
        list($text, $nuked_quotes, $images) = parse_post(strip_tags($article->getPageText()), false);
        if (count($fr_images) > 0) {
            $text .= "<br/>";
            foreach ($fr_images as $attachment) {
                $text .= "<img src=\"{$attachment['img']}\"/>";
            }
        }
        foreach ($images as $image) {
            $fr_images[] = array('img' => $image);
        }
        $avatarurl = '';
        // Avatar work
        if ($vbulletin->options['avatarenabled']) {
            require_once DIR . '/includes/functions_user.php';
            $userinfo = fetch_userinfo($article->getUserId(), FETCH_USERINFO_AVATAR);
            fetch_avatar_from_userinfo($userinfo);
            if ($userinfo['avatarurl']) {
                $avatarurl = process_avatarurl($userinfo['avatarurl']);
            }
        }
        $tmp = array('post_id' => $article->getPostId() ? $article->getPostId() : 999999999, 'thread_id' => $associated_thread_id, 'username' => prepare_utf8_string($article->getUsername()), 'joindate' => prepare_utf8_string($userinfo['joindate']), 'usertitle' => prepare_utf8_string(strip_tags($userinfo['usertitle'])), 'numposts' => $userinfo['posts'], 'userid' => $userinfo['userid'], 'post_timestamp' => prepare_utf8_string(date_trunc($postdate) . ' ' . $posttime), 'fr_images' => $fr_images, 'image_thumbs' => array());
        $tmp['text'] = $text;
        $tmp['quotable'] = $nuked_quotes;
        if ($post['editlink']) {
            $tmp['canedit'] = true;
            $tmp['edittext'] = prepare_utf8_string($post['pagetext']);
        }
        if ($avatarurl != '') {
            $tmp['avatarurl'] = $avatarurl;
        }
        if ($article->getPreviewVideo()) {
            if (preg_match(',data="(.*?)",', $article->getPreviewVideo(), $matches)) {
                $video = $matches[1];
                if (strpos($matches[1], 'vimeo')) {
                    $clip_id = 0;
                    if (preg_match(',clip_id=(\\d+),', $matches[1], $matches2)) {
                        $clip_id = $matches2[1];
                    } else {
                        if (preg_match(',vimeo\\.com/(\\d*)?,', $matches[1], $matches2)) {
                            $clip_id = $matches2[1];
                        } else {
                            $clip_id = $matches[1];
                        }
                    }
                    $video = "<iframe src=\"http://player.vimeo.com/video/{$clip_id}\" ignore=\"%@\" width=\"%0.0f\" height=\"%d\" frameborder=\"0\"></iframe>";
                } else {
                    $video = <<<EOF
<object id="videoc" width="%0.0f" height="%d">
<param name="movie" value="{$matches[1]}"></param>
<param name="wmode" value="transparent"></param>
<embed wmode="transparent" id="video" src="{$matches[1]}" type="application/x-shockwave-flash" width="%0.0f" height="%d"></embed>
</object>
EOF;
                }
                $tmp['video'] = prepare_utf8_string($video);
            }
        }
        $posts_out[] = $tmp;
    }
    $this_user = new vB_Legacy_CurrentUser();
    $threadinfo = verify_id('thread', $associated_thread_id, 0, 1);
    // Now, get the posts
    $total = 0;
    if ($associated_thread_id) {
        $comments = get_article_comments($article, $associated_thread_id, $this_user, $page, $perpage, $total);
        $posts_out = array_merge($posts_out, $comments);
    }
    $canpost = true;
    $userid = $this_user->get_field('userid');
    if (empty($userid)) {
        $canpost = false;
    }
    if ($userid != $threadinfo['postuserid']) {
        $canpost = $this_user->hasForumPermission($threadinfo['forumid'], 'canreplyothers');
    } else {
        $canpost = $this_user->hasForumPermission($threadinfo['forumid'], 'canreplyown');
    }
    return array('posts' => $posts_out, 'total_posts' => $total, 'page' => $page, 'canpost' => $canpost, 'threadid' => $associated_thread_id, 'title' => prepare_utf8_string($article->getTitle()));
}
Esempio n. 2
0
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
//check usergroup of user to see if they can use this
if (!$vbulletin->userinfo['userid']) {
    print_no_permission();
}
$reportthread = ($rpforumid = $vbulletin->options['rpforumid'] and $rpforuminfo = fetch_foruminfo($rpforumid));
$reportemail = ($vbulletin->options['enableemail'] and $vbulletin->options['rpemail']);
if (!$reportthread and !$reportemail) {
    eval(standard_error(fetch_error('emaildisabled')));
}
$vbulletin->input->clean_array_gpc('r', array('return_node' => TYPE_UINT));
if ($vbulletin->GPC['return_node']) {
    $report_type = 'article_comment';
    $content = new vBCms_Item_Content_Article($vbulletin->GPC['return_node']);
    $reportobj = new vB_ReportItem_ArticleComment($vbulletin);
    $reportobj->set_extrainfo('node', $vbulletin->GPC['return_node']);
    $reportobj->set_extrainfo('forum', $foruminfo);
    $reportobj->set_extrainfo('thread', $threadinfo);
    // check cms permissions on the article
    if (!$content->canView()) {
        print_no_permission();
    }
    define('CMS_SCRIPT', true);
    vB_View::registerTemplater(vB_View::OT_XHTML, new vB_Templater_vB());
    vBCms_NavBar::prepareNavBar($content);
} else {
    $report_type = 'post';
    $reportobj = new vB_ReportItem_Post($vbulletin);
    $reportobj->set_extrainfo('forum', $foruminfo);
Esempio n. 3
0
	/** Gets the preview text for the article
	 *
	 * @return	string	previewtext
	 ***/
	public function getPreviewText($article)
	{
		$context = new vB_Context('vbcms_article_previewtext_' . $article['nodeid']);
		$hashkey = strval($context);
		if ($rendered = vB_Cache::instance()->read($hashkey, true, true))
		{
			return $rendered;
		}

		$item =  new vBCms_Item_Content_Article($article['nodeid'], vBCms_Item_Content::INFO_CONTENT);
		return fetch_censored_text($item->getPreviewText()) ;
	}
Esempio n. 4
0
 /**
  * Sets information regarding the report
  *
  * @param	array	Information regarding the report
  *
  */
 function set_reportinfo(&$reportinfo)
 {
     $content = new vBCms_Item_Content_Article($this->extrainfo['node']);
     parent::set_reportinfo($reportinfo);
     $reportinfo = array_merge($reportinfo, array('entrytitle' => unhtmlspecialchars($content->getTitle()), 'node' => $this->extrainfo['node'], 'itemlink' => vBCms_Route_Content::getURL(array('node' => $this->extrainfo['node'] . '-' . $content->getUrl())), 'postid' => $this->iteminfo['postid']));
 }