Vergleich inc/datahandlers/post.php - 1.8.17 - 1.8.26

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 261Zeile 261
			if(stripos($db->type, 'my') !== false)
{
$fields = $db->show_fields_from("posts");

			if(stripos($db->type, 'my') !== false)
{
$fields = $db->show_fields_from("posts");

				$dblimit = reset(array_filter(array_map(function($field)


				$type = $fields[array_search('message', array_column($fields, 'Field'))]['Type'];
switch(strtolower($type))

				{

				{

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

					case 'longtext':
$dblimit = 4294967295;
break;
case 'mediumtext':
$dblimit = 16777215;
break;
case 'text':
default:
$dblimit = 65535;
break;
}
}








if($limit > 0 || $dblimit > 0)
{


if($limit > 0 || $dblimit > 0)
{

Zeile 289Zeile 284
				if($limit > 0 && $dblimit > 0)
{
$limit = $is_moderator ? $dblimit : min($limit, $dblimit);

				if($limit > 0 && $dblimit > 0)
{
$limit = $is_moderator ? $dblimit : min($limit, $dblimit);

				}

				}

				else
{
$limit = max($limit, $dblimit);

				else
{
$limit = max($limit, $dblimit);

Zeile 298Zeile 293
				if(strlen($post['message']) > $limit && (!$is_moderator || $limit == $dblimit))
{
$this->set_error("message_too_long", array($limit, strlen($post['message'])));

				if(strlen($post['message']) > $limit && (!$is_moderator || $limit == $dblimit))
{
$this->set_error("message_too_long", array($limit, strlen($post['message'])));

					return false;
}
}


					return false;
}
}


			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;

Zeile 324Zeile 319
			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 false;
}
}

		return true;
}


		return true;
}


Zeile 376Zeile 371
				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 401Zeile 396

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


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

		{

		{

			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;

		{
return true;

		}

// Assign a default separator if none is specified

		}

// Assign a default separator if none is specified

Zeile 426Zeile 421
		// 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);

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

Zeile 476Zeile 471

/**
* Verifies the image count.


/**
* Verifies the image count.

	*

	*

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

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

Zeile 501Zeile 496
		{
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 512Zeile 507
			);

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 525Zeile 520
			// 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.

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

				$this->set_error("too_many_images", array(1 => $image_count, 2 => $mybb->settings['maxpostimages']));
return false;
}

Zeile 545Zeile 540
		global $mybb, $db;

$post = &$this->data;

		global $mybb, $db;

$post = &$this->data;





		// Get the permissions of the user who is making this post or thread
$permissions = user_permissions($post['uid']);

// Check if this post contains more videos than the forum allows
if((!isset($post['savedraft']) || $post['savedraft'] != 1) && $mybb->settings['maxpostvideos'] != 0 && $permissions['cancp'] != 1)

		// Get the permissions of the user who is making this post or thread
$permissions = user_permissions($post['uid']);

// Check if this post contains more videos than the forum allows
if((!isset($post['savedraft']) || $post['savedraft'] != 1) && $mybb->settings['maxpostvideos'] != 0 && $permissions['cancp'] != 1)

		{

		{

			// And count the number of video tags in the message.
$video_count = substr_count($post['message'], "[video=");
if($video_count > $mybb->settings['maxpostvideos'])

			// And count the number of video tags in the message.
$video_count = substr_count($post['message'], "[video=");
if($video_count > $mybb->settings['maxpostvideos'])

Zeile 626Zeile 621
			$post['icon'] = 0;
}
return true;

			$post['icon'] = 0;
}
return true;

	}

	}


/**
* Verify the dateline.


/**
* Verify the dateline.

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

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

				{

				{

					// Post is being edited
$user = get_user($this->data['edit_uid']);
}

					// Post is being edited
$user = get_user($this->data['edit_uid']);
}

Zeile 720Zeile 715
			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 737Zeile 732
						{
continue;
}

						{
continue;
}

					}

					}


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


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

			}


			}


			if($prefix == 0 && $num_prefixes)
{
$this->set_error('require_prefix');

			if($prefix == 0 && $num_prefixes)
{
$this->set_error('require_prefix');

Zeile 815Zeile 810
			$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('dateline', $post))
{
$this->verify_dateline();

		}

		}


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


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

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

Zeile 838Zeile 833
		}

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

		}

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

		{

		{

			$this->verify_prefix();

			$this->verify_prefix();

		}


		}


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

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

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

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

			return false;
}
else
{
return true;

		}

		}

	}

/**

	}

/**

Zeile 862Zeile 857
	 * @return array Array of new post details, pid and visibility.
*/
function insert_post()

	 * @return array Array of new post details, pid and visibility.
*/
function insert_post()

	{
global $db, $mybb, $plugins, $cache, $lang;

$post = &$this->data;

// Yes, validating is required.
if(!$this->get_validated())
{
die("The post needs to be validated before inserting it into the DB.");
}
if(count($this->get_errors()) > 0)
{
die("The post is not valid.");
}


	{
global $db, $mybb, $plugins, $cache, $lang;

$post = &$this->data;

// Yes, validating is required.
if(!$this->get_validated())
{
die("The post needs to be validated before inserting it into the DB.");
}
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']);


Zeile 951Zeile 946

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


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

				{

				{

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

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

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

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

			}


			}


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

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





			// Decide on the visibility of this post.
$forumpermissions = forum_permissions($post['fid'], $post['uid']);
if($forumpermissions['modposts'] == 1 && !$ismod)
{
$visible = 0;

			// Decide on the visibility of this post.
$forumpermissions = forum_permissions($post['fid'], $post['uid']);
if($forumpermissions['modposts'] == 1 && !$ismod)
{
$visible = 0;

			}

			}

			else
{
$visible = 1;

			else
{
$visible = 1;

			}


			}


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

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

		}


		}


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

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

Zeile 1000Zeile 995
		else
{
$draft_check = false;

		else
{
$draft_check = false;

		}


		}


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

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

Zeile 1051Zeile 1046
					"visible" => $visible,
"merge" => true
);

					"visible" => $visible,
"merge" => true
);





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

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





				return $this->return_values;

				return $this->return_values;

			}
}

			}
}


