Vergleich inc/datahandlers/post.php - 1.8.20 - 1.8.37

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 279Zeile 279

if($limit > 0 || $dblimit > 0)
{


if($limit > 0 || $dblimit > 0)
{

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


















				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)
{

				// Consider minimum in user defined and database limit other than 0
if($limit > 0 && $dblimit > 0)
{

Zeile 423Zeile 440
		$thread = $db->fetch_array($query);

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

		$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))
{
return true;
}






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


if($mybb->settings['postmergefignore'] == -1)


if($mybb->settings['postmergefignore'] == -1)

		{

		{

			return true;
}
elseif($mybb->settings['postmergefignore'] != '')
{
$fids = explode(',', (string)$mybb->settings['postmergefignore']);

			return true;
}
elseif($mybb->settings['postmergefignore'] != '')
{
$fids = explode(',', (string)$mybb->settings['postmergefignore']);





			if(is_array($fids))
{
foreach($fids as &$fid)
{
$fid = (int)$fid;

			if(is_array($fids))
{
foreach($fids as &$fid)
{
$fid = (int)$fid;

				}

				}

				unset($fid);

if(in_array($thread['fid'], $fids))

				unset($fid);

if(in_array($thread['fid'], $fids))

Zeile 449Zeile 471
					return true;
}
}

					return true;
}
}

		}


		}


		if($simple_mode == true)
{
return false;

		if($simple_mode == true)
{
return false;

		}

if($post['uid'])
{

		}

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

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

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

Zeile 475Zeile 497
	* @return boolean True when valid, false when not valid.
*/
function verify_image_count()

	* @return boolean True when valid, false when not valid.
*/
function verify_image_count()

	{

	{

		global $mybb, $db;

		global $mybb, $db;





		$post = &$this->data;

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


// Fetch the forum this post is being made in


// Fetch the forum this post is being made in

		if(!$post['fid'])

		if(empty($post['fid']))

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

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

Zeile 506Zeile 537
				"filter_badwords" => 1
);


				"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'];
}

Zeile 523Zeile 554
			{
// Throw back a message if over the count with the number of images as well as the maximum number of images per post.
$this->set_error("too_many_images", array(1 => $image_count, 2 => $mybb->settings['maxpostimages']));

			{
// Throw back a message if over the count with the number of images as well as the maximum number of images per post.
$this->set_error("too_many_images", array(1 => $image_count, 2 => $mybb->settings['maxpostimages']));

				return false;
}
}

return true;
}

				return false;
}
}

return true;
}


