Vergleich inc/datahandlers/post.php - 1.6.5 - 1.6.10

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * $Id: post.php 5625 2011-10-02 19:16:35Z ralgith $

 * $Id$

 */

// Disallow direct access to this file for security reasons

 */

// Disallow direct access to this file for security reasons

Zeile 145Zeile 145
		global $db;
$post = &$this->data;
$subject = &$post['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'])


// Are we editing an existing thread or post?
if($this->method == "update" && $post['pid'])

Zeile 173Zeile 174
			}

// 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(trim_blank_chrs($subject)) == 0 && $first_post)

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

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

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

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

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

			if(my_strlen(trim_blank_chrs($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 198Zeile 199
		// This is a new thread and we require that a subject is present.
else
{

		// This is a new thread and we require that a subject is present.
else
{

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

			if(my_strlen($subject) == 0)

			{
$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($this->action == "post")
{
$position_re = my_strpos($subject, "RE: ");
if($position_re !== false && $position_re == 0)
{
$subject_length = $subject_length - 4;
}
}

if($subject_length > 85)
{
// Subject is too long
$this->set_error('subject_too_long', my_strlen($subject));
return false;

		}

// Subject is valid - return true.
return true;
}

		}

// Subject is valid - return true.
return true;
}





	/**
* Verifies a post message.
*

	/**
* Verifies a post message.
*

Zeile 219Zeile 238
		global $mybb;

$post = &$this->data;

		global $mybb;

$post = &$this->data;

		


		$post['message'] = trim_blank_chrs($post['message']);


		// Do we even have a message at all?

		// Do we even have a message at all?

		if(my_strlen(trim_blank_chrs($post['message'])) == 0)

		if(my_strlen($post['message']) == 0)

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

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

Zeile 268Zeile 288
	{
global $mybb;


	{
global $mybb;


		$post = &$this->data;


		$post = &$this->data;


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

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

Zeile 330Zeile 350
		{
$gids = explode(',', $mybb->settings['postmergeuignore']);
$gids = array_map('intval', $gids);

		{
$gids = explode(',', $mybb->settings['postmergeuignore']);
$gids = array_map('intval', $gids);

			


			


			$user_usergroups = explode(',', $mybb->user['usergroup'].",".$mybb->user['additionalgroups']);
if(count(array_intersect($user_usergroups, $gids)) > 0)
{

			$user_usergroups = explode(',', $mybb->user['usergroup'].",".$mybb->user['additionalgroups']);
if(count(array_intersect($user_usergroups, $gids)) > 0)
{

Zeile 382Zeile 402
			$user_check = "ipaddress='".$db->escape_string($session->ipaddress)."'";
}


			$user_check = "ipaddress='".$db->escape_string($session->ipaddress)."'";
}


		$query = $db->simple_select("posts", "pid,message,visible,posthash", "{$user_check} AND tid='".$post['tid']."' AND dateline='".$thread['lastpost']."'", array('order_by' => 'pid', 'order_dir' => 'DESC', 'limit' => 1));

		$query = $db->simple_select("posts", "pid,message,visible", "{$user_check} AND tid='".$post['tid']."' AND dateline='".$thread['lastpost']."'", array('order_by' => 'pid', 'order_dir' => 'DESC', 'limit' => 1));

		return $db->fetch_array($query);
}


		return $db->fetch_array($query);
}


Zeile 583Zeile 603
		$this->action = "post";

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

		$this->action = "post";

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

		{

		{

			$this->verify_post_flooding();
}


			$this->verify_post_flooding();
}


Zeile 626Zeile 646
			$this->verify_options();
}


			$this->verify_options();
}


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

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


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


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

Zeile 784Zeile 804
			{
$this->pid = $double_post['pid'];


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


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

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

				$update_query = array(
"message" => $db->escape_string($double_post['message'])
);

				$update_query = array(
"message" => $db->escape_string($double_post['message'])
);

Zeile 798Zeile 818
				}

// Assign any uploaded attachments with the specific posthash to the merged post.

				}

// Assign any uploaded attachments with the specific posthash to the merged post.

				if($double_post['posthash'])






				$post['posthash'] = $db->escape_string($post['posthash']);

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

if($attachmentcount > 0)

				{

				{

					$post['posthash'] = $db->escape_string($post['posthash']);
$double_post['posthash'] = $db->escape_string($double_post['posthash']);

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





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

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

				

				

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

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

$post['posthash'] = $double_post['posthash'];
}


 
				// Return the post's pid and whether or not it is visible.
return array(
"pid" => $double_post['pid'],

				// Return the post's pid and whether or not it is visible.
return array(
"pid" => $double_post['pid'],

Zeile 860Zeile 874
				"longipaddress" => intval(my_ip2long($post['ipaddress'])),
"includesig" => $post['options']['signature'],
"smilieoff" => $post['options']['disablesmilies'],

				"longipaddress" => intval(my_ip2long($post['ipaddress'])),
"includesig" => $post['options']['signature'],
"smilieoff" => $post['options']['disablesmilies'],

				"visible" => $visible,
"posthash" => $db->escape_string($post['posthash'])

				"visible" => $visible


			);


			);


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


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


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

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

Zeile 886Zeile 899
				"longipaddress" => intval(my_ip2long($post['ipaddress'])),
"includesig" => $post['options']['signature'],
"smilieoff" => $post['options']['disablesmilies'],

				"longipaddress" => intval(my_ip2long($post['ipaddress'])),
"includesig" => $post['options']['signature'],
"smilieoff" => $post['options']['disablesmilies'],

				"visible" => $visible,
"posthash" => $db->escape_string($post['posthash'])

				"visible" => $visible


			);


			);


			$plugins->run_hooks_by_ref("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 900Zeile 912
		{
$post['posthash'] = $db->escape_string($post['posthash']);
$attachmentassign = array(

		{
$post['posthash'] = $db->escape_string($post['posthash']);
$attachmentassign = array(

				"pid" => $this->pid


				"pid" => $this->pid,
"posthash" => ''

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

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

Zeile 1017Zeile 1030
			// Update the unapproved posts count for the current forum
update_thread_counters($post['tid'], array("replies" => "+1"));
update_forum_counters($post['fid'], array("unapprovedposts" => "+1"));

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

 
		}

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

		}

// Return the post's pid and whether or not it is visible.

		}

// Return the post's pid and whether or not it is visible.

Zeile 1028Zeile 1048

/**
* Validate a thread.


/**
* Validate a thread.

	 *

	 *

	 * @return boolean True when valid, false when invalid.
*/
function validate_thread()

	 * @return boolean True when valid, false when invalid.
*/
function validate_thread()

Zeile 1050Zeile 1070
		}

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

		}

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

		{

		{

			$this->verify_prefix();
}


			$this->verify_prefix();
}


Zeile 1072Zeile 1092
		}

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


