Vergleich inc/datahandlers/post.php - 1.4.0 - 1.4.4

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * $Id: post.php 4036 2008-07-24 11:35:12Z ZiNgaBuRgA $

 * $Id: post.php 4276 2008-11-23 03:01:33Z Tikitiki $

 */

// Disallow direct access to this file for security reasons

 */

// Disallow direct access to this file for security reasons

Zeile 309Zeile 309
		global $mybb, $db, $session;

$post = &$this->data;

		global $mybb, $db, $session;

$post = &$this->data;

 
		
// Are we starting a new thread?
if(!$post['tid'])
{
return true;
}

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

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

		{

		{

			return true;

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


Zeile 326Zeile 332
		if(trim($mybb->settings['postmergeuignore']) != "")
{
$gids = explode(',', $mybb->settings['postmergeuignore']);

		if(trim($mybb->settings['postmergeuignore']) != "")
{
$gids = explode(',', $mybb->settings['postmergeuignore']);

			array_walk($gids, 'intval');



			$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 363Zeile 369
		else if(trim($mybb->settings['postmergefignore']) != "" && $thread['fid'] == intval($mybb->settings['postmergefignore']))
{
return true;

		else if(trim($mybb->settings['postmergefignore']) != "" && $thread['fid'] == intval($mybb->settings['postmergefignore']))
{
return true;

		}

		}

		
if($simple_mode == true)

		
if($simple_mode == true)

		{

		{

			return false;

			return false;

		}

		}

		
if($post['uid'])
{

		
if($post['uid'])
{

Zeile 381Zeile 387
		
$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));
return $db->fetch_array($query);

		
$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));
return $db->fetch_array($query);

	}

	}


