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

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 130Zeile 130
		}
// if the uid is 0 verify the username
else if($post['uid'] == 0 && $post['username'] != $lang->guest)

		}
// if the uid is 0 verify the username
else if($post['uid'] == 0 && $post['username'] != $lang->guest)

		{	

		{

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

Zeile 150Zeile 157
		if(!$post['username'])
{
$post['username'] = "Guest";

		if(!$post['username'])
{
$post['username'] = "Guest";

		}

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

		}

return true;



	}

/**

	}

/**

Zeile 216Zeile 221
			{
$thread = get_thread($post['tid']);
$subject = "RE: ".$thread['subject'];

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

			}
}


			}
}


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

Zeile 283Zeile 288
			if(!isset($post['fid']))
{
$post['fid'] = 0;

			if(!isset($post['fid']))
{
$post['fid'] = 0;

			}

			}

			if(!$mybb->settings['mycodemessagelength'])

			if(!$mybb->settings['mycodemessagelength'])

			{

			{

				// 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 301Zeile 306
			else if(my_strlen($post['message']) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid']))
{
$this->set_error("message_too_short", array($mybb->settings['minmessagelength']));

			else if(my_strlen($post['message']) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid']))
{
$this->set_error("message_too_short", array($mybb->settings['minmessagelength']));

				return false;
}
}
return true;

				return false;
}
}
return true;

	}

/**

	}

/**

Zeile 315Zeile 320
	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 370Zeile 375
		global $mybb, $db, $session;

$post = &$this->data;

		global $mybb, $db, $session;

$post = &$this->data;





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

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

		{

		{

			return true;
}


			return true;
}


Zeile 381Zeile 386
		if(empty($mybb->settings['postmergemins']))
{
return true;

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

		{

		{

			$mybb->settings['postmergesep'] = "[hr]";

			$mybb->settings['postmergesep'] = "[hr]";

		}

		}


// Check to see if this person is in a usergroup that is excluded


// Check to see if this person is in a usergroup that is excluded

		if($mybb->settings['postmergeuignore'] == -1)
{
return true;
}
elseif($mybb->settings['postmergeuignore'] != '' && is_member($mybb->settings['postmergeuignore'], $post['uid']))

		if(is_member($mybb->settings['postmergeuignore'], $post['uid']))





		{
return true;
}

		{
return true;
}

Zeile 822Zeile 823
		if(count($this->get_errors()) > 0)
{
die("The post is not valid.");

		if(count($this->get_errors()) > 0)
{
die("The post is not valid.");

		}


		}


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

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





		$closed = $thread['closed'];

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

		$closed = $thread['closed'];

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

		{

		{

			$visible = -2;
}


			$visible = -2;
}


Zeile 851Zeile 852
						break;
default:
$notification = 0;

						break;
default:
$notification = 0;

				}

				}


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


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

Zeile 866Zeile 867
				$modoptions = $post['modoptions'];
$modlogdata['fid'] = $thread['fid'];
$modlogdata['tid'] = $thread['tid'];

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


$newstick = $newclosed = '';

 

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


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

				{
$modoptions['closethread'] = 0;
}




				{
$modoptions['closethread'] = $closed;
}

$modoptions_update = array();


				// Close the thread.
if($modoptions['closethread'] == 1 && $thread['closed'] != 1)
{

				// Close the thread.
if($modoptions['closethread'] == 1 && $thread['closed'] != 1)
{

					$newclosed = "closed=1";

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

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

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

					$closed = 1;

 
				}

// Open the thread.
if($modoptions['closethread'] != 1 && $thread['closed'] == 1)
{

				}

// Open the thread.
if($modoptions['closethread'] != 1 && $thread['closed'] == 1)
{

					$newclosed = "closed=0";

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

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

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

					$closed = 0;

 
				}

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

				}

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

					$modoptions['stickthread'] = 0;

					$modoptions['stickthread'] = $thread['sticky'];

				}

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

				}

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

					$newstick = "sticky='1'";

					$modoptions_update['sticky'] = 1;

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

// Unstick the thread.
if($modoptions['stickthread'] != 1 && $thread['sticky'])
{

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

// Unstick the thread.
if($modoptions['stickthread'] != 1 && $thread['sticky'])
{

					$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 1106Zeile 1093
			$done_users = array();

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

			$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

			$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

Zeile 1118Zeile 1111
				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()
);


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


				$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 1208Zeile 1211
					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)
{

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

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

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

		{

		{

			$thread_update['attachmentcount'] = "+{$attachmentcount}";
}
update_thread_counters($post['tid'], $thread_update);

			$thread_update['attachmentcount'] = "+{$attachmentcount}";
}
update_thread_counters($post['tid'], $thread_update);

Zeile 1264Zeile 1270

/**
* 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 1300Zeile 1306
			$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', $thread))
{
$this->verify_dateline();

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

Zeile 1339Zeile 1345
	function insert_thread()
{
global $db, $mybb, $plugins, $cache, $lang;

	function insert_thread()
{
global $db, $mybb, $plugins, $cache, $lang;





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

			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;

		if(count($this->get_errors()) > 0)
{
die("The thread is not valid.");
}

$thread = &$this->data;





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

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

		{

		{

			$visible = -2;
}

			$visible = -2;
}





		// Thread is being made now and we have a bit to do.
else
{
$forumpermissions = forum_permissions($thread['fid'], $thread['uid']);
// Decide on the visibility of this post.
if($forumpermissions['modthreads'] == 1 && !is_moderator($thread['fid'], "", $thread['uid']))

		// Thread is being made now and we have a bit to do.
else
{
$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
{
$visible = 1;

			else
{
$visible = 1;

Zeile 1377Zeile 1383

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

			{

			{

				$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 1397Zeile 1403
		else
{
$draft_check = false;

		else
{
$draft_check = false;

		}


		}


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

		// Are we updating a post which is already a draft? Perhaps changing it into a visible post?
if($draft_check)
{
$this->thread_insert_data = array(

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

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

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

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

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

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

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


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


$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())),

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

Zeile 1513Zeile 1519
					$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']))

				{

				{

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

				{

				{

					$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)
{
$sep = ",";
}
else
{
$sep = '';
}
if($newstick || $newclosed)

				if($modoptions_update)









				{

				{

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