if($visible == 1)


if($visible == 1)

		{
$now = TIME_NOW;


		{
$now = TIME_NOW;


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

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

Zeile 1072Zeile 1067
			}

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

			}

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

		}

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

			// Update a post that is a draft
$this->post_update_data = array(
"subject" => $db->escape_string($post['subject']),

			// Update a post that is a draft
$this->post_update_data = array(
"subject" => $db->escape_string($post['subject']),

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


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


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

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

Zeile 1266Zeile 1260
				}
elseif($subscribedmember['notification'] == 2)
{

				}
elseif($subscribedmember['notification'] == 2)
{

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

 
					$pm = array(
'subject' => array('pmsubject_subscription', $subject),

					$pm = array(
'subject' => array('pmsubject_subscription', $subject),

						'message' => array('pm_subscription', $subscribedmember['username'], $post['username'], $subject, $excerpt, $mybb->settings['bburl'], str_replace("&amp;", "&", get_thread_link($thread['tid'], 0, "newpost")), $thread['tid'], $post_code),

						'message' => array('pm_subscription', $subscribedmember['username'], $post['username'], $subject, $excerpt, $mybb->settings['bburl'], str_replace("&amp;", "&", get_thread_link($thread['tid'], 0, "newpost")), $thread['tid']),

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

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

Zeile 1479Zeile 1472

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

		{
$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'],

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

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



				"visible" => $visible
);

				"visible" => $visible
);

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


















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


$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 1530Zeile 1523
				"replies" => 0,
"visible" => $visible,
"notes" => ''

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

			);

			);


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



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


Zeile 1680Zeile 1673
						continue;
}
$done_users[$subscribedmember['uid']] = 1;

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





					$forumpermissions = forum_permissions($thread['fid'], $subscribedmember['uid']);
if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0)
{

					$forumpermissions = forum_permissions($thread['fid'], $subscribedmember['uid']);
if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0)
{

Zeile 1699Zeile 1692
						$uselang = $subscribedmember['language'];
}
else if($mybb->settings['bblanguage'])

						$uselang = $subscribedmember['language'];
}
else if($mybb->settings['bblanguage'])

					{

					{

						$uselang = $mybb->settings['bblanguage'];
}
else
{
$uselang = "english";

						$uselang = $mybb->settings['bblanguage'];
}
else
{
$uselang = "english";

					}

					}


if($uselang == $mybb->settings['bblanguage'])
{


if($uselang == $mybb->settings['bblanguage'])
{

Zeile 1743Zeile 1736
					}
$emailsubject = $lang->sprintf($emailsubject, $forum['name']);


					}
$emailsubject = $lang->sprintf($emailsubject, $forum['name']);


					$post_code = md5($subscribedmember['loginkey'].$subscribedmember['salt'].$subscribedmember['regdate']);
$emailmessage = $lang->sprintf($emailmessage, $subscribedmember['username'], $thread['username'], $forum['name'], $mybb->settings['bbname'], $thread['subject'], $excerpt, $mybb->settings['bburl'], get_thread_link($this->tid), $thread['fid'], $post_code);

					$emailmessage = $lang->sprintf($emailmessage, $subscribedmember['username'], $thread['username'], $forum['name'], $mybb->settings['bbname'], $thread['subject'], $excerpt, $mybb->settings['bburl'], get_thread_link($this->tid), $thread['fid']);


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

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

Zeile 1782Zeile 1774
			update_forum_lastpost($thread['fid']);
}
else if($visible == 0)

			update_forum_lastpost($thread['fid']);
}
else if($visible == 0)

		{

		{

			update_forum_counters($thread['fid'], array("unapprovedthreads" => "+1", "unapprovedposts" => "+1"));
}


			update_forum_counters($thread['fid'], array("unapprovedthreads" => "+1", "unapprovedposts" => "+1"));
}


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

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

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

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

 
			}

// Update any moved thread links to have corresponding new subject.
if(isset($post['subject']))
{
$query = $db->simple_select("threads", "tid, closed", "closed='moved|".$this->tid."'");
if($db->num_rows($query) > 0)
{
$update_data['subject'] = $db->escape_string($post['subject']);
while($result = $db->fetch_array($query))
{
$db->update_query("threads", $update_data, "tid='".(int)$result['tid']."'");
}
}

			}
}


			}
}