Vergleich inc/datahandlers/post.php - 1.8.4 - 1.8.16

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 53Zeile 53
	 * post = New post
* thread = New thread
* edit = Editing a thread or post

	 * post = New post
* thread = New thread
* edit = Editing a thread or post

 
	 *
* @var string

	 */
public $action;

	 */
public $action;


/**


/**

	 * Array of data inserted in to a post.

	 * Array of data inserted in to a post.

	 *
* @var array

	 *
* @var array

	 */
public $post_insert_data = array();

	 */
public $post_insert_data = array();


/**


/**

	 * Array of data used to update a post.
*
* @var array
*/
public $post_update_data = array();

	 * Array of data used to update a post.
*
* @var array
*/
public $post_update_data = array();





	/**
* Post ID currently being manipulated by the datahandlers.
*

	/**
* Post ID currently being manipulated by the datahandlers.
*

Zeile 79Zeile 81

/**
* Array of data inserted in to a thread.


/**
* Array of data inserted in to a thread.

	 *

	 *

	 * @var array
*/
public $thread_insert_data = array();

/**
* Array of data used to update a thread.

	 * @var array
*/
public $thread_insert_data = array();

/**
* Array of data used to update a thread.

	 *
* @var array
*/

	 *
* @var array
*/

	public $thread_update_data = array();

	public $thread_update_data = array();


/**


/**

	 * Thread ID currently being manipulated by the datahandlers.
*
* @var int

	 * Thread ID currently being manipulated by the datahandlers.
*
* @var int

Zeile 99Zeile 101
	public $tid = 0;

/**

	public $tid = 0;

/**

	 * Values to be returned after inserting/updating a post/thread.








	 * Values to be returned after inserting/updating a post/thread.
*
* @var array
*/
public $return_values = array();

/**
* Is this the first post of a thread when editing

	 *

	 *

	 * @var array

	 * @var boolean

	 */

	 */

	public $return_values = array();

	public $first_post = false;


/**
* Verifies the author of a post and fetches the username if necessary.


/**
* Verifies the author of a post and fetches the username if necessary.

Zeile 112Zeile 121
	 */
