Vergleich inc/datahandlers/post.php - 1.4.1 - 1.4.15

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * $Id: post.php 4092 2008-08-10 03:03:04Z Tikitiki $

 * $Id: post.php 5379 2011-02-21 11:06:42Z Tomm $

 */

// Disallow direct access to this file for security reasons

 */

// Disallow direct access to this file for security reasons

Zeile 309Zeile 309
		global $mybb, $db, $session;

$post = &$this->data;

		global $mybb, $db, $session;

$post = &$this->data;

 
		
// Are we starting a new thread?
if(!$post['tid'])
{
return true;
}

		
// Are we even turned on?
if(empty($mybb->settings['postmergemins']))

		
// Are we even turned on?
if(empty($mybb->settings['postmergemins']))

		{

		{

			return true;

			return true;

		}

		}

		
// Assign a default separator if none is specified
if(trim($mybb->settings['postmergesep']) == "")

		
// Assign a default separator if none is specified
if(trim($mybb->settings['postmergesep']) == "")

		{

		{

			$mybb->settings['postmergesep'] = "[hr]";
}


			$mybb->settings['postmergesep'] = "[hr]";
}


Zeile 326Zeile 332
		if(trim($mybb->settings['postmergeuignore']) != "")
{
$gids = explode(',', $mybb->settings['postmergeuignore']);

		if(trim($mybb->settings['postmergeuignore']) != "")
{
$gids = explode(',', $mybb->settings['postmergeuignore']);

			array_walk($gids, 'intval');


			$gids = array_map('intval', $gids);


			
$user_usergroups = explode(',', $mybb->user['usergroup'].",".$mybb->user['additionalgroups']);
if(count(array_intersect($user_usergroups, $gids)) > 0)
{
return true;
}

			
$user_usergroups = explode(',', $mybb->user['usergroup'].",".$mybb->user['additionalgroups']);
if(count(array_intersect($user_usergroups, $gids)) > 0)
{
return true;
}

		}

		}

		
// Select the lastpost and fid information for this thread
$query = $db->simple_select("threads", "lastpost,fid", "lastposteruid='".$post['uid']."' AND tid='".$post['tid']."'", array('limit' => '1'));

		
// Select the lastpost and fid information for this thread
$query = $db->simple_select("threads", "lastpost,fid", "lastposteruid='".$post['uid']."' AND tid='".$post['tid']."'", array('limit' => '1'));

Zeile 342Zeile 348
		
