Vergleich inc/datahandlers/post.php - 1.2.1 - 1.2.8

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 3Zeile 3
 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/eula.html

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html

 *

 *

 * $Id: post.php 2280 2006-09-27 12:21:17Z chris $

 * $Id: post.php 3030 2007-04-26 00:19:47Z Tikitiki $

 */

 */

 

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}


/*
EXAMPLE USE:


/*
EXAMPLE USE:

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

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

			if($post['options']['disablesmilies'] == "yes")
{
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;

// Parse the message.
$parser_options = array(
"allow_html" => $forum['allowhtml'],
"allow_mycode" => $forum['allowmycode'],
"allow_smilies" => $forum['allowmilies'],
"allow_imgcode" => $forum['allowimgcode']
);

$image_check = $parser->parse_message($post['message'], $parser_options);

// 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.
$this->set_error("too_many_images", array(1 => $image_count, 2 => $mybb->settings['maxpostimages']));
return false;
}

}
}
}

/**





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

// Parse the message.
$parser_options = array(
"allow_html" => $forum['allowhtml'],
"allow_mycode" => $forum['allowmycode'],
"allow_imgcode" => $forum['allowimgcode']
);

if($post['options']['disablesmilies'] != "yes")
{
$parser_options['allow_smilies'] = $forum['allowsmilies'];
}
else
{
$parser_options['allow_smilies'] = "no";
}

$image_check = $parser->parse_message($post['message'], $parser_options);

// 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.
$this->set_error("too_many_images", array(1 => $image_count, 2 => $mybb->settings['maxpostimages']));
return false;
}
}
}

/**

	* Verify the reply-to post.
*
* @return boolean True when valid, false when not valid.

	* Verify the reply-to post.
*
* @return boolean True when valid, false when not valid.

Zeile 380Zeile 390
			$query = $db->simple_select(TABLE_PREFIX."posts", "pid", "tid='{$post['tid']}'", $options);
$reply_to = $db->fetch_array($query);
$post['replyto'] = $reply_to['pid'];

			$query = $db->simple_select(TABLE_PREFIX."posts", "pid", "tid='{$post['tid']}'", $options);
$reply_to = $db->fetch_array($query);
$post['replyto'] = $reply_to['pid'];

		}


		}


		return true;
}


		return true;
}


Zeile 394Zeile 404
	{
global $cache;


	{
global $cache;


		$post = &$this->data;


		$post = &$this->data;


		// If we don't assign it as 0.
if(!$post['icon'] || $post['icon'] < 0)
{

		// If we don't assign it as 0.
if(!$post['icon'] || $post['icon'] < 0)
{

Zeile 433Zeile 443
		$time = time();

// Verify all post assets.

		$time = time();

// Verify all post assets.

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


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


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

		{

		{

			$this->verify_subject();

			$this->verify_subject();

		}


		}


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


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


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

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

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






		{

		{

			$this->verify_post_flooding();

			$this->verify_dateline();

		}

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

		}

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

Zeile 602Zeile 612
				$visible = 1;
}
}

				$visible = 1;
}
}

 
		
if($visible != -2)
{
$now = time();
if($forum['usepostcounts'] != "no")
{
$queryadd = ",postnum=postnum+1";
}
else
{
$queryadd = '';
}
$db->query("UPDATE ".TABLE_PREFIX."users SET lastpost='{$now}' {$queryadd} WHERE uid='{$post['uid']}'");
}



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


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

Zeile 618Zeile 643
				"uid" => $post['uid'],
"username" => $db->escape_string($post['username']),
"dateline" => intval($post['dateline']),

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

				"message" => $db->escape_string($post['message']),
"ipaddress" => $db->escape_string($post['ipaddress']),
"includesig" => $post['options']['signature'],
"smilieoff" => $post['options']['disablesmilies'],
"visible" => $visible,

				"message" => $db->escape_string($post['message']),
"ipaddress" => $db->escape_string($post['ipaddress']),
"includesig" => $post['options']['signature'],
"smilieoff" => $post['options']['disablesmilies'],
"visible" => $visible,

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


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


Zeile 685Zeile 710
				AND u.uid=f.uid
AND f.uid!='{$mybb->user['uid']}'
AND u.lastactive>'{$thread['lastpost']}'

				AND u.uid=f.uid
AND f.uid!='{$mybb->user['uid']}'
AND u.lastactive>'{$thread['lastpost']}'

			");
while($subscribedmember = $db->fetch_array($query))
{
if($done_users[$subscribedmember['uid']])
{
continue;
}
$done_users[$subscribedmember['uid']] = 1;
if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language']))
{
$uselang = $subscribedmember['language'];

			");
while($subscribedmember = $db->fetch_array($query))
{
if($done_users[$subscribedmember['uid']])
{
continue;
}
$done_users[$subscribedmember['uid']] = 1;
if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language']))
{
$uselang = $subscribedmember['language'];

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

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

Zeile 732Zeile 757
					"mailto" => $db->escape_string($subscribedmember['email']),
"mailfrom" => '',
"subject" => $db->escape_string($emailsubject),

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

					"message" => $db->escape_string($emailmessage)


					"message" => $db->escape_string($emailmessage),
"headers" => ''

				);
$db->insert_query(TABLE_PREFIX."mailqueue", $new_email);
unset($userlang);

				);
$db->insert_query(TABLE_PREFIX."mailqueue", $new_email);
unset($userlang);

Zeile 743Zeile 769
			{
$cache->updatemailqueue();
}

			{
$cache->updatemailqueue();
}

 
			$thread_update = array("replies" => "+1"); 

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

$thread_update['attachmentcount'] = "+{$attachmentcount}";


// Update forum count


// Update forum count

			update_thread_count($post['tid']);
update_forum_count($post['fid']);
$cache->updatestats();

			update_thread_counters($post['tid'], $thread_update); 
update_forum_counters($post['fid'], array("posts" => "+1"));


		}
// Post is stuck in moderation queue
else if($visible == 0)
{
// Update the unapproved posts count for the current thread and current forum

		}
// Post is stuck in moderation queue
else if($visible == 0)
{
// Update the unapproved posts count for the current thread and current forum

			update_thread_count($post['tid']);
update_forum_count($post['fid']);
}

if($visible != -2)
{
$now = time();
if($forum['usepostcounts'] != "no")
{
$queryadd = ",postnum=postnum+1";
}
else
{
$queryadd = '';
}
$db->query("UPDATE ".TABLE_PREFIX."users SET lastpost='{$now}' {$queryadd} WHERE uid='{$post['uid']}'");

			update_thread_counters($post['tid'], array("unapprovedposts" => "+1")); 
update_forum_counters($post['fid'], array("unapprovedposts" => "+1"));















		}

// 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 790Zeile 807
		$thread = &$this->data;

// Validate all thread assets.

		$thread = &$this->data;

// Validate all thread assets.

 
		
if(!$thread['savedraft'])
{
$this->verify_post_flooding();
}


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


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

Zeile 813Zeile 835
		}

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


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

if(!$thread['savedraft'])

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






		{

		{

			$this->verify_post_flooding();

			$this->verify_options();

		}

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

		}

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

Zeile 852Zeile 869

// 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 874Zeile 891
		// Thread is being made now and we have a bit to do.
else
{

		// Thread is being made now and we have a bit to do.
else
{


// Fetch the permissions for this user
$user_permisions = user_permissions($thread['uid']);

 

// Decide on the visibility of this post.


// Decide on the visibility of this post.

			if($forum['modposts'] == "yes" && is_moderator($thread['fid'], "", $thread['uid']) != "yes")

			if(($forum['modthreads'] == "yes" || $forum['modposts'] == "yes") && is_moderator($thread['fid'], "", $thread['uid']) != "yes")

			{
$visible = 0;
}

			{
$visible = 0;
}

Zeile 892Zeile 906
		// Have a post ID but not a thread ID - fetch thread ID
if($thread['pid'] && !$thread['tid'])
{

		// Have a post ID but not a thread ID - fetch thread ID
if($thread['pid'] && !$thread['tid'])
{

			$db->simple_select(TABLE_PREFIX."posts", "tid", "pid='{$thread['pid']}");

			$query = $db->simple_select(TABLE_PREFIX."posts", "tid", "pid='{$thread['pid']}");

			$thread['tid'] = $db->fetch_field($query, "tid");
}


			$thread['tid'] = $db->fetch_field($query, "tid");
}


Zeile 901Zeile 915

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

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

				"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(TABLE_PREFIX."threads", $this->thread_insert_data, "tid='{$thread['tid']}'");

			$db->update_query(TABLE_PREFIX."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']),


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

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

Zeile 949Zeile 963
				"lastposter" => $db->escape_string($thread['username']),
"views" => 0,
"replies" => 0,

				"lastposter" => $db->escape_string($thread['username']),
"views" => 0,
"replies" => 0,

				"visible" => $visible


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

			);

			);





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

$db->insert_query(TABLE_PREFIX."threads", $this->thread_insert_data);

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

$db->insert_query(TABLE_PREFIX."threads", $this->thread_insert_data);

Zeile 984Zeile 999

// If we're not saving a draft there are some things we need to check now
if(!$thread['savedraft'])


// If we're not saving a draft there are some things we need to check now
if(!$thread['savedraft'])

		{

// Automatic subscription to the thread
if($thread['options']['emailnotify'] != "no" && $thread['uid'] > 0)
{
$favoriteadd = array(
"uid" => intval($thread['uid']),
"tid" => intval($this->tid),
"type" => "s"
);
$db->insert_query(TABLE_PREFIX."favorites", $favoriteadd);
}


		{

// Automatically subscribe the user to this thread if they've chosen to.
if($thread['options']['emailnotify'] != "no" && $thread['uid'] > 0)
{
$insert_favorite = array(
'uid' => intval($thread['uid']),
'tid' => $this->tid,
'type' => 's'
);
$db->insert_query(TABLE_PREFIX.'favorites', $insert_favorite);
}


			// Perform any selected moderation tools.
if(is_moderator($thread['fid'], "", $thread['uid']) == "yes" && is_array($thread['modoptions']))
{

			// Perform any selected moderation tools.
if(is_moderator($thread['fid'], "", $thread['uid']) == "yes" && is_array($thread['modoptions']))
{

Zeile 1030Zeile 1045
						SET $newclosed$sep$newstick
WHERE tid='{$this->tid}'
");

						SET $newclosed$sep$newstick
WHERE tid='{$this->tid}'
");

				}
}

				}
}

			// If we have a registered user then update their post count and last post times.
if($thread['uid'] > 0)
{

			// If we have a registered user then update their post count and last post times.
if($thread['uid'] > 0)
{

Zeile 1049Zeile 1064
				}

// Only update the table if we need to.

				}

// Only update the table if we need to.

				if(is_array($update_query))

				if(!empty($update_query))

				{
$update_query = implode(", ", $update_query);
$db->query("UPDATE ".TABLE_PREFIX."users SET $update_query WHERE uid='".$thread['uid']."'");

				{
$update_query = implode(", ", $update_query);
$db->query("UPDATE ".TABLE_PREFIX."users SET $update_query WHERE uid='".$thread['uid']."'");

Zeile 1113Zeile 1128
					"mailto" => $db->escape_string($subscribedmember['email']),
"mailfrom" => '',
"subject" => $db->escape_string($emailsubject),

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

					"message" => $db->escape_string($emailmessage)


					"message" => $db->escape_string($emailmessage),
"headers" => ''

				);
$db->insert_query(TABLE_PREFIX."mailqueue", $new_email);
unset($userlang);

				);
$db->insert_query(TABLE_PREFIX."mailqueue", $new_email);
unset($userlang);

Zeile 1124Zeile 1140
			{
$cache->updatemailqueue();
}

			{
$cache->updatemailqueue();
}

			// Automatically subscribe the user to this thread if they've chosen to.
if($thread['options']['emailnotify'] != "no" && $thread['uid'] > 0)
{
$insert_favorite = array(
'uid' => intval($thread['uid']),
'tid' => $this->tid,
'type' => 's'
);
$db->insert_query(TABLE_PREFIX.'favorites', $insert_favorite);
}
}


		}












		// Assign any uploaded attachments with the specific posthash to the newly created post.
if($thread['posthash'])

		// Assign any uploaded attachments with the specific posthash to the newly created post.
if($thread['posthash'])

		{

		{

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

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

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


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


		// Thread is public - update the forum counts.
if($visible == 1 || $visible == 0)
{
$cache->updatestats();
update_thread_count($this->tid);
update_forum_count($thread['fid']);












		$query = $db->simple_select(TABLE_PREFIX."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}"));
}

if($visible == 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"));

		}

// 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 1292Zeile 1309
		{
$db->delete_query(TABLE_PREFIX."favorites", "type='s' AND uid='{$post['uid']}' AND tid='{$post['tid']}'");
}

		{
$db->delete_query(TABLE_PREFIX."favorites", "type='s' AND uid='{$post['uid']}' AND tid='{$post['tid']}'");
}

		update_thread_attachment_count($post['tid']);

 




		update_forum_count($post['fid']);

		update_forum_lastpost($post['fid']);

	}
}
?>

	}
}
?>