Vergleich inc/datahandlers/post.php - 1.8.9 - 1.8.24

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 138Zeile 138
			$post['username'] = $user['username'];
}
// if the uid is 0 verify the username

			$post['username'] = $user['username'];
}
// if the uid is 0 verify the username

		else if($post['uid'] == 0 && $post['username'] != $lang->guest)

		else if($post['uid'] == 0 && $post['username'] != '')

		{
// Set up user handler
require_once MYBB_ROOT."inc/datahandlers/user.php";

		{
// Set up user handler
require_once MYBB_ROOT."inc/datahandlers/user.php";

Zeile 160Zeile 160
				$this->errors = array_merge($this->errors, $userhandler->get_errors());
return false;
}

				$this->errors = array_merge($this->errors, $userhandler->get_errors());
return false;
}

		}

// After all of this, if we still don't have a username, force the username as "Guest" (Note, this is not translatable as it is always a fallback)
if(!$post['username'])
{
$post['username'] = "Guest";

 
		}

return true;

		}

return true;

Zeile 177Zeile 171
	 * @return boolean True when valid, false when not valid.
*/
function verify_subject()

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

	{

	{

		global $db;
$post = &$this->data;
$subject = &$post['subject'];

		global $db;
$post = &$this->data;
$subject = &$post['subject'];

Zeile 189Zeile 183
			if(my_strlen($subject) == 0 && $this->first_post)
{
$this->set_error("firstpost_no_subject");

			if(my_strlen($subject) == 0 && $this->first_post)
{
$this->set_error("firstpost_no_subject");

				return false;
}

				return false;
}

			elseif(my_strlen($subject) == 0)
{
$thread = get_thread($post['tid']);

			elseif(my_strlen($subject) == 0)
{
$thread = get_thread($post['tid']);

Zeile 215Zeile 209
			{
$this->set_error("missing_subject");
return false;

			{
$this->set_error("missing_subject");
return false;

			}
}

			}
}


// If post is reply and begins with "RE: ", remove 4 from subject length.
$subject_length = my_strlen($subject);


// If post is reply and begins with "RE: ", remove 4 from subject length.
$subject_length = my_strlen($subject);

Zeile 247Zeile 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 258Zeile 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)
{
$is_moderator = is_moderator($post['fid'], "", $post['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'])
{
// Check to see of the text is full of MyCode

			if(!$mybb->settings['mycodemessagelength'])
{
// Check to see of the text is full of MyCode

Zeile 575Zeile 604

/**
* Verify the post icon.


/**
* Verify the post icon.

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

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

	*/
function verify_post_icon()

	*/
function verify_post_icon()

	{

	{

		global $cache;

$post = &$this->data;

$posticons_cache = $cache->read("posticons");

		global $cache;

$post = &$this->data;

$posticons_cache = $cache->read("posticons");





		// If we don't have a post icon assign it as 0.
if(empty($post['icon']) || !isset($posticons_cache[$post['icon']]))
{

		// If we don't have a post icon assign it as 0.
if(empty($post['icon']) || !isset($posticons_cache[$post['icon']]))
{

Zeile 600Zeile 629
	* @return boolean True when valid, false when not valid.
*/
function verify_dateline()

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

	{

	{

		$dateline = &$this->data['dateline'];

// The date has to be numeric and > 0.

		$dateline = &$this->data['dateline'];

// The date has to be numeric and > 0.

Zeile 609Zeile 638
			$dateline = TIME_NOW;
}
}

			$dateline = TIME_NOW;
}
}





	/**
* Verify thread prefix.
*

	/**
* Verify thread prefix.
*

Zeile 621Zeile 650

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

			$prefix = 0;
}
else

		{

		{

			if(!empty($this->data['tid']))

			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 642Zeile 671
			if($prefix_cache['groups'] != "-1")
{
if(!empty($this->data['edit_uid']))

			if($prefix_cache['groups'] != "-1")
{
if(!empty($this->data['edit_uid']))

				{

				{

					// 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']))
{
$this->set_error('invalid_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');

Zeile 777Zeile 806
		}

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

		}

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

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

		}

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

Zeile 801Zeile 830
		if($this->method == "insert" || array_key_exists('options', $post))
{
$this->verify_options();

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

		}


		}


		if($this->method == "update" && $this->first_post)
{
$this->verify_prefix();

		if($this->method == "update" && $this->first_post)
{
$this->verify_prefix();

Zeile 852Zeile 881
		if($post['savedraft'])
{
$visible = -2;

		if($post['savedraft'])
{
$visible = -2;

		}


		}


		// Otherwise this post is being made now and we have a bit to do.
else
{
// Automatic subscription to the thread

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

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

			{

			{

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


				require_once MYBB_ROOT."inc/functions_user.php";
if($post['options']['subscriptionmethod'] == "")

				{

				{

					case "pm":
$notification = 2;
break;
case "email":
$notification = 1;
break;
default:
$notification = 0;









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

				}

				}


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

 
			}

// Perform any selected moderation tools.

			}

// Perform any selected moderation tools.

Zeile 885Zeile 920
				$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.

				if(!empty($modoptions['closethread']) && $thread['closed'] != 1)

				if(!empty($modoptions['closethread']) && $thread['closed'] != 1 && is_moderator($post['fid'], "canopenclosethreads", $post['uid']))

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

// Open the thread.

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

// Open the thread.

				if(empty($modoptions['closethread']) && $thread['closed'] == 1)

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

				{
$modoptions_update['closed'] = $closed = 0;
log_moderator_action($modlogdata, $lang->thread_opened);
}

// Stick the thread.

				{
$modoptions_update['closed'] = $closed = 0;
log_moderator_action($modlogdata, $lang->thread_opened);
}

// Stick the thread.

				if(!empty($modoptions['stickthread']) && $thread['sticky'] != 1)

				if(!empty($modoptions['stickthread']) && $thread['sticky'] != 1 && is_moderator($post['fid'], "canstickunstickthreads", $post['uid']))

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

// Unstick the thread.

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

// Unstick the thread.

				if(empty($modoptions['stickthread']) && $thread['sticky'] == 1)

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

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

				}

				}


// Execute moderation options.
if($modoptions_update)


// Execute moderation options.
if($modoptions_update)

Zeile 965Zeile 1000
		if($this->method != "update" && $visible == 1)
{
$double_post = $this->verify_post_merge();

		if($this->method != "update" && $visible == 1)
{
$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)
{

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

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

				$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($draft_check)
{
$db->delete_query("posts", "pid='".$post['pid']."'");

Zeile 991Zeile 1026

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


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

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





					$attachmentassign = array(
"pid" => $double_post['pid'],
"posthash" => ''

					$attachmentassign = array(
"pid" => $double_post['pid'],
"posthash" => ''

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

return $this->return_values;

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

return $this->return_values;

			}
}

if($visible == 1 && $thread['visible'] == 1)
{
$now = TIME_NOW;

			}
}

if($visible == 1)
{
$now = TIME_NOW;


// Yes, the value to the lastpost key in this array has single quotes within double quotes. It's not a bug.
$update_array = array(
'lastpost' => "'{$now}'"
);


// Yes, the value to the lastpost key in this array has single quotes within double quotes. It's not a bug.
$update_array = array(
'lastpost' => "'{$now}'"
);

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

			if($forum['usepostcounts'] != 0 && $thread['visible'] == 1)

			{
$update_array['postnum'] = 'postnum+1';
}

			{
$update_array['postnum'] = 'postnum+1';
}





			$db->update_query("users", $update_array, "uid='{$post['uid']}'", 1, true);
}


			$db->update_query("users", $update_array, "uid='{$post['uid']}'", 1, true);
}


Zeile 1039Zeile 1074
		{
// Update a post that is a draft
$this->post_update_data = array(

		{
// Update a post that is a draft
$this->post_update_data = array(

				"subject" => $db->escape_string($post['subject']),
"icon" => (int)$post['icon'],
"uid" => $post['uid'],
"username" => $db->escape_string($post['username']),

				"subject" => $db->escape_string($post['subject']),
"icon" => (int)$post['icon'],
"uid" => $post['uid'],
"username" => $db->escape_string($post['username']),

				"dateline" => (int)$post['dateline'],
"message" => $db->escape_string($post['message']),
"ipaddress" => $db->escape_binary($post['ipaddress']),

				"dateline" => (int)$post['dateline'],
"message" => $db->escape_string($post['message']),
"ipaddress" => $db->escape_binary($post['ipaddress']),

Zeile 1094Zeile 1129
		$thread_update = array();
if($visible == 1 && $thread['visible'] == 1)
{

		$thread_update = array();
if($visible == 1 && $thread['visible'] == 1)
{

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

 
			require_once MYBB_ROOT.'inc/class_parser.php';
$parser = new Postparser;


			require_once MYBB_ROOT.'inc/class_parser.php';
$parser = new Postparser;


Zeile 1119Zeile 1153
				AND s.uid != '{$post['uid']}'
AND u.lastactive>'{$thread['lastpost']}'
");

				AND s.uid != '{$post['uid']}'
AND u.lastactive>'{$thread['lastpost']}'
");





			$args = array(
'this' => &$this,
'done_users' => &$done_users,
'users' => array()
);

			$args = array(
'this' => &$this,
'done_users' => &$done_users,
'users' => array()
);





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

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

				}

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


				}

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


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

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

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

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

Zeile 1144Zeile 1178
				}

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

				}

if($thread['uid'] != $subscribedmember['uid'] && $forumpermissions['canonlyviewownthread'] == 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 1152Zeile 1186
				if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language']))
{
$uselang = $subscribedmember['language'];

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

				}

				}

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

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

				{

				{

					$uselang = "english";
}

					$uselang = "english";
}





				if($uselang == $mybb->settings['bblanguage'])
{
if($subscribedmember['notification'] == 1)
{
$emailsubject = $lang->emailsubject_subscription;
$emailmessage = $lang->email_subscription;

				if($uselang == $mybb->settings['bblanguage'])
{
if($subscribedmember['notification'] == 1)
{
$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'])
{
$post['username'] = htmlspecialchars_uni($lang->guest);

					}
}
else
{

					}
}
else
{

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



if(($subscribedmember['notification'] == 1 && !isset($langcache[$uselang]['emailsubject_subscription'])) || !isset($langcache[$uselang]['guest']))

					{

					{

						if(!isset($langcache[$uselang]['emailsubject_subscription']))




						$userlang = new MyLanguage;
$userlang->set_path(MYBB_ROOT."inc/languages");
$userlang->set_language($uselang);
if($subscribedmember['notification'] == 1)

						{

						{

							$userlang = new MyLanguage;
$userlang->set_path(MYBB_ROOT."inc/languages");
$userlang->set_language($uselang);

 
							$userlang->load("messages");
$langcache[$uselang]['emailsubject_subscription'] = $userlang->emailsubject_subscription;
$langcache[$uselang]['email_subscription'] = $userlang->email_subscription;

							$userlang->load("messages");
$langcache[$uselang]['emailsubject_subscription'] = $userlang->emailsubject_subscription;
$langcache[$uselang]['email_subscription'] = $userlang->email_subscription;

							unset($userlang);

 
						}

						}

 
						$userlang->load("global");

$langcache[$uselang]['guest'] = $userlang->guest;
unset($userlang);
}
if($subscribedmember['notification'] == 1)
{

						$emailsubject = $langcache[$uselang]['emailsubject_subscription'];
$emailmessage = $langcache[$uselang]['email_subscription'];

						$emailsubject = $langcache[$uselang]['emailsubject_subscription'];
$emailmessage = $langcache[$uselang]['email_subscription'];

 
					}

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

					}
}

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

					}
}

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

				{
$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);
$new_email = array(
"mailto" => $db->escape_string($subscribedmember['email']),
"mailfrom" => '',
"subject" => $db->escape_string($emailsubject),
"message" => $db->escape_string($emailmessage),
"headers" => ''

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

$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" => '',
"subject" => $db->escape_string($emailsubject),
"message" => $db->escape_string($emailmessage),
"headers" => ''


					);
$db->insert_query("mailqueue", $new_email);
unset($userlang);

					);
$db->insert_query("mailqueue", $new_email);
unset($userlang);

Zeile 1208Zeile 1260
				}
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'

Zeile 1219Zeile 1270
					send_pm($pm, -1, true);
}
}

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





			$plugins->run_hooks('datahandler_post_insert_subscribed', $args);

// Have one or more emails been queued? Update the queue count
if(isset($queued_email) && $queued_email == 1)
{
$cache->update_mailqueue();

			$plugins->run_hooks('datahandler_post_insert_subscribed', $args);

// Have one or more emails been queued? Update the queue count
if(isset($queued_email) && $queued_email == 1)
{
$cache->update_mailqueue();

			}

$thread_update = array('replies' => '+1');

			}

$thread_update = array('replies' => '+1');





			// Update forum count

			// Update counters

			update_last_post($post['tid']);
update_forum_counters($post['fid'], array("posts" => "+1"));
update_forum_lastpost($thread['fid']);

			update_last_post($post['tid']);
update_forum_counters($post['fid'], array("posts" => "+1"));
update_forum_lastpost($thread['fid']);

Zeile 1241Zeile 1292
			// 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"));
}

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

Zeile 1254Zeile 1305
			// 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"));

		}







		}

// Update last poster
if($visible == 1 && $thread['visible'] != 1)
{
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 1280Zeile 1337
	 * Validate a thread.
*
* @return boolean True when valid, false when invalid.

	 * Validate a thread.
*
* @return boolean True when valid, false when invalid.

	 */

	 */

	function validate_thread()
{
global $mybb, $db, $plugins;

	function validate_thread()
{
global $mybb, $db, $plugins;





		$thread = &$this->data;

// Validate all thread assets.

if(!$thread['savedraft'])

		$thread = &$this->data;

// Validate all thread assets.

if(!$thread['savedraft'])

		{

		{

			$this->verify_post_flooding();

			$this->verify_post_flooding();

		}


		}


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

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

Zeile 1305Zeile 1362
		}

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

		}

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

		{

		{

			$this->verify_subject();

			$this->verify_subject();

		}

		}


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


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

		{

		{

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

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

Zeile 1319Zeile 1376
		if($this->method == "insert" || array_key_exists('dateline', $thread))
{
$this->verify_dateline();

		if($this->method == "insert" || array_key_exists('dateline', $thread))
{
$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("datahandler_post_validate_thread", $this);

		}

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


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


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

		}

		}

		else
{
return true;
}
}

		else
{
return true;
}
}





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

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

Zeile 1356Zeile 1413

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


// Yes, validating is required.
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.");

			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.");

		}

$thread = &$this->data;


		}

$thread = &$this->data;


		// Fetch the forum this thread is being made in
$forum = get_forum($thread['fid']);

		// Fetch the forum this thread is being made in
$forum = get_forum($thread['fid']);





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

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

		{

		{

			$visible = -2;
}


			$visible = -2;
}


Zeile 1381Zeile 1438
			$forumpermissions = forum_permissions($thread['fid'], $thread['uid']);
// Decide on the visibility of this post.
if($forumpermissions['modthreads'] == 1 && !is_moderator($thread['fid'], "", $thread['uid']))

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

			{
$visible = 0;

			{
$visible = 0;

			}
else
{

			}
else
{

Zeile 1394Zeile 1451
			{
$visible = 0;
}

			{
$visible = 0;
}

		}


		}


		// Have a post ID but not a thread ID - fetch thread ID
if(!empty($thread['pid']) && !$thread['tid'])

		// Have a post ID but not a thread ID - fetch thread ID
if(!empty($thread['pid']) && !$thread['tid'])

		{

		{

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

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

Zeile 1407Zeile 1464
		{
$query = $db->simple_select("posts", "pid", "pid='{$thread['pid']}' AND uid='{$thread['uid']}' AND visible='-2'");
$draft_check = $db->fetch_field($query, "pid");

		{
$query = $db->simple_select("posts", "pid", "pid='{$thread['pid']}' AND uid='{$thread['uid']}' AND visible='-2'");
$draft_check = $db->fetch_field($query, "pid");

		}

		}

		else

		else

		{

		{

			$draft_check = false;
}

			$draft_check = false;
}





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

Zeile 1429Zeile 1486
			$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(


$this->post_insert_data = array(

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

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

Zeile 1442Zeile 1499
				"visible" => $visible
);
$plugins->run_hooks("datahandler_post_insert_thread_post", $this);

				"visible" => $visible
);
$plugins->run_hooks("datahandler_post_insert_thread_post", $this);





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

Zeile 1452Zeile 1509
		else
{
$this->thread_insert_data = array(

		else
{
$this->thread_insert_data = array(

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

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

				"prefix" => (int)$thread['prefix'],
"icon" => (int)$thread['icon'],
"uid" => $thread['uid'],

				"prefix" => (int)$thread['prefix'],
"icon" => (int)$thread['icon'],
"uid" => $thread['uid'],

Zeile 1499Zeile 1556
		if(!$thread['savedraft'])
{
if($thread['options']['subscriptionmethod'] != "" && $thread['uid'] > 0)

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

			{

			{

				switch($thread['options']['subscriptionmethod'])
{
case "pm":

				switch($thread['options']['subscriptionmethod'])
{
case "pm":

Zeile 1531Zeile 1588
				$modoptions_update = array();

// Close the thread.

				$modoptions_update = array();

// Close the thread.

				if(!empty($modoptions['closethread']))

				if(!empty($modoptions['closethread']) && is_moderator($thread['fid'], "canopenclosethreads", $thread['uid']))

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

// Stick the thread.

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

// Stick the thread.

				if(!empty($modoptions['stickthread']))

				if(!empty($modoptions['stickthread']) && is_moderator($thread['fid'], "canstickunstickthreads", $thread['uid']))

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

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

Zeile 1588Zeile 1645
				$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 1643Zeile 1704
					{
$emailsubject = $lang->emailsubject_forumsubscription;
$emailmessage = $lang->email_forumsubscription;

					{
$emailsubject = $lang->emailsubject_forumsubscription;
$emailmessage = $lang->email_forumsubscription;

 

// If the poster is unregistered and hasn't set a username, call them Guest
if(!$thread['uid'] && !$thread['username'])
{
$thread['username'] = htmlspecialchars_uni($lang->guest);
}

					}
else
{

					}
else
{

Zeile 1652Zeile 1719
							$userlang->set_path(MYBB_ROOT."inc/languages");
$userlang->set_language($uselang);
$userlang->load("messages");

							$userlang->set_path(MYBB_ROOT."inc/languages");
$userlang->set_language($uselang);
$userlang->load("messages");

 
							$userlang->load("global");

							$langcache[$uselang]['emailsubject_forumsubscription'] = $userlang->emailsubject_forumsubscription;
$langcache[$uselang]['email_forumsubscription'] = $userlang->email_forumsubscription;

							$langcache[$uselang]['emailsubject_forumsubscription'] = $userlang->emailsubject_forumsubscription;
$langcache[$uselang]['email_forumsubscription'] = $userlang->email_forumsubscription;

 
							$langcache[$uselang]['guest'] = $userlang->guest;

							unset($userlang);
}
$emailsubject = $langcache[$uselang]['emailsubject_forumsubscription'];
$emailmessage = $langcache[$uselang]['email_forumsubscription'];

							unset($userlang);
}
$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'])
{
$thread['username'] = $langcache[$uselang]['guest'];
}

					}
$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 1709Zeile 1783
		if($attachmentcount > 0)
{
update_thread_counters($this->tid, array("attachmentcount" => "+{$attachmentcount}"));

		if($attachmentcount > 0)
{
update_thread_counters($this->tid, array("attachmentcount" => "+{$attachmentcount}"));

		}


		}


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

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

Zeile 1775Zeile 1849
		else
{
$visible = 1;

		else
{
$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 1801Zeile 1875
				$plugins->run_hooks("datahandler_post_update_thread", $this);

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

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

$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 1809Zeile 1897
		$this->pid = $post['pid'];

if(isset($post['subject']))

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

if(isset($post['subject']))

		{

		{

			$this->post_update_data['subject'] = $db->escape_string($post['subject']);

			$this->post_update_data['subject'] = $db->escape_string($post['subject']);

		}

		}


if(isset($post['message']))
{
$this->post_update_data['message'] = $db->escape_string($post['message']);


if(isset($post['message']))
{
$this->post_update_data['message'] = $db->escape_string($post['message']);

		}

		}


if(isset($post['editreason']) && trim($post['editreason']) != '')
{
$this->post_update_data['editreason'] = $db->escape_string(trim($post['editreason']));


if(isset($post['editreason']) && trim($post['editreason']) != '')
{
$this->post_update_data['editreason'] = $db->escape_string(trim($post['editreason']));

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

		}

if(isset($post['icon']))

		}

if(isset($post['icon']))