/**
* Verifies the video count.


/**
* Verifies the video count.

Zeile 538Zeile 569
	function verify_video_count()
{
global $mybb, $db;

	function verify_video_count()
{
global $mybb, $db;





		$post = &$this->data;

		$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 576Zeile 616
			$query = $db->simple_select("posts", "pid", "pid='".(int)$post['replyto']."'");
$valid_post = $db->fetch_array($query);
if(!$valid_post['pid'])

			$query = $db->simple_select("posts", "pid", "pid='".(int)$post['replyto']."'");
$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 591Zeile 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);
$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;
}

/**

	* Verify the post icon.
*
* @return boolean True when valid, false when not valid.

	* Verify the post icon.
*
* @return boolean True when valid, false when not valid.

Zeile 650Zeile 689

// If a valid prefix isn't supplied, don't assign one.
if(empty($prefix))


// If a valid prefix isn't supplied, don't assign one.
if(empty($prefix))

		{

		{

			$prefix = 0;
}
else
{
if(!empty($this->data['tid']))

			$prefix = 0;
}
else
{
if(!empty($this->data['tid']))

			{

			{

				// Fetch the thread
$thread = get_thread($this->data['tid']);

				// Fetch the thread
$thread = get_thread($this->data['tid']);

			}

			}


$prefix_cache = build_prefixes($prefix);



$prefix_cache = build_prefixes($prefix);


Zeile 674Zeile 713
				{
// Post is being edited
$user = get_user($this->data['edit_uid']);

				{
// Post is being edited
$user = get_user($this->data['edit_uid']);

				}

				}

				else
{
$user = get_user($this->data['uid']);

				else
{
$user = get_user($this->data['uid']);

				}


				}


				if(!is_member($prefix_cache['groups'], array('usergroup' => $user['usergroup'], 'additionalgroups' => $user['additionalgroups'])) && (empty($this->data['tid']) || $prefix != $thread['prefix']))

				if(!is_member($prefix_cache['groups'], array('usergroup' => $user['usergroup'], 'additionalgroups' => $user['additionalgroups'])) && (empty($this->data['tid']) || $prefix != $thread['prefix']))

				{
$this->set_error('invalid_prefix');
return false;
}

				{
$this->set_error('invalid_prefix');
return false;
}

			}
if($prefix_cache['forums'] != "-1")
{

			}
if($prefix_cache['forums'] != "-1")
{

Zeile 695Zeile 734
				{
$this->set_error('invalid_prefix');
return false;

				{
$this->set_error('invalid_prefix');
return false;

				}
}

				}
}

		}

// Does this forum require a prefix?

		}

// Does this forum require a prefix?

Zeile 762Zeile 801

$post = &$this->data;
$time = TIME_NOW;


$post = &$this->data;
$time = TIME_NOW;


$this->action = "post";



$this->action = "post";


		if($this->method != "update" && !$post['savedraft'])
{
$this->verify_post_flooding();

		if($this->method != "update" && !$post['savedraft'])
{
$this->verify_post_flooding();

Zeile 782Zeile 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 810Zeile 848
			$this->verify_message();
$this->verify_image_count();
$this->verify_video_count();

			$this->verify_message();
$this->verify_image_count();
$this->verify_video_count();

		}


		}


		if($this->method == "insert" || array_key_exists('dateline', $post))
{
$this->verify_dateline();

		if($this->method == "insert" || array_key_exists('dateline', $post))
{
$this->verify_dateline();

Zeile 857Zeile 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())
{
die("The post needs to be validated before inserting it into the DB.");
}
if(count($this->get_errors()) > 0)
{
die("The post is not valid.");

	{
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 is not valid.");

		}

// Fetch the thread
$thread = get_thread($post['tid']);

$closed = $thread['closed'];

		}

// Fetch the thread
$thread = get_thread($post['tid']);

$closed = $thread['closed'];





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

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

		{

		{

			$visible = -2;
}


			$visible = -2;
}


Zeile 893Zeile 931
				if($post['options']['subscriptionmethod'] == "")
{
remove_subscribed_thread($post['tid'], $post['uid']);

				if($post['options']['subscriptionmethod'] == "")
{
remove_subscribed_thread($post['tid'], $post['uid']);

				}
else

				}
else

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

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

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

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

				}

				}


// Unstick the thread.
if(empty($modoptions['stickthread']) && $thread['sticky'] == 1 && is_moderator($post['fid'], "canstickunstickthreads", $post['uid']))
{
$modoptions_update['sticky'] = 0;
log_moderator_action($modlogdata, $lang->thread_unstuck);


// Unstick the thread.
if(empty($modoptions['stickthread']) && $thread['sticky'] == 1 && is_moderator($post['fid'], "canstickunstickthreads", $post['uid']))
{
$modoptions_update['sticky'] = 0;
log_moderator_action($modlogdata, $lang->thread_unstuck);

				}


				}


				// Execute moderation options.
if($modoptions_update)
{

				// Execute moderation options.
if($modoptions_update)
{

Zeile 964Zeile 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 1004Zeile 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 1090Zeile 1138

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


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

		}

		}

		else
{
// Insert the post.

		else
{
// Insert the post.

Zeile 1113Zeile 1161
			$plugins->run_hooks("datahandler_post_insert_post", $this);

$this->pid = $db->insert_query("posts", $this->post_insert_data);

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

$this->pid = $db->insert_query("posts", $this->post_insert_data);

		}


		}


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

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

Zeile 1161Zeile 1209
			);

while($subscribedmember = $db->fetch_array($query))

			);

while($subscribedmember = $db->fetch_array($query))

			{
if($done_users[$subscribedmember['uid']])
{
continue;
}


			{
if(isset($done_users[$subscribedmember['uid']]))
{
continue;
}


				$args['users'][$subscribedmember['uid']] = (int)$subscribedmember['uid'];

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

				$args['users'][$subscribedmember['uid']] = (int)$subscribedmember['uid'];

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

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

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

				}

				}





				if($thread['uid'] != $subscribedmember['uid'] && $forumpermissions['canonlyviewownthread'] == 1 && !is_moderator($thread['fid'], "", $subscribedmember['uid']))

				if($thread['uid'] != $subscribedmember['uid'] && $forumpermissions['canonlyviewownthreads'] == 1 && !is_moderator($thread['fid'], "", $subscribedmember['uid']))

				{
// User isn't a moderator or the author of the thread...
continue;

				{
// User isn't a moderator or the author of the thread...
continue;

Zeile 1188Zeile 1236
					$uselang = $subscribedmember['language'];
}
elseif($mybb->settings['orig_bblanguage'])

					$uselang = $subscribedmember['language'];
}
elseif($mybb->settings['orig_bblanguage'])

				{

				{

					$uselang = $mybb->settings['orig_bblanguage'];

					$uselang = $mybb->settings['orig_bblanguage'];

				}

				}

				else
{
$uselang = "english";

				else
{
$uselang = "english";

				}

if($uselang == $mybb->settings['bblanguage'])

				}

if($uselang == $mybb->settings['bblanguage'])

				{
if($subscribedmember['notification'] == 1)

				{
if($subscribedmember['notification'] == 1)

					{

					{

						$emailsubject = $lang->emailsubject_subscription;
$emailmessage = $lang->email_subscription;

						$emailsubject = $lang->emailsubject_subscription;
$emailmessage = $lang->email_subscription;

					}

					}


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


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

Zeile 1211Zeile 1259
					}
}
else

					}
}
else

				{


				{


					if(($subscribedmember['notification'] == 1 && !isset($langcache[$uselang]['emailsubject_subscription'])) || !isset($langcache[$uselang]['guest']))
{
$userlang = new MyLanguage;

					if(($subscribedmember['notification'] == 1 && !isset($langcache[$uselang]['emailsubject_subscription'])) || !isset($langcache[$uselang]['guest']))
{
$userlang = new MyLanguage;

Zeile 1246Zeile 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("&", "&", 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("&", "&", 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 1261Zeile 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("&", "&", 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("&", "&", 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'
);

 
					// Workaround for eliminating PHP warnings in PHP 8. Ref: https://github.com/mybb/mybb/issues/4630#issuecomment-1369144163
$pm['sender']['uid'] = -1;

					send_pm($pm, -1, true);
}
}

					send_pm($pm, -1, true);
}
}

Zeile 1289Zeile 1337
			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

		{
// 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)

			$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 1311Zeile 1359

// 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 1333Zeile 1381
		$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 1347Zeile 1395
		$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 1356Zeile 1404
		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 1403Zeile 1451
			return true;
}
}

			return true;
}
}





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

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

Zeile 1417Zeile 1465
		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 1426Zeile 1474
		$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 1474Zeile 1523

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


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

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

$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 1509Zeile 1558

// Inserting a new thread into the database.
else


// Inserting a new thread into the database.
else

		{

		{

			$this->thread_insert_data = array(
"fid" => $thread['fid'],
"subject" => $db->escape_string($thread['subject']),

			$this->thread_insert_data = array(
"fid" => $thread['fid'],
"subject" => $db->escape_string($thread['subject']),

Zeile 1605Zeile 1654

// 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 1639Zeile 1688
					}
}


					}
}


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

$done_users = array();

				$done_users = array();







// Queue up any forum subscription notices to users who are subscribed to this forum.
$excerpt = $thread['message'];


// Queue up any forum subscription notices to users who are subscribed to this forum.
$excerpt = $thread['message'];

Zeile 1655Zeile 1699
				$excerpt = $parser->parse_badwords($excerpt);
$excerpt = $parser->text_parse_message($excerpt);
if(strlen($excerpt) > $mybb->settings['subscribeexcerpt'])

				$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("

					$excerpt = my_substr($excerpt, 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;
}
$query = $db->query("

Zeile 1670Zeile 1714
				");
while($subscribedmember = $db->fetch_array($query))
{

				");
while($subscribedmember = $db->fetch_array($query))
{

					if($done_users[$subscribedmember['uid']])
{

					if(!empty($done_users[$subscribedmember['uid']]))
{

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

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

Zeile 1680Zeile 1724
					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)
{


if(!is_moderator($thread['fid'], "", $subscribedmember['uid']) && $forumpermissions['canonlyviewownthreads'] == 1)
{

Zeile 1729Zeile 1773
						}
$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 1738Zeile 1782
					}
$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 1755Zeile 1798
				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 1779Zeile 1822
		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 1826Zeile 1869
		$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 1853Zeile 1905
		{
$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 1864Zeile 1916
				$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 1899Zeile 1965
		{
$this->post_update_data['editreason'] = $db->escape_string(trim($post['editreason']));
}

		{
$this->post_update_data['editreason'] = $db->escape_string(trim($post['editreason']));
}

		elseif($post['editreason'] == '')

		elseif(empty($post['editreason']))

		{
$this->post_update_data['editreason'] = '';
}

		{
$this->post_update_data['editreason'] = '';
}

Zeile 1933Zeile 1999
		$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 1951Zeile 2017
		}
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']);