Vergleich inc/datahandlers/post.php - 1.8.15 - 1.8.27

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 241Zeile 241
	 */
function verify_message()
{

	 */
function verify_message()
{

		global $mybb;

		global $db, $mybb;


$post = &$this->data;
$post['message'] = trim_blank_chrs($post['message']);


$post = &$this->data;
$post['message'] = trim_blank_chrs($post['message']);

Zeile 252Zeile 252
			$this->set_error("missing_message");
return false;
}

			$this->set_error("missing_message");
return false;
}


// If this board has a maximum message length check if we're over it. Use strlen because SQL limits are in bytes
else if(strlen($post['message']) > $mybb->settings['maxmessagelength'] && $mybb->settings['maxmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid']))
{
$this->set_error("message_too_long", array($mybb->settings['maxmessagelength'], strlen($post['message'])));
return false;
}

// And if we've got a minimum message length do we meet that requirement too?

 
		else
{

		else
{

 
			$limit = (int)$mybb->settings['maxmessagelength'];
$dblimit = 0;

// If database is mysql or mysqli check field type and set max database limit
if(stripos($db->type, 'my') !== false)
{
$fields = $db->show_fields_from("posts");
$type = $fields[array_search('message', array_column($fields, 'Field'))]['Type'];
switch(strtolower($type))
{
case 'longtext':
$dblimit = 4294967295;
break;
case 'mediumtext':
$dblimit = 16777215;
break;
case 'text':
default:
$dblimit = 65535;
break;
}
}

if($limit > 0 || $dblimit > 0)
{
if(isset($post['fid']))
{
$fid = $post['fid'];
}
else
{
$fid = 0;
}
if(isset($post['uid']))
{
$uid = $post['uid'];
}
else
{
$uid = 0;
}

$is_moderator = is_moderator($fid, "", $uid);
// Consider minimum in user defined and database limit other than 0
if($limit > 0 && $dblimit > 0)
{
$limit = $is_moderator ? $dblimit : min($limit, $dblimit);
}
else
{
$limit = max($limit, $dblimit);
}

if(strlen($post['message']) > $limit && (!$is_moderator || $limit == $dblimit))
{
$this->set_error("message_too_long", array($limit, strlen($post['message'])));
return false;
}
}


			if(!isset($post['fid']))
{
$post['fid'] = 0;
}

			if(!isset($post['fid']))
{
$post['fid'] = 0;
}

 


			if(!$mybb->settings['mycodemessagelength'])

			if(!$mybb->settings['mycodemessagelength'])

			{

			{

				// Check to see of the text is full of MyCode
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;

$message = $parser->text_parse_message($post['message']);

				// Check to see of the text is full of MyCode
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;

$message = $parser->text_parse_message($post['message']);





				if(my_strlen($message) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid']))
{
$this->set_error("message_too_short", array($mybb->settings['minmessagelength']));
return false;
}

				if(my_strlen($message) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid']))
{
$this->set_error("message_too_short", array($mybb->settings['minmessagelength']));
return false;
}

			}

			}

			else if(my_strlen($post['message']) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid']))
{
$this->set_error("message_too_short", array($mybb->settings['minmessagelength']));

			else if(my_strlen($post['message']) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid']))
{
$this->set_error("message_too_short", array($mybb->settings['minmessagelength']));

Zeile 292Zeile 344

/**
* Verifies the specified post options are correct.


/**
* Verifies the specified post options are correct.

	 *

	 *

	 * @return boolean True
*/
function verify_options()

	 * @return boolean True
*/
function verify_options()

Zeile 302Zeile 354
		// Verify yes/no options.
$this->verify_yesno_option($options, 'signature', 0);
$this->verify_yesno_option($options, 'disablesmilies', 0);

		// Verify yes/no options.
$this->verify_yesno_option($options, 'signature', 0);
$this->verify_yesno_option($options, 'disablesmilies', 0);





		return true;
}

		return true;
}





	/**
* Verify that the user is not flooding the system.
*

	/**
* Verify that the user is not flooding the system.
*

Zeile 314Zeile 366
	function verify_post_flooding()
{
global $mybb;

	function verify_post_flooding()
{
global $mybb;


$post = &$this->data;



$post = &$this->data;


		// Check if post flooding is enabled within MyBB or if the admin override option is specified.
if($mybb->settings['postfloodcheck'] == 1 && $post['uid'] != 0 && $this->admin_override == false)
{

		// Check if post flooding is enabled within MyBB or if the admin override option is specified.
if($mybb->settings['postfloodcheck'] == 1 && $post['uid'] != 0 && $this->admin_override == false)
{

Zeile 334Zeile 386
				// Oops, user has been flooding - throw back error message.
$time_to_wait = ($mybb->settings['postfloodsecs'] - (TIME_NOW-$user['lastpost'])) + 1;
if($time_to_wait == 1)

				// Oops, user has been flooding - throw back error message.
$time_to_wait = ($mybb->settings['postfloodsecs'] - (TIME_NOW-$user['lastpost'])) + 1;
if($time_to_wait == 1)

				{

				{

					$this->set_error("post_flooding_one_second");
}
else
{
$this->set_error("post_flooding", array($time_to_wait));

					$this->set_error("post_flooding_one_second");
}
else
{
$this->set_error("post_flooding", array($time_to_wait));

				}

				}

				return false;
}
}
// All is well that ends well - return true.
return true;
}

				return false;
}
}
// All is well that ends well - return true.
return true;
}





	/**
* @param bool $simple_mode
*

	/**
* @param bool $simple_mode
*

Zeile 358Zeile 410
		global $mybb, $db, $session;

$post = &$this->data;

		global $mybb, $db, $session;

$post = &$this->data;





		// Are we starting a new thread?
if(empty($post['tid']))

		// Are we starting a new thread?
if(empty($post['tid']))

		{
return true;
}


		{
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]";

		}


		}


		// Check to see if this person is in a usergroup that is excluded
if(is_member($mybb->settings['postmergeuignore'], $post['uid']))
{
return true;
}

		// Check to see if this person is in a usergroup that is excluded
if(is_member($mybb->settings['postmergeuignore'], $post['uid']))
{
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'));
$thread = $db->fetch_array($query);

// Check to see if the same author has posted within the merge post time limit

		// 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'));
$thread = $db->fetch_array($query);

// Check to see if the same author has posted within the merge post time limit

		if(((int)$mybb->settings['postmergemins'] != 0 && trim($mybb->settings['postmergemins']) != "") && (TIME_NOW-$thread['lastpost']) > ((int)$mybb->settings['postmergemins']*60))
{






		if(
!$thread || (
((int)$mybb->settings['postmergemins'] != 0 && trim($mybb->settings['postmergemins']) != "") &&
(TIME_NOW-$thread['lastpost']) > ((int)$mybb->settings['postmergemins']*60)
)
)
{

			return true;
}


			return true;
}


Zeile 421Zeile 478
			return false;
}


			return false;
}


		if($post['uid'])

		if(!empty($post['uid']))

		{
$user_check = "uid='".$post['uid']."'";
}

		{
$user_check = "uid='".$post['uid']."'";
}

Zeile 436Zeile 493

/**
* Verifies the image count.


/**
* Verifies the image count.

	*
* @return boolean True when valid, false when not valid.
*/

	*
* @return boolean True when valid, false when not valid.
*/

	function verify_image_count()

	function verify_image_count()

	{
global $mybb, $db;

$post = &$this->data;

// Get the permissions of the user who is making this post or thread
$permissions = user_permissions($post['uid']);











	{
global $mybb, $db;

$post = &$this->data;

if(isset($post['uid']))
{
$uid = $post['uid'];
}
else
{
$uid = null;
}

// Get the permissions of the user who is making this post or thread
$permissions = user_permissions($uid);


		// Fetch the forum this post is being made in
if(!$post['fid'])
{

		// Fetch the forum this post is being made in
if(!$post['fid'])
{

Zeile 455Zeile 521
			$post['fid'] = $db->fetch_field($query, 'fid');
}
$forum = get_forum($post['fid']);

			$post['fid'] = $db->fetch_field($query, 'fid');
}
$forum = get_forum($post['fid']);





		// Check if this post contains more images than the forum allows
if((!isset($post['savedraft']) || $post['savedraft'] != 1) && $mybb->settings['maxpostimages'] != 0 && $permissions['cancp'] != 1)
{

		// Check if this post contains more images than the forum allows
if((!isset($post['savedraft']) || $post['savedraft'] != 1) && $mybb->settings['maxpostimages'] != 0 && $permissions['cancp'] != 1)
{

Zeile 470Zeile 536
				"allow_videocode" => $forum['allowvideocode'],
"filter_badwords" => 1
);

				"allow_videocode" => $forum['allowvideocode'],
"filter_badwords" => 1
);


if($post['options']['disablesmilies'] != 1)
{


if(empty($post['options']['disablesmilies']))
{

				$parser_options['allow_smilies'] = $forum['allowsmilies'];

				$parser_options['allow_smilies'] = $forum['allowsmilies'];

			}

			}

			else
{
$parser_options['allow_smilies'] = 0;

			else
{
$parser_options['allow_smilies'] = 0;

			}

$image_check = $parser->parse_message($post['message'], $parser_options);

			}

$image_check = $parser->parse_message($post['message'], $parser_options);


// And count the number of image tags in the message.
$image_count = substr_count($image_check, "<img");


// And count the number of image tags in the message.
$image_count = substr_count($image_check, "<img");

Zeile 505Zeile 571
		global $mybb, $db;

$post = &$this->data;

		global $mybb, $db;

$post = &$this->data;

 

if(isset($post['uid']))
{
$uid = $post['uid'];
}
else
{
$uid = null;
}


// Get the permissions of the user who is making this post or thread


// Get the permissions of the user who is making this post or thread

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

		$permissions = user_permissions($uid);


// Check if this post contains more videos than the forum allows
if((!isset($post['savedraft']) || $post['savedraft'] != 1) && $mybb->settings['maxpostvideos'] != 0 && $permissions['cancp'] != 1)


// Check if this post contains more videos than the forum allows
if((!isset($post['savedraft']) || $post['savedraft'] != 1) && $mybb->settings['maxpostvideos'] != 0 && $permissions['cancp'] != 1)

Zeile 556Zeile 631
			$options = array(
"limit_start" => 0,
"limit" => 1,

			$options = array(
"limit_start" => 0,
"limit" => 1,

				"order_by" => "dateline",
"order_dir" => "asc"

				"order_by" => "dateline, pid",


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

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

Zeile 747Zeile 821
			$options = array(
"limit" => 1,
"limit_start" => 0,

			$options = array(
"limit" => 1,
"limit_start" => 0,

				"order_by" => "dateline",
"order_dir" => "asc"

				"order_by" => "dateline, pid",


			);
$query = $db->simple_select("posts", "pid", "tid='".$post['tid']."'", $options);
$first_check = $db->fetch_array($query);

			);
$query = $db->simple_select("posts", "pid", "tid='".$post['tid']."'", $options);
$first_check = $db->fetch_array($query);

Zeile 822Zeile 895
	 * @return array Array of new post details, pid and visibility.
*/
function insert_post()

	 * @return array Array of new post details, pid and visibility.
*/
function insert_post()

	{
global $db, $mybb, $plugins, $cache, $lang;

$post = &$this->data;

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

	{
global $db, $mybb, $plugins, $cache, $lang;

$post = &$this->data;

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

			die("The post needs to be validated before inserting it into the DB.");
}
if(count($this->get_errors()) > 0)

			die("The post needs to be validated before inserting it into the DB.");
}
if(count($this->get_errors()) > 0)

Zeile 852Zeile 925
		else
{
// Automatic subscription to the thread

		else
{
// Automatic subscription to the thread

			if($post['options']['subscriptionmethod'] != "" && $post['uid'] > 0)

			if($post['uid'] > 0)

			{

			{

				switch($post['options']['subscriptionmethod'])
{
case "pm":
$notification = 2;
break;
case "email":
$notification = 1;
break;
default:
$notification = 0;
}


 
				require_once MYBB_ROOT."inc/functions_user.php";

				require_once MYBB_ROOT."inc/functions_user.php";

				add_subscribed_thread($post['tid'], $notification, $post['uid']);
}




















				if($post['options']['subscriptionmethod'] == "")
{
remove_subscribed_thread($post['tid'], $post['uid']);
}
else
{
switch($post['options']['subscriptionmethod'])
{
case "pm":
$notification = 2;
break;
case "email":
$notification = 1;
break;
default:
$notification = 0;
}
add_subscribed_thread($post['tid'], $notification, $post['uid']);
}
}


			// Perform any selected moderation tools.
$ismod = is_moderator($post['fid'], "", $post['uid']);
if($ismod && isset($post['modoptions']))

			// Perform any selected moderation tools.
$ismod = is_moderator($post['fid'], "", $post['uid']);
if($ismod && isset($post['modoptions']))

Zeile 879Zeile 958
				$modoptions = $post['modoptions'];
$modlogdata['fid'] = $thread['fid'];
$modlogdata['tid'] = $thread['tid'];

				$modoptions = $post['modoptions'];
$modlogdata['fid'] = $thread['fid'];
$modlogdata['tid'] = $thread['tid'];





				$modoptions_update = array();

// Close the thread.

				$modoptions_update = array();

// Close the thread.

Zeile 887Zeile 966
				{
$modoptions_update['closed'] = $closed = 1;
log_moderator_action($modlogdata, $lang->thread_closed);

				{
$modoptions_update['closed'] = $closed = 1;
log_moderator_action($modlogdata, $lang->thread_closed);

				}


				}


				// Open the thread.
if(empty($modoptions['closethread']) && $thread['closed'] == 1 && is_moderator($post['fid'], "canopenclosethreads", $post['uid']))
{

				// Open the thread.
if(empty($modoptions['closethread']) && $thread['closed'] == 1 && is_moderator($post['fid'], "canopenclosethreads", $post['uid']))
{

Zeile 923Zeile 1002
			// Decide on the visibility of this post.
$forumpermissions = forum_permissions($post['fid'], $post['uid']);
if($forumpermissions['modposts'] == 1 && !$ismod)

			// Decide on the visibility of this post.
$forumpermissions = forum_permissions($post['fid'], $post['uid']);
if($forumpermissions['modposts'] == 1 && !$ismod)

			{
$visible = 0;
}

			{
$visible = 0;
}

			else
{
$visible = 1;

			else
{
$visible = 1;

Zeile 963Zeile 1042
			// Only combine if they are both invisible (mod queue'd forum) or both visible
if($double_post !== true && $double_post['visible'] == $visible)
{

			// Only combine if they are both invisible (mod queue'd forum) or both visible
if($double_post !== true && $double_post['visible'] == $visible)
{

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

				$_message = $post['message'];


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


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

				$update_query = array(
"message" => $db->escape_string($double_post['message'])
);
$update_query['edituid'] = (int)$post['uid'];
$update_query['edittime'] = TIME_NOW;
$db->update_query("posts", $update_query, "pid='".$double_post['pid']."'");

if($draft_check)
{
$db->delete_query("posts", "pid='".$post['pid']."'");
}

if($post['posthash'])

				
if ($this->validate_post())












				{

				{

					// Assign any uploaded attachments with the specific posthash to the merged post.
$post['posthash'] = $db->escape_string($post['posthash']);

$query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='0' AND visible='1' AND posthash='{$post['posthash']}'");
$attachmentcount = $db->fetch_field($query, "attachmentcount");

if($attachmentcount > 0)




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

$update_query = array(
"message" => $db->escape_string($double_post['message'])
);
$update_query['edituid'] = (int)$post['uid'];
$update_query['edittime'] = TIME_NOW;
$db->update_query("posts", $update_query, "pid='".$double_post['pid']."'");

if($draft_check)

					{

					{

						// Update forum count
update_thread_counters($post['tid'], array('attachmentcount' => "+{$attachmentcount}"));

						$db->delete_query("posts", "pid='".$post['pid']."'");


					}

					}


$attachmentassign = array(























					
if($post['posthash'])
{
// Assign any uploaded attachments with the specific posthash to the merged post.
$post['posthash'] = $db->escape_string($post['posthash']);

$query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='0' AND visible='1' AND posthash='{$post['posthash']}'");
$attachmentcount = $db->fetch_field($query, "attachmentcount");

if($attachmentcount > 0)
{
// Update forum count
update_thread_counters($post['tid'], array('attachmentcount' => "+{$attachmentcount}"));
}

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

// Return the post's pid and whether or not it is visible.
$this->return_values = array(

						"pid" => $double_post['pid'],

						"pid" => $double_post['pid'],

						"posthash" => ''


						"visible" => $visible,
"merge" => true

					);

					);

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








					
$plugins->run_hooks("datahandler_post_insert_merge", $this);

return $this->return_values;
}
else
{
$post['message'] = $_message;

				}

				}


// Return the post's pid and whether or not it is visible.
$this->return_values = array(
"pid" => $double_post['pid'],
"visible" => $visible,
"merge" => true
);

$plugins->run_hooks("datahandler_post_insert_merge", $this);

return $this->return_values;

 
			}
}


			}
}


Zeile 1205Zeile 1294
				{
$emailsubject = $lang->sprintf($emailsubject, $subject);


				{
$emailsubject = $lang->sprintf($emailsubject, $subject);


					$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'], $post_code);

					$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']);


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

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

Zeile 1220Zeile 1308
				}
elseif($subscribedmember['notification'] == 2)
{

				}
elseif($subscribedmember['notification'] == 2)
{

					$post_code = md5($subscribedmember['loginkey'].$subscribedmember['salt'].$subscribedmember['regdate']);

 
					$pm = array(
'subject' => array('pmsubject_subscription', $subject),

					$pm = array(
'subject' => array('pmsubject_subscription', $subject),

						'message' => array('pm_subscription', $subscribedmember['username'], $post['username'], $subject, $excerpt, $mybb->settings['bburl'], str_replace("&amp;", "&", get_thread_link($thread['tid'], 0, "newpost")), $thread['tid'], $post_code),

						'message' => array('pm_subscription', $subscribedmember['username'], $post['username'], $subject, $excerpt, $mybb->settings['bburl'], str_replace("&amp;", "&", get_thread_link($thread['tid'], 0, "newpost")), $thread['tid']),

						'touid' => $subscribedmember['uid'],
'language' => $subscribedmember['language'],
'language_file' => 'messages'

						'touid' => $subscribedmember['uid'],
'language' => $subscribedmember['language'],
'language_file' => 'messages'

Zeile 1248Zeile 1335
			update_forum_lastpost($thread['fid']);
}
// Post is stuck in moderation queue

			update_forum_lastpost($thread['fid']);
}
// Post is stuck in moderation queue

		else if($visible == 0)

		else if($visible == 0)

		{
// Update the unapproved posts count for the current thread and current forum
$thread_update = array('unapprovedposts' => '+1');
update_thread_counters($post['tid'], array("unapprovedposts" => "+1"));

		{
// Update the unapproved posts count for the current thread and current forum
$thread_update = array('unapprovedposts' => '+1');
update_thread_counters($post['tid'], array("unapprovedposts" => "+1"));

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

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

		else if($thread['visible'] == 0)

		else if($thread['visible'] == 0)

		{

		{

			// Update the unapproved posts count for the current forum
$thread_update = array('replies' => '+1');
update_forum_counters($post['fid'], array("unapprovedposts" => "+1"));
}
else if($thread['visible'] == -1)

			// Update the unapproved posts count for the current forum
$thread_update = array('replies' => '+1');
update_forum_counters($post['fid'], array("unapprovedposts" => "+1"));
}
else if($thread['visible'] == -1)

		{

		{

			// Update the unapproved posts count for the current forum
$thread_update = array('replies' => '+1');
update_forum_counters($post['fid'], array("deletedposts" => "+1"));

			// Update the unapproved posts count for the current forum
$thread_update = array('replies' => '+1');
update_forum_counters($post['fid'], array("deletedposts" => "+1"));

Zeile 1270Zeile 1357

// Update last poster
if($visible == 1 && $thread['visible'] != 1)


// Update last poster
if($visible == 1 && $thread['visible'] != 1)

		{

		{

			update_last_post($post['tid']);

			update_last_post($post['tid']);

		}

		}


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


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

Zeile 1292Zeile 1379
		$plugins->run_hooks("datahandler_post_insert_post_end", $this);

return $this->return_values;

		$plugins->run_hooks("datahandler_post_insert_post_end", $this);

return $this->return_values;

	}


	}


	/**
* Validate a thread.
*

	/**
* Validate a thread.
*

Zeile 1306Zeile 1393
		$thread = &$this->data;

// Validate all thread assets.

		$thread = &$this->data;

// Validate all thread assets.





		if(!$thread['savedraft'])
{
$this->verify_post_flooding();

		if(!$thread['savedraft'])
{
$this->verify_post_flooding();

Zeile 1315Zeile 1402
		if($this->method == "insert" || array_key_exists('uid', $thread))
{
$this->verify_author();

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

		}


		}


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

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

Zeile 1362Zeile 1449
			return true;
}
}

			return true;
}
}





	/**
* Insert a thread into the database.
*

	/**
* Insert a thread into the database.
*

Zeile 1376Zeile 1463
		if(!$this->get_validated())
{
die("The thread needs to be validated before inserting it into the DB.");

		if(!$this->get_validated())
{
die("The thread needs to be validated before inserting it into the DB.");

		}

		}

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

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

Zeile 1385Zeile 1472
		$thread = &$this->data;

// Fetch the forum this thread is being made in

		$thread = &$this->data;

// Fetch the forum this thread is being made in

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



		$query = $db->simple_select("forums", "*", "fid='{$thread['fid']}'");
$forum = $db->fetch_array($query);


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

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

Zeile 1433Zeile 1521

// Are we updating a post which is already a draft? Perhaps changing it into a visible post?
if($draft_check)


// Are we updating a post which is already a draft? Perhaps changing it into a visible post?
if($draft_check)

		{
$this->thread_insert_data = array(
"subject" => $db->escape_string($thread['subject']),
"icon" => (int)$thread['icon'],
"username" => $db->escape_string($thread['username']),
"dateline" => (int)$thread['dateline'],
"lastpost" => (int)$thread['dateline'],
"lastposter" => $db->escape_string($thread['username']),
"visible" => $visible
);

$plugins->run_hooks("datahandler_post_insert_thread", $this);

		{
$this->thread_insert_data = array(
"subject" => $db->escape_string($thread['subject']),
"icon" => (int)$thread['icon'],
"username" => $db->escape_string($thread['username']),
"dateline" => (int)$thread['dateline'],
"lastpost" => (int)$thread['dateline'],
"lastposter" => $db->escape_string($thread['username']),
"visible" => $visible
);

$plugins->run_hooks("datahandler_post_insert_thread", $this);


$db->update_query("threads", $this->thread_insert_data, "tid='{$thread['tid']}'");


$db->update_query("threads", $this->thread_insert_data, "tid='{$thread['tid']}'");





			$this->post_insert_data = array(
"subject" => $db->escape_string($thread['subject']),
"icon" => (int)$thread['icon'],

			$this->post_insert_data = array(
"subject" => $db->escape_string($thread['subject']),
"icon" => (int)$thread['icon'],

Zeile 1464Zeile 1552
			$db->update_query("posts", $this->post_insert_data, "pid='{$thread['pid']}'");
$this->tid = $thread['tid'];
$this->pid = $thread['pid'];

			$db->update_query("posts", $this->post_insert_data, "pid='{$thread['pid']}'");
$this->tid = $thread['tid'];
$this->pid = $thread['pid'];

		}


		}


		// Inserting a new thread into the database.
else
{

		// Inserting a new thread into the database.
else
{

Zeile 1489Zeile 1577
			$plugins->run_hooks("datahandler_post_insert_thread", $this);

$this->tid = $db->insert_query("threads", $this->thread_insert_data);

			$plugins->run_hooks("datahandler_post_insert_thread", $this);

$this->tid = $db->insert_query("threads", $this->thread_insert_data);





			$this->post_insert_data = array(
"tid" => $this->tid,
"fid" => $thread['fid'],

			$this->post_insert_data = array(
"tid" => $this->tid,
"fid" => $thread['fid'],

Zeile 1560Zeile 1648
				{
$modoptions_update['sticky'] = 1;
log_moderator_action($modlogdata, $lang->thread_stuck);

				{
$modoptions_update['sticky'] = 1;
log_moderator_action($modlogdata, $lang->thread_stuck);

				}


				}


				// Execute moderation options.
if($modoptions_update)

				// Execute moderation options.
if($modoptions_update)

				{

				{

					$db->update_query('threads', $modoptions_update, "tid='{$this->tid}'");
}
}

					$db->update_query('threads', $modoptions_update, "tid='{$this->tid}'");
}
}

Zeile 1585Zeile 1673
					if($forum['usepostcounts'] != 0)
{
$update_query['postnum'] = "postnum+1";

					if($forum['usepostcounts'] != 0)
{
$update_query['postnum'] = "postnum+1";

					}

					}

					if($forum['usethreadcounts'] != 0)

					if($forum['usethreadcounts'] != 0)

					{

					{

						$update_query['threadnum'] = 'threadnum+1';

						$update_query['threadnum'] = 'threadnum+1';

					}


					}


					// Only update the table if we need to.
if(!empty($update_query))
{
$db->update_query("users", $update_query, "uid='{$thread['uid']}'", 1, true);
}

					// Only update the table if we need to.
if(!empty($update_query))
{
$db->update_query("users", $update_query, "uid='{$thread['uid']}'", 1, true);
}

				}

if(!isset($forum['lastpost']))
{
$forum['lastpost'] = 0;

 
				}

$done_users = array();

// Queue up any forum subscription notices to users who are subscribed to this forum.

				}

$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;

				$excerpt = $thread['message'];


// Parse badwords
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
$excerpt = $parser->parse_badwords($excerpt);


// Parse badwords
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
$excerpt = $parser->parse_badwords($excerpt);







				$excerpt = $parser->text_parse_message($excerpt);
if(strlen($excerpt) > $mybb->settings['subscribeexcerpt'])
{
$excerpt = my_substr($excerpt, 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;
}

				$query = $db->query("
SELECT u.username, u.email, u.uid, u.language, u.loginkey, u.salt, u.regdate
FROM ".TABLE_PREFIX."forumsubscriptions fs

				$query = $db->query("
SELECT u.username, u.email, u.uid, u.language, u.loginkey, u.salt, u.regdate
FROM ".TABLE_PREFIX."forumsubscriptions fs

Zeile 1635Zeile 1722
					if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0)
{
continue;

					if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0)
{
continue;

					}


					}


					if(!is_moderator($thread['fid'], "", $subscribedmember['uid']) && $forumpermissions['canonlyviewownthreads'] == 1)
{
// In a 'view own only' forum and not a moderator

					if(!is_moderator($thread['fid'], "", $subscribedmember['uid']) && $forumpermissions['canonlyviewownthreads'] == 1)
{
// In a 'view own only' forum and not a moderator

Zeile 1684Zeile 1771
						}
$emailsubject = $langcache[$uselang]['emailsubject_forumsubscription'];
$emailmessage = $langcache[$uselang]['email_forumsubscription'];

						}
$emailsubject = $langcache[$uselang]['emailsubject_forumsubscription'];
$emailmessage = $langcache[$uselang]['email_forumsubscription'];





						// If the poster is unregistered and hasn't set a username, call them Guest
if(!$thread['uid'] && !$thread['username'])
{

						// If the poster is unregistered and hasn't set a username, call them Guest
if(!$thread['uid'] && !$thread['username'])
{

Zeile 1693Zeile 1780
					}
$emailsubject = $lang->sprintf($emailsubject, $forum['name']);


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


					$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);

					$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']);


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

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

Zeile 1710Zeile 1796
				if(isset($queued_email) && $queued_email == 1)
{
$cache->update_mailqueue();

				if(isset($queued_email) && $queued_email == 1)
{
$cache->update_mailqueue();

				}

				}

			}

			}

		}


		}


		// Assign any uploaded attachments with the specific posthash to the newly created post.
if($thread['posthash'])

		// Assign any uploaded attachments with the specific posthash to the newly created post.
if($thread['posthash'])

		{

		{

			$thread['posthash'] = $db->escape_string($thread['posthash']);
$attachmentassign = array(
"pid" => $this->pid,

			$thread['posthash'] = $db->escape_string($thread['posthash']);
$attachmentassign = array(
"pid" => $this->pid,

Zeile 1734Zeile 1820
		else if($visible == 0)
{
update_forum_counters($thread['fid'], array("unapprovedthreads" => "+1", "unapprovedposts" => "+1"));

		else if($visible == 0)
{
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");


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

Zeile 1781Zeile 1867
		$existing_post = get_post($post['pid']);
$post['tid'] = $existing_post['tid'];
$post['fid'] = $existing_post['fid'];

		$existing_post = get_post($post['pid']);
$post['tid'] = $existing_post['tid'];
$post['fid'] = $existing_post['fid'];

 

if(isset($post['uid']))
{
$uid = $post['uid'];
}
else
{
$uid = 0;
}


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


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

		$forumpermissions = forum_permissions($post['fid'], $post['uid']);

		$forumpermissions = forum_permissions($post['fid'], $uid);


// Decide on the visibility of this post.


// Decide on the visibility of this post.

		$ismod = is_moderator($post['fid'], "", $post['uid']);

		$ismod = is_moderator($post['fid'], "", $uid);


// Keep visibility for unapproved and deleted posts
if($existing_post['visible'] == 0)


// Keep visibility for unapproved and deleted posts
if($existing_post['visible'] == 0)

Zeile 1808Zeile 1903
		{
$visible = 1;
}

		{
$visible = 1;
}





		// Update the thread details that might have been changed first.
if($this->first_post)
{

		// Update the thread details that might have been changed first.
if($this->first_post)
{

Zeile 1819Zeile 1914
				$this->thread_update_data['prefix'] = (int)$post['prefix'];
}


				$this->thread_update_data['prefix'] = (int)$post['prefix'];
}


			if(isset($post['subject']))
{
$this->thread_update_data['subject'] = $db->escape_string($post['subject']);
}


			if(isset($post['subject']))
{
$this->thread_update_data['subject'] = $db->escape_string($post['subject']);
}


			if(isset($post['icon']))
{
$this->thread_update_data['icon'] = (int)$post['icon'];
}
if(count($this->thread_update_data) > 0)

			if(isset($post['icon']))
{
$this->thread_update_data['icon'] = (int)$post['icon'];
}
if(count($this->thread_update_data) > 0)

			{

			{

				$plugins->run_hooks("datahandler_post_update_thread", $this);

				$plugins->run_hooks("datahandler_post_update_thread", $this);





				$db->update_query("threads", $this->thread_update_data, "tid='".(int)$post['tid']."'");

				$db->update_query("threads", $this->thread_update_data, "tid='".(int)$post['tid']."'");

 
			}

// Update any moved thread links to have corresponding new subject.
if(isset($post['subject']))
{
$query = $db->simple_select("threads", "tid, closed", "closed='moved|".$this->tid."'");
if($db->num_rows($query) > 0)
{
$update_data['subject'] = $db->escape_string($post['subject']);
while($result = $db->fetch_array($query))
{
$db->update_query("threads", $update_data, "tid='".(int)$result['tid']."'");
}
}

			}
}


			}
}


Zeile 1888Zeile 1997
		$db->update_query("posts", $this->post_update_data, "pid='".(int)$post['pid']."'");

// Automatic subscription to the thread

		$db->update_query("posts", $this->post_update_data, "pid='".(int)$post['pid']."'");

// Automatic subscription to the thread

		if($post['options']['subscriptionmethod'] != "" && $post['uid'] > 0)

		if($post && !empty($post['options']['subscriptionmethod']) && $uid > 0)

		{
switch($post['options']['subscriptionmethod'])
{

		{
switch($post['options']['subscriptionmethod'])
{

Zeile 1906Zeile 2015
		}
else
{

		}
else
{

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

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

		}

update_forum_lastpost($post['fid']);

		}

update_forum_lastpost($post['fid']);