/** * Формирует(но не сохраняет) тело сообщения * * @param array $post * @global vB_Registry $vbulletin * @return string */ protected function _make_message_body($post) { global $vbulletin, $foruminfo, $threadinfo; $message = ''; if (!intval($this->_post_id)) { return $message; } if (empty($post['pagetext'])) { $post['pagetext'] = $post['message']; } $post['allowsmilie'] = $post['enablesmilies']; // get attachments require_once DIR . '/packages/vbattach/attach.php'; $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post'); $postattach = $attach->fetch_postattach(0, $this->_post_id); $post['attachments'] = $postattach; $userinfo = fetch_userinfo($post['userid']); require_once DIR . '/includes/class_postbit.php'; $postbit_factory = new vB_Postbit_Factory(); $postbit_factory->registry =& $vbulletin; $postbit_factory->forum =& $foruminfo; $postbit_factory->thread =& $threadinfo; $postbit_factory->cache = array(); $postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list()); $postbit_factory->bbcode_parser->set_parse_userinfo($userinfo); $postbit_obj =& $postbit_factory->fetch_postbit('post_nntp'); $this->_body = $postbit_obj->construct_postbit($post); return $this->_body; }
// remove sessionhash from urls: $thread['prefix_plain'] = ($thread['prefixid'] ? $vbphrase["prefix_$thread[prefixid]_title_plain"] . ' ' : ''); $threadcache[] = $thread; if ($thread['attach']) { $postids["$thread[postid]"] = $thread['threadid']; } } $lastmodified = (!empty($thread[0]['dateline']) ? $thread[0]['dateline'] : TIMENOW); $expires = TIMENOW + $cachetime; $attachmentcache = array(); if (!$vbulletin->GPC['nohtml'] AND !empty($postids) AND ($vbulletin->GPC['type'] == 'RSS1' OR $vbulletin->GPC['type'] == 'RSS2')) { require_once(DIR . '/packages/vbattach/attach.php'); $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post'); $attachmentcache = $attach->fetch_postattach(0, array_keys($postids)); } if ($number_of_forums == 1 AND $vbulletin->GPC['type'] == 'RSS2' AND $vbulletin->options['rsspodcast']) { $podcastinfo = $db->query_first_slave(" SELECT * FROM " . TABLE_PREFIX . "podcast WHERE forumid = $forumid AND enabled = 1 "); $podcastforumid = $forumchoice[0]; } else { $podcastforumid = 0;
$globalignore = ''; } $categories = array(); // Get categories $cats = $db->query_read_slave("\r\n\t\tSELECT blog_categoryuser.blogcategoryid, blog_categoryuser.userid, blog_category.userid AS creatorid\r\n\t\tFROM " . TABLE_PREFIX . "blog_categoryuser AS blog_categoryuser\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "blog_category AS blog_category ON (blog_category.blogcategoryid = blog_categoryuser.blogcategoryid)\r\n\t\tWHERE blog_categoryuser.blogid = {$bloginfo['blogid']}\r\n\t"); while ($category = $db->fetch_array($cats)) { if (!($bloginfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_cancreatecategory']) and $category['creatorid']) { continue; } $category['title'] = $category['creatorid'] ? $bloginfo['categorycache']["{$category['blogcategoryid']}"]['title'] : $vbphrase['category' . $category['blogcategoryid'] . '_title']; $entry_categories["{$bloginfo['blogid']}"][] = $category; } // load attachments if ($bloginfo['attach']) { require_once DIR . '/packages/vbattach/attach.php'; $attach = new vB_Attach_Display_Content($vbulletin, 'vBBlog_BlogEntry'); $postattach = $attach->fetch_postattach(0, $bloginfo['blogid']); } if ($vbulletin->options['vbblog_pingback'] and $bloginfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canreceivepingback']) { $show['pingbacklink'] = true; $pingbackurl = $vbulletin->options['bburl'] . '/blog_callback.php'; header("X-Pingback: {$pingbackurl}"); } if ($vbulletin->options['vbblog_trackback'] and $bloginfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canreceivepingback']) { $show['trackbackrdf'] = true; $trackbackurl = $vbulletin->options['bburl'] . '/blog_callback.php?b=' . $bloginfo['blogid']; $abouturl = $vbulletin->options['bburl'] . '/' . fetch_seo_url('entry', $bloginfo); } // Load trackbacks if ($show['pingbacklink'] or $show['trackbackrdf']) { $canmoderation = (can_moderate_blog('canmoderatecomments') or is_member_of_blog($vbulletin->userinfo, $bloginfo));
/** * Prepare any data needed for the output * * @param string The id of the block * @param array Options specific to the block */ function prepare_output($id = '', $options = array()) { global $show, $vbphrase; if (!$this->registry->userinfo['userid']) { prepare_blog_category_permissions($this->registry->userinfo); } $show['lastentry'] = true; $this->block_data['entries'] = vb_number_format($this->profile->userinfo['entries']); $this->block_data['lastblogtitle'] = ''; $this->block_data['lastblogdate'] = $vbphrase['never']; $this->block_data['lastblogtime'] = ''; $memberblogs = explode(',', $this->profile->userinfo['memberblogids']); if (count($memberblogs) > 1) { $sqland = array( "bu.bloguserid IN (" . $this->profile->userinfo['memberblogids'] . ")" ); if (!($this->registry->userinfo['permissions']['vbblog_general_permissions'] & $this->registry->bf_ugp_vbblog_general_permissions['blog_canviewothers'])) { $sqland[] = "bu.bloguserid = " . $this->registry->userinfo['userid']; } if (!($this->registry->userinfo['permissions']['vbblog_general_permissions'] & $this->registry->bf_ugp_vbblog_general_permissions['blog_canviewown']) AND $this->registry->userinfo['userid']) { $sqland[] = "bu.bloguserid <> " . $this->registry->userinfo['userid']; } if (trim($this->registry->options['globalignore']) != '') { require_once(DIR . '/includes/functions_bigthree.php'); if ($coventry = fetch_coventry('string') AND !can_moderate_blog()) { $sqland[] = "bu.bloguserid NOT IN ($coventry)"; } } $sqlor = array(); $sqljoin = array(); if (!can_moderate_blog()) { if ($this->registry->userinfo['userid']) { $sqlor[] = "bu.bloguserid IN (" . $this->registry->userinfo['memberblogids'] . ")"; $sqlor[] = "(options_ignore & " . $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND ignored.relationid IS NOT NULL)"; $sqlor[] = "(options_buddy & " . $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddy.relationid IS NOT NULL)"; $sqlor[] = "(options_member & " . $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND (options_buddy & " .$this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR buddy.relationid IS NULL) AND (options_ignore & " . $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR ignored.relationid IS NULL))"; $sqland[] = "(" . implode(" OR ", $sqlor) . ")"; $sqljoin[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS buddy ON (buddy.userid = bu.bloguserid AND buddy.relationid = " . $this->registry->userinfo['userid'] . " AND buddy.type = 'buddy')"; $sqljoin[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS ignored ON (ignored.userid = bu.bloguserid AND ignored.relationid = " . $this->registry->userinfo['userid'] . " AND ignored.type = 'ignore')"; } else { $sqland[] = "options_guest & " . $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog']; $sqland[] = "~blog.options & " . $this->registry->bf_misc_vbblogoptions['private']; } } if ($this->registry->userinfo['userid'] AND in_coventry($this->registry->userinfo['userid'], true)) { $sqlfields[] = "IF(blog_tachyentry.userid IS NULL, blog.lastcomment, blog_tachyentry.lastcomment) AS lastcomment"; $sqlfields[] = "IF(blog_tachyentry.userid IS NULL, blog.lastcommenter, blog_tachyentry.lastcommenter) AS lastcommenter"; $sqlfields[] = "IF(blog_tachyentry.userid IS NULL, blog.lastblogtextid, blog_tachyentry.lastblogtextid) AS lastblogtextid"; $sqljoin[] = "LEFT JOIN " . TABLE_PREFIX . "blog_tachyentry AS blog_tachyentry ON (blog_tachyentry.blogid = bu.lastblogid AND blog_tachyentry.userid = " . $this->registry->userinfo['userid'] . ")"; $sqljoin[] = "LEFT JOIN " . TABLE_PREFIX . "blog_text AS blog_text ON (blog_text.blogtextid = IF(blog_tachyentry.userid IS NULL, blog.lastblogtextid, blog_tachyentry.lastblogtextid))"; } else { $sqljoin[] = "LEFT JOIN " . TABLE_PREFIX . "blog_text AS blog_text ON (blog_text.blogtextid = bu.lastblogtextid)"; } $temp = $show['inlinemod']; $show['inlinemod'] = false; $blogs = $this->registry->db->query_read_slave(" SELECT user.*, IF(bu.title, bu.title, user.username) AS blogtitle, user.userid, user.username, bu.lastblog, bu.lastblogid AS lastblogid, bu.lastblogtitle, bu.lastcomment, bu.lastblogtextid AS lastblogtextid, bu.lastcommenter, bu.options_member, bu.options_buddy, bu.ratingnum, bu.ratingtotal, bu.title, bu.entries, bu.comments, bu.title, blog.categories, blog2.categories AS categories_lastcomment FROM " . TABLE_PREFIX . "blog_user AS bu LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = bu.bloguserid) LEFT JOIN " . TABLE_PREFIX . "blog AS blog ON (blog.blogid = bu.lastblogid) " . (!empty($sqljoin) ? implode("\r\n", $sqljoin) : "") . " LEFT JOIN " . TABLE_PREFIX . "blog AS blog2 ON (blog2.blogid = blog_text.blogid) WHERE " . implode("\r\n\tAND ", $sqland) . " "); while ($blog = $this->registry->db->fetch_array($blogs)) { $blog = array_merge($blog, convert_bits_to_array($blog['options'], $this->registry->bf_misc_useroptions)); $blog = array_merge($blog, convert_bits_to_array($blog['adminoptions'], $this->registry->bf_misc_adminoptions)); $show['private'] = false; if (can_moderate() AND $blog['userid'] != $this->registry->userinfo['userid']) { $membercanview = $blog['options_member'] & $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog']; $buddiescanview = $blog['options_buddy'] & $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog']; if (!$membercanview AND (!$blog['buddyid'] OR !$buddiescanview)) { $show['private'] = true; } } $blog['entries'] = vb_number_format($blog['entries']); $blog['comments'] = vb_number_format($blog['comments']); $blog['lastentrydate'] = vbdate($this->registry->options['dateformat'], $blog['lastblog'], true); $blog['lastentrytime'] = vbdate($this->registry->options['timeformat'], $blog['lastblog']); $blog['entrytitle'] = fetch_trimmed_title($blog['lastblogtitle'], 20); if ($blog['title']) { $blog['title'] = fetch_trimmed_title($blog['title'], 50); } $lastentrycats = explode(',', $blog['categories']); $lastcommentcats = explode(',', $blog['categories_lastcomment']); $show['lastentry'] = array_intersect($this->registry->userinfo['blogcategorypermissions']['cantview'], $lastentrycats) ? false : true; $show['lastcomment'] = array_intersect($this->registry->userinfo['blogcategorypermissions']['cantview'], $lastcommentcats) ? false : true; $templater = vB_Template::create('blog_blog_row'); $templater->register('blog', $blog); $templater->register('thread', $thread); $groupbits .= $templater->render(); } $this->block_data['groupblogs'] = $groupbits; $show['inlinemod'] = $temp; } if (!in_coventry($this->profile->userinfo['userid']) AND ($this->profile->userinfo['lastblog'])) { $sql_and = array(); $state = array('visible'); $sql_and[] = "blog.state IN('" . implode("', '", $state) . "')"; $sql_and[] = "blog.dateline <= " . TIMENOW; $sql_and[] = "blog.pending = 0"; $sql_and[] = "blog.userid = " . $this->profile->userinfo['userid']; if (!can_moderate_blog() AND $this->profile->userinfo['userid'] != $this->registry->userinfo['userid'] AND !$bloginfo['buddyid']) { $sql_and[] = "~blog.options & " . $this->registry->bf_misc_vbblogoptions['private']; } if (!empty($this->registry->userinfo['blogcategorypermissions']['cantview']) AND $this->profile->userinfo['userid'] != $this->registry->userinfo['userid']) { $joinsql = "LEFT JOIN " . TABLE_PREFIX . "blog_categoryuser AS cu ON (cu.blogid = blog.blogid AND cu.blogcategoryid IN (" . implode(", ", $this->registry->userinfo['blogcategorypermissions']['cantview']) . "))"; $sql_and[] = "cu.blogcategoryid IS NULL"; } $blogids = array(); $blogs = $this->registry->db->query_read_slave(" SELECT blog.blogid, blog.attach FROM " . TABLE_PREFIX . "blog AS blog $joinsql WHERE " . implode("\r\n\tAND ", $sql_and) . " ORDER BY blog.dateline DESC LIMIT 5 "); while ($blog = $this->registry->db->fetch_array($blogs)) { $blogids[] = $blog['blogid']; $attachcount += $blog['attach']; } if ($blogids) { // Query Attachments if ($attachcount) { require_once(DIR . '/packages/vbattach/attach.php'); $attach = new vB_Attach_Display_Content($this->registry, 'vBBlog_BlogEntry'); $postattach = $attach->fetch_postattach(0, $blogids); } $this->block_data['lastblogtitle'] = $this->profile->userinfo['lastblogtitle']; $this->block_data['lastblogdate'] = vbdate($this->registry->options['dateformat'], $this->profile->userinfo['lastblog']); $this->block_data['lastblogtime'] = vbdate($this->registry->options['timeformat'], $this->profile->userinfo['lastblog'], true); $categories = array(); $cats = $this->registry->db->query_read_slave(" SELECT blogid, title, blog_category.blogcategoryid, blog_categoryuser.userid, blog_category.userid AS creatorid FROM " . TABLE_PREFIX . "blog_categoryuser AS blog_categoryuser LEFT JOIN " . TABLE_PREFIX . "blog_category AS blog_category ON (blog_category.blogcategoryid = blog_categoryuser.blogcategoryid) WHERE blogid IN (" . implode(',', $blogids) . ") ORDER BY blogid, displayorder "); while ($cat = $this->registry->db->fetch_array($cats)) { $categories["$cat[blogid]"][] = $cat; } require_once(DIR . '/includes/class_bbcode_blog.php'); require_once(DIR . '/includes/class_blog_entry.php'); $bbcode = new vB_BbCodeParser_Blog_Snippet($this->registry, fetch_tag_list()); $factory = new vB_Blog_EntryFactory($this->registry, $bbcode, $categories); $first = true; // Last Five Entries $entries = $this->registry->db->query_read_slave(" SELECT blog.*, blog.options AS blogoptions, blog_text.pagetext, blog_text.allowsmilie, blog_text.ipaddress, blog_text.reportthreadid, blog_text.ipaddress AS blogipaddress, user.*, userfield.*, usertextfield.* " . (($this->registry->options['threadvoted'] AND $this->registry->userinfo['userid']) ? ', blog_rate.vote' : '') . " " . (!($this->registry->userinfo['permissions']['genericpermissions'] & $this->registry->bf_ugp_genericpermissions['canseehiddencustomfields']) ? $this->registry->profilefield['hidden'] : "") . " " . (($this->registry->options['threadmarking'] AND $this->registry->userinfo['userid']) ? ", blog_read.readtime AS blogread, blog_userread.readtime AS bloguserread" : "") . " FROM " . TABLE_PREFIX . "blog AS blog INNER JOIN " . TABLE_PREFIX . "blog_text AS blog_text ON (blog_text.blogtextid = blog.firstblogtextid) LEFT JOIN " . TABLE_PREFIX . "user AS user ON (blog.userid = user.userid) LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid) LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid) " . (($this->registry->options['threadmarking'] AND $this->registry->userinfo['userid']) ? " LEFT JOIN " . TABLE_PREFIX . "blog_read AS blog_read ON (blog_read.blogid = blog.blogid AND blog_read.userid = " . $this->registry->userinfo['userid'] . ") LEFT JOIN " . TABLE_PREFIX . "blog_userread AS blog_userread ON (blog_userread.bloguserid = blog.userid AND blog_userread.userid = " . $this->registry->userinfo['userid'] . ") " : "") . " " . (($this->registry->options['threadvoted'] AND $this->registry->userinfo['userid']) ? "LEFT JOIN " . TABLE_PREFIX . "blog_rate AS blog_rate ON (blog_rate.blogid = blog.blogid AND blog_rate.userid = " . $this->registry->userinfo['userid'] . ")" : '') . " WHERE blog.blogid IN (" . implode(',', $blogids) . ") ORDER BY blog.dateline DESC LIMIT 5 "); while ($blog = $this->registry->db->fetch_array($entries)) { if ($first) { $show['latestentry'] = true; $first = false; } else { $show['latestentry'] = false; } $entry_handler =& $factory->create($blog, '_Profile'); $entry_handler->cachable = false; $entry_handler->excerpt = true; $entry_handler->attachments = $postattach["$blog[blogid]"]; $this->block_data['latestentries'] .= $entry_handler->construct(); } // Comments $state = array('visible'); $commentstate = array('visible'); $sql_and = array(); $sql_and[] = "blog.state IN('" . implode("', '", $state) . "')"; $sql_and[] = "blog.dateline <= " . TIMENOW; $sql_and[] = "blog.pending = 0"; $sql_and[] = "blog_text.state IN('" . implode("', '", $commentstate) . "')"; $sql_and[] = "blog.firstblogtextid <> blog_text.blogtextid"; $sql_and[] = "blog_text.bloguserid = " . $this->profile->userinfo['userid']; if (!can_moderate_blog() AND !is_member_of_blog($this->registry->userinfo, $this->profile->userinfo) AND !$bloginfo['buddyid']) { $sql_and[] = "~blog.options & " . $this->registry->bf_misc_vbblogoptions['private']; } if (!empty($this->registry->userinfo['blogcategorypermissions']['cantview']) AND $this->profile->userinfo['userid'] != $this->registry->userinfo['userid']) { $joinsql = "LEFT JOIN " . TABLE_PREFIX . "blog_categoryuser AS cu ON (cu.blogid = blog.blogid AND cu.blogcategoryid IN (" . implode(", ", $this->registry->userinfo['blogcategorypermissions']['cantview']) . "))"; $sql_and[] = "cu.blogcategoryid IS NULL"; } $this->registry->options['vbblog_snippet'] = 20; require_once(DIR . '/includes/class_blog_response.php'); $bbcode = new vB_BbCodeParser_Blog_Snippet_Featured($this->registry, fetch_tag_list()); $factory = new vB_Blog_ResponseFactory($this->registry, $bbcode, $bloginfo); $comments = $this->registry->db->query_read_slave(" SELECT blog_text.username AS postusername, blog_text.ipaddress AS blogipaddress, blog_text.state, blog_text.blogtextid, blog_text.title, blog_text.dateline, blog_text.pagetext, blog_text.allowsmilie, blog.userid AS blog_userid, blog.blogid, blog.title AS entrytitle, blog.state AS blog_state, blog.firstblogtextid, blog.options AS blogoptions, blog_user.memberids, blog_user.memberblogids, blog.postedby_userid, blog.postedby_username, user2.usergroupid AS blog_usergroupid, user2.infractiongroupids AS blog_inractiongroupids, user2.membergroupids AS blog_membergroupids, user.*, blog_user.title AS blogtitle, IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid, user.infractiongroupid, options_ignore, options_buddy, options_member, options_guest, blog.userid AS blog_userid, blog.state AS blog_state, blog.firstblogtextid " . ($this->registry->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . " " . (($this->registry->options['threadmarking'] AND $this->registry->userinfo['userid']) ? ", blog_read.readtime AS blogread, blog_userread.readtime AS bloguserread" : "") . " " . ($vbulletin->userinfo['userid'] ? ", gm.permissions AS grouppermissions" : "") . " FROM " . TABLE_PREFIX . "blog_text AS blog_text LEFT JOIN " . TABLE_PREFIX . "blog AS blog ON (blog.blogid = blog_text.blogid) LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = blog_text.userid) LEFT JOIN " . TABLE_PREFIX . "user AS user2 ON (user2.userid = blog.userid) LEFT JOIN " . TABLE_PREFIX . "blog_user AS blog_user ON (blog_user.bloguserid = blog.userid) " . (($this->registry->options['threadmarking'] AND $this->registry->userinfo['userid']) ? " LEFT JOIN " . TABLE_PREFIX . "blog_read AS blog_read ON (blog_read.blogid = blog.blogid AND blog_read.userid = " . $this->registry->userinfo['userid'] . ") LEFT JOIN " . TABLE_PREFIX . "blog_userread AS blog_userread ON (blog_userread.bloguserid = blog.userid AND blog_userread.userid = " . $this->registry->userinfo['userid'] . ") " : "") . " " . ($vbulletin->userinfo['userid'] ? "LEFT JOIN " . TABLE_PREFIX . "blog_groupmembership AS gm ON (blog.userid = gm.bloguserid AND gm.userid = " . $vbulletin->userinfo['userid'] . ")" : '') . " " . ($this->registry->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . " $joinsql WHERE " . implode("\r\n\tAND ", $sql_and) . " ORDER BY blog_text.dateline DESC LIMIT 5 "); while ($comment = $this->registry->db->fetch_array($comments)) { $bloginfo = array( 'blogid' => $comment['blogid'], 'userid' => $comment['blog_userid'], 'state' => $comment['blog_state'], 'firstblogtextid' => $comment['firstblogtextid'], 'blogread' => $comment['blogread'], 'bloguserread' => $comment['bloguserread'], 'usergroupid' => $comment['blog_usergroupid'], 'infractiongroupids' => $comment['blog_infractiongroupids'], 'membergroupids' => $comment['blog_membergroupids'], 'memberids' => $comment['memberids'], 'memberblogids' => $comment['memberblogids'], 'postedby_userid' => $comment['postedby_userid'], 'postedby_username' => $comment['postedby_username'], 'grouppermissions' => $comment['grouppermissions'], ); cache_permissions($bloginfo, false); $response_handler->bloginfo =& $bloginfo; $response_handler =& $factory->create($comment, 'Comment_Profile'); $response_handler->cachable = false; $response_handler->linkblog = true; $this->block_data['commentsreceived'] .= $response_handler->construct(); } } } }
unset($ipostarray[$dpostid]); } if ($curpostparent == $dpostid) { $curpostparent = $dparentid; } } } unset($post, $listposts, $deletedparents); if ($thread['attach']) { require_once(DIR . '/packages/vbattach/attach.php'); $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post'); $postattach = $attach->fetch_postattach(0, $ids); } // get list of usernames from post list $userjs = ''; foreach ($userarray AS $userid => $username) { if ($userid) { $userjs .= "pu[$userid] = \"" . addslashes_js($username) . "\";\n"; } } unset($userarray, $userid, $username); $parent_postids = fetch_post_parentlist($curpostid);
require_once(DIR . '/includes/functions_editor.php'); require_once(DIR . '/includes/functions_attach.php'); $forum_allowsmilies = ($foruminfo['allowsmilies'] ? 1 : 0); $editor_parsesmilies = ($forum_allowsmilies AND $postinfo['allowsmilie'] ? 1 : 0); $post =& $postinfo; $posthash = md5(TIMENOW . $vbulletin->userinfo['userid'] . $vbulletin->userinfo['salt']); $poststarttime = TIMENOW; if ($forumperms & $vbulletin->bf_ugp_forumpermissions['canpostattachment'] AND $vbulletin->userinfo['userid'] AND !empty($vbulletin->userinfo['attachmentextensions'])) { $values = "values[t]=$threadinfo[threadid]"; require_once(DIR . '/packages/vbattach/attach.php'); $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post'); $attachmentoption = $attach->fetch_edit_attachments($posthash, $poststarttime, $postattach, 0, $values, $vbulletin->GPC['editorid'], $attachcount); $contenttypeid = $attach->fetch_contenttypeid(); } else { $attachmentoption = ''; $contenttypeid = 0; } // This function creates the global var $messagearea, that is used below construct_edit_toolbar( htmlspecialchars_uni($postinfo['pagetext']), 0, $foruminfo['forumid'], $forum_allowsmilies,
if (!fetch_entry_perm('edit', $bloginfo)) { print_no_permission(); } require_once(DIR . '/includes/functions_editor.php'); require_once(DIR . '/includes/functions_newpost.php'); ($hook = vBulletinHook::fetch_hook('blog_post_editentry_start')) ? eval($hook) : false; // Use our permission to attach or the person who owns the post? check what vB does in this situation if ($vbulletin->userinfo['permissions']['vbblog_entry_permissions'] & $vbulletin->bf_ugp_vbblog_entry_permissions['blog_canpostattach']) { $values = "values[blogid]=$bloginfo[blogid]"; require_once(DIR . '/packages/vbattach/attach.php'); $attach = new vB_Attach_Display_Content($vbulletin, 'vBBlog_BlogEntry'); $attachmentoption = $attach->fetch_edit_attachments($posthash, $poststarttime, $postattach, $bloginfo['blogid'], $values, $editorid, $attachcount, explode(',', $bloginfo['memberids'])); $contenttypeid = $attach->fetch_contenttypeid(); } else { $attachmentoption = ''; $contenttypeid = 0; } if ($vbulletin->GPC['advanced'] OR !defined('POSTPREVIEW')) { $title = $bloginfo['title']; $reason = $blog['reason']; $blog['allowsmilie'] = $bloginfo['allowsmilie'];
require_once(DIR . '/includes/class_bbcode_alt.php'); $blogids = $blogcache = $postattach = array(); while($blog = $db->fetch_array($blog_posts)) { $blogcache[] = $blog; if ($blog['attach']) { $blogids["$blog[blogid]"] = $blog['blogid']; } } if (!$vbulletin->GPC['nohtml'] AND !empty($blogids)) { require_once(DIR . '/packages/vbattach/attach.php'); $attach = new vB_Attach_Display_Content($vbulletin, 'vBBlog_BlogEntry'); $postattach = $attach->fetch_postattach(0, $blogids); } require_once(DIR . '/includes/class_blog_entry.php'); require_once(DIR . '/includes/class_bbcode_blog.php'); $bbcode = new vB_BbCodeParser_Blog($vbulletin, fetch_tag_list()); $i = 0; $viewattachedimages = $vbulletin->options['viewattachedimages']; $attachthumbs = $vbulletin->options['attachthumbs']; // list returned blog entries $perm_cache = array(); foreach($blogcache AS $blog_post) {
$forumperms = fetch_permissions($thread['forumid']); if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads'])) { // Don't show thread content and attachments $thread['message'] = ''; } else { $postids["{$thread['postid']}"] = $thread['threadid']; } $thread['prefix_plain'] = $thread['prefixid'] ? $vbphrase["prefix_{$thread['prefixid']}_title_plain"] . ' ' : ''; $threadcache[] = $thread; } $lastmodified = !empty($thread[0]['dateline']) ? $thread[0]['dateline'] : TIMENOW; $expires = TIMENOW + $cachetime; $attachmentcache = array(); if (!$vbulletin->GPC['nohtml'] and !empty($postids) and ($vbulletin->GPC['type'] == 'RSS1' or $vbulletin->GPC['type'] == 'RSS2')) { require_once DIR . '/packages/vbattach/attach.php'; $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post'); $attachmentcache = $attach->fetch_postattach(0, array_keys($postids), null, true); } if ($number_of_forums == 1 and $vbulletin->GPC['type'] == 'RSS2' and $vbulletin->options['rsspodcast']) { $podcastinfo = $db->query_first_slave("\n\t\tSELECT *\n\t\tFROM " . TABLE_PREFIX . "podcast\n\t\tWHERE forumid = {$forumid} AND enabled = 1\n\t"); $podcastforumid = $forumchoice[0]; } else { $podcastforumid = 0; } $output = ''; $headers = array(); if ($vbulletin->GPC['type'] == 'JS') { // javascript output $output = "\n\tfunction thread(threadid, title, poster, threaddate, threadtime)\n\t{\n\t\tthis.threadid = threadid;\n\t\tthis.title = title;\n\t\tthis.poster = poster;\n\t\tthis.threaddate = threaddate;\n\t\tthis.threadtime = threadtime;\n\t}\n\t"; $output .= "var threads = new Array(" . sizeof($threadcache) . ");\r\n"; if (!empty($threadcache)) {
/** * Processes any attachments to this post. */ function process_attachments() { global $show; $forumperms = fetch_permissions($this->thread['forumid']); require_once DIR . '/packages/vbattach/attach.php'; $attach = new vB_Attach_Display_Content($this->registry, 'vBForum_Post'); if ($this->post['allattachments']) { foreach ($this->post['allattachments'] as $attachmentid => $info) { if (!$this->post['attachments'][$attachmentid]) { unset($this->post['allattachments'][$attachmentid]); } } $attach->process_attachments($this->post, $this->post['allattachments'], THIS_SCRIPT == 'external', can_moderate($this->forum['forumid'], 'canmoderateattachments'), $forumperms & $this->registry->bf_ugp_forumpermissions['cangetattachment'], $forumperms & $this->registry->bf_ugp_forumpermissions['canseethumbnails']); } else { $show['attachments'] = $show['moderatedattachment'] = $show['thumbnailattachment'] = $show['otherattachment'] = false; $show['imageattachment'] = $show['imageattachmentlink'] = false; } }
/** * Fetches a list of blog entries * * @param array Blogids to be retrieved * @param int Sum of attachments belonging to the set of blogids * @param array Information pertaining to each attachment - set within this function * @param array Category information - set within this function * @param array Additional sql joins * @param array Additional where conditions * @param string Additional deletion join * @param string Order By clause * * @return object mysql result of blog list */ function &fetch_blog_list($blogids, $attachcount, &$postattach, &$categories, $sqljoin = null, $wheresql = null, $deljoinsql = null, $orderby = "blog.dateline DESC") { global $vbulletin; $userperms = array(); $cats = $vbulletin->db->query_read_slave(" SELECT blog_categoryuser.blogid, blog_category.title, blog_category.blogcategoryid, blog_categoryuser.userid, blog_category.userid AS creatorid, user.usergroupid, user.membergroupids, user.infractiongroupids FROM " . TABLE_PREFIX . "blog_categoryuser AS blog_categoryuser LEFT JOIN " . TABLE_PREFIX . "blog_category AS blog_category ON (blog_category.blogcategoryid = blog_categoryuser.blogcategoryid) LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = blog_categoryuser.userid) WHERE blogid IN (" . implode(',', $blogids) . ") ORDER BY blogid, displayorder "); while ($cat = $vbulletin->db->fetch_array($cats)) { if (empty($userperms["$cat[userid]"])) { $userperms["$cat[userid]"] = cache_permissions($cat, false); } $perms = $userperms["$cat[userid]"]; if ($perms['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_cancreatecategory'] OR !$cat['creatorid']) { $categories["$cat[blogid]"][] = $cat; } } // Query Attachments if ($attachcount) { require_once(DIR . '/packages/vbattach/attach.php'); $attach = new vB_Attach_Display_Content($vbulletin, 'vBBlog_BlogEntry'); $postattach = $attach->fetch_postattach(0, $blogids); } if (!($vbulletin->userinfo['permissions']['vbblog_entry_permissions'] & $vbulletin->bf_ugp_vbblog_entry_permissions['blog_cangetattach'])) { $vbulletin->options['viewattachedimages'] = 0; $vbulletin->options['attachthumbs'] = 0; } $hook_query_joins = $hook_query_fields = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('blog_fetch_list_query')) ? eval($hook) : false; $blogs = $vbulletin->db->query_read(" SELECT blog.*, blog.options AS blogoptions, blog_text.pagetext, blog_text.ipaddress AS blogipaddress, blog_text.allowsmilie, blog_text.htmlstate, user.*, bu.title AS blogtitle, bu.memberids, bu.options_member, bu.options_guest, bu.options_buddy, bu.bloguserid, blog_textparsed.pagetexthtml, blog_textparsed.hasimages, blog_editlog.userid AS edit_userid, blog_editlog.dateline AS edit_dateline, blog_editlog.reason AS edit_reason, blog_editlog.username AS edit_username, customprofilepic.userid AS profilepic, customprofilepic.dateline AS profilepicdateline, customprofilepic.width AS ppwidth, customprofilepic.height AS ppheight " . ($deljoinsql ? ",blog_deletionlog.moddelete AS del_moddelete, blog_deletionlog.userid AS del_userid, blog_deletionlog.username AS del_username, blog_deletionlog.reason AS del_reason" : "") . " " . ($vbulletin->userinfo['userid'] ? ", gm.permissions AS grouppermissions, IF(blog_subscribeentry.blogsubscribeentryid, 1, 0) AS entrysubscribed" : "") . " " . ($vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . " " . (($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid']) ? ", blog_read.readtime AS blogread, blog_userread.readtime AS bloguserread" : "") . " " . ($vbulletin->userinfo['userid'] AND $sql1join ? ", ignored.relationid AS ignoreid, buddy.relationid AS buddyid" : "") . " $hook_query_fields FROM " . TABLE_PREFIX . "blog AS blog INNER JOIN " . TABLE_PREFIX . "blog_text AS blog_text ON (blog.firstblogtextid = blog_text.blogtextid) LEFT JOIN " . TABLE_PREFIX . "blog_editlog AS blog_editlog ON (blog_editlog.blogtextid = blog.firstblogtextid) LEFT JOIN " . TABLE_PREFIX . "blog_textparsed AS blog_textparsed ON(blog_textparsed.blogtextid = blog_text.blogtextid AND blog_textparsed.styleid = " . intval(STYLEID) . " AND blog_textparsed.languageid = " . intval(LANGUAGEID) . ") " . (($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid']) ? " LEFT JOIN " . TABLE_PREFIX . "blog_read AS blog_read ON (blog_read.blogid = blog.blogid AND blog_read.userid = " . $vbulletin->userinfo['userid'] . ") LEFT JOIN " . TABLE_PREFIX . "blog_userread AS blog_userread ON (blog_userread.bloguserid = blog.userid AND blog_userread.userid = " . $vbulletin->userinfo['userid'] . ") " : "") . " LEFT JOIN " . TABLE_PREFIX . "user AS user ON (blog.postedby_userid = user.userid) LEFT JOIN " . TABLE_PREFIX . "customprofilepic AS customprofilepic ON (user.userid = customprofilepic.userid) LEFT JOIN " . TABLE_PREFIX . "blog_user AS bu ON (bu.bloguserid = blog.userid) " . ($vbulletin->userinfo['userid'] ? "LEFT JOIN " . TABLE_PREFIX . "blog_groupmembership AS gm ON (blog.userid = gm.bloguserid AND gm.userid = " . $vbulletin->userinfo['userid'] . ")" : '') . " " . ($vbulletin->userinfo['userid'] ? "LEFT JOIN " . TABLE_PREFIX . "blog_subscribeentry AS blog_subscribeentry ON (blog.blogid = blog_subscribeentry.blogid AND blog_subscribeentry.userid = " . $vbulletin->userinfo['userid'] . ")" : "") . " " . ($vbulletin->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . " " . (!empty($sqljoin) ? implode("\r\n", $sqljoin) : "") . " $deljoinsql $hook_query_jons WHERE blog.blogid IN (" . implode(',', $blogids) . ") " . (!empty($wheresql) ? "AND " . implode("\r\nAND ", $wheresql) : "") . " $hook_query_where ORDER BY $orderby "); return $blogs; }
function do_post_edit() { global $vbulletin, $db, $foruminfo, $forumperms, $threadinfo; global $postinfo, $vbphrase, $stylevar, $permissions; $checked = array(); $edit = array(); $postattach = array(); $contenttype = 'vBForum_Post'; if (!$postinfo['postid'] or $postinfo['isdeleted'] or !$postinfo['visible'] and !can_moderate($threadinfo['forumid'], 'canmoderateposts')) { json_error(ERR_INVALID_TOP, RV_POST_ERROR); } if (!$threadinfo['threadid'] or $threadinfo['isdeleted'] or !$threadinfo['visible'] and !can_moderate($threadinfo['forumid'], 'canmoderateposts')) { json_error(ERR_INVALID_TOP, RV_POST_ERROR); } if ($vbulletin->options['wordwrap']) { $threadinfo['title'] = fetch_word_wrapped_string($threadinfo['title']); } // get permissions info $_permsgetter_ = 'edit post'; $forumperms = fetch_permissions($threadinfo['forumid']); if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) and ($threadinfo['postuserid'] != $vbulletin->userinfo['userid'] or $vbulletin->userinfo['userid'] == 0)) { json_error(ERR_NO_PERMISSION, RV_POST_ERROR); } $foruminfo = fetch_foruminfo($threadinfo['forumid'], false); // check if there is a forum password and if so, ensure the user has it set verify_forum_password($foruminfo['forumid'], $foruminfo['password']); // need to get last post-type information cache_ordered_forums(1); // determine if we are allowed to be updating the thread's info $can_update_thread = ($threadinfo['firstpostid'] == $postinfo['postid'] and (can_moderate($threadinfo['forumid'], 'caneditthreads') or $postinfo['dateline'] + $vbulletin->options['editthreadtitlelimit'] * 60 > TIMENOW)); // otherwise, post is being edited if (!can_moderate($threadinfo['forumid'], 'caneditposts')) { // check for moderator if (!$threadinfo['open']) { $vbulletin->url = 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "t={$threadinfo['threadid']}"; json_error(fetch_error('threadclosed'), RV_POST_ERROR); } if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['caneditpost'])) { json_error(ERR_NO_PERMISSION, RV_POST_ERROR); } else { if ($vbulletin->userinfo['userid'] != $postinfo['userid']) { // check user owns this post json_error(ERR_NO_PERMISSION, RV_POST_ERROR); } else { // check for time limits if ($postinfo['dateline'] < TIMENOW - $vbulletin->options['edittimelimit'] * 60 and $vbulletin->options['edittimelimit'] != 0) { json_error(fetch_error('edittimelimit', $vbulletin->options['edittimelimit'], $vbulletin->options['contactuslink']), RV_POST_ERROR); } } } } // Variables reused in templates $poststarttime =& $vbulletin->input->clean_gpc('r', poststarttime, TYPE_UINT); $posthash = md5($vbulletin->GPC['poststarttime'] . $vbulletin->userinfo['userid'] . $vbulletin->userinfo['salt']); $vbulletin->input->clean_array_gpc('p', array('stickunstick' => TYPE_BOOL, 'openclose' => TYPE_BOOL, 'wysiwyg' => TYPE_BOOL, 'message' => TYPE_STR, 'title' => TYPE_STR, 'prefixid' => TYPE_NOHTML, 'iconid' => TYPE_UINT, 'parseurl' => TYPE_BOOL, 'signature' => TYPE_BOOL, 'disablesmilies' => TYPE_BOOL, 'reason' => TYPE_NOHTML, 'preview' => TYPE_STR, 'folderid' => TYPE_UINT, 'emailupdate' => TYPE_UINT, 'ajax' => TYPE_BOOL, 'advanced' => TYPE_BOOL, 'postcount' => TYPE_UINT, 'podcasturl' => TYPE_STR, 'podcastsize' => TYPE_UINT, 'podcastexplicit' => TYPE_BOOL, 'podcastkeywords' => TYPE_STR, 'podcastsubtitle' => TYPE_STR, 'podcastauthor' => TYPE_STR, 'quickeditnoajax' => TYPE_BOOL)); if ($vbulletin->GPC['message']) { $vbulletin->GPC['message'] = prepare_remote_utf8_string($vbulletin->GPC['message']); } $vbulletin->GPC['signature'] = $vbulletin->GPC_exists['signature'] = true; // Make sure the posthash is valid ($hook = vBulletinHook::fetch_hook('editpost_update_start')) ? eval($hook) : false; if (md5($poststarttime . $vbulletin->userinfo['userid'] . $vbulletin->userinfo['salt']) != $posthash) { $posthash = 'invalid posthash'; // don't phrase me } // ### PREP INPUT ### if ($vbulletin->GPC['wysiwyg']) { require_once DIR . '/includes/functions_wysiwyg.php'; $edit['message'] = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], $foruminfo['allowhtml']); } else { $edit['message'] =& $vbulletin->GPC['message']; } $cansubscribe = true; // Are we editing someone else's post? If so load that users subscription info for this thread. if ($vbulletin->userinfo['userid'] != $postinfo['userid']) { if ($postinfo['userid']) { $userinfo = fetch_userinfo($postinfo['userid']); cache_permissions($userinfo); } $cansubscribe = ($userinfo['forumpermissions']["{$foruminfo['forumid']}"] & $vbulletin->bf_ugp_forumpermissions['canview'] and $userinfo['forumpermissions']["{$foruminfo['forumid']}"] & $vbulletin->bf_ugp_forumpermissions['canviewthreads'] and ($threadinfo['postuserid'] == $userinfo['userid'] or $userinfo['forumpermissions']["{$foruminfo['forumid']}"] & $vbulletin->bf_ugp_forumpermissions['canviewothers'])); if ($cansubscribe and $otherthreadinfo = $db->query_first_slave("\n\t\t\tSELECT emailupdate, folderid\n\t\t\tFROM " . TABLE_PREFIX . "subscribethread\n\t\t\tWHERE threadid = {$threadinfo['threadid']} AND\n\t\t\t\tuserid = {$postinfo['userid']} AND\n\t\t\t\tcanview = 1")) { $threadinfo['issubscribed'] = true; $threadinfo['emailupdate'] = $otherthreadinfo['emailupdate']; $threadinfo['folderid'] = $otherthreadinfo['folderid']; } else { $threadinfo['issubscribed'] = false; // use whatever emailupdate setting came through } } if ($vbulletin->GPC['ajax'] or $vbulletin->GPC['quickeditnoajax']) { // quick edit $tmpmessage = $vbulletin->GPC['ajax'] ? convert_urlencoded_unicode($edit['message']) : $edit['message']; $edit = $postinfo; $edit['message'] =& $tmpmessage; $edit['title'] = unhtmlspecialchars($edit['title']); $edit['signature'] =& $edit['showsignature']; $edit['enablesmilies'] =& $edit['allowsmilie']; $edit['disablesmilies'] = $edit['enablesmilies'] ? 0 : 1; $edit['parseurl'] = true; $edit['prefixid'] = $threadinfo['prefixid']; $edit['reason'] = fetch_censored_text($vbulletin->GPC['ajax'] ? convert_urlencoded_unicode($vbulletin->GPC['reason']) : $vbulletin->GPC['reason']); } else { $edit['iconid'] =& $vbulletin->GPC['iconid']; $edit['title'] =& $vbulletin->GPC['title']; $edit['prefixid'] = ($vbulletin->GPC_exists['prefixid'] and can_use_prefix($vbulletin->GPC['prefixid'])) ? $vbulletin->GPC['prefixid'] : $threadinfo['prefixid']; $edit['podcasturl'] =& $vbulletin->GPC['podcasturl']; $edit['podcastsize'] =& $vbulletin->GPC['podcastsize']; $edit['podcastexplicit'] =& $vbulletin->GPC['podcastexplicit']; $edit['podcastkeywords'] =& $vbulletin->GPC['podcastkeywords']; $edit['podcastsubtitle'] =& $vbulletin->GPC['podcastsubtitle']; $edit['podcastauthor'] =& $vbulletin->GPC['podcastauthor']; // Leave this off for quickedit->advanced so that a post with unparsed links doesn't get parsed just by going to Advanced Edit $edit['parseurl'] = true; $edit['signature'] =& $vbulletin->GPC['signature']; $edit['disablesmilies'] =& $vbulletin->GPC['disablesmilies']; $edit['enablesmilies'] = $edit['allowsmilie'] = $edit['disablesmilies'] ? 0 : 1; $edit['stickunstick'] =& $vbulletin->GPC['stickunstick']; $edit['openclose'] =& $vbulletin->GPC['openclose']; $edit['reason'] = fetch_censored_text($vbulletin->GPC['reason']); $edit['preview'] =& $vbulletin->GPC['preview']; $edit['folderid'] =& $vbulletin->GPC['folderid']; if (!$vbulletin->GPC['advanced']) { if ($vbulletin->GPC_exists['emailupdate']) { $edit['emailupdate'] =& $vbulletin->GPC['emailupdate']; } else { $edit['emailupdate'] = array_pop($array = array_keys(fetch_emailchecked($threadinfo))); } } } $dataman =& datamanager_init('Post', $vbulletin, ERRTYPE_ARRAY, 'threadpost'); $dataman->set_existing($postinfo); ($hook = vBulletinHook::fetch_hook('editpost_update_process')) ? eval($hook) : false; // set info $dataman->set_info('parseurl', $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_URL and $foruminfo['allowbbcode'] and $edit['parseurl']); $dataman->set_info('posthash', $posthash); $dataman->set_info('forum', $foruminfo); $dataman->set_info('thread', $threadinfo); $dataman->set_info('show_title_error', true); $dataman->set_info('podcasturl', $edit['podcasturl']); $dataman->set_info('podcastsize', $edit['podcastsize']); $dataman->set_info('podcastexplicit', $edit['podcastexplicit']); $dataman->set_info('podcastkeywords', $edit['podcastkeywords']); $dataman->set_info('podcastsubtitle', $edit['podcastsubtitle']); $dataman->set_info('podcastauthor', $edit['podcastauthor']); if ($postinfo['userid'] == $vbulletin->userinfo['userid']) { $dataman->set_info('user', $vbulletin->userinfo); } // set options $dataman->setr('showsignature', $edit['signature']); $dataman->setr('allowsmilie', $edit['enablesmilies']); // set data /*$dataman->setr('userid', $vbulletin->userinfo['userid']); if ($vbulletin->userinfo['userid'] == 0) { $dataman->setr('username', $post['username']); }*/ $dataman->setr('title', $edit['title']); $dataman->setr('pagetext', $edit['message']); if ($postinfo['userid'] != $vbulletin->userinfo['userid']) { $dataman->setr('iconid', $edit['iconid'], true, false); } else { $dataman->setr('iconid', $edit['iconid']); } $postusername = $vbulletin->userinfo['username']; $dataman->pre_save(); if ($dataman->errors) { $errors = $dataman->errors; } if ($dataman->info['podcastsize']) { $edit['podcastsize'] = $dataman->info['podcastsize']; } if (sizeof($errors) > 0) { fr_standard_error($errors[0]); } else { if ($edit['preview']) { require_once DIR . '/packages/vbattach/attach.php'; $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post'); $postattach = $attach->fetch_postattach($posthash, $postinfo['postid']); // ### PREVIEW POST ### $postpreview = process_post_preview($edit, $postinfo['userid'], $postattach); $previewpost = true; $_REQUEST['do'] = 'editpost'; } else { if ($vbulletin->GPC['advanced']) { // Don't display preview on QuickEdit->Advanced as parseurl is turned off and so the preview won't be correct unless the post originally had checked to not parse links // If you turn on parseurl then the opposite happens and you have to go unparse your links if that is what you want. Compromise $_REQUEST['do'] = 'editpost'; } else { // ### POST HAS NO ERRORS ### $dataman->save(); $update_edit_log = true; // don't show edited by AND reason unchanged - don't update edit log if (!($permissions['genericoptions'] & $vbulletin->bf_ugp_genericoptions['showeditedby']) and $edit['reason'] == $postinfo['edit_reason']) { $update_edit_log = false; } if ($update_edit_log) { // ug perm: show edited by if ($postinfo['dateline'] < TIMENOW - $vbulletin->options['noeditedbytime'] * 60 or !empty($edit['reason'])) { // save the postedithistory if ($vbulletin->options['postedithistory']) { // insert original post on first edit if (!$db->query_first("SELECT postedithistoryid FROM " . TABLE_PREFIX . "postedithistory WHERE original = 1 AND postid = " . $postinfo['postid'])) { $db->query_write("\n\t\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "postedithistory\n\t\t\t\t\t\t\t\t(postid, userid, username, title, iconid, dateline, reason, original, pagetext)\n\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t({$postinfo['postid']},\n\t\t\t\t\t\t\t\t" . $postinfo['userid'] . ",\n\t\t\t\t\t\t\t\t'" . $db->escape_string($postinfo['username']) . "',\n\t\t\t\t\t\t\t\t'" . $db->escape_string($postinfo['title']) . "',\n\t\t\t\t\t\t\t\t{$postinfo['iconid']},\n\t\t\t\t\t\t\t\t" . $postinfo['dateline'] . ",\n\t\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\t'" . $db->escape_string($postinfo['pagetext']) . "')\n\t\t\t\t\t\t"); } // insert the new version $db->query_write("\n\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "postedithistory\n\t\t\t\t\t\t\t(postid, userid, username, title, iconid, dateline, reason, pagetext)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t({$postinfo['postid']},\n\t\t\t\t\t\t\t" . $vbulletin->userinfo['userid'] . ",\n\t\t\t\t\t\t\t'" . $db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t\t\t\t\t'" . $db->escape_string($edit['title']) . "',\n\t\t\t\t\t\t\t{$edit['iconid']},\n\t\t\t\t\t\t\t" . TIMENOW . ",\n\t\t\t\t\t\t\t'" . $db->escape_string($edit['reason']) . "',\n\t\t\t\t\t\t\t'" . $db->escape_string($edit['message']) . "')\n\t\t\t\t\t"); } /*insert query*/ $db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "editlog\n\t\t\t\t\t\t(postid, userid, username, dateline, reason, hashistory)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t({$postinfo['postid']},\n\t\t\t\t\t\t" . $vbulletin->userinfo['userid'] . ",\n\t\t\t\t\t\t'" . $db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t\t\t\t" . TIMENOW . ",\n\t\t\t\t\t\t'" . $db->escape_string($edit['reason']) . "',\n\t\t\t\t\t\t" . ($vbulletin->options['postedithistory'] ? 1 : 0) . ")\n\t\t\t\t"); } } $date = vbdate($vbulletin->options['dateformat'], TIMENOW); $time = vbdate($vbulletin->options['timeformat'], TIMENOW); // initialize thread / forum update clauses $forumupdate = false; $threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_SILENT, 'threadpost'); $threadman->set_existing($threadinfo); $threadman->set_info('pagetext', $edit['message']); if ($can_update_thread and $edit['title'] != '') { // need to update thread title and iconid if (!can_moderate($threadinfo['forumid'])) { $threadman->set_info('skip_moderator_log', true); } $threadman->set_info('skip_first_post_update', true); if ($edit['title'] != $postinfo['title']) { $threadman->set('title', unhtmlspecialchars($edit['title'])); } if ($edit['iconid'] != $postinfo['iconid']) { $threadman->set('iconid', $edit['iconid']); } if ($vbulletin->GPC_exists['prefixid'] and can_use_prefix($vbulletin->GPC['prefixid'])) { $threadman->set('prefixid', $vbulletin->GPC['prefixid']); if ($threadman->thread['prefixid'] === '' and $foruminfo['options'] & $vbulletin->bf_misc_forumoptions['prefixrequired']) { // the prefix wasn't valid or was set to an empty one, but that's not allowed $threadman->do_unset('prefixid'); } } // do we need to update the forum counters? $forumupdate = $foruminfo['lastthreadid'] == $threadinfo['threadid'] ? true : false; } // can this user open/close this thread if they want to? if ($vbulletin->GPC['openclose'] and ($threadinfo['postuserid'] != 0 and $threadinfo['postuserid'] == $vbulletin->userinfo['userid'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['canopenclose'] or can_moderate($threadinfo['forumid'], 'canopenclose'))) { $threadman->set('open', $threadman->fetch_field('open') == 1 ? 0 : 1); } if ($vbulletin->GPC['stickunstick'] and can_moderate($threadinfo['forumid'], 'canmanagethreads')) { $threadman->set('sticky', $threadman->fetch_field('sticky') == 1 ? 0 : 1); } ($hook = vBulletinHook::fetch_hook('editpost_update_thread')) ? eval($hook) : false; $threadman->save(); // if this is a mod edit, then log it if ($vbulletin->userinfo['userid'] != $postinfo['userid'] and can_moderate($threadinfo['forumid'], 'caneditposts')) { $modlog = array('threadid' => $threadinfo['threadid'], 'forumid' => $threadinfo['forumid'], 'postid' => $postinfo['postid']); log_moderator_action($modlog, 'post_x_edited', $postinfo['title']); } require_once DIR . '/includes/functions_databuild.php'; // do forum update if necessary if ($forumupdate) { build_forum_counters($threadinfo['forumid']); } // don't do thread subscriptions if we are doing quick edit if (!$vbulletin->GPC['ajax'] and !$vbulletin->GPC['quickeditnoajax']) { // ### DO THREAD SUBSCRIPTION ### // We use $postinfo[userid] so that we update the user who posted this, not the user who is editing this if (!$threadinfo['issubscribed'] and $edit['emailupdate'] != 9999) { // user is not subscribed to this thread so insert it /*insert query*/ $db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "subscribethread (userid, threadid, emailupdate, folderid, canview)\n\t\t\t\t\tVALUES ({$postinfo['userid']}, {$threadinfo['threadid']}, {$edit['emailupdate']}, {$edit['folderid']}, 1)\n\t\t\t\t"); } else { // User is subscribed, see if they changed the settings for this thread if ($edit['emailupdate'] == 9999) { // Remove this subscription, user chose 'No Subscription' /*insert query*/ $db->query_write("\n\t\t\t\t\t\tDELETE FROM " . TABLE_PREFIX . "subscribethread\n\t\t\t\t\t\tWHERE threadid = {$threadinfo['threadid']}\n\t\t\t\t\t\t\tAND userid = {$postinfo['userid']}\n\t\t\t\t\t"); } else { if ($threadinfo['emailupdate'] != $edit['emailupdate'] or $threadinfo['folderid'] != $edit['folderid']) { // User changed the settings so update the current record /*insert query*/ $db->query_write("\n\t\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "subscribethread (userid, threadid, emailupdate, folderid, canview)\n\t\t\t\t\t\tVALUES ({$postinfo['userid']}, {$threadinfo['threadid']}, {$edit['emailupdate']}, {$edit['folderid']}, 1)\n\t\t\t\t\t"); } } } } ($hook = vBulletinHook::fetch_hook('editpost_update_complete')) ? eval($hook) : false; } } } return array('success' => true); }
$prefix_options = ''; } if ($postinfo['userid']) { $userinfo = fetch_userinfo($postinfo['userid']); $postinfo['username'] = $userinfo['username']; } if ($edit['iconid']) { $posticons = construct_icons($edit['iconid'], $foruminfo['allowicons']); } else { $posticons = construct_icons($postinfo['iconid'], $foruminfo['allowicons']); } // edit / add attachment if ($forumperms & $vbulletin->bf_ugp_forumpermissions['canpostattachment'] and $vbulletin->userinfo['userid'] and !empty($vbulletin->userinfo['attachmentextensions'])) { $values = "values[p]={$postinfo['postid']}&editpost=1"; require_once DIR . '/packages/vbattach/attach.php'; $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post'); $attachmentoption = $attach->fetch_edit_attachments($posthash, $poststarttime, $postattach, $postid, $values, $editorid, $attachcount); $contenttypeid = $attach->fetch_contenttypeid(); if (!$foruminfo['allowposting'] and $attachcount == 0) { $attachmentoption = ''; } } else { $attachmentoption = ''; $contenttypeid = 0; } require_once DIR . '/includes/functions_file.php'; $attachinfo = fetch_attachmentinfo($posthash, $poststarttime, $contenttypeid, array('p' => $postinfo['postid'])); $editorid = construct_edit_toolbar($newpost['message'], 0, $foruminfo['forumid'], $foruminfo['allowsmilies'] ? 1 : 0, ($postinfo['allowsmilie'] and !$edit['disablesmilies']) ? 1 : 0, $forumperms & $vbulletin->bf_ugp_forumpermissions['canpostattachment'] and $vbulletin->userinfo['userid'] and $postinfo['userid'] and !empty($vbulletin->userinfo['attachmentextensions']), 'fe', '', $attachinfo); if ($isfirstpost and can_moderate($threadinfo['forumid'], 'canmanagethreads')) { $show['deletepostoption'] = true; } else {
public function getRendered($forceload = false) { $context = new vB_Context($this->package . '_' . $this->class . '_pagetext_' , array( 'nodeid' => $this->nodeid, 'permissions' => vB::$vbulletin->userinfo['permissions']['cms'])); $hashkey = strval($context); if (!$forceload AND ($rendered = vB_Cache::instance()->read($hashkey, true, true))) { return $rendered; } $this->Load(self::INFO_CONTENT); $bbcode_parser = new vBCms_BBCode_HTML(vB::$vbulletin, vBCms_BBCode_HTML::fetchCmsTags()); $bbcode_parser->setCanDownload($this->canDownload()); $pages = array(); // Articles will generally have an attachment but they should still keep a counter so that this query isn't always running require_once(DIR . '/packages/vbattach/attach.php'); if ($this->canDownload()) { $viewinfo = array(); $attach = new vB_Attach_Display_Content(vB::$vbulletin, 'vBCms_Article'); $attachments = $attach->fetch_postattach(0, $this->nodeid); $bbcode_parser->attachments = $attachments; $bbcode_parser->unsetattach = true; } $validpage = true; $pageno = 1; require_once DIR . '/includes/functions.php'; while($validpage) { $bbcode_parser->setOutputPage($pageno); $pagetext = fetch_censored_text($bbcode_parser->do_parse( $this->pagetext, vBCMS_Permissions::canUseHtml($this->nodeid, $this->contenttypeid, $this->userid), $this->htmlstate )); $validpage = $bbcode_parser->fetchedValidPage(); if ($pageno == 1) { $pagelist = $bbcode_parser->getPageTitles(); } if ($validpage) { $pages[$pageno] = $pagetext; } $pageno++; } if ($this->canDownload()) { $attach->process_attachments($viewinfo, $bbcode_parser->attachments, false, false, true, false, true); } $rendered = array('pages' => $pages, 'attachments' => $bbcode_parser->attachments, 'viewinfo' => $viewinfo, 'pagelist' => $pagelist); vB_Cache::instance()->write($hashkey , $rendered, 1440, array_merge($this->getCacheEvents(), array($this->getContentCacheEvent()))); //If we updated the page text we need to also update the preview. $this->getPreviewText(true); return $rendered; }
function do_get_thread() { global $vbulletin, $db, $foruminfo, $threadinfo, $postid, $vault, $vbphrase; $vbulletin->input->clean_array_gpc('r', array('pagenumber' => TYPE_UINT, 'perpage' => TYPE_UINT, 'password' => TYPE_STR, 'signature' => TYPE_BOOL)); if (empty($threadinfo['threadid'])) { json_error(ERR_INVALID_THREAD); } $threadedmode = 0; $threadid = $vbulletin->GPC['threadid']; // Goto first unread post? if ($vbulletin->GPC['pagenumber'] == FR_LAST_POST) { $threadinfo = verify_id('thread', $threadid, 1, 1); if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) { $vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400); } else { if (($tview = intval(fetch_bbarray_cookie('thread_lastview', $threadid))) > $vbulletin->userinfo['lastvisit']) { $vbulletin->userinfo['lastvisit'] = $tview; } } $coventry = fetch_coventry('string'); $posts = $db->query_first("\n\t SELECT MIN(postid) AS postid\n\t FROM " . TABLE_PREFIX . "post\n\t WHERE threadid = {$threadinfo['threadid']}\n\t AND visible = 1\n\t AND dateline > " . intval($vbulletin->userinfo['lastvisit']) . "\n\t " . ($coventry ? "AND userid NOT IN ({$coventry})" : "") . "\n\t LIMIT 1\n\t"); if ($posts['postid']) { $postid = $posts['postid']; } else { $postid = $threadinfo['lastpostid']; } } // ********************************************************************************* // workaround for header redirect issue from forms with enctype in IE // (use a scrollIntoView javascript call in the <body> onload event) $onload = ''; // ********************************************************************************* // set $perpage $perpage = max(FR_MIN_PERPAGE, min($vbulletin->GPC['perpage'], FR_MAX_PERPAGE)); // FRNR //$perpage = sanitize_maxposts($vbulletin->GPC['perpage']); // ********************************************************************************* // set post order if ($vbulletin->userinfo['postorder'] == 0) { $postorder = ''; } else { $postorder = 'DESC'; } // ********************************************************************************* // get thread info $thread = verify_id('thread', $threadid, 1, 1); $threadinfo =& $thread; ($hook = vBulletinHook::fetch_hook('showthread_getinfo')) ? eval($hook) : false; // ********************************************************************************* // check for visible / deleted thread if (!$thread['visible'] and !can_moderate($thread['forumid'], 'canmoderateposts') or $thread['isdeleted'] and !can_moderate($thread['forumid'])) { json_error(ERR_INVALID_THREAD); } // ********************************************************************************* // Tachy goes to coventry if (in_coventry($thread['postuserid']) and !can_moderate($thread['forumid'])) { json_error(ERR_INVALID_THREAD); } // FRNR Start // Check the forum password (set necessary cookies) if ($vbulletin->GPC['password'] && $foruminfo['password'] == $vbulletin->GPC['password']) { // set a temp cookie for guests if (!$vbulletin->userinfo['userid']) { set_bbarray_cookie('forumpwd', $foruminfo['forumid'], md5($vbulletin->userinfo['userid'] . $vbulletin->GPC['password'])); } else { set_bbarray_cookie('forumpwd', $foruminfo['forumid'], md5($vbulletin->userinfo['userid'] . $vbulletin->GPC['password']), 1); } } // FRNR End // ********************************************************************************* // do word wrapping for the thread title if ($vbulletin->options['wordwrap'] != 0) { $thread['title'] = fetch_word_wrapped_string($thread['title']); } $thread['title'] = fetch_censored_text($thread['title']); $thread['meta_description'] = strip_bbcode(strip_quotes($thread['description']), false, true); $thread['meta_description'] = htmlspecialchars_uni(fetch_censored_text(fetch_trimmed_title($thread['meta_description'], 500, false))); // ********************************************************************************* // words to highlight from the search engine if (!empty($vbulletin->GPC['highlight'])) { $highlight = preg_replace('#\\*+#s', '*', $vbulletin->GPC['highlight']); if ($highlight != '*') { $regexfind = array('\\*', '\\<', '\\>'); $regexreplace = array('[\\w.:@*/?=]*?', '<', '>'); $highlight = preg_quote(strtolower($highlight), '#'); $highlight = explode(' ', $highlight); $highlight = str_replace($regexfind, $regexreplace, $highlight); foreach ($highlight as $val) { if ($val = trim($val)) { $replacewords[] = htmlspecialchars_uni($val); } } } } // ********************************************************************************* // make the forum jump in order to fill the forum caches $navpopup = array('id' => 'showthread_navpopup', 'title' => $foruminfo['title_clean'], 'link' => fetch_seo_url('thread', $threadinfo)); construct_quick_nav($navpopup); // ********************************************************************************* // get forum info $forum = fetch_foruminfo($thread['forumid']); $foruminfo =& $forum; // ********************************************************************************* // check forum permissions $forumperms = fetch_permissions($thread['forumid']); if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads'])) { json_error(ERR_NO_PERMISSION); } if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) and ($thread['postuserid'] != $vbulletin->userinfo['userid'] or $vbulletin->userinfo['userid'] == 0)) { json_error(ERR_NO_PERMISSION); } // ********************************************************************************* // check if there is a forum password and if so, ensure the user has it set if (!verify_forum_password($foruminfo['forumid'], $foruminfo['password'])) { // FRNR json_error(ERR_NEED_PASSWORD, RV_NEED_FORUM_PASSWORD); } // verify that we are at the canonical SEO url // and redirect to this if not //verify_seo_url('thread|js', $threadinfo, array('pagenumber' => $_REQUEST['pagenumber'])); // ********************************************************************************* // jump page if thread is actually a redirect if ($thread['open'] == 10) { $destthreadinfo = fetch_threadinfo($threadinfo['pollid']); exec_header_redirect(fetch_seo_url('thread|js', $destthreadinfo, $pageinfo)); } // ********************************************************************************* // get ignored users $ignore = array(); if (trim($vbulletin->userinfo['ignorelist'])) { $ignorelist = preg_split('/( )+/', trim($vbulletin->userinfo['ignorelist']), -1, PREG_SPLIT_NO_EMPTY); foreach ($ignorelist as $ignoreuserid) { $ignore["{$ignoreuserid}"] = 1; } } DEVDEBUG('ignored users: ' . implode(', ', array_keys($ignore))); // ********************************************************************************* // filter out deletion notices if can't be seen if ($forumperms & $vbulletin->bf_ugp_forumpermissions['canseedelnotice'] or can_moderate($threadinfo['forumid'])) { $deljoin = "LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(post.postid = deletionlog.primaryid AND deletionlog.type = 'post')"; } else { $deljoin = ''; } $show['viewpost'] = can_moderate($threadinfo['forumid']) ? true : false; $show['managepost'] = iif(can_moderate($threadinfo['forumid'], 'candeleteposts') or can_moderate($threadinfo['forumid'], 'canremoveposts'), true, false); $show['approvepost'] = can_moderate($threadinfo['forumid'], 'canmoderateposts') ? true : false; $show['managethread'] = can_moderate($threadinfo['forumid'], 'canmanagethreads') ? true : false; $show['approveattachment'] = can_moderate($threadinfo['forumid'], 'canmoderateattachments') ? true : false; $show['inlinemod'] = (!$show['threadedmode'] and ($show['managethread'] or $show['managepost'] or $show['approvepost'])) ? true : false; $show['spamctrls'] = ($show['inlinemod'] and $show['managepost']); $url = $show['inlinemod'] ? SCRIPTPATH : ''; // build inline moderation popup if ($show['popups'] and $show['inlinemod']) { $threadadmin_imod_menu_post = vB_Template::create('threadadmin_imod_menu_post')->render(); } else { $threadadmin_imod_menu_post = ''; } // ********************************************************************************* // find the page that we should be on to display this post if (!empty($postid) and $threadedmode == 0) { $postinfo = verify_id('post', $postid, 1, 1); $threadid = $postinfo['threadid']; $getpagenum = $db->query_first("\n \t\tSELECT COUNT(*) AS posts\n \t\tFROM " . TABLE_PREFIX . "post AS post\n \t\tWHERE threadid = {$threadid} AND visible = 1\n \t\tAND dateline " . iif(!$postorder, '<=', '>=') . " {$postinfo['dateline']}\n \t"); $vbulletin->GPC['pagenumber'] = ceil($getpagenum['posts'] / $perpage); } // ********************************************************************************* // update views counter if ($vbulletin->options['threadviewslive']) { // doing it as they happen; for optimization purposes, this cannot use a DM! $db->shutdown_query("\n \t\tUPDATE " . TABLE_PREFIX . "thread\n \t\tSET views = views + 1\n \t\tWHERE threadid = " . intval($threadinfo['threadid'])); } else { // or doing it once an hour $db->shutdown_query("\n \t\tINSERT INTO " . TABLE_PREFIX . "threadviews (threadid)\n \t\tVALUES (" . intval($threadinfo['threadid']) . ')'); } // ********************************************************************************* // display ratings if enabled $show['rating'] = false; if ($forum['allowratings'] == 1) { if ($thread['votenum'] > 0) { $thread['voteavg'] = vb_number_format($thread['votetotal'] / $thread['votenum'], 2); $thread['rating'] = intval(round($thread['votetotal'] / $thread['votenum'])); if ($thread['votenum'] >= $vbulletin->options['showvotes']) { $show['rating'] = true; } } devdebug("threadinfo[vote] = {$threadinfo['vote']}"); if ($threadinfo['vote']) { $voteselected["{$threadinfo['vote']}"] = 'selected="selected"'; $votechecked["{$threadinfo['vote']}"] = 'checked="checked"'; } else { $voteselected[0] = 'selected="selected"'; $votechecked[0] = 'checked="checked"'; } } // ********************************************************************************* // set page number if ($vbulletin->GPC['pagenumber'] < 1) { $vbulletin->GPC['pagenumber'] = 1; } else { if ($vbulletin->GPC['pagenumber'] > ceil(($thread['replycount'] + 1) / $perpage)) { $vbulletin->GPC['pagenumber'] = ceil(($thread['replycount'] + 1) / $perpage); } } // ********************************************************************************* // initialise some stuff... $limitlower = ($vbulletin->GPC['pagenumber'] - 1) * $perpage; $limitupper = $vbulletin->GPC['pagenumber'] * $perpage; $counter = 0; if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) { $threadview = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400); } else { $threadview = intval(fetch_bbarray_cookie('thread_lastview', $thread['threadid'])); if (!$threadview) { $threadview = $vbulletin->userinfo['lastvisit']; } } $threadinfo['threadview'] = intval($threadview); $displayed_dateline = 0; ################################################################################ ############################### SHOW POLL ###################################### ################################################################################ $poll = ''; if ($thread['pollid']) { $pollbits = ''; $counter = 1; $pollid = $thread['pollid']; $show['editpoll'] = iif(can_moderate($threadinfo['forumid'], 'caneditpoll'), true, false); // get poll info $pollinfo = $db->query_first_slave("\n \t\tSELECT *\n \t\tFROM " . TABLE_PREFIX . "poll\n \t\tWHERE pollid = {$pollid}\n \t"); require_once DIR . '/includes/class_bbcode.php'; $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list()); $pollinfo['question'] = $bbcode_parser->parse(unhtmlspecialchars($pollinfo['question']), $forum['forumid'], true); $splitoptions = explode('|||', $pollinfo['options']); $splitoptions = array_map('rtrim', $splitoptions); $splitvotes = explode('|||', $pollinfo['votes']); $showresults = 0; $uservoted = 0; if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canvote'])) { $nopermission = 1; } if (!$pollinfo['active'] or !$thread['open'] or $pollinfo['dateline'] + $pollinfo['timeout'] * 86400 < TIMENOW and $pollinfo['timeout'] != 0 or $nopermission) { //thread/poll is closed, ie show results no matter what $showresults = 1; } else { //get userid, check if user already voted $voted = intval(fetch_bbarray_cookie('poll_voted', $pollid)); if ($voted) { $uservoted = 1; } } ($hook = vBulletinHook::fetch_hook('showthread_poll_start')) ? eval($hook) : false; if ($pollinfo['timeout'] and !$showresults) { $pollendtime = vbdate($vbulletin->options['timeformat'], $pollinfo['dateline'] + $pollinfo['timeout'] * 86400); $pollenddate = vbdate($vbulletin->options['dateformat'], $pollinfo['dateline'] + $pollinfo['timeout'] * 86400); $show['pollenddate'] = true; } else { $show['pollenddate'] = false; } foreach ($splitvotes as $index => $value) { $pollinfo['numbervotes'] += $value; } if ($vbulletin->userinfo['userid'] > 0) { $pollvotes = $db->query_read_slave("\n \t\t\tSELECT voteoption\n \t\t\tFROM " . TABLE_PREFIX . "pollvote\n \t\t\tWHERE userid = " . $vbulletin->userinfo['userid'] . " AND pollid = {$pollid}\n \t\t"); if ($db->num_rows($pollvotes) > 0) { $uservoted = 1; } } if ($showresults or $uservoted) { if ($uservoted) { $uservote = array(); while ($pollvote = $db->fetch_array($pollvotes)) { $uservote["{$pollvote['voteoption']}"] = 1; } } } $left = vB_Template_Runtime::fetchStyleVar('left'); $right = vB_Template_Runtime::fetchStyleVar('right'); $option['open'] = $left[0]; $option['close'] = $right[0]; foreach ($splitvotes as $index => $value) { $arrayindex = $index + 1; $option['uservote'] = iif($uservote["{$arrayindex}"], true, false); $option['question'] = $bbcode_parser->parse($splitoptions["{$index}"], $forum['forumid'], true); // public link if ($pollinfo['public'] and $value) { $option['votes'] = '<a href="poll.php?' . $vbulletin->session->vars['sessionurl'] . 'do=showresults&pollid=' . $pollinfo['pollid'] . '">' . vb_number_format($value) . '</a>'; } else { $option['votes'] = vb_number_format($value); //get the vote count for the option } $option['number'] = $counter; //number of the option //Now we check if the user has voted or not if ($showresults or $uservoted) { // user did vote or poll is closed if ($value <= 0) { $option['percentraw'] = 0; } else { if ($pollinfo['multiple']) { $option['percentraw'] = $value < $pollinfo['voters'] ? $value / $pollinfo['voters'] * 100 : 100; } else { $option['percentraw'] = $value < $pollinfo['numbervotes'] ? $value / $pollinfo['numbervotes'] * 100 : 100; } } $option['percent'] = vb_number_format($option['percentraw'], 2); $option['graphicnumber'] = $option['number'] % 6 + 1; $option['barnumber'] = round($option['percent']) * 2; $option['remainder'] = 201 - $option['barnumber']; // Phrase parts below if ($nopermission) { $pollstatus = $vbphrase['you_may_not_vote_on_this_poll']; } else { if ($showresults) { $pollstatus = $vbphrase['this_poll_is_closed']; } else { if ($uservoted) { $pollstatus = $vbphrase['you_have_already_voted_on_this_poll']; } } } ($hook = vBulletinHook::fetch_hook('showthread_polloption')) ? eval($hook) : false; $templater = vB_Template::create('pollresult'); $templater->register('names', $names); $templater->register('option', $option); $pollbits .= $templater->render(); } else { ($hook = vBulletinHook::fetch_hook('showthread_polloption')) ? eval($hook) : false; if ($pollinfo['multiple']) { $templater = vB_Template::create('polloption_multiple'); $templater->register('option', $option); $pollbits .= $templater->render(); } else { $templater = vB_Template::create('polloption'); $templater->register('option', $option); $pollbits .= $templater->render(); } } $counter++; } if ($pollinfo['multiple']) { $pollinfo['numbervotes'] = $pollinfo['voters']; $show['multiple'] = true; } if ($pollinfo['public']) { $show['publicwarning'] = true; } else { $show['publicwarning'] = false; } $displayed_dateline = $threadinfo['lastpost']; ($hook = vBulletinHook::fetch_hook('showthread_poll_complete')) ? eval($hook) : false; if ($showresults or $uservoted) { $templater = vB_Template::create('pollresults_table'); $templater->register('pollbits', $pollbits); $templater->register('pollenddate', $pollenddate); $templater->register('pollendtime', $pollendtime); $templater->register('pollinfo', $pollinfo); $templater->register('pollstatus', $pollstatus); $poll = $templater->render(); } else { $templater = vB_Template::create('polloptions_table'); $templater->register('pollbits', $pollbits); $templater->register('pollenddate', $pollenddate); $templater->register('pollendtime', $pollendtime); $templater->register('pollinfo', $pollinfo); $poll = $templater->render(); } } // work out if quickreply should be shown or not if ($vbulletin->options['quickreply'] and !$thread['isdeleted'] and !is_browser('netscape') and $vbulletin->userinfo['userid'] and ($vbulletin->userinfo['userid'] == $threadinfo['postuserid'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyown'] or $vbulletin->userinfo['userid'] != $threadinfo['postuserid'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyothers']) and ($thread['open'] or can_moderate($threadinfo['forumid'], 'canopenclose')) and !fetch_require_hvcheck('post')) { $show['quickreply'] = true; } else { $show['quickreply'] = false; $show['wysiwyg'] = 0; $quickreply = ''; } $show['largereplybutton'] = (!$thread['isdeleted'] and !$show['threadedmode'] and $forum['allowposting'] and !$show['search_engine']); if (!$forum['allowposting']) { $show['quickreply'] = false; } $show['multiquote_global'] = ($vbulletin->options['multiquote'] and $vbulletin->userinfo['userid']); if ($show['multiquote_global']) { $vbulletin->input->clean_array_gpc('c', array('vbulletin_multiquote' => TYPE_STR)); $vbulletin->GPC['vbulletin_multiquote'] = explode(',', $vbulletin->GPC['vbulletin_multiquote']); } // post is cachable if option is enabled, last post is newer than max age, and this user // isn't showing a sessionhash $post_cachable = ($vbulletin->options['cachemaxage'] > 0 and TIMENOW - $vbulletin->options['cachemaxage'] * 60 * 60 * 24 <= $thread['lastpost'] and $vbulletin->session->vars['sessionurl'] == ''); $saveparsed = ''; $save_parsed_sigs = ''; ($hook = vBulletinHook::fetch_hook('showthread_post_start')) ? eval($hook) : false; ################################################################################ ####################### SHOW THREAD IN LINEAR MODE ############################# ################################################################################ if ($threadedmode == 0) { // allow deleted posts to not be counted in number of posts displayed on the page; // prevents issue with page count on forum display being incorrect $ids = array(); $lastpostid = 0; $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('showthread_query_postids')) ? eval($hook) : false; if (empty($deljoin) and !$show['approvepost']) { $totalposts = $threadinfo['replycount'] + 1; if (can_moderate($thread['forumid'])) { $coventry = ''; } else { $coventry = fetch_coventry('string'); } $getpostids = $db->query_read("\n \t\t\tSELECT post.postid\n \t\t\tFROM " . TABLE_PREFIX . "post AS post\n \t\t\t{$hook_query_joins}\n \t\t\tWHERE post.threadid = {$threadid}\n \t\t\t\tAND post.visible = 1\n \t\t\t\t" . ($coventry ? "AND post.userid NOT IN ({$coventry})" : '') . "\n \t\t\t\t{$hook_query_where}\n \t\t\tORDER BY post.dateline {$postorder}\n \t\t\tLIMIT {$limitlower}, {$perpage}\n \t\t"); while ($post = $db->fetch_array($getpostids)) { if (!isset($qrfirstpostid)) { $qrfirstpostid = $post['postid']; } $qrlastpostid = $post['postid']; $ids[] = $post['postid']; } $db->free_result($getpostids); $lastpostid = $qrlastpostid; } else { $getpostids = $db->query_read("\n \t\t\tSELECT post.postid, post.visible, post.userid\n \t\t\tFROM " . TABLE_PREFIX . "post AS post\n \t\t\t{$hook_query_joins}\n \t\t\tWHERE post.threadid = {$threadid}\n \t\t\t\tAND post.visible IN (1\n \t\t\t\t" . (!empty($deljoin) ? ",2" : "") . "\n \t\t\t\t" . ($show['approvepost'] ? ",0" : "") . "\n \t\t\t\t)\n \t\t\t\t{$hook_query_where}\n \t\t\tORDER BY post.dateline {$postorder}\n \t\t"); $totalposts = 0; if ($limitlower != 0) { $limitlower++; } while ($post = $db->fetch_array($getpostids)) { if (!isset($qrfirstpostid)) { $qrfirstpostid = $post['postid']; } $qrlastpostid = $post['postid']; if ($post['visible'] == 1 and !in_coventry($post['userid']) and !$ignore[$post['userid']]) { $totalposts++; } if ($totalposts < $limitlower or $totalposts > $limitupper) { continue; } // remember, these are only added if they're going to be displayed $ids[] = $post['postid']; $lastpostid = $post['postid']; } $db->free_result($getpostids); } // '0' inside parenthesis in unlikely case we have no ids for this page // (this could happen if the replycount is wrong in the db) $postids = "post.postid IN (0" . implode(',', $ids) . ")"; // load attachments if ($thread['attach']) { require_once DIR . '/packages/vbattach/attach.php'; $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post'); $postattach = $attach->fetch_postattach(0, $ids); } $hook_query_fields = $hook_query_joins = ''; ($hook = vBulletinHook::fetch_hook('showthread_query')) ? eval($hook) : false; $posts = $db->query_read("\n \t\tSELECT\n \t\t\tpost.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,\n \t\t\tuser.*, userfield.*, usertextfield.*,\n \t\t\t" . iif($forum['allowicons'], 'icon.title as icontitle, icon.iconpath,') . "\n \t\t\t" . iif($vbulletin->options['avatarenabled'], 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight,') . "\n \t\t\t" . ((can_moderate($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? 'spamlog.postid AS spamlog_postid,' : '') . "\n \t\t\t" . iif($deljoin, 'deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason,') . "\n \t\t\teditlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline,\n \t\t\teditlog.reason AS edit_reason, editlog.hashistory,\n \t\t\tpostparsed.pagetext_html, postparsed.hasimages,\n \t\t\tsigparsed.signatureparsed, sigparsed.hasimages AS sighasimages,\n \t\t\tsigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight,\n \t\t\tIF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid\n \t\t\t" . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), $vbulletin->profilefield['hidden']) . "\n \t\t\t{$hook_query_fields}\n \t\tFROM " . TABLE_PREFIX . "post AS post\n \t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)\n \t\t" . iif($forum['allowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = post.iconid)") . "\n \t\t" . iif($vbulletin->options['avatarenabled'], "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)") . "\n \t\t" . ((can_moderate($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? "LEFT JOIN " . TABLE_PREFIX . "spamlog AS spamlog ON(spamlog.postid = post.postid)" : '') . "\n \t\t\t{$deljoin}\n \t\tLEFT JOIN " . TABLE_PREFIX . "editlog AS editlog ON(editlog.postid = post.postid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "postparsed AS postparsed ON(postparsed.postid = post.postid AND postparsed.styleid = " . intval(STYLEID) . " AND postparsed.languageid = " . intval(LANGUAGEID) . ")\n \t\tLEFT JOIN " . TABLE_PREFIX . "sigparsed AS sigparsed ON(sigparsed.userid = user.userid AND sigparsed.styleid = " . intval(STYLEID) . " AND sigparsed.languageid = " . intval(LANGUAGEID) . ")\n \t\tLEFT JOIN " . TABLE_PREFIX . "sigpic AS sigpic ON(sigpic.userid = post.userid)\n \t\t\t{$hook_query_joins}\n \t\tWHERE {$postids}\n \t\tORDER BY post.dateline {$postorder}\n \t"); if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canseethumbnails']) and !($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment'])) { $vbulletin->options['attachthumbs'] = 0; } if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment'])) { $vbulletin->options['viewattachedimages'] = 0; } $postcount = ($vbulletin->GPC['pagenumber'] - 1) * $perpage; if ($postorder) { // Newest first $postcount = $totalposts - $postcount + 1; } $counter = 0; $postbits = ''; $postbit_factory = new vB_Postbit_Factory(); $postbit_factory->registry =& $vbulletin; $postbit_factory->forum =& $foruminfo; $postbit_factory->thread =& $thread; $postbit_factory->cache = array(); $postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list()); while ($post = $db->fetch_array($posts)) { if ($tachyuser = in_coventry($post['userid']) and !can_moderate($thread['forumid'])) { continue; } if ($post['visible'] == 1 and !$tachyuser) { ++$counter; if ($postorder) { $post['postcount'] = --$postcount; } else { $post['postcount'] = ++$postcount; } } if ($tachyuser) { $fetchtype = 'post_global_ignore'; } else { if ($ignore["{$post['userid']}"]) { $fetchtype = 'post_ignore'; } else { if ($post['visible'] == 2) { $fetchtype = 'post_deleted'; } else { $fetchtype = 'post'; } } } if ($vbulletin->GPC['viewfull'] and $post['postid'] == $postinfo['postid'] and $fetchtype != 'post' and (can_moderate($threadinfo['forumid']) or !$post['isdeleted'])) { $fetchtype = 'post'; } if ($fetchtype != 'post' && $fetchtype != 'post_deleted') { continue; } ($hook = vBulletinHook::fetch_hook('showthread_postbit_create')) ? eval($hook) : false; $postbit_obj =& $postbit_factory->fetch_postbit($fetchtype); if ($fetchtype == 'post') { $postbit_obj->highlight =& $replacewords; } $postbit_obj->cachable = $post_cachable; $post['islastshown'] = $post['postid'] == $lastpostid; $post['isfirstshown'] = ($counter == 1 and $fetchtype == 'post' and $post['visible'] == 1); $post['islastshown'] = $post['postid'] == $lastpostid; $post['attachments'] = $postattach["{$post['postid']}"]; $parsed_postcache = array('text' => '', 'images' => 1, 'skip' => false); $postbits .= $postbit_obj->construct_postbit($post); // Only show after the first post, counter isn't incremented for deleted/moderated posts if ($post['isfirstshown']) { $postbits .= vB_Template::create('ad_showthread_firstpost')->render(); } if ($post_cachable and $post['pagetext_html'] == '') { if (!empty($saveparsed)) { $saveparsed .= ','; } $saveparsed .= "({$post['postid']}, " . intval($thread['lastpost']) . ', ' . intval($postbit_obj->post_cache['has_images']) . ", '" . $db->escape_string($postbit_obj->post_cache['text']) . "', " . intval(STYLEID) . ", " . intval(LANGUAGEID) . ")"; } if (!empty($postbit_obj->sig_cache) and $post['userid']) { if (!empty($save_parsed_sigs)) { $save_parsed_sigs .= ','; } $save_parsed_sigs .= "({$post['userid']}, " . intval(STYLEID) . ", " . intval(LANGUAGEID) . ", '" . $db->escape_string($postbit_obj->sig_cache['text']) . "', " . intval($postbit_obj->sig_cache['has_images']) . ")"; } // get first and last post ids for this page (for big reply buttons) if (!isset($FIRSTPOSTID)) { $FIRSTPOSTID = $post['postid']; } $LASTPOSTID = $post['postid']; if ($post['dateline'] > $displayed_dateline) { $displayed_dateline = $post['dateline']; if ($displayed_dateline <= $threadview) { $updatethreadcookie = true; } } // FRNR Start // find out if first post $getpost = $db->query_first("\n SELECT firstpostid\n FROM " . TABLE_PREFIX . "thread\n WHERE threadid = {$threadinfo['threadid']}\n "); $isfirstpost = $getpost['firstpostid'] == $post['postid']; $candelete = false; if ($isfirstpost and can_moderate($threadinfo['forumid'], 'canmanagethreads')) { $candelete = true; } else { if (!$isfirstpost and can_moderate($threadinfo['forumid'], 'candeleteposts')) { $candelete = true; } else { if (($forumperms & $vbulletin->bf_ugp_forumpermissions['candeletepost'] and !$isfirstpost or $forumperms & $vbulletin->bf_ugp_forumpermissions['candeletethread'] and $isfirstpost) and $vbulletin->userinfo['userid'] == $post['userid']) { $candelete = true; } } } // Get post date/time $postdate = vbdate($vbulletin->options['dateformat'], $post['dateline'], 1); $posttime = vbdate($vbulletin->options['timeformat'], $post['dateline']); $fr_images = array(); $docattach = array(); // Attachments (images). if (is_array($post['attachments']) && 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) { $tmp = array('img' => $vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid']); if ($vbulletin->options['attachthumbs']) { $tmp['tmb'] = $vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid'] . '&stc=1&thumb=1'; } $fr_images[] = $tmp; } if (strpos($lfilename, '.pdf') !== false) { $docattach[] = $vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid']; } } } // Parse the post for quotes and inline images list($text, $nuked_quotes, $images) = parse_post($post['pagetext'], $post['allowsmilie'] && $usesmilies); 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 ($post['avatarurl']) { $avatarurl = process_avatarurl($post['avatarurl']); } $tmp = array('post_id' => $post['postid'], 'thread_id' => $post['threadid'], 'forum_id' => $foruminfo['forumid'], 'forum_title' => prepare_utf8_string($foruminfo['title_clean']), 'username' => prepare_utf8_string(strip_tags($post['username'])), 'joindate' => prepare_utf8_string($post['joindate']), 'usertitle' => prepare_utf8_string(strip_tags($post['usertitle'])), 'numposts' => $post['posts'] ? (string) $post['posts'] : '0', 'userid' => $post['userid'], 'title' => prepare_utf8_string($post['title']), 'online' => fetch_online_status(fetch_userinfo($post['userid']), false), 'post_timestamp' => prepare_utf8_string(date_trunc($postdate) . ' ' . $posttime), 'fr_images' => $fr_images); if ($candelete) { $tmp['candelete'] = true; } // Soft Deleted if ($post['visible'] == 2) { $tmp['deleted'] = true; $tmp['del_username'] = prepare_utf8_string($post['del_username']); if ($post['del_reason']) { $tmp['del_reason'] = prepare_utf8_string($post['del_reason']); } } else { $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 (count($docattach) > 0) { $tmp['docattach'] = $docattach; } if ($vbulletin->GPC['signature']) { $sig = trim(remove_bbcode(strip_tags($post['signatureparsed']), true, true), '<a>'); $sig = str_replace(array("\t", "\r"), array('', ''), $sig); $sig = str_replace("\n\n", "\n", $sig); $tmp['sig'] = prepare_utf8_string($sig); } // Begin Support for Post Thanks Hack - http://www.vbulletin.org/forum/showthread.php?t=122944 if ($vbulletin->userinfo['userid'] && function_exists('post_thanks_off') && function_exists('can_thank_this_post') && function_exists('thanked_already') && function_exists('fetch_thanks')) { if (!post_thanks_off($thread['forumid'], $post, $thread['firstpostid'], THIS_SCRIPT)) { global $ids; if (can_thank_this_post($post, $thread['isdeleted'])) { $tmp['canlike'] = true; } if (thanked_already($post, 0, true)) { $tmp['likes'] = true; if (!$vbulletin->options['post_thanks_delete_own']) { $tmp['canlike'] = $tmp['likes'] = false; } } $thanks = fetch_thanks($post['postid']); $thank_users = array(); if (is_array($thanks)) { foreach ($thanks as $thank) { $thank_users[] = $thank['username']; } } if (count($thank_users)) { $tmp['likestext'] = prepare_utf8_string($vbphrase['fr_thanked_by'] . ': ' . join(', ', $thank_users)); $tmp['likesusers'] = join(', ', $thank_users); } } } // End Support for Post Thanks Hack $posts_out[] = $tmp; // FRNR End } $db->free_result($posts); unset($post); if ($postbits == '' and $vbulletin->GPC['pagenumber'] > 1) { $pageinfo = array('page' => $vbulletin->GPC['pagenumber'] - 1); if (!empty($vbulletin->GPC['perpage'])) { $pageinfo['pp'] = $perpage; } if (!empty($vbulletin->GPC['highlight'])) { $pageinfo['highlight'] = urlencode($vbulletin->GPC['highlight']); } exec_header_redirect(fetch_seo_url('thread|js', $threadinfo, $pageinfo)); } DEVDEBUG("First Post: {$FIRSTPOSTID}; Last Post: {$LASTPOSTID}"); $pageinfo = array(); if ($vbulletin->GPC['highlight']) { $pageinfo['highlight'] = urlencode($vbulletin->GPC['highlight']); } if (!empty($vbulletin->GPC['perpage'])) { $pageinfo['pp'] = $perpage; } $pagenav = construct_page_nav($vbulletin->GPC['pagenumber'], $perpage, $totalposts, 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "t={$threadinfo['threadid']}", '', '', 'thread', $threadinfo, $pageinfo); if ($thread['lastpost'] > $threadview) { if ($firstnew) { $firstunread = fetch_seo_url('thread', $threadinfo, array('page' => $vbulletin->GPC['pagenumber'])) . '#post' . $firstnew; $show['firstunreadlink'] = true; } else { $firstunread = fetch_seo_url('thread', $threadinfo, array('goto' => 'newpost')); $show['firstunreadlink'] = true; } } else { $firstunread = ''; $show['firstunreadlink'] = false; } if ($vbulletin->userinfo['postorder']) { // disable ajax qr when displaying linear newest first $show['allow_ajax_qr'] = 0; } else { // only allow ajax on the last page of a thread when viewing oldest first $show['allow_ajax_qr'] = $vbulletin->GPC['pagenumber'] == ceil($totalposts / $perpage) ? 1 : 0; } ################################################################################ ################ SHOW THREAD IN THREADED OR HYBRID MODE ######################## ################################################################################ } else { // ajax qr doesn't work with threaded controls $show['allow_ajax_qr'] = 0; require_once DIR . '/includes/functions_threadedmode.php'; // save data $ipostarray = array(); $postarray = array(); $userarray = array(); $postparent = array(); $postorder = array(); $hybridposts = array(); $deletedparents = array(); $totalposts = 0; $links = ''; $cache_postids = ''; $hook_query_fields = $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('showthread_query_postids_threaded')) ? eval($hook) : false; // get all posts $listposts = $db->query_read("\n \t\tSELECT\n \t\t\tpost.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,\n \t\t\tuser.*, userfield.*\n \t\t\t" . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), $vbulletin->profilefield['hidden']) . "\n \t\t\t{$hook_query_fields}\n \t\tFROM " . TABLE_PREFIX . "post AS post\n \t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)\n \t\t{$hook_query_joins}\n \t\tWHERE threadid = {$threadid}\n \t\t\t{$hook_query_where}\n \t\tORDER BY postid\n \t"); // $toppostid is the first post in the thread // $curpostid is the postid passed from the URL, or if not specified, the first post in the thread $ids = array(); while ($post = $db->fetch_array($listposts)) { if ($post['visible'] == 2 and !$deljoin or $post['visible'] == 0 and !$show['approvepost'] or in_coventry($post['userid']) and !can_moderate($thread['forumid'])) { $deletedparents["{$post['postid']}"] = iif(isset($deletedparents["{$post['parentid']}"]), $deletedparents["{$post['parentid']}"], $post['parentid']); continue; } if (empty($toppostid)) { $toppostid = $post['postid']; } if (empty($postid)) { if (empty($curpostid)) { $curpostid = $post['postid']; if ($threadedmode == 2 and empty($vbulletin->GPC['postid'])) { $vbulletin->GPC['postid'] = $curpostid; } $curpostparent = $post['parentid']; } } else { if ($post['postid'] == $postid) { $curpostid = $post['postid']; $curpostparent = $post['parentid']; } } $postparent["{$post['postid']}"] = $post['parentid']; $ipostarray["{$post['parentid']}"][] = $post['postid']; $postarray["{$post['postid']}"] = $post; $userarray["{$post['userid']}"] = $db->escape_string($post['username']); $totalposts++; $ids[] = $post['postid']; } $db->free_result($listposts); // hooks child posts up to new parent if actual parent has been deleted or hidden if (count($deletedparents) > 0) { foreach ($deletedparents as $dpostid => $dparentid) { if (is_array($ipostarray[$dpostid])) { foreach ($ipostarray[$dpostid] as $temppostid) { $postparent[$temppostid] = $dparentid; $ipostarray[$dparentid][] = $temppostid; $postarray[$temppostid]['parentid'] = $dparentid; } unset($ipostarray[$dpostid]); } if ($curpostparent == $dpostid) { $curpostparent = $dparentid; } } } unset($post, $listposts, $deletedparents); if ($thread['attach']) { require_once DIR . '/packages/vbattach/attach.php'; $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post'); $postattach = $attach->fetch_postattach(0, $ids); } // get list of usernames from post list $userjs = ''; foreach ($userarray as $userid => $username) { if ($userid) { $userjs .= "pu[{$userid}] = \"" . addslashes_js($username) . "\";\n"; } } unset($userarray, $userid, $username); $parent_postids = fetch_post_parentlist($curpostid); if (!$parent_postids) { $currentdepth = 0; } else { $currentdepth = sizeof(explode(',', $parent_postids)); } sort_threaded_posts(); if (empty($curpostid)) { eval(standard_error(fetch_error('invalidid', $vbphrase['post'], $vbulletin->options['contactuslink']))); } if ($threadedmode == 2) { $numhybrids = sizeof($hybridposts); if ($vbulletin->GPC['pagenumber'] < 1) { $vbulletin->GPC['pagenumber'] = 1; } $startat = ($vbulletin->GPC['pagenumber'] - 1) * $perpage; if ($startat > $numhybrids) { $vbulletin->GPC['pagenumber'] = 1; $startat = 0; } $endat = $startat + $perpage; for ($i = $startat; $i < $endat; $i++) { if (isset($hybridposts["{$i}"])) { if (!isset($FIRSTPOSTID)) { $FIRSTPOSTID = $hybridposts["{$i}"]; } $cache_postids .= ",{$hybridposts[$i]}"; $LASTPOSTID = $hybridposts["{$i}"]; } } $pageinfo = array('p' => $vbulletin->GPC['postid']); if ($vbulletin->GPC['highlight']) { $pageinfo['highlight'] = urlencode($vbulletin->GPC['highlight']); } if (!empty($vbulletin->GPC['perpage'])) { $pageinfo['pp'] = $perpage; } $pagenav = construct_page_nav($vbulletin->GPC['pagenumber'], $perpage, $numhybrids, 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "t={$threadinfo['threadid']}", '', '', 'thread', $threadinfo, $pageinfo); } else { $FIRSTPOSTID = $curpostid; $LASTPOSTID = $curpostid; // sort out which posts to cache: if (!$vbulletin->options['threaded_maxcache']) { $vbulletin->options['threaded_maxcache'] = 999999; } // cache $vbulletin->options['threaded_maxcache'] posts // take 0.25 from above $curpostid // and take 0.75 below if (sizeof($postorder) <= $vbulletin->options['threaded_maxcache']) { $startat = 0; } else { if ($curpostidkey + $vbulletin->options['threaded_maxcache'] * 0.75 > sizeof($postorder)) { $startat = sizeof($postorder) - $vbulletin->options['threaded_maxcache']; } else { if ($curpostidkey - $vbulletin->options['threaded_maxcache'] * 0.25 < 0) { $startat = 0; } else { $startat = intval($curpostidkey - $vbulletin->options['threaded_maxcache'] * 0.25); } } } unset($curpostidkey); foreach ($postorder as $postkey => $pid) { if ($postkey > $startat + $vbulletin->options['threaded_maxcache']) { break; } if ($postkey >= $startat and empty($morereplies["{$pid}"])) { $cache_postids .= ',' . $pid; } } // get next/previous posts for each post in the list // key: NAVJS[postid][0] = prev post, [1] = next post $NAVJS = array(); $prevpostid = 0; foreach ($postorder as $pid) { $NAVJS["{$pid}"][0] = $prevpostid; $NAVJS["{$prevpostid}"][1] = $pid; $prevpostid = $pid; } $NAVJS["{$toppostid}"][0] = $pid; //prev button for first post $NAVJS["{$pid}"][1] = $toppostid; //next button for last post $navjs = ''; foreach ($NAVJS as $pid => $info) { $navjs .= "pn[{$pid}] = \"{$info['0']},{$info['1']}\";\n"; } } unset($ipostarray, $postparent, $postorder, $NAVJS, $postid, $info, $prevpostid, $postkey); $cache_postids = substr($cache_postids, 1); if (empty($cache_postids)) { // umm... something weird happened. Just prevent an error. eval(standard_error(fetch_error('invalidid', $vbphrase['post'], $vbulletin->options['contactuslink']))); } $hook_query_fields = $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('showthread_query')) ? eval($hook) : false; $cacheposts = $db->query_read("\n \t\tSELECT\n \t\t\tpost.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,\n \t\t\tuser.*, userfield.*, usertextfield.*,\n \t\t\t" . iif($forum['allowicons'], 'icon.title as icontitle, icon.iconpath,') . "\n \t\t\t" . iif($vbulletin->options['avatarenabled'], 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,') . "\n \t\t\t" . ((can_moderate($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? 'spamlog.postid AS spamlog_postid,' : '') . "\n \t\t\t" . iif($deljoin, "deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason,") . "\n \t\t\teditlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline,\n \t\t\teditlog.reason AS edit_reason, editlog.hashistory,\n \t\t\tpostparsed.pagetext_html, postparsed.hasimages,\n \t\t\tsigparsed.signatureparsed, sigparsed.hasimages AS sighasimages,\n \t\t\tsigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight,\n \t\t\tIF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid\n \t\t\t" . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), $vbulletin->profilefield['hidden']) . "\n \t\t\t{$hook_query_fields}\n \t\tFROM " . TABLE_PREFIX . "post AS post\n \t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)\n \t\t" . iif($forum['allowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = post.iconid)") . "\n \t\t" . iif($vbulletin->options['avatarenabled'], "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)") . "\n \t\t" . ((can_moderate($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? "LEFT JOIN " . TABLE_PREFIX . "spamlog AS spamlog ON(spamlog.postid = post.postid)" : '') . "\n \t\t\t{$deljoin}\n \t\tLEFT JOIN " . TABLE_PREFIX . "editlog AS editlog ON(editlog.postid = post.postid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "postparsed AS postparsed ON(postparsed.postid = post.postid AND postparsed.styleid = " . intval(STYLEID) . " AND postparsed.languageid = " . intval(LANGUAGEID) . ")\n \t\tLEFT JOIN " . TABLE_PREFIX . "sigparsed AS sigparsed ON(sigparsed.userid = user.userid AND sigparsed.styleid = " . intval(STYLEID) . " AND sigparsed.languageid = " . intval(LANGUAGEID) . ")\n \t\tLEFT JOIN " . TABLE_PREFIX . "sigpic AS sigpic ON(sigpic.userid = post.userid)\n \t\t\t{$hook_query_joins}\n \t\tWHERE post.postid IN (" . $cache_postids . ") {$hook_query_where}\n \t"); // re-initialise the $postarray variable $postarray = array(); while ($post = $db->fetch_array($cacheposts)) { $postarray["{$post['postid']}"] = $post; } if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment'])) { $vbulletin->options['viewattachedimages'] = 0; $vbulletin->options['attachthumbs'] = 0; } // init $postcount = 0; $postbits = ''; $saveparsed = ''; $jspostbits = ''; $postbit_factory = new vB_Postbit_Factory(); $postbit_factory->registry =& $vbulletin; $postbit_factory->forum =& $foruminfo; $postbit_factory->thread =& $thread; $postbit_factory->cache = array(); $postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list()); foreach (explode(',', $cache_postids) as $id) { // get the post from the post array if (!isset($postarray["{$id}"])) { continue; } $post = $postarray["{$id}"]; if ($tachyuser = in_coventry($post['userid']) and !can_moderate($thread['forumid'])) { continue; } if ($tachyuser) { $fetchtype = 'post_global_ignore'; } else { if ($ignore["{$post['userid']}"]) { $fetchtype = 'post_ignore'; } else { if ($post['visible'] == 2) { $fetchtype = 'post_deleted'; } else { $fetchtype = 'post'; } } } if ($vbulletin->GPC['viewfull'] and $post['postid'] == $postinfo['postid'] and $fetchtype != 'post' and (can_moderate($threadinfo['forumid']) or !$post['isdeleted'])) { $fetchtype = 'post'; } ($hook = vBulletinHook::fetch_hook('showthread_postbit_create')) ? eval($hook) : false; $postbit_obj =& $postbit_factory->fetch_postbit($fetchtype); if ($fetchtype == 'post') { $postbit_obj->highlight =& $replacewords; } $postbit_obj->cachable = $post_cachable; $post['postcount'] = ++$postcount; $post['attachments'] =& $postattach["{$post['postid']}"]; $parsed_postcache = array('text' => '', 'images' => 1); $bgclass = 'alt2'; if ($threadedmode == 2) { $postbits .= $postbit_obj->construct_postbit($post); } else { $postbit = $postbit_obj->construct_postbit($post); if ($curpostid == $post['postid']) { $curpostdateline = $post['dateline']; $curpostbit = $postbit; } $postbit = preg_replace('#</script>#i', "<\\/scr' + 'ipt>", addslashes_js($postbit)); $jspostbits .= "pd[{$post['postid']}] = '{$postbit}';\n"; } // end threaded mode if ($post_cachable and $post['pagetext_html'] == '') { if (!empty($saveparsed)) { $saveparsed .= ','; } $saveparsed .= "({$post['postid']}, " . intval($thread['lastpost']) . ', ' . intval($postbit_obj->post_cache['has_images']) . ", '" . $db->escape_string($postbit_obj->post_cache['text']) . "'," . intval(STYLEID) . ", " . intval(LANGUAGEID) . ")"; } if (!empty($postbit_obj->sig_cache) and $post['userid']) { if (!empty($save_parsed_sigs)) { $save_parsed_sigs .= ','; } $save_parsed_sigs .= "({$post['userid']}, " . intval(STYLEID) . ", " . intval(LANGUAGEID) . ", '" . $db->escape_string($postbit_obj->sig_cache['text']) . "', " . intval($postbit_obj->sig_cache['has_images']) . ")"; } if ($post['dateline'] > $displayed_dateline) { $displayed_dateline = $post['dateline']; if ($displayed_dateline <= $threadview) { $updatethreadcookie = true; } } } // end while ($post) $db->free_result($cacheposts); if ($threadedmode == 1) { $postbits = $curpostbit; } $templater = vB_Template::create('showthread_list'); $templater->register('curpostid', $curpostid); $templater->register('highlightwords', $highlightwords); $templater->register('jspostbits', $jspostbits); $templater->register('links', $links); $templater->register('navjs', $navjs); $templater->register('threadedmode', $threadedmode); $templater->register('userjs', $userjs); $threadlist = $templater->render(); unset($curpostbit, $post, $cacheposts, $parsed_postcache, $postbit); } ################################################################################ ########################## END LINEAR / THREADED ############################### ################################################################################ $effective_lastpost = max($displayed_dateline, $thread['lastpost']); // ********************************************************************************* //set thread last view if ($thread['pollid'] and $vbulletin->options['updatelastpost'] and ($displayed_dateline == $thread['lastpost'] or $threadview == $thread['lastpost']) and $pollinfo['lastvote'] > $thread['lastpost']) { $displayed_dateline = $pollinfo['lastvote']; } if ((!$vbulletin->GPC['posted'] or $updatethreadcookie) and $displayed_dateline and $displayed_dateline > $threadview) { mark_thread_read($threadinfo, $foruminfo, $vbulletin->userinfo['userid'], $displayed_dateline); } // FRNR Below fr_update_subsent($threadinfo['threadid'], $displayed_dateline); if (!is_array($posts_out)) { $posts_out = array(); } // Figure out if we can post $canpost = true; if ($threadinfo['isdeleted'] or !$threadinfo['visible'] and !can_moderate($threadinfo['forumid'], 'canmoderateposts')) { $canpost = false; } if (!$foruminfo['allowposting'] or $foruminfo['link'] or !$foruminfo['cancontainthreads']) { $canpost = false; } if (!$threadinfo['open']) { if (!can_moderate($threadinfo['forumid'], 'canopenclose')) { $canpost = false; } } if (($vbulletin->userinfo['userid'] != $threadinfo['postuserid'] or !$vbulletin->userinfo['userid']) and (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyothers']))) { $canpost = false; } if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyown']) and $vbulletin->userinfo['userid'] == $threadinfo['postuserid']) { $canpost = false; } $mod = 0; if (can_moderate($threadinfo['forumid'], 'candeleteposts') or can_moderate($threadinfo['forumid'], 'canremoveposts')) { $mod |= MOD_DELETEPOST; } if (can_moderate($threadinfo['forumid'], 'canmanagethreads')) { if ($threadinfo['sticky']) { $mod |= MOD_UNSTICK; } else { $mod |= MOD_STICK; } } if ($threadinfo['visible'] != 2 and can_moderate($threadinfo['forumid'], 'candeleteposts') or can_moderate($threadinfo['forumid'], 'canremoveposts') or $forumperms & $vbulletin->bf_ugp_forumpermissions['candeletepost'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['candeletethread'] and $vbulletin->userinfo['userid'] == $threadinfo['postuserid'] and ($vbulletin->options['edittimelimit'] == 0 or $threadinfo['dateline'] > TIMENOW - $vbulletin->options['edittimelimit'] * 60)) { $mod |= MOD_DELETETHREAD; } if (can_moderate($threadinfo['forumid'], 'canopenclose') or $forumperms & $vbulletin->bf_ugp_forumpermissions['canopenclose'] and $threadinfo['postuserid'] == $vbulletin->userinfo['userid']) { if ($threadinfo['open']) { $mod |= MOD_CLOSE; } else { $mod |= MOD_OPEN; } } if (can_moderate($threadinfo['forumid'], 'canmanagethreads') or $forumperms & $vbulletin->bf_ugp_forumpermissions['canmove'] and $threadinfo['postuserid'] == $vbulletin->userinfo['userid']) { $mod |= MOD_MOVETHREAD; } if ($show['spamctrls']) { $mod |= MOD_SPAM_CONTROLS; } $out = array('posts' => $posts_out, 'total_posts' => $totalposts, 'page' => $vbulletin->GPC['pagenumber'], 'canpost' => $canpost ? 1 : 0, 'mod' => $mod, 'pollid' => $thread['pollid'], 'subscribed' => $threadinfo['issubscribed'] ? 1 : 0, 'title' => prepare_utf8_string($thread['title']), 'canattach' => $forumperms & $vbulletin->bf_ugp_forumpermissions['canpostattachment'] and $vbulletin->userinfo['userid']); if ($postid) { $out['gotopostid'] = $postid; } return $out; }
$prefix_options = ''; } if ($postinfo['userid']) { $userinfo = fetch_userinfo($postinfo['userid']); $postinfo['username'] = $userinfo['username']; } if ($edit['iconid']) { $posticons = construct_icons($edit['iconid'], $foruminfo['allowicons']); } else { $posticons = construct_icons($postinfo['iconid'], $foruminfo['allowicons']); } // edit / add attachment if ($forumperms & $vbulletin->bf_ugp_forumpermissions['canpostattachment'] and $vbulletin->userinfo['userid'] and !empty($vbulletin->userinfo['attachmentextensions'])) { $values = "values[p]={$postinfo['postid']}&editpost=1"; require_once DIR . '/packages/vbattach/attach.php'; $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post'); $attachmentoption = $attach->fetch_edit_attachments($posthash, $poststarttime, $postattach['bycontent'][$postid], $postid, $values, $editorid, $attachcount, $postinfo['userid']); $contenttypeid = $attach->fetch_contenttypeid(); if (!$foruminfo['allowposting'] and $attachcount == 0) { $attachmentoption = ''; } } else { $attachmentoption = ''; $contenttypeid = 0; } require_once DIR . '/includes/functions_file.php'; $attachinfo = fetch_attachmentinfo($posthash, $poststarttime, $contenttypeid, array('p' => $postinfo['postid'])); $editorid = construct_edit_toolbar($newpost['message'], 0, $foruminfo['forumid'], $foruminfo['allowsmilies'] ? 1 : 0, ($postinfo['allowsmilie'] and !$edit['disablesmilies']) ? 1 : 0, $forumperms & $vbulletin->bf_ugp_forumpermissions['canpostattachment'] and $vbulletin->userinfo['userid'] and $postinfo['userid'] and !empty($vbulletin->userinfo['attachmentextensions']), 'fe', '', $attachinfo, 'content', 'vBForum_Post', $postinfo['postid'], 0, $previewpost, true, 'titlefield'); if ($isfirstpost and can_moderate($threadinfo['forumid'], 'canmanagethreads')) { $show['deletepostoption'] = true; } else {
/** * Processes any attachments to this post. */ function process_attachments() { $forumperms = fetch_permissions($this->thread['forumid']); require_once(DIR . '/packages/vbattach/attach.php'); $attach = new vB_Attach_Display_Content($this->registry, 'vBForum_Post'); $attach->process_attachments( $this->post, $this->post['attachments'], (THIS_SCRIPT == 'external'), can_moderate($this->forum['forumid'], 'canmoderateattachments'), $forumperms & $this->registry->bf_ugp_forumpermissions['cangetattachment'], $forumperms & $this->registry->bf_ugp_forumpermissions['canseethumbnails'] ); }
public function getInlineEditBodyView() { global $vbphrase; require_once DIR . '/includes/functions_databuild.php'; require_once DIR . '/includes/functions.php'; fetch_phrase_group('cpcms'); $this->editing = true; //confirm that the user has edit rights if (!$this->content->canEdit() AND !($this->getUserId() == vB::$vbulletin->userinfo['userid']) AND !$this->content->canPublish()) { return $vb_phrase['no_edit_permissions']; } vB::$vbulletin->input->clean_array_gpc('r', array( 'postid' => vB_Input::TYPE_UINT, 'blogcommentid' => vB_Input::TYPE_UINT, 'do' => vB_Input::TYPE_STR, 'blogid' => TYPE_UINT )); if ($_REQUEST['do'] == 'delete') { $dm = $this->content->getDM(); $dm->delete(); $this->cleanContentCache(); return $vbphrase['article_deleted']; } if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update') { $this->SaveData($view); } require_once DIR . '/packages/vbcms/contentmanager.php'; // Load the content item if (!$this->loadContent($this->getViewInfoFlags(self::VIEW_PAGE))) { throw (new vB_Exception_404()); } global $show; $show['img_bbcode'] = true; // Get smiliecache and bbcodecache vB::$vbulletin->datastore->fetch(array('smiliecache','bbcodecache')); // Create view $view = $this->createView('inline', self::VIEW_PAGE); // Add the content to the view $view = $this->populateViewContent($view, self::VIEW_PAGE, false); $pagetext = $this->content->getPageText(); // Get postings phrasegroup // need posting group require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('posting'); // Build editor global $messagearea; require_once DIR . '/includes/functions_file.php'; require_once DIR . '/includes/functions_editor.php'; require_once(DIR . '/packages/vbattach/attach.php'); $view->formid = "cms_content_data"; $view->can_edit = $this->content->canEdit(); if ($this->content->canEdit()) { $attach = new vB_Attach_Display_Content(vB::$vbulletin, 'vBCms_Article'); //this will set a number of its parameters if they are not already set. $posthash = null; $poststarttime = null; $postattach = array(); $attachcount = 0; $values = "values[f]=" . $this->content->getNodeId() ; $attachmentoption = $attach->fetch_edit_attachments($posthash, $poststarttime, $postattach, $this->content->getNodeId(), $values, '', $attachcount); $attachinfo = fetch_attachmentinfo($posthash, $poststarttime, $this->getContentTypeId(), array('f' => $this->content->getNodeId())); $view->editorid = construct_edit_toolbar( $pagetext, false, new vBCms_Editor_Override(vB::$vbulletin), true, true, true, 'cms_article', '', $attachinfo ); $templater = vB_Template::create('vbcms_article_editor'); $templater->register('attachmentoption', $attachmentoption); $templater->register('attachmentoption', $attachmentoption); $templater->register('posthash', $posthash); $templater->register('poststarttime', $poststarttime); $templater->register('contenttypeid', $this->getContentTypeId()); $templater->register('values', $values); $templater->register('contentid', $this->content->getNodeId()); $templater->register('insertinline ', 1); $templater->register('checked', $checked); $templater->register('disablesmiliesoption', $disablesmiliesoption); $templater->register('editorid', $view->editorid); $templater->register('messagearea', $messagearea); $tag_delimiters = addslashes_js(vB::$vbulletin->options['tagdelimiter']); $templater->register('tag_delimiters', $tag_delimiters); $content = $templater->render(); $view->editor = $content; } else { $view->previewtext = $this->content->getPreviewText();; } $view->url = $this->content->getUrl(); $view->type = new vB_Phrase('vbcms', 'content'); $view->adding = new vB_Phrase('cpcms', 'adding_x', $vbphrase['article']); $view->html_title = $this->content->getHtmlTitle(); $view->title = $this->content->getTitle(); $view->metadata = $this->content->getMetadataEditor(); $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')); $view->view_url = vBCms_Route_Content::getURL($segments); // Add URL to submit to $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage')); $view->submit_url = vBCms_Route_Content::getURL($segments); $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')); $view->editbar = $this->content->getEditBar($view->submit_url, vBCms_Route_Content::getURL($segments), $view->formid); $view->publisher = $this->content->getPublishEditor($view->submit_url, $view->formid, true, true, $this->content->getPublicPreview(), $this->content->getComments_Enabled()); $view->authorid = ($this->content->getUserId()); $view->authorname = ($this->content->getUsername()); $view->viewcount = ($this->content->getViewCount()); $view->parentid = $this->content->getParentId(); $view->post_started = ($this->content->getPostStarted()); $view->post_posted = ($this->content->getPostPosted()); $view->comment_count = ($this->content->getReplyCount()); $view->contentid = $this->content->getContentId(true); $view->show_threaded = true; $view->per_page = 10; $view->indent_per_level = 5; $view->max_level = 4; // Add form check $this->addPostId($view); return $view; }
foreach ($ipostarray[$dpostid] as $temppostid) { $postparent[$temppostid] = $dparentid; $ipostarray[$dparentid][] = $temppostid; $postarray[$temppostid]['parentid'] = $dparentid; } unset($ipostarray[$dpostid]); } if ($curpostparent == $dpostid) { $curpostparent = $dparentid; } } } unset($post, $listposts, $deletedparents); if ($thread['attach']) { require_once DIR . '/packages/vbattach/attach.php'; $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post'); $postattach = $attach->fetch_postattach(0, $ids, null, true); } // get list of usernames from post list $userjs = ''; foreach ($userarray as $userid => $username) { if ($userid) { $userjs .= "pu[{$userid}] = \"" . addslashes_js($username) . "\";\n"; } } unset($userarray, $userid, $username); $parent_postids = fetch_post_parentlist($curpostid); if (!$parent_postids) { $currentdepth = 0; } else { $currentdepth = sizeof(explode(',', $parent_postids));
/** * Processes any attachments to this entry. */ function process_attachments() { require_once(DIR . '/packages/vbattach/attach.php'); $attach = new vB_Attach_Display_Content($this->registry, 'vBBlog_BlogEntry'); $attach->process_attachments($this->blog, $this->attachments, (THIS_SCRIPT == 'blogexternal'), true, true, true); }