Zeile 1081Zeile 1101
			$this->verify_options();
}


			$this->verify_options();
}


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

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


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


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

Zeile 1106Zeile 1126

// 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 needs to be validated before inserting it into the DB.");
}
if(count($this->get_errors()) > 0)

Zeile 1138Zeile 1158
			{
$visible = 1;
}

			{
$visible = 1;
}





			// Are posts from this user being moderated? Change visibility
if($mybb->user['uid'] == $thread['uid'] && $mybb->user['moderateposts'] == 1)
{

			// Are posts from this user being moderated? Change visibility
if($mybb->user['uid'] == $thread['uid'] && $mybb->user['moderateposts'] == 1)
{

Zeile 1165Zeile 1185

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


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

		{
$this->thread_insert_data = array(
"subject" => $db->escape_string($thread['subject']),
"icon" => intval($thread['icon']),
"username" => $db->escape_string($thread['username']),

		{
$this->thread_insert_data = array(
"subject" => $db->escape_string($thread['subject']),
"icon" => intval($thread['icon']),
"username" => $db->escape_string($thread['username']),

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


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


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

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


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


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


$this->post_insert_data = array(
"subject" => $db->escape_string($thread['subject']),
"icon" => intval($thread['icon']),
"username" => $db->escape_string($thread['username']),
"dateline" => intval($thread['dateline']),
"message" => $db->escape_string($thread['message']),
"ipaddress" => $db->escape_string(get_ip()),


$this->post_insert_data = array(
"subject" => $db->escape_string($thread['subject']),
"icon" => intval($thread['icon']),
"username" => $db->escape_string($thread['username']),
"dateline" => intval($thread['dateline']),
"message" => $db->escape_string($thread['message']),
"ipaddress" => $db->escape_string(get_ip()),

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

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

				"visible" => $visible,
"posthash" => $db->escape_string($thread['posthash'])

				"visible" => $visible


			);

			);

			$plugins->run_hooks_by_ref("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 1203Zeile 1222
		else
{
$this->thread_insert_data = array(

		else
{
$this->thread_insert_data = array(

				"fid" => $thread['fid'],

				"fid" => $thread['fid'],

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

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

Zeile 1218Zeile 1237
				"notes" => ''
);


				"notes" => ''
);


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

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


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



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


Zeile 1235Zeile 1254
				"longipaddress" => intval(my_ip2long(get_ip())),
"includesig" => $thread['options']['signature'],
"smilieoff" => $thread['options']['disablesmilies'],

				"longipaddress" => intval(my_ip2long(get_ip())),
"includesig" => $thread['options']['signature'],
"smilieoff" => $thread['options']['disablesmilies'],

				"visible" => $visible,
"posthash" => $db->escape_string($thread['posthash'])

				"visible" => $visible


			);

			);

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

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


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



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


Zeile 1435Zeile 1453
		{
$thread['posthash'] = $db->escape_string($thread['posthash']);
$attachmentassign = array(

		{
$thread['posthash'] = $db->escape_string($thread['posthash']);
$attachmentassign = array(

				"pid" => $this->pid


				"pid" => $this->pid,
"posthash" => ''

			);
$db->update_query("attachments", $attachmentassign, "posthash='{$thread['posthash']}'");
}

			);
$db->update_query("attachments", $attachmentassign, "posthash='{$thread['posthash']}'");
}

Zeile 1587Zeile 1606
			}
if(count($this->thread_update_data) > 0)
{

			}
if(count($this->thread_update_data) > 0)
{

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

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


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


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

Zeile 1633Zeile 1652

$this->post_update_data['visible'] = $visible;



$this->post_update_data['visible'] = $visible;


		$plugins->run_hooks_by_ref("datahandler_post_update", $this);

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


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



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