function verify_author()
{

	 */
function verify_author()
{

		global $mybb;

		global $mybb, $lang;


$post = &$this->data;



$post = &$this->data;


Zeile 121Zeile 130
		{
$this->set_error("invalid_user_id");
return false;

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

		}

		}

		// If we have a user id but no username then fetch the username.
else if($post['uid'] > 0 && empty($post['username']))

		// If we have a user id but no username then fetch the username.
else if($post['uid'] > 0 && empty($post['username']))

		{

		{

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

			$user = get_user($post['uid']);
$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";
$userhandler = new UserDataHandler();

			// Set up user handler
require_once MYBB_ROOT."inc/datahandlers/user.php";
$userhandler = new UserDataHandler();

			



			$data_array = array('username' => $post['username']);
$userhandler->set_data($data_array);

			$data_array = array('username' => $post['username']);
$userhandler->set_data($data_array);

			



			if(!$userhandler->verify_username())

			if(!$userhandler->verify_username())

			{

			{

				// invalid username

				// invalid username

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

if($userhandler->verify_username_exists())
{
// username is in use

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

// Sanitize the username
$post['username'] = htmlspecialchars_uni($post['username']);

 
		return true;
}

/**
* Verifies a post subject.
*

		return true;
}

/**
* Verifies a post subject.
*

	 * @param string True if the subject is valid, false if invalid.

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

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

Zeile 169Zeile 176
		$post = &$this->data;
$subject = &$post['subject'];
$subject = trim_blank_chrs($subject);

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


// Are we editing an existing thread or post?




		if($this->method == "update" && $post['pid'])
{

		if($this->method == "update" && $post['pid'])
{

			if(empty($post['tid']))
{
$query = $db->simple_select("posts", "tid", "pid='".(int)$post['pid']."'");
$post['tid'] = $db->fetch_field($query, "tid");
}
// Here we determine if we're editing the first post of a thread or not.
$options = array(
"limit" => 1,
"limit_start" => 0,
"order_by" => "dateline",
"order_dir" => "asc"
);
$query = $db->simple_select("posts", "pid", "tid='".$post['tid']."'", $options);
$first_check = $db->fetch_array($query);
if($first_check['pid'] == $post['pid'])
{
$first_post = true;
}
else
{
$first_post = false;
}


 
			// If this is the first post there needs to be a subject, else make it the default one.

			// If this is the first post there needs to be a subject, else make it the default one.

			if(my_strlen($subject) == 0 && $first_post)

			if(my_strlen($subject) == 0 && $this->first_post)

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

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

Zeile 254Zeile 237
	/**
* Verifies a post message.
*

	/**
* Verifies a post message.
*

	 * @param string The message content.

	 * @return bool

	 */
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 269Zeile 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");
$dblimit = reset(array_filter(array_map(function($field)
{
if($field['Field'] == 'message')
{
switch(strtolower($field['Type']))
{
case 'longtext':
return 4294967295;
break;
case 'mediumtext':
return 16777215;
break;
case 'text':
default:
return 65535;
break;
}
}
}, $fields)));
}

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 326Zeile 349
	/**
* Verify that the user is not flooding the system.
*

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

	* @return boolean True

	* @return boolean

	*/
function verify_post_flooding()
{

	*/
function verify_post_flooding()
{

Zeile 338Zeile 361
		if($mybb->settings['postfloodcheck'] == 1 && $post['uid'] != 0 && $this->admin_override == false)
{
if($this->verify_post_merge(true) !== true)

		if($mybb->settings['postfloodcheck'] == 1 && $post['uid'] != 0 && $this->admin_override == false)
{
if($this->verify_post_merge(true) !== true)

			{

			{

				return true;

				return true;

			}


			}


			// Fetch the user information for this post - used to check their last post date.
$user = get_user($post['uid']);

			// Fetch the user information for this post - used to check their last post date.
$user = get_user($post['uid']);





			// A little bit of calculation magic and moderator status checking.
if(TIME_NOW-$user['lastpost'] <= $mybb->settings['postfloodsecs'] && !is_moderator($post['fid'], "", $user['uid']))
{

			// A little bit of calculation magic and moderator status checking.
if(TIME_NOW-$user['lastpost'] <= $mybb->settings['postfloodsecs'] && !is_moderator($post['fid'], "", $user['uid']))
{

Zeile 353Zeile 376
				if($time_to_wait == 1)
{
$this->set_error("post_flooding_one_second");

				if($time_to_wait == 1)
{
$this->set_error("post_flooding_one_second");

				}

				}

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

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

Zeile 363Zeile 386
		}
// All is well that ends well - return true.
return true;

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

	}







	}

/**
* @param bool $simple_mode
*
* @return array|bool
*/

	function verify_post_merge($simple_mode=false)
{
global $mybb, $db, $session;

	function verify_post_merge($simple_mode=false)
{
global $mybb, $db, $session;





		$post = &$this->data;

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

		$post = &$this->data;

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

		{
return true;
}

		{
return true;
}


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


// Are we even turned on?
if(empty($mybb->settings['postmergemins']))
{
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']) == "")

Zeile 391Zeile 419

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


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

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

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

		{
return true;

		}

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

		}

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

Zeile 418Zeile 446
				foreach($fids as &$fid)
{
$fid = (int)$fid;

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

				}

				}

				unset($fid);

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

				unset($fid);

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

Zeile 497Zeile 525
			// And count the number of image tags in the message.
$image_count = substr_count($image_check, "<img");
if($image_count > $mybb->settings['maxpostimages'])

			// And count the number of image tags in the message.
$image_count = substr_count($image_check, "<img");
if($image_count > $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;
}
}

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

	}

/**

	}

/**

Zeile 531Zeile 561
				return false;
}
}

				return false;
}
}

 

return true;

	}

/**

	}

/**

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

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

		}

return true;

		}

return true;

	}

/**

	}

/**

Zeile 587Zeile 619
		$post = &$this->data;

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

		$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']]))
{
$post['icon'] = 0;
}
return true;

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

	}


	}


	/**
* Verify the dateline.
*

	/**
* Verify the dateline.
*

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

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





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

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

Zeile 620Zeile 652
	function verify_prefix()
{
$prefix = &$this->data['prefix'];

	function verify_prefix()
{
$prefix = &$this->data['prefix'];


$prefix_cache = build_prefixes();

 

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

Zeile 630Zeile 660
		}
else
{

		}
else
{

 
			if(!empty($this->data['tid']))
{
// Fetch the thread
$thread = get_thread($this->data['tid']);
}


			$prefix_cache = build_prefixes($prefix);

if(empty($prefix_cache))

			$prefix_cache = build_prefixes($prefix);

if(empty($prefix_cache))

Zeile 649Zeile 685
					$user = get_user($this->data['uid']);
}


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


				if(!is_member($prefix_cache['groups'], array('usergroup' => $user['usergroup'], 'additionalgroups' => $user['additionalgroups'])))

				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;

Zeile 660Zeile 696
				// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix_cache['forums']);


				// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix_cache['forums']);


				if(!in_array($this->data['fid'], $forums))

				if(!in_array($this->data['fid'], $forums) && (empty($this->data['tid']) || $prefix != $thread['prefix']))

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

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

Zeile 674Zeile 710
		if($forum['requireprefix'] == 1)
{
$num_prefixes = false;

		if($forum['requireprefix'] == 1)
{
$num_prefixes = false;





			// Go through each of our prefixes and decide if there are any possible prefixes to use.
if(!empty($this->data['edit_uid']))
{

			// Go through each of our prefixes and decide if there are any possible prefixes to use.
if(!empty($this->data['edit_uid']))
{

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

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

			}


			}


			$prefix_cache = build_prefixes();

			$prefix_cache = build_prefixes();





			if(!empty($prefix_cache))
{
foreach($prefix_cache as $required)
{
if($required['forums'] != "-1")

			if(!empty($prefix_cache))
{
foreach($prefix_cache as $required)
{
if($required['forums'] != "-1")

					{

					{

						// Decide whether this prefix can be used in our forum
$forums = explode(",", $required['forums']);

						// Decide whether this prefix can be used in our forum
$forums = explode(",", $required['forums']);





						if(!in_array($forum['fid'], $forums))

						if(!in_array($forum['fid'], $forums))

						{

						{

							continue;

							continue;

						}
}

if($required['groups'] != "-1")
{
if(!is_member($required['groups'], array('usergroup' => $user['usergroup'], 'additionalgroups' => $user['additionalgroups'])))
{
$num_prefixes = true;
}
}
else
{
$num_prefixes = true;
}
}
}

						}
}

if(is_member($required['groups'], array('usergroup' => $user['usergroup'], 'additionalgroups' => $user['additionalgroups'])))
{
$num_prefixes = true;
}
}
}









if($prefix == 0 && $num_prefixes)
{


if($prefix == 0 && $num_prefixes)
{

Zeile 746Zeile 775
			$this->verify_post_flooding();
}


			$this->verify_post_flooding();
}


		// Verify all post assets.
























		// Are we editing an existing thread or post?
if($this->method == "update")
{
if(empty($post['tid']))
{
$query = $db->simple_select("posts", "tid", "pid='".(int)$post['pid']."'");
$post['tid'] = $db->fetch_field($query, "tid");
}
// Here we determine if we're editing the first post of a thread or not.
$options = array(
"limit" => 1,
"limit_start" => 0,
"order_by" => "dateline",
"order_dir" => "asc"
);
$query = $db->simple_select("posts", "pid", "tid='".$post['tid']."'", $options);
$first_check = $db->fetch_array($query);
if($first_check['pid'] == $post['pid'])
{
$this->first_post = true;
}
}

// Verify all post assets.


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


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

		{

		{

			$this->verify_author();

			$this->verify_author();

		}


		}


		if($this->method == "insert" || array_key_exists('subject', $post))
{
$this->verify_subject();
}

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

		if($this->method == "insert" || array_key_exists('subject', $post))
{
$this->verify_subject();
}

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

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

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

		}

		}


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


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

		}

		}


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


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

Zeile 781Zeile 833
		}

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

		}

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

		{

		{

			$this->verify_options();

			$this->verify_options();

 
		}

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

		}

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

		}

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

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

			}

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

			if($ismod)

			if($ismod && isset($post['modoptions']))

			{
$lang->load($this->language_file, true);


			{
$lang->load($this->language_file, true);


Zeile 863Zeile 926
				$modlogdata['fid'] = $thread['fid'];
$modlogdata['tid'] = $thread['tid'];


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


				$newstick = $newclosed = '';

if(!isset($modoptions['closethread']))
{
$modoptions['closethread'] = 0;
}


				$modoptions_update = array();







				// Close the thread.

				// Close the thread.

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

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

				{

				{

					$newclosed = "closed=1";

					$modoptions_update['closed'] = $closed = 1;

					log_moderator_action($modlogdata, $lang->thread_closed);

					log_moderator_action($modlogdata, $lang->thread_closed);

					$closed = 1;

 
				}

// Open the thread.

				}

// Open the thread.

				if($modoptions['closethread'] != 1 && $thread['closed'] == 1)
{
$newclosed = "closed=0";

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

					log_moderator_action($modlogdata, $lang->thread_opened);

					$closed = 0;
}

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

				}

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

				{

				{

					$modoptions['stickthread'] = 0;
}

// Stick the thread.
if($modoptions['stickthread'] == 1 && $thread['sticky'] != 1)
{
$newstick = "sticky='1'";

					$modoptions_update['sticky'] = 1;







					log_moderator_action($modlogdata, $lang->thread_stuck);

					log_moderator_action($modlogdata, $lang->thread_stuck);

				}

				}


// Unstick the thread.


// Unstick the thread.

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

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

				{

				{

					$newstick = "sticky='0'";

					$modoptions_update['sticky'] = 0;

					log_moderator_action($modlogdata, $lang->thread_unstuck);
}

// Execute moderation options.

					log_moderator_action($modlogdata, $lang->thread_unstuck);
}

// Execute moderation options.

				if($newstick && $newclosed)
{
$sep = ",";
}
else
{
$sep = '';
}
if($newstick || $newclosed)

				if($modoptions_update)









				{

				{

					$db->write_query("
UPDATE ".TABLE_PREFIX."threads
SET {$newclosed}{$sep}{$newstick}
WHERE tid='{$thread['tid']}'
");

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





				}
}


				}
}


Zeile 978Zeile 1017
				);
$update_query['edituid'] = (int)$post['uid'];
$update_query['edittime'] = TIME_NOW;

				);
$update_query['edituid'] = (int)$post['uid'];
$update_query['edittime'] = TIME_NOW;

				$query = $db->update_query("posts", $update_query, "pid='".$double_post['pid']."'");

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


if($draft_check)
{


if($draft_check)
{

Zeile 1019Zeile 1058
			}
}


			}
}


		if($visible == 1 && $thread['visible'] == 1)

		if($visible == 1)

		{
$now = TIME_NOW;


		{
$now = TIME_NOW;


Zeile 1027Zeile 1066
			$update_array = array(
'lastpost' => "'{$now}'"
);

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

Zeile 1074Zeile 1113
				"includesig" => $post['options']['signature'],
"smilieoff" => $post['options']['disablesmilies'],
"visible" => $visible

				"includesig" => $post['options']['signature'],
"smilieoff" => $post['options']['disablesmilies'],
"visible" => $visible

			);

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

			);

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


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


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

Zeile 1095Zeile 1134
		$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;

$done_users = array();

$subject = $parser->parse_badwords($thread['subject']);

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

$done_users = array();

$subject = $parser->parse_badwords($thread['subject']);

			$excerpt = $parser->text_parse_message($post['message'], array('me_username' => $post['username'], 'filter_badwords' => 1, 'safe_html' => 1));








$parser_options = array(
'me_username' => $post['username'],
'filter_badwords' => 1
);

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

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

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

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

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

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

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

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

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

Zeile 1163Zeile 1207
					{
$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'])
{
$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'];

					}
}


					}
}


Zeile 1189Zeile 1252
					$emailsubject = $lang->sprintf($emailsubject, $subject);

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

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

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

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

Zeile 1206Zeile 1269
					$post_code = md5($subscribedmember['loginkey'].$subscribedmember['salt'].$subscribedmember['regdate']);
$pm = array(
'subject' => array('pmsubject_subscription', $subject),

					$post_code = md5($subscribedmember['loginkey'].$subscribedmember['salt'].$subscribedmember['regdate']);
$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'], $subscribedmember['subscriptionkey'], $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'], $post_code),

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

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

Zeile 1225Zeile 1288

$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']);
}
// Post is stuck in moderation queue
else if($visible == 0)

			update_last_post($post['tid']);
update_forum_counters($post['fid'], array("posts" => "+1"));
update_forum_lastpost($thread['fid']);
}
// Post is stuck in moderation queue
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"));
}

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

Zeile 1249Zeile 1312
			// 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'");

		}

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

Zeile 1285Zeile 1354
		// Validate all thread assets.

if(!$thread['savedraft'])

		// Validate all thread assets.

if(!$thread['savedraft'])

		{

		{

			$this->verify_post_flooding();
}


			$this->verify_post_flooding();
}


Zeile 1388Zeile 1457
			if($mybb->user['uid'] == $thread['uid'] && $mybb->user['moderateposts'] == 1)
{
$visible = 0;

			if($mybb->user['uid'] == $thread['uid'] && $mybb->user['moderateposts'] == 1)
{
$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 1402Zeile 1471
		{
$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
{
$draft_check = false;

		else
{
$draft_check = false;

Zeile 1410Zeile 1479

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















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

$this->post_insert_data = array(

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

				"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']),



				"message" => $db->escape_string($thread['message']),
"ipaddress" => $db->escape_binary(my_inet_pton(get_ip())),
"includesig" => $thread['options']['signature'],
"smilieoff" => $thread['options']['disablesmilies'],

				"visible" => $visible
);

				"visible" => $visible
);


$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'],
"username" => $db->escape_string($thread['username']),
"dateline" => (int)$thread['dateline'],
"message" => $db->escape_string($thread['message']),
"ipaddress" => $db->escape_binary(my_inet_pton(get_ip())),
"includesig" => $thread['options']['signature'],
"smilieoff" => $thread['options']['disablesmilies'],
"visible" => $visible
);
$plugins->run_hooks("datahandler_post_insert_thread_post", $this);

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


















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


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

Zeile 1456Zeile 1525
				"dateline" => (int)$thread['dateline'],
"lastpost" => (int)$thread['dateline'],
"lastposter" => $db->escape_string($thread['username']),

				"dateline" => (int)$thread['dateline'],
"lastpost" => (int)$thread['dateline'],
"lastposter" => $db->escape_string($thread['username']),

 
				"lastposteruid" => $thread['uid'],

				"views" => 0,
"replies" => 0,
"visible" => $visible,
"notes" => ''

				"views" => 0,
"replies" => 0,
"visible" => $visible,
"notes" => ''

			);

			);


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



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


Zeile 1508Zeile 1578

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


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

			}

			}


// Perform any selected moderation tools.


// Perform any selected moderation tools.

			if(is_moderator($thread['fid'], "", $thread['uid']) && is_array($thread['modoptions']))

			if(is_moderator($thread['fid'], "", $thread['uid']) && isset($thread['modoptions']))

			{
$lang->load($this->language_file, true);


			{
$lang->load($this->language_file, true);


Zeile 1522Zeile 1592
					$modlogdata['tid'] = $thread['tid'];
}


					$modlogdata['tid'] = $thread['tid'];
}


				$newclosed = $newstick = '';

				$modoptions_update = array();


// Close the thread.


// Close the thread.

				if(isset($modoptions['closethread']) && $modoptions['closethread'] == 1)

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

				{

				{

					$newclosed = "closed=1";

					$modoptions_update['closed'] = 1;

					log_moderator_action($modlogdata, $lang->thread_closed);
}

// Stick the thread.

					log_moderator_action($modlogdata, $lang->thread_closed);
}

// Stick the thread.

				if(isset($modoptions['stickthread']) && $modoptions['stickthread'] == 1)

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

				{

				{

					$newstick = "sticky='1'";

					$modoptions_update['sticky'] = 1;

					log_moderator_action($modlogdata, $lang->thread_stuck);
}

// Execute moderation options.

					log_moderator_action($modlogdata, $lang->thread_stuck);
}

// Execute moderation options.

				if($newstick && $newclosed)

				if($modoptions_update)

				{

				{

					$sep = ",";
}
else
{
$sep = '';
}
if($newstick || $newclosed)
{
$db->write_query("
UPDATE ".TABLE_PREFIX."threads
SET $newclosed$sep$newstick
WHERE tid='{$this->tid}'
");

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













				}
}
if($visible == 1)

				}
}
if($visible == 1)

Zeile 1594Zeile 1652
				$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 1649Zeile 1711
					{
$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 1658Zeile 1726
							$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']);


Zeile 1732Zeile 1808
	/**
* Updates a post that is already in the database.
*

	/**
* Updates a post that is already in the database.
*

 
	 * @return array

	 */
function update_post()
{

	 */
function update_post()
{

Zeile 1757Zeile 1834

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


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


// Check if this is the first post in a thread.
$options = array(
"order_by" => "dateline",
"order_dir" => "asc",
"limit_start" => 0,
"limit" => 1
);
$query = $db->simple_select("posts", "pid", "tid='".(int)$post['tid']."'", $options);
$first_post_check = $db->fetch_array($query);
if($first_post_check['pid'] == $post['pid'])
{
$first_post = true;
}
else
{
$first_post = false;
}

 

// Decide on the visibility of this post.
$ismod = is_moderator($post['fid'], "", $post['uid']);


// Decide on the visibility of this post.
$ismod = is_moderator($post['fid'], "", $post['uid']);

Zeile 1801Zeile 1860
		}

// Update the thread details that might have been changed first.

		}

// Update the thread details that might have been changed first.

		if($first_post)

		if($this->first_post)

		{
$this->tid = $post['tid'];


		{
$this->tid = $post['tid'];


Zeile 1844Zeile 1903
		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']))

Zeile 1902Zeile 1965
		// Return the thread's first post id and whether or not it is visible.
$this->return_values = array(
'visible' => $visible,

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

			'first_post' => $first_post

			'first_post' => $this->first_post

		);

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

		);

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