/**
* Verifies the image count.


/**
* Verifies the image count.

Zeile 393Zeile 399
		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']);

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

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

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





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

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

Zeile 449Zeile 455
		// Check if the post being replied to actually exists in this thread.
if($post['replyto'])
{

		// Check if the post being replied to actually exists in this thread.
if($post['replyto'])
{

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

			$query = $db->simple_select("posts", "pid", "pid='".intval($post['replyto'])."'");

			$valid_post = $db->fetch_array($query);
if(!$valid_post['pid'])

			$valid_post = $db->fetch_array($query);
if(!$valid_post['pid'])

			{

			{

				$post['replyto'] = 0;
}
else

				$post['replyto'] = 0;
}
else

Zeile 486Zeile 492
	function verify_post_icon()
{
global $cache;

	function verify_post_icon()
{
global $cache;





		$post = &$this->data;

// If we don't assign it as 0.

		$post = &$this->data;

// If we don't assign it as 0.

Zeile 521Zeile 527
	function validate_post()
{
global $mybb, $db, $plugins;

	function validate_post()
{
global $mybb, $db, $plugins;





		$post = &$this->data;
$time = TIME_NOW;

		$post = &$this->data;
$time = TIME_NOW;

		

		

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

		}

// Verify all post assets.

		}

// Verify all post assets.


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


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

		}


		}


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

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

		{

		{

			$this->verify_message();
$this->verify_image_count();
}

			$this->verify_message();
$this->verify_image_count();
}

Zeile 556Zeile 562
		}

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


Zeile 591Zeile 597
	 * @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;

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


$post = &$this->data;



$post = &$this->data;


Zeile 854Zeile 860
			// 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, s.subscriptionkey

			// 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, s.subscriptionkey

				FROM ".TABLE_PREFIX."threadsubscriptions s, ".TABLE_PREFIX."users u


				FROM ".TABLE_PREFIX."threadsubscriptions s
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=s.uid)

				WHERE s.notification='1' AND s.tid='{$post['tid']}'

				WHERE s.notification='1' AND s.tid='{$post['tid']}'

				AND u.uid=s.uid

 
				AND s.uid != '{$post['uid']}'
AND u.lastactive>'{$thread['lastpost']}'
");

				AND s.uid != '{$post['uid']}'
AND u.lastactive>'{$thread['lastpost']}'
");

Zeile 871Zeile 877
				{
$uselang = $subscribedmember['language'];
}

				{
$uselang = $subscribedmember['language'];
}

				elseif($mybb->settings['bblanguage'])

				elseif($mybb->settings['orig_bblanguage'])

				{

				{

					$uselang = $mybb->settings['bblanguage'];

					$uselang = $mybb->settings['orig_bblanguage'];

				}
else
{

				}
else
{

Zeile 901Zeile 907
					$emailmessage = $langcache[$uselang]['email_subscription'];
}
$emailsubject = $lang->sprintf($emailsubject, $subject);

					$emailmessage = $langcache[$uselang]['email_subscription'];
}
$emailsubject = $lang->sprintf($emailsubject, $subject);

				$emailmessage = $lang->sprintf($emailmessage, $subscribedmember['username'], $post['username'], $mybb->settings['bbname'], $subject, $excerpt, $mybb->settings['bburl'], get_thread_link($thread['tid'], 0, "newpost"), $thread['tid'], $subscribedmember['subscriptionkey']);

				$emailmessage = $lang->sprintf($emailmessage, $subscribedmember['username'], $post['username'], $mybb->settings['bbname'], $subject, $excerpt, $mybb->settings['bburl'], str_replace("&", "&", get_thread_link($thread['tid'], 0, "newpost")), $thread['tid'], $subscribedmember['subscriptionkey']);

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

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

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

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

		}

		}


$thread = &$this->data;



$thread = &$this->data;


Zeile 1072Zeile 1078

// 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" => intval($thread['icon']),

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

				"username" => $db->escape_string($thread['username']),
"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_by_ref("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']),


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

				"username" => $db->escape_string($thread['username']),
"dateline" => intval($thread['dateline']),
"message" => $db->escape_string($thread['message']),

Zeile 1159Zeile 1165
			if($thread['options']['subscriptionmethod'] != "" && $thread['uid'] > 0)
{
switch($thread['options']['subscriptionmethod'])

			if($thread['options']['subscriptionmethod'] != "" && $thread['uid'] > 0)
{
switch($thread['options']['subscriptionmethod'])

				{

				{

					case "instant":
$notification = 1;
break;

					case "instant":
$notification = 1;
break;

Zeile 1331Zeile 1337
		
if($visible == 1)
{

		
if($visible == 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($this->tid, array("attachmentcount" => "+{$attachmentcount}"));
}


 
			update_thread_data($this->tid);
update_forum_counters($thread['fid'], array("threads" => "+1", "posts" => "+1"));

			update_thread_data($this->tid);
update_forum_counters($thread['fid'], array("threads" => "+1", "posts" => "+1"));

		}

		}

		else if($visible == 0)
{
update_thread_data($this->tid);
update_thread_counters($thread['tid'], array("replies" => 0, "unapprovedposts" => 1));
update_forum_counters($thread['fid'], array("unapprovedthreads" => "+1", "unapprovedposts" => "+1"));

		else if($visible == 0)
{
update_thread_data($this->tid);
update_thread_counters($thread['tid'], array("replies" => 0, "unapprovedposts" => 1));
update_forum_counters($thread['fid'], array("unapprovedthreads" => "+1", "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($this->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 1375Zeile 1381
		}

$post = &$this->data;

		}

$post = &$this->data;





		$post['pid'] = intval($post['pid']);

$existing_post = get_post($post['pid']);

		$post['pid'] = intval($post['pid']);

$existing_post = get_post($post['pid']);

Zeile 1388Zeile 1394
		if($forum['mod_edit_posts'] == 1 && !is_moderator($post['fid'], "", $post['uid']))
{
if($existing_post['visible'] == 1)

		if($forum['mod_edit_posts'] == 1 && !is_moderator($post['fid'], "", $post['uid']))
{
if($existing_post['visible'] == 1)

			{

			{

				update_thread_data($existing_post['tid']);
update_thread_counters($existing_post['tid'], array('replies' => '-1', 'unapprovedposts' => '+1'));
update_forum_counters($existing_post['fid'], array('unapprovedthreads' => '+1', 'unapprovedposts' => '+1'));

				update_thread_data($existing_post['tid']);
update_thread_counters($existing_post['tid'], array('replies' => '-1', 'unapprovedposts' => '+1'));
update_forum_counters($existing_post['fid'], array('unapprovedthreads' => '+1', 'unapprovedposts' => '+1'));

Zeile 1401Zeile 1407
				}
}
$visible = 0;

				}
}
$visible = 0;

		}
else

		}
else

		{
if($existing_post['visible'] == 0)
{

		{
if($existing_post['visible'] == 0)
{

Zeile 1415Zeile 1421
				{
$db->write_query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum+1 WHERE uid='{$existing_post['uid']}'");
}

				{
$db->write_query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum+1 WHERE uid='{$existing_post['uid']}'");
}

			}

			}

			$visible = 1;
}


			$visible = 1;
}


Zeile 1429Zeile 1435
		$query = $db->simple_select("posts", "pid", "tid='".intval($post['tid'])."'", $options);
$first_post_check = $db->fetch_array($query);
if($first_post_check['pid'] == $post['pid'])

		$query = $db->simple_select("posts", "pid", "tid='".intval($post['tid'])."'", $options);
$first_post_check = $db->fetch_array($query);
if($first_post_check['pid'] == $post['pid'])

		{

		{

			$first_post = true;

			$first_post = true;

		}

		}

		else

		else

		{

		{

			$first_post = false;

			$first_post = false;

 
		}

if($existing_post['visible'] == 0)
{
$visible = 0;

		}

// Update the thread details that might have been changed first.
if($first_post)

		}

// Update the thread details that might have been changed first.
if($first_post)

		{
if($existing_post['visible'] == 0)
{
$visible = 0;
}


		{			






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

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

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

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

Zeile 1526Zeile 1532
		}
else
{

		}
else
{

			$db->delete_query("threadsubscriptions", "uid='{$post['uid']}' AND tid='{$post['tid']}'");

			$db->delete_query("threadsubscriptions", "uid='".intval($post['uid'])."' AND tid='".intval($post['tid'])."'");

		}

update_forum_lastpost($post['fid']);

		}

update_forum_lastpost($post['fid']);