/**
* Load object from an id
*
* @param int $id
* @return vB_Legacy_Forum
*/
public static function create_from_id($id)
{
$foruminfo = fetch_foruminfo($id);
//try to work with bad data integrity. There are dbs out there
//with threads that belong to a nonexistant forum.
if ($foruminfo) {
return self::create_from_record($foruminfo);
} else {
return null;
}
}
开发者ID:0hyeah,项目名称:yurivn,代码行数:17,代码来源:forum.php
示例3: fetch_forum
function fetch_forum($forumid)
{
global $vbulletin;
if ($forumid == -1) {
return array('title' => str($vbulletin->options['bbtitle']), 'threadcount' => 0);
}
// Don't use cache as it doesn't include threadcount by default
$foruminfo = fetch_foruminfo($forumid, false);
if (!$foruminfo) {
return false;
}
return array('id' => intval($foruminfo['forumid']), 'title' => str($foruminfo['title'], true), 'description' => str($foruminfo['description'], true), 'threadcount' => intval($foruminfo['threadcount']), 'replycount' => intval($foruminfo['replycount']));
}
/**
* Load object from an id
*
* @param int $id
* @return vB_Legacy_Forum
*/
public static function create_from_id($id)
{
//the cache get prefilled with abbreviated data that is *different* from what
//the query in fetch_foruminfo provides. We can skip the cache, but that means
//we never cache, even if we want to.
//this is going to prove to be a problem.
//There is an incomplete copy stored in cache. Not sure why,
// but it consistently doesn't give me the lastthreadid unless I pass "false"
// to prevent reading from cache
$foruminfo = fetch_foruminfo($id, false);
//try to work with bad data integrity. There are dbs out there
//with threads that belong to a nonexistant forum.
if ($foruminfo) {
return self::create_from_record($foruminfo);
} else {
return null;
}
}
开发者ID:Kheros,项目名称:MMOver,代码行数:24,代码来源:forum.php
示例5: verify_forum_password
/**
* Returns whether or not the visiting user can view the specified password-protected forum
*
* @param integer Forum ID
* @param string Provided password
* @param boolean If true, show error when access is denied
*
* @return boolean
*/
function verify_forum_password($forumid, $password, $showerror = true)
{
global $vbulletin;
if (!$password OR ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) OR ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['ismoderator']) OR can_moderate($forumid))
{
return true;
}
$foruminfo = fetch_foruminfo($forumid);
$parents = explode(',', $foruminfo['parentlist']);
foreach ($parents AS $fid)
{ // get the pwd from any parent forums -- allows pwd cookies to cascade down
if ($temp = fetch_bbarray_cookie('forumpwd', $fid) AND $temp === md5($vbulletin->userinfo['userid'] . $password))
{
return true;
}
}
// didn't match the password in any cookie
if ($showerror)
{
require_once(DIR . '/includes/functions_misc.php');
$security_token_html = '<input type="hidden" name="securitytoken" value="' . $vbulletin->userinfo['securitytoken'] . '" />';
// forum password is bad - show error
// TODO convert the 'forumpasswordmissoing' phrase to vB4
eval(standard_error(fetch_error('forumpasswordmissing',
$vbulletin->session->vars['sessionhash'],
$vbulletin->scriptpath,
$forumid,
construct_post_vars_html() . $security_token_html,
10,
1
)));
}
else
{
// forum password is bad - return false
return false;
}
}
$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'])) {
print_no_permission();
}
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) and ($thread['postuserid'] != $vbulletin->userinfo['userid'] or $vbulletin->userinfo['userid'] == 0)) {
print_no_permission();
}
// *********************************************************************************
// check if there is a forum password and if so, ensure the user has it set
verify_forum_password($foruminfo['forumid'], $foruminfo['password']);
// *********************************************************************************
// jump page if thread is actually a redirect
/**
* Does the report
*
* @param string The Reason for the report
* @param array Information regarding the item being reported
*
*/
function do_report($reason, &$iteminfo)
{
global $vbphrase;
$this->iteminfo =& $iteminfo;
$reportinfo = array('rusername' => unhtmlspecialchars($this->registry->userinfo['username']), 'ruserid' => $this->registry->userinfo['userid'], 'remail' => $this->registry->userinfo['email']);
if ($this->registry->options['postmaxchars'] > 0) {
$reportinfo['reason'] = substr($reason, 0, $this->registry->options['postmaxchars']);
} else {
$reportinfo['reason'] = $reason;
}
$reportthread = ($rpforumid = $this->registry->options['rpforumid'] and $rpforuminfo = fetch_foruminfo($rpforumid));
$reportemail = ($this->registry->options['enableemail'] and $this->registry->options['rpemail']);
$mods = array();
$reportinfo['modlist'] = '';
$moderators = $this->fetch_affected_moderators();
if ($moderators) {
while ($moderator = $this->registry->db->fetch_array($moderators)) {
$mods["{$moderator['userid']}"] = $moderator;
$reportinfo['modlist'] .= (!empty($reportinfo['modlist']) ? ', ' : '') . unhtmlspecialchars($moderator['username']);
}
}
if (empty($reportinfo['modlist'])) {
$reportinfo['modlist'] = $vbphrase['n_a'];
}
$this->set_reportinfo($reportinfo);
if ($reportthread) {
// Determine if we need to create a thread or a post
if (!$this->iteminfo['reportthreadid'] or !($rpthreadinfo = fetch_threadinfo($this->iteminfo['reportthreadid'])) or $rpthreadinfo and ($rpthreadinfo['isdeleted'] or !$rpthreadinfo['visible'] or $rpthreadinfo['forumid'] != $rpforuminfo['forumid'])) {
eval(fetch_email_phrases('report' . $this->phrasekey . '_newthread', 0));
if (!$this->registry->options['rpuserid'] or !($userinfo = fetch_userinfo($this->registry->options['rpuserid']))) {
$userinfo =& $this->registry->userinfo;
}
$threadman =& datamanager_init('Thread_FirstPost', $this->registry, ERRTYPE_SILENT, 'threadpost');
$threadman->set_info('forum', $rpforuminfo);
$threadman->set_info('is_automated', true);
$threadman->set_info('skip_moderator_email', true);
$threadman->set_info('mark_thread_read', true);
$threadman->set_info('parseurl', true);
$threadman->set('allowsmilie', true);
$threadman->set('userid', $userinfo['userid']);
$threadman->setr_info('user', $userinfo);
$threadman->set('title', $subject);
$threadman->set('pagetext', $message);
$threadman->set('forumid', $rpforuminfo['forumid']);
$threadman->set('visible', 1);
if ($userinfo['userid'] != $this->registry->userinfo['userid']) {
// not posting as the current user, IP won't make sense
$threadman->set('ipaddress', '');
}
$rpthreadid = $threadman->save();
if ($this->update_item_reportid($rpthreadid)) {
$threadman->set_info('skip_moderator_email', false);
$threadman->email_moderators(array('newthreademail', 'newpostemail'));
$this->iteminfo['reportthreadid'] = 0;
$rpthreadinfo = array('threadid' => $rpthreadid, 'forumid' => $rpforuminfo['forumid'], 'postuserid' => $userinfo['userid']);
// check the permission of the other user
$userperms = fetch_permissions($rpthreadinfo['forumid'], $userinfo['userid'], $userinfo);
if ($userperms & $this->registry->bf_ugp_forumpermissions['canview'] and $userperms & $this->registry->bf_ugp_forumpermissions['canviewthreads'] and $userinfo['autosubscribe'] != -1) {
$this->registry->db->query_write("\n\t\t\t\t\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "subscribethread\n\t\t\t\t\t\t\t\t(userid, threadid, emailupdate, folderid, canview)\n\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t(" . $userinfo['userid'] . ", {$rpthreadinfo['threadid']}, {$userinfo['autosubscribe']}, 0, 1)\n\t\t\t\t\t\t");
}
} else {
// Delete the thread we just created
if ($delthread = fetch_threadinfo($rpthreadid)) {
$threadman =& datamanager_init('Thread', $this->registry, ERRTYPE_SILENT, 'threadpost');
$threadman->set_existing($delthread);
$threadman->delete($rpforuminfo['countposts'], true, NULL, false);
unset($threadman);
}
$this->refetch_iteminfo();
}
}
if ($this->iteminfo['reportthreadid'] and $rpthreadinfo = fetch_threadinfo($this->iteminfo['reportthreadid']) and !$rpthreadinfo['isdeleted'] and $rpthreadinfo['visible'] == 1 and $rpthreadinfo['forumid'] == $rpforuminfo['forumid']) {
eval(fetch_email_phrases('reportitem_newpost', 0));
// Already reported, thread still exists/visible, and thread is in the right forum.
// Technically, if the thread exists but is in the wrong forum, we should create the
// thread, but that should only occur in a race condition.
if (!$this->registry->options['rpuserid'] or !$userinfo and !($userinfo = fetch_userinfo($this->registry->options['rpuserid']))) {
$userinfo =& $this->registry->userinfo;
}
$postman =& datamanager_init('Post', $this->registry, ERRTYPE_STANDARD, 'threadpost');
$postman->set_info('thread', $rpthreadinfo);
$postman->set_info('forum', $rpforuminfo);
$postman->set_info('is_automated', true);
$postman->set_info('parseurl', true);
$postman->set('threadid', $rpthreadinfo['threadid']);
$postman->set('userid', $userinfo['userid']);
$postman->set('allowsmilie', true);
$postman->set('visible', true);
$postman->set('title', $subject);
$postman->set('pagetext', $message);
if ($userinfo['userid'] != $this->registry->userinfo['userid']) {
// not posting as the current user, IP won't make sense
$postman->set('ipaddress', '');
//.........这里部分代码省略.........
/**
* Creates a new thread to use for comments
*
* @param int $forumid - The forum to create the thread in
* @param int $node - The node to associate with the thread
* @return int - The id of the new thread
*/
protected function createAssociatedThread($forumid, $node)
{
$foruminfo = fetch_foruminfo($forumid);
if (!$foruminfo)
{
return false;
}
$dataman =& datamanager_init('Thread_FirstPost', vB::$vbulletin, ERRTYPE_ARRAY, 'threadpost');
//$dataman->set('prefixid', $post['prefixid']);
// set info
$dataman->set_info('preview', '');
$dataman->set_info('parseurl', true);
$dataman->set_info('posthash', '');
$dataman->set_info('forum', $foruminfo);
$dataman->set_info('thread', array());
$dataman->set_info('show_title_error', false);
// set options
$dataman->set('showsignature', true);
$dataman->set('allowsmilie', false);
// set data
//title and message are needed for dupcheck later
$title = new vB_Phrase('vbcms', 'comment_thread_title', htmlspecialchars_decode($node->getTitle()));
$message = new vB_Phrase('vbcms', 'comment_thread_firstpost', $this->getPageURL());
$dataman->set('userid', $node->getUserId());
$dataman->set('title', $title);
$dataman->set('pagetext', $message);
$dataman->set('iconid', '');
$dataman->set('visible', 1);
$dataman->setr('forumid', $foruminfo['forumid']);
$errors = array();
// done!
//($hook = vBulletinHook::fetch_hook('newpost_process')) ? eval($hook) : false;
$dataman->pre_save();
$errors = array_merge($errors, $dataman->errors);
vB_Cache::instance()->event($this->content->getCacheEvents());
if (sizeof($errors) > 0)
{
return false;
}
if (!($id = $dataman->save()))
{
throw (new vB_Exception_Content('Could not create comments thread for content'));
}
return $id;
}
//.........这里部分代码省略.........
}
// 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;
请发表评论