Vergleich inc/datahandlers/post.php - 1.8.5 - 1.8.7

  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;


Zeile 104Zeile 106
	 * @var array
*/
public $return_values = array();

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

 

/**
* Is this the first post of a thread when editing
*
* @var boolean
*/
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 120Zeile 129
		if(!isset($post['uid']))
{
$this->set_error("invalid_user_id");

		if(!isset($post['uid']))
{
$this->set_error("invalid_user_id");

			return false;

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

Zeile 165Zeile 174
	/**
* Verifies a post subject.
*

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

	{

	{

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


		global $db;
$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(my_strlen($subject) == 0 && $first_post)

			// If this is the first post there needs to be a subject, else make it the default one.
if(my_strlen($subject) == 0 && $this->first_post)
























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

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

			}

			}

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

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

Zeile 216Zeile 200

// This is a new post
else if($this->action == "post")


// This is a new post
else if($this->action == "post")

		{
if(my_strlen($subject) == 0)
{

		{
if(my_strlen($subject) == 0)
{

				$thread = get_thread($post['tid']);
$subject = "RE: ".$thread['subject'];
}

				$thread = get_thread($post['tid']);
$subject = "RE: ".$thread['subject'];
}

Zeile 259Zeile 243
	/**
* Verifies a post message.
*

	/**
* Verifies a post message.
*

	 * @param string The message content.

	 * @return bool

	 */
function verify_message()
{

	 */
function verify_message()
{

Zeile 267Zeile 251

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


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





		// Do we even have a message at all?
if(my_strlen($post['message']) == 0)
{
$this->set_error("missing_message");

		// Do we even have a message at all?
if(my_strlen($post['message']) == 0)
{
$this->set_error("missing_message");

			return false;
}


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

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

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

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





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

if(my_strlen($message) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid']))

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

if(my_strlen($message) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid']))

Zeile 320Zeile 304
	function verify_options()
{
$options = &$this->data['options'];

	function verify_options()
{
$options = &$this->data['options'];





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

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

Zeile 331Zeile 315
	/**
* 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 370Zeile 354
		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?

		$post = &$this->data;

// Are we starting a new thread?

Zeile 478Zeile 467
		{
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;

		{
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;





			// Parse the message.
$parser_options = array(
"allow_html" => $forum['allowhtml'],

			// Parse the message.
$parser_options = array(
"allow_html" => $forum['allowhtml'],

Zeile 489Zeile 478
			);

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

			);

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

			{

			{

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

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

Zeile 505Zeile 494
			{
// 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 false;

			}
}

			}
}

 

return true;

	}

/**

	}

/**

Zeile 536Zeile 527
				return false;
}
}

				return false;
}
}

 

return true;

	}

/**

	}

/**

Zeile 556Zeile 549
			if(!$valid_post['pid'])
{
$post['replyto'] = 0;

			if(!$valid_post['pid'])
{
$post['replyto'] = 0;

			}
else

			}
else

			{
return true;
}

			{
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 582Zeile 575

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

Zeile 625Zeile 618
	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))

		{

		{

			$prefix = 0;
}
else
{

			$prefix = 0;
}
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 654Zeile 651
					$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 664Zeile 661
			{
// 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;
}

			}

			}

		}

// Does this forum require a prefix?

		}

// Does this forum require a prefix?

Zeile 679Zeile 676
		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']))

			{

			{

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

			}

$prefix_cache = build_prefixes();

			}

$prefix_cache = build_prefixes();


if(!empty($prefix_cache))
{


if(!empty($prefix_cache))
{

Zeile 708Zeile 705
						}
}


						}
}


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

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








					{
$num_prefixes = true;
}

					{
$num_prefixes = true;
}

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

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

 
		}

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

		}

// Verify all post assets.

Zeile 764Zeile 777
		}

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))
{
$this->verify_dateline();
}

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

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

			$this->verify_reply_to();

		}


		}


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

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

		{

		{

			$this->verify_post_icon();
}


			$this->verify_post_icon();
}


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






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

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

		{

		{

			$this->verify_options();

			$this->verify_prefix();

		}

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

		}

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

Zeile 969Zeile 987
				);
$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 1104Zeile 1122

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


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

				SELECT u.username, u.email, u.uid, u.language, 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 1116Zeile 1134
				'this' => &$this,
'done_users' => &$done_users,
'users' => array()

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

			);

			);


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


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

				{
continue;
}

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


				{
continue;
}

$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 1142Zeile 1160
				}

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

				}

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

				{

				{

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

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

Zeile 1186Zeile 1204
					$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 1203Zeile 1221
					$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 1299Zeile 1317
		if($this->method == "insert" || array_key_exists('subject', $thread))
{
$this->verify_subject();

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

		}


		}


		if($this->method == "insert" || array_key_exists('message', $thread))
{
$this->verify_message();
$this->verify_image_count();
$this->verify_video_count();

		if($this->method == "insert" || array_key_exists('message', $thread))
{
$this->verify_message();
$this->verify_image_count();
$this->verify_video_count();

		}


		}


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

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

Zeile 1316Zeile 1334
		if($this->method == "insert" || array_key_exists('icon', $thread))
{
$this->verify_post_icon();

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

Zeile 1327Zeile 1345

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


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

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

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

			return false;
}
else

			return false;
}
else

Zeile 1453Zeile 1471
				"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,

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

Zeile 1717Zeile 1736
	/**
* 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 1742Zeile 1762

$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 1786Zeile 1788
		}

// 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 1887Zeile 1889
		// 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);