// Check to see if the same author has posted within the merge post time limit
if((intval($mybb->settings['postmergemins']) != 0 && trim($mybb->settings['postmergemins']) != "") && (TIME_NOW-$thread['lastpost']) > (intval($mybb->settings['postmergemins'])*60))

		
// Check to see if the same author has posted within the merge post time limit
if((intval($mybb->settings['postmergemins']) != 0 && trim($mybb->settings['postmergemins']) != "") && (TIME_NOW-$thread['lastpost']) > (intval($mybb->settings['postmergemins'])*60))

		{
return true;
}

		{
return true;
}

		
if(strstr($mybb->settings['postmergefignore'], ','))
{

		
if(strstr($mybb->settings['postmergefignore'], ','))
{

Zeile 352Zeile 358
			foreach($fids as $key => $forumid)
{
$fid[] = intval($forumid);

			foreach($fids as $key => $forumid)
{
$fid[] = intval($forumid);

			}


			}


			if(in_array($thread['fid'], $fid))
{
return true;

			if(in_array($thread['fid'], $fid))
{
return true;

Zeile 361Zeile 367
			
}
else if(trim($mybb->settings['postmergefignore']) != "" && $thread['fid'] == intval($mybb->settings['postmergefignore']))

			
}
else if(trim($mybb->settings['postmergefignore']) != "" && $thread['fid'] == intval($mybb->settings['postmergefignore']))

		{

		{

			return true;
}


			return true;
}


Zeile 398Zeile 404
		$permissions = user_permissions($post['uid']);

// Fetch the forum this post is being made in

		$permissions = user_permissions($post['uid']);

// Fetch the forum this post is being made in

 
		if(!$post['fid'])
{
$query = $db->simple_select('posts', 'fid', "pid = '{$post['pid']}'");
$post['fid'] = $db->fetch_field($query, 'fid');
}

		$forum = get_forum($post['fid']);

// Check if this post contains more images than the forum allows

		$forum = get_forum($post['fid']);

// Check if this post contains more images than the forum allows

Zeile 444Zeile 455
	function verify_reply_to()
{
global $db;

	function verify_reply_to()
{
global $db;

		$post = &$this->data;


		$post = &$this->data;


		// Check if the post being replied to actually exists in this thread.
if($post['replyto'])
{

		// Check if the post being replied to actually exists in this thread.
if($post['replyto'])
{

			$query = $db->simple_select("posts", "pid", "pid='{$post['replyto']}'");

			$query = $db->simple_select("posts", "pid", "pid='".intval($post['replyto'])."'");

			$valid_post = $db->fetch_array($query);
if(!$valid_post['pid'])

			$valid_post = $db->fetch_array($query);
if(!$valid_post['pid'])

			{

			{

				$post['replyto'] = 0;

				$post['replyto'] = 0;

			}

			}

			else
{
return true;
}

			else
{
return true;
}

		}


		}


		// If this post isn't a reply to a specific post, attach it to the first post.
if(!$post['replyto'])
{

		// If this post isn't a reply to a specific post, attach it to the first post.
if(!$post['replyto'])
{

Zeile 473Zeile 484
			$query = $db->simple_select("posts", "pid", "tid='{$post['tid']}'", $options);
$reply_to = $db->fetch_array($query);
$post['replyto'] = $reply_to['pid'];

			$query = $db->simple_select("posts", "pid", "tid='{$post['tid']}'", $options);
$reply_to = $db->fetch_array($query);
$post['replyto'] = $reply_to['pid'];

		}

return true;

		}

return true;

	}

/**

	}

/**

Zeile 505Zeile 516
	function verify_dateline()
{
$dateline = &$this->data['dateline'];

	function verify_dateline()
{
$dateline = &$this->data['dateline'];





		// The date has to be numeric and > 0.
if($dateline < 0 || is_numeric($dateline) == false)
{

		// The date has to be numeric and > 0.
if($dateline < 0 || is_numeric($dateline) == false)
{

Zeile 535Zeile 546
		// Verify all post assets.

if($this->method == "insert" || array_key_exists('uid', $post))

		// Verify all post assets.

if($this->method == "insert" || array_key_exists('uid', $post))

		{

		{

			$this->verify_author();
}


			$this->verify_author();
}


Zeile 566Zeile 577
		}

if($this->method == "insert" || array_key_exists('options', $post))

		}

if($this->method == "insert" || array_key_exists('options', $post))

		{
$this->verify_options();
}

$plugins->run_hooks_by_ref("datahandler_post_validate_post", $this);

// We are done validating, return.
$this->set_validated(true);
if(count($this->get_errors()) > 0)
{
return false;
}
else
{
return true;
}
}


		{
$this->verify_options();
}

$plugins->run_hooks_by_ref("datahandler_post_validate_post", $this);

// We are done validating, return.
$this->set_validated(true);
if(count($this->get_errors()) > 0)
{
return false;
}
else
{
return true;
}
}



/**
* Insert a post into the database.


/**
* Insert a post into the database.

Zeile 598Zeile 609

// Yes, validating is required.
if(!$this->get_validated())


// Yes, validating is required.
if(!$this->get_validated())

		{

		{

			die("The post needs to be validated before inserting it into the DB.");

			die("The post needs to be validated before inserting it into the DB.");

		}

		}

		if(count($this->get_errors()) > 0)

		if(count($this->get_errors()) > 0)

		{

		{

			die("The post is not valid.");

			die("The post is not valid.");

		}

		}


// This post is being saved as a draft.
if($post['savedraft'])


// This post is being saved as a draft.
if($post['savedraft'])

Zeile 614Zeile 625
		
// Otherwise this post is being made now and we have a bit to do.
else

		
// Otherwise this post is being made now and we have a bit to do.
else

		{

		{

			// Automatic subscription to the thread
if($post['options']['subscriptionmethod'] != "" && $post['uid'] > 0)
{

			// Automatic subscription to the thread
if($post['options']['subscriptionmethod'] != "" && $post['uid'] > 0)
{

Zeile 629Zeile 640

require_once MYBB_ROOT."inc/functions_user.php";
add_subscribed_thread($post['tid'], $notification, $post['uid']);


require_once MYBB_ROOT."inc/functions_user.php";
add_subscribed_thread($post['tid'], $notification, $post['uid']);

			}


			}


			// Perform any selected moderation tools.
if(is_moderator($post['fid'], "", $post['uid']))
{

			// Perform any selected moderation tools.
if(is_moderator($post['fid'], "", $post['uid']))
{

Zeile 662Zeile 673
				{
$newstick = "sticky='1'";
log_moderator_action($modlogdata, $lang->thread_stuck);

				{
$newstick = "sticky='1'";
log_moderator_action($modlogdata, $lang->thread_stuck);

				}


				}


				// Unstick the thread.
if($modoptions['stickthread'] != 1 && $thread['sticky'])
{

				// Unstick the thread.
if($modoptions['stickthread'] != 1 && $thread['sticky'])
{

Zeile 695Zeile 706
				$visible = 0;
}
else

				$visible = 0;
}
else

			{

			{

				$visible = 1;

				$visible = 1;

			}

			}


// Are posts from this user being moderated? Change visibility
if($mybb->user['uid'] == $post['uid'] && $mybb->user['moderateposts'] == 1)


// Are posts from this user being moderated? Change visibility
if($mybb->user['uid'] == $post['uid'] && $mybb->user['moderateposts'] == 1)

			{

			{

				$visible = 0;
}
}

				$visible = 0;
}
}

Zeile 710Zeile 721
		{
$double_post = $this->verify_post_merge();


		{
$double_post = $this->verify_post_merge();


 
			// Only combine if they are both invisible (mod queue'd forum) or both visible

			if($double_post !== true && $double_post['visible'] == $visible)
{

			if($double_post !== true && $double_post['visible'] == $visible)
{

				// Only combine if they are both invisible (mod queue'd forum) or both visible
$double_post['message'] .= $mybb->settings['postmergesep']."\n".$post['message'];


				$this->pid = $double_post['pid'];

$post['message'] = $double_post['message'] .= $mybb->settings['postmergesep']."\n".$post['message'];

				$update_query = array(
"message" => $db->escape_string($double_post['message'])
);

				$update_query = array(
"message" => $db->escape_string($double_post['message'])
);

Zeile 741Zeile 754
						"posthash" => $double_post['posthash'],
);
$db->update_query("attachments", $attachmentassign, "posthash='{$post['posthash']}'");

						"posthash" => $double_post['posthash'],
);
$db->update_query("attachments", $attachmentassign, "posthash='{$post['posthash']}'");

 
				
$post['posthash'] = $double_post['posthash'];

				}

// Return the post's pid and whether or not it is visible.

				}

// Return the post's pid and whether or not it is visible.

Zeile 853Zeile 868

// Fetch any users subscribed to this thread receiving instant notification and queue up their subscription notices
$query = $db->query("


// Fetch any users subscribed to this thread receiving instant notification and queue up their subscription notices
$query = $db->query("

				SELECT u.username, u.email, u.uid, u.language, s.subscriptionkey

				SELECT u.username, u.email, u.uid, u.language, u.loginkey, u.salt, u.regdate, s.subscriptionkey

				FROM ".TABLE_PREFIX."threadsubscriptions s
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=s.uid)
WHERE s.notification='1' AND s.tid='{$post['tid']}'

				FROM ".TABLE_PREFIX."threadsubscriptions s
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=s.uid)
WHERE s.notification='1' AND s.tid='{$post['tid']}'

Zeile 867Zeile 882
					continue;
}
$done_users[$subscribedmember['uid']] = 1;

					continue;
}
$done_users[$subscribedmember['uid']] = 1;

 
				
$forumpermissions = forum_permissions($thread['fid'], $subscribedmember['uid']);
if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0)
{
continue;
}


				if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language']))
{
$uselang = $subscribedmember['language'];

				if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language']))
{
$uselang = $subscribedmember['language'];

Zeile 901Zeile 923
					$emailmessage = $langcache[$uselang]['email_subscription'];
}
$emailsubject = $lang->sprintf($emailsubject, $subject);

					$emailmessage = $langcache[$uselang]['email_subscription'];
}
$emailsubject = $lang->sprintf($emailsubject, $subject);

				$emailmessage = $lang->sprintf($emailmessage, $subscribedmember['username'], $post['username'], $mybb->settings['bbname'], $subject, $excerpt, $mybb->settings['bburl'], str_replace("&amp;", "&", get_thread_link($thread['tid'], 0, "newpost")), $thread['tid'], $subscribedmember['subscriptionkey']);



				
$post_code = md5($subscribedmember['loginkey'].$subscribedmember['salt'].$subscribedmember['regdate']);
$emailmessage = $lang->sprintf($emailmessage, $subscribedmember['username'], $post['username'], $mybb->settings['bbname'], $subject, $excerpt, $mybb->settings['bburl'], str_replace("&amp;", "&", get_thread_link($thread['tid'], 0, "newpost")), $thread['tid'], $subscribedmember['subscriptionkey'], $post_code);

				$new_email = array(
"mailto" => $db->escape_string($subscribedmember['email']),
"mailfrom" => '',

				$new_email = array(
"mailto" => $db->escape_string($subscribedmember['email']),
"mailfrom" => '',

Zeile 974Zeile 998
		}

if($this->method == "insert" || array_key_exists('dateline', $thread))

		}

if($this->method == "insert" || array_key_exists('dateline', $thread))

		{

		{

			$this->verify_dateline();

			$this->verify_dateline();

		}

		}


if($this->method == "insert" || array_key_exists('icon', $thread))


if($this->method == "insert" || array_key_exists('icon', $thread))

		{

		{

			$this->verify_post_icon();

			$this->verify_post_icon();

		}


		}


		if($this->method == "insert" || array_key_exists('options', $thread))
{
$this->verify_options();

		if($this->method == "insert" || array_key_exists('options', $thread))
{
$this->verify_options();

		}

$plugins->run_hooks_by_ref("datahandler_post_validate_thread", $this);


		}

$plugins->run_hooks_by_ref("datahandler_post_validate_thread", $this);


		// We are done validating, return.
$this->set_validated(true);
if(count($this->get_errors()) > 0)

		// We are done validating, return.
$this->set_validated(true);
if(count($this->get_errors()) > 0)

Zeile 1238Zeile 1262
				{
$forum['lastpost'] = 0;
}

				{
$forum['lastpost'] = 0;
}





				
$done_users = array();


				// Queue up any forum subscription notices to users who are subscribed to this forum.
$excerpt = my_substr($thread['message'], 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;


				// Queue up any forum subscription notices to users who are subscribed to this forum.
$excerpt = my_substr($thread['message'], 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;


Zeile 1248Zeile 1274
				$excerpt = $parser->parse_badwords($excerpt);

$query = $db->query("

				$excerpt = $parser->parse_badwords($excerpt);

$query = $db->query("

					SELECT u.username, u.email, u.uid, u.language

					SELECT u.username, u.email, u.uid, u.language, u.loginkey, u.salt, u.regdate

					FROM ".TABLE_PREFIX."forumsubscriptions fs
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=fs.uid)
LEFT JOIN ".TABLE_PREFIX."usergroups g ON (g.gid=u.usergroup)

					FROM ".TABLE_PREFIX."forumsubscriptions fs
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=fs.uid)
LEFT JOIN ".TABLE_PREFIX."usergroups g ON (g.gid=u.usergroup)

Zeile 1260Zeile 1286
				while($subscribedmember = $db->fetch_array($query))
{
if($done_users[$subscribedmember['uid']])

				while($subscribedmember = $db->fetch_array($query))
{
if($done_users[$subscribedmember['uid']])

					{

					{

						continue;

						continue;

					}

					}

					$done_users[$subscribedmember['uid']] = 1;

					$done_users[$subscribedmember['uid']] = 1;

 
					
$forumpermissions = forum_permissions($thread['fid'], $subscribedmember['uid']);
if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0)
{
continue;
}


					// Determine the language pack we'll be using to send this email in and load it if it isn't already.
if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language']))
{

					// Determine the language pack we'll be using to send this email in and load it if it isn't already.
if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language']))
{

Zeile 1299Zeile 1332
						$emailmessage = $langcache[$uselang]['email_forumsubscription'];
}
$emailsubject = $lang->sprintf($emailsubject, $forum['name']);

						$emailmessage = $langcache[$uselang]['email_forumsubscription'];
}
$emailsubject = $lang->sprintf($emailsubject, $forum['name']);

					$emailmessage = $lang->sprintf($emailmessage, $subscribedmember['username'], $thread['username'], $forum['name'], $mybb->settings['bbname'], $thread['subject'], $excerpt, $mybb->settings['bburl'], get_thread_link($this->tid), $thread['fid']);



					
$post_code = md5($subscribedmember['loginkey'].$subscribedmember['salt'].$subscribedmember['regdate']);
$emailmessage = $lang->sprintf($emailmessage, $subscribedmember['username'], $thread['username'], $forum['name'], $mybb->settings['bbname'], $thread['subject'], $excerpt, $mybb->settings['bburl'], get_thread_link($this->tid), $thread['fid'], $post_code);

					$new_email = array(
"mailto" => $db->escape_string($subscribedmember['email']),
"mailfrom" => '',

					$new_email = array(
"mailto" => $db->escape_string($subscribedmember['email']),
"mailfrom" => '',

Zeile 1331Zeile 1366
		
if($visible == 1)
{

		
if($visible == 1)
{

			$query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='{$this->pid}' AND visible='1'");
$attachmentcount = $db->fetch_field($query, "attachmentcount");
if($attachmentcount > 0)
{
update_thread_counters($this->tid, array("attachmentcount" => "+{$attachmentcount}"));
}


 
			update_thread_data($this->tid);
update_forum_counters($thread['fid'], array("threads" => "+1", "posts" => "+1"));
}
else if($visible == 0)

			update_thread_data($this->tid);
update_forum_counters($thread['fid'], array("threads" => "+1", "posts" => "+1"));
}
else if($visible == 0)

		{

		{

			update_thread_data($this->tid);

			update_thread_data($this->tid);

			update_thread_counters($thread['tid'], array("replies" => 0, "unapprovedposts" => 1));

			update_thread_counters($this->tid, array("replies" => 0, "unapprovedposts" => 1));

			update_forum_counters($thread['fid'], array("unapprovedthreads" => "+1", "unapprovedposts" => "+1"));

			update_forum_counters($thread['fid'], array("unapprovedthreads" => "+1", "unapprovedposts" => "+1"));

 
		}

$query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='{$this->pid}' AND visible='1'");
$attachmentcount = $db->fetch_field($query, "attachmentcount");
if($attachmentcount > 0)
{
update_thread_counters($this->tid, array("attachmentcount" => "+{$attachmentcount}"));

		}

// Return the post's pid and whether or not it is visible.

		}

// Return the post's pid and whether or not it is visible.

Zeile 1372Zeile 1407
		if(count($this->get_errors()) > 0)
{
die("The post is not valid.");

		if(count($this->get_errors()) > 0)
{
die("The post is not valid.");

		}

		}


$post = &$this->data;



$post = &$this->data;


Zeile 1385Zeile 1420
		$forum = get_forum($post['fid']);

// Decide on the visibility of this post.

		$forum = get_forum($post['fid']);

// Decide on the visibility of this post.

		if($forum['mod_edit_posts'] == 1 && !is_moderator($post['fid'], "", $post['uid']))
{
if($existing_post['visible'] == 1)
{
update_thread_data($existing_post['tid']);
update_thread_counters($existing_post['tid'], array('replies' => '-1', 'unapprovedposts' => '+1'));
update_forum_counters($existing_post['fid'], array('unapprovedthreads' => '+1', 'unapprovedposts' => '+1'));

// Subtract from the users post count
// Update the post count if this forum allows post counts to be tracked
if($forum['usepostcounts'] != 0)
{
$db->write_query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum-1 WHERE uid='{$existing_post['uid']}'");
}
}
























		if(isset($post['visible']) && $post['visible'] != $existing_post['visible'])
{
if($forum['mod_edit_posts'] == 1 && !is_moderator($post['fid'], "", $post['uid']))
{
if($existing_post['visible'] == 1)
{
update_thread_data($existing_post['tid']);
update_thread_counters($existing_post['tid'], array('replies' => '-1', 'unapprovedposts' => '+1'));
update_forum_counters($existing_post['fid'], array('unapprovedthreads' => '+1', 'unapprovedposts' => '+1'));

// Subtract from the users post count
// Update the post count if this forum allows post counts to be tracked
if($forum['usepostcounts'] != 0)
{
$db->write_query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum-1 WHERE uid='{$existing_post['uid']}'");
}
}
$visible = 0;
}
else
{
if($existing_post['visible'] == 0)
{
update_thread_data($existing_post['tid']);
update_thread_counters($existing_post['tid'], array('replies' => '+1', 'unapprovedposts' => '-1'));
update_forum_counters($existing_post['fid'], array('unapprovedthreads' => '-1', 'unapprovedposts' => '-1'));

// Update the post count if this forum allows post counts to be tracked
if($forum['usepostcounts'] != 0)
{
$db->write_query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum+1 WHERE uid='{$existing_post['uid']}'");
}
}
$visible = 1;
}
}
else
{

			$visible = 0;

			$visible = 0;

		}
else
{
if($existing_post['visible'] == 0)

			if($forum['mod_edit_posts'] != 1 || is_moderator($post['fid'], "", $post['uid']))




			{

			{

				update_thread_data($existing_post['tid']);
update_thread_counters($existing_post['tid'], array('replies' => '+1', 'unapprovedposts' => '-1'));
update_forum_counters($existing_post['fid'], array('unapprovedthreads' => '-1', 'unapprovedposts' => '-1'));

// Update the post count if this forum allows post counts to be tracked
if($forum['usepostcounts'] != 0)
{
$db->write_query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum+1 WHERE uid='{$existing_post['uid']}'");
}

				$visible = 1;









			}

			}

			$visible = 1;
}

        }



// Check if this is the first post in a thread.
$options = array(


// Check if this is the first post in a thread.
$options = array(

Zeile 1526Zeile 1572
		}
else
{

		}
else
{

			$db->delete_query("threadsubscriptions", "uid='{$post['uid']}' AND tid='{$post['tid']}'");

			$db->delete_query("threadsubscriptions", "uid='".intval($post['uid'])."' AND tid='".intval($post['tid'])."'");

		}

update_forum_lastpost($post['fid']);

		}

update_forum_lastpost($post['fid']);