Vergleich inc/datahandlers/post.php - 1.2.0 - 1.2.14

  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 2180 2006-09-02 07:36:22Z chris $

 * $Id: post.php 4005 2008-07-10 17:53:25Z 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 60Zeile 66

/**
* Array of data used to update a post.


/**
* Array of data used to update a post.

	 *
* @var array
*/

	 *
* @var array
*/

	var $post_update_data = array();

	var $post_update_data = array();


/**


/**

	 * Post ID currently being manipulated by the datahandlers.

	 * Post ID currently being manipulated by the datahandlers.

	 *

	 *

	 * @var int

	 * @var int

	 */

	 */

	var $pid = 0;

/**

	var $pid = 0;

/**

Zeile 78Zeile 84
	 * @var array
*/
var $thread_insert_data = array();

	 * @var array
*/
var $thread_insert_data = array();


/**


/**

	 * Array of data used to update a thread.
*
* @var array
*/
var $thread_update_data = array();

	 * Array of data used to update a thread.
*
* @var array
*/
var $thread_update_data = array();


/**


/**

	 * Thread ID currently being manipulated by the datahandlers.

	 * Thread ID currently being manipulated by the datahandlers.

	 *

	 *

	 * @var int
*/
var $tid = 0;

	 * @var int
*/
var $tid = 0;

Zeile 97Zeile 103
	 * Verifies the author of a post and fetches the username if necessary.
*
* @return boolean True if the author information is valid, false if invalid.

	 * Verifies the author of a post and fetches the username if necessary.
*
* @return boolean True if the author information is valid, false if invalid.

	 */

	 */

	function verify_author()
{
global $mybb;

	function verify_author()
{
global $mybb;

Zeile 106Zeile 112

// Don't have a user ID at all - not good (note, a user id of 0 will still work).
if(!isset($post['uid']))


// Don't have a user ID at all - not good (note, a user id of 0 will still work).
if(!isset($post['uid']))

		{

		{

			$this->set_error("invalid_user_id");
return false;
}

			$this->set_error("invalid_user_id");
return false;
}

Zeile 115Zeile 121
		{
$user = get_user($post['uid']);
$post['username'] = $user['username'];

		{
$user = get_user($post['uid']);
$post['username'] = $user['username'];

		}

		}


// After all of this, if we still don't have a username, force the username as "Guest" (Note, this is not translatable as it is always a fallback)
if(!$post['username'])


// After all of this, if we still don't have a username, force the username as "Guest" (Note, this is not translatable as it is always a fallback)
if(!$post['username'])

Zeile 125Zeile 131

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


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

 
		

		return true;
}


		return true;
}


Zeile 151Zeile 158
				$post['tid'] = $db->fetch_field($query, "tid");
}
// Here we determine if we're editing the first post of a thread or not.

				$post['tid'] = $db->fetch_field($query, "tid");
}
// Here we determine if we're editing the first post of a thread or not.

			$options = array(

			$options = array(

				"limit" => 1,
"limit_start" => 0,
"order_by" => "dateline",

				"limit" => 1,
"limit_start" => 0,
"order_by" => "dateline",

Zeile 202Zeile 209
		}

// Subject is valid - return true.

		}

// Subject is valid - return true.

		return true;
}

/**

		return true;
}

/**

	 * Verifies a post message.
*
* @param string The message content.

	 * Verifies a post message.
*
* @param string The message content.

Zeile 221Zeile 228
		if(my_strlen($post['message']) == 0)
{
$this->set_error("missing_message");

		if(my_strlen($post['message']) == 0)
{
$this->set_error("missing_message");

			return false;
}


			return false;
}


		// If this board has a maximum message length check if we're over it.
else if(my_strlen($post['message']) > $mybb->settings['maxmessagelength'] && $mybb->settings['maxmessagelength'] > 0 && is_moderator($post['fid'], "", $post['uid']) != "yes")
{

		// If this board has a maximum message length check if we're over it.
else if(my_strlen($post['message']) > $mybb->settings['maxmessagelength'] && $mybb->settings['maxmessagelength'] > 0 && is_moderator($post['fid'], "", $post['uid']) != "yes")
{

Zeile 259Zeile 266

/**
* Verify that the user is not flooding the system.


/**
* Verify that the user is not flooding the system.

	*

	*

	* @return boolean True
*/
function verify_post_flooding()

	* @return boolean True
*/
function verify_post_flooding()

Zeile 296Zeile 303

/**
* 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 313Zeile 320

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


/**
* Verify the reply-to post.

Zeile 386Zeile 397

/**
* Verify the post icon.


/**
* Verify the post icon.

	*

	*

	* @return boolean True when valid, false when not valid.
*/
function verify_post_icon()
{
global $cache;

	* @return boolean True when valid, false when not valid.
*/
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 401Zeile 412
			$post['icon'] = 0;
}
return true;

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

	}

	}


/**
* Verify the dateline.


/**
* Verify the dateline.

Zeile 416Zeile 427
		if($dateline < 0 || is_numeric($dateline) == false)
{
$dateline = time();

		if($dateline < 0 || is_numeric($dateline) == false)
{
$dateline = time();

		}

		}

	}

	}





	/**
* Validate a post.
*

	/**
* Validate a post.
*

Zeile 432Zeile 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))
{


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

Zeile 454Zeile 470
			$this->verify_dateline();
}


			$this->verify_dateline();
}


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

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

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

		{

		{

			$this->verify_post_icon();
}

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

			$this->verify_post_icon();
}

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

		{

		{

			$this->verify_options();

			$this->verify_options();

		}


		}


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

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

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

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

		{

		{

			return false;

			return false;

		}

		}

		else
{
return true;
}
}


		else
{
return true;
}
}






	/**
* Insert a post into the database.
*

	/**
* Insert a post into the database.
*

Zeile 522Zeile 533
			// Automatic subscription to the thread
if($post['options']['emailnotify'] != "no" && $post['uid'] > 0)
{

			// Automatic subscription to the thread
if($post['options']['emailnotify'] != "no" && $post['uid'] > 0)
{

				$query = $db->simple_select(TABLE_PREFIX."favorites", "fid", "tid='".intval($post['uid'])."' AND tid='".intval($post['tid'])."' AND type='s'", array("limit" => 1));

				$query = $db->simple_select(TABLE_PREFIX."favorites", "fid", "uid='".intval($post['uid'])."' AND tid='".intval($post['tid'])."' AND type='s'", array("limit" => 1));

				$already_subscribed = $db->fetch_field($query, "fid");
if(!$already_subscribed)
{

				$already_subscribed = $db->fetch_field($query, "fid");
if(!$already_subscribed)
{

Zeile 536Zeile 547
			}

// Perform any selected moderation tools.

			}

// Perform any selected moderation tools.

			if(is_moderator($post['fid'], "", $post['uid']) == "yes" && $post['modoptions'])

			if(is_moderator($post['fid'], "", $post['uid']) == "yes")

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

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

Zeile 571Zeile 582
				{
$newstick = "sticky='0'";
log_moderator_action($modlogdata, "Thread unstuck");

				{
$newstick = "sticky='0'";
log_moderator_action($modlogdata, "Thread unstuck");

				}


				}


				// Execute moderation options.
if($newstick && $newclosed)
{

				// Execute moderation options.
if($newstick && $newclosed)
{

Zeile 582Zeile 593
				{
$db->query("
UPDATE ".TABLE_PREFIX."threads

				{
$db->query("
UPDATE ".TABLE_PREFIX."threads

						SET $newclosed$sep$newstick

						SET {$newclosed}{$sep}{$newstick}

						WHERE tid='{$thread['tid']}'
");
}

						WHERE tid='{$thread['tid']}'
");
}

			}


			}


			// Fetch the forum this post is being made in

			// Fetch the forum this post is being made in

			$forum = get_forum($post['fid']);

// Decide on the visibility of this post.
if($forum['modposts'] == "yes" && is_moderator($thread['fid'], "", $thread['uid']) != "yes")
{
$visible = 0;
}














			$forum = get_forum($post['fid']);

// Decide on the visibility of this post.
if($forum['modposts'] == "yes" && is_moderator($thread['fid'], "", $thread['uid']) != "yes")
{
$visible = 0;
}
else
{
$visible = 1;
}
}

if($visible == 1)
{
$now = time();
if($forum['usepostcounts'] != "no")
{
$queryadd = ",postnum=postnum+1";
}

			else
{

			else
{

				$visible = 1;

				$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']);
$query = $db->simple_select(TABLE_PREFIX."posts", "tid", "pid='{$post['pid']}' AND uid='{$post['uid']}' AND visible='-2'");
$draft_check = $db->fetch_field($query, "tid");


$post['pid'] = intval($post['pid']);
$post['uid'] = intval($post['uid']);
$query = $db->simple_select(TABLE_PREFIX."posts", "tid", "pid='{$post['pid']}' AND uid='{$post['uid']}' AND visible='-2'");
$draft_check = $db->fetch_field($query, "tid");





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

Zeile 617Zeile 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,
"posthash" => $db->escape_string($post['posthash'])
);

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


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



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


Zeile 671Zeile 697
			$thread = get_thread($post['tid']);
require_once MYBB_ROOT.'inc/class_parser.php';
$parser = new Postparser();

			$thread = get_thread($post['tid']);
require_once MYBB_ROOT.'inc/class_parser.php';
$parser = new Postparser();

 

$done_users = array();


$subject = $parser->parse_badwords($thread['subject']);
$excerpt = $parser->strip_mycode($post['message']);
$excerpt = my_substr($excerpt, 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;


$subject = $parser->parse_badwords($thread['subject']);
$excerpt = $parser->strip_mycode($post['message']);
$excerpt = my_substr($excerpt, 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;








// Parse badwords
$excerpt = $parser->parse_badwords($excerpt);



			// Fetch any users subscribed to this thread and queue up their subscription notices
$query = $db->query("
SELECT u.username, u.email, u.uid, u.language

			// Fetch any users subscribed to this thread and queue up their subscription notices
$query = $db->query("
SELECT u.username, u.email, u.uid, u.language

Zeile 709Zeile 741
				{
$emailsubject = $lang->emailsubject_subscription;
$emailmessage = $lang->email_subscription;

				{
$emailsubject = $lang->emailsubject_subscription;
$emailmessage = $lang->email_subscription;

				}

				}

				else
{
if(!isset($langcache[$uselang]['emailsubject_subscription']))

				else
{
if(!isset($langcache[$uselang]['emailsubject_subscription']))

Zeile 727Zeile 759
				}
$emailsubject = sprintf($emailsubject, $subject);
$emailmessage = sprintf($emailmessage, $subscribedmember['username'], $post['username'], $mybb->settings['bbname'], $subject, $excerpt, $mybb->settings['bburl'], $thread['tid']);

				}
$emailsubject = sprintf($emailsubject, $subject);
$emailmessage = sprintf($emailmessage, $subscribedmember['username'], $post['username'], $mybb->settings['bbname'], $subject, $excerpt, $mybb->settings['bburl'], $thread['tid']);

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


				$new_email = array(
"mailto" => $db->escape_string($subscribedmember['email']),
"mailfrom" => '',
"subject" => $db->escape_string($emailsubject),
"message" => $db->escape_string($emailmessage),
"headers" => ''

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

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

			}

			}

			// Have one or more emails been queued? Update the queue count
if($queued_email == 1)
{
$cache->updatemailqueue();
}

			// Have one or more emails been queued? Update the queue count
if($queued_email == 1)
{
$cache->updatemailqueue();
}

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


// 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 array(
"pid" => $this->pid,

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

Zeile 785Zeile 804
	function validate_thread()
{
global $mybb, $db, $plugins;

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


$thread = &$this->data;



$thread = &$this->data;


		// Validate all thread assets.

		// Validate all thread assets.

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


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


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

		}


		}


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

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

		{

		{

			$this->verify_subject();
}

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

			$this->verify_subject();
}

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

		{

		{

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

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

		}


		}


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

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

		{

		{

			$this->verify_dateline();

			$this->verify_dateline();

		}

		}


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($this->method == "insert" || array_key_exists('options', $thread))
{
$this->verify_options();

		}

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

		}







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



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


Zeile 857Zeile 876
		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;


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

		// 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 891Zeile 907
		// 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 900Zeile 916

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

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


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


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

				"ipaddress" => $db->escape_string(get_ip()),
"includesig" => $thread['options']['signature'],
"smilieoff" => $thread['options']['disablesmilies'],

Zeile 938Zeile 954
		else
{
$this->thread_insert_data = array(

		else
{
$this->thread_insert_data = array(

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

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

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

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

Zeile 948Zeile 964
				"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);

			);

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

Zeile 977Zeile 994
			$this->pid = $db->insert_id();

// Now that we have the post id for this first post, update the threads table.

			$this->pid = $db->insert_id();

// Now that we have the post id for this first post, update the threads table.

			$firstpostup = array("firstpost" => $pid);
$db->update_query(TABLE_PREFIX."threads", $firstpostup, "tid='{$tid}'");

			$firstpostup = array("firstpost" => $this->pid);
$db->update_query(TABLE_PREFIX."threads", $firstpostup, "tid='{$this->tid}'");

		}

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

			// Automatically subscribe the user to this thread if they've chosen to.

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

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

				$favoriteadd = array(
"uid" => intval($thread['uid']),
"tid" => intval($this->tid),
"type" => "s"

				$insert_favorite = array(
'uid' => intval($thread['uid']),
'tid' => $this->tid,
'type' => 's'

				);

				);

				$db->insert_query(TABLE_PREFIX."favorites", $favoriteadd);
}

				$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 1012Zeile 1029

// Stick the thread.
if($modoptions['stickthread'] == "yes")


// Stick the thread.
if($modoptions['stickthread'] == "yes")

				{

				{

					$newstick = "sticky='1'";
log_moderator_action($modlogdata, "Thread stuck");

					$newstick = "sticky='1'";
log_moderator_action($modlogdata, "Thread stuck");

				}


				}


				// Execute moderation options.
if($newstick && $newclosed)
{

				// Execute moderation options.
if($newstick && $newclosed)
{

Zeile 1031Zeile 1048
					");
}
}

					");
}
}

			// If we have a registered user then update their post count and last post times.
if($thread['uid'] > 0)
{
$user = get_user($thread['uid']);
$update_query = array();
// Only update the lastpost column of the user if the date of the thread is newer than their last post.
if($thread['dateline'] > $user['lastpost'])
{
$update_query[] = "lastpost='".$thread['dateline']."'";
}
// Update the post count if this forum allows post counts to be tracked
if($forum['usepostcounts'] != "no")
{
$update_query[] = "postnum=postnum+1";
}

// Only update the table if we need to.
if(is_array($update_query))
{
$update_query = implode(", ", $update_query);
$db->query("UPDATE ".TABLE_PREFIX."users SET $update_query WHERE uid='".$thread['uid']."'");
}
}

// Queue up any forum subscription notices to users who are subscribed to this forum.
$excerpt = my_substr($thread['message'], 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;
$query = $db->query("
SELECT u.username, u.email, u.uid, u.language
FROM ".TABLE_PREFIX."forumsubscriptions fs, ".TABLE_PREFIX."users u
WHERE fs.fid='".intval($thread['fid'])."'
AND u.uid=fs.uid
AND fs.uid!='".intval($thread['uid'])."'
AND u.lastactive>'{$forum['lastpost']}'
");
while($subscribedmember = $db->fetch_array($query))

			
if($visible == 1)


































			{

			{

				if($done_users[$subscribedmember['uid']])
{
continue;
}
$done_users[$subscribedmember['uid']] = 1;
// Determine the language pack we'll be using to send this email in and load it if it isn't already.
if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language']))
{
$uselang = $subscribedmember['language'];
}
else if($mybb->settings['bblanguage'])
{
$uselang = $mybb->settings['bblanguage'];
}
else
{
$uselang = "english";






				// If we have a registered user then update their post count and last post times.
if($thread['uid'] > 0)
{
$user = get_user($thread['uid']);
$update_query = array();
// Only update the lastpost column of the user if the date of the thread is newer than their last post.
if($thread['dateline'] > $user['lastpost'])
{
$update_query[] = "lastpost='".$thread['dateline']."'";
}
// Update the post count if this forum allows post counts to be tracked
if($forum['usepostcounts'] != "no")
{
$update_query[] = "postnum=postnum+1";
}

// Only update the table if we need to.
if(!empty($update_query))
{
$update_query = implode(", ", $update_query);
$db->query("UPDATE ".TABLE_PREFIX."users SET $update_query WHERE uid='".$thread['uid']."'");
}

				}


				}


				if($uselang == $mybb->settings['bblanguage'])
{
$emailsubject = $lang->emailsubject_forumsubscription;
$emailmessage = $lang->email_forumsubscription;
}
else












				// Queue up any forum subscription notices to users who are subscribed to this forum.
$excerpt = my_substr($thread['message'], 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;

// Parse badwords
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
$excerpt = $parser->parse_badwords($excerpt);

$query = $db->query("
SELECT u.username, u.email, u.uid, u.language
FROM ".TABLE_PREFIX."forumsubscriptions fs, ".TABLE_PREFIX."users u
WHERE fs.fid='".intval($thread['fid'])."'
AND u.uid=fs.uid
AND fs.uid!='".intval($thread['uid'])."'
AND u.lastactive>'{$forum['lastpost']}'
");
while($subscribedmember = $db->fetch_array($query))

				{

				{

					if(!isset($langcache[$uselang]['emailsubject_forumsubscription']))

					if($done_users[$subscribedmember['uid']])

					{

					{

						$userlang = new MyLanguage;
$userlang->set_path(MYBB_ROOT."inc/languages");
$userlang->set_language($uselang);
$userlang->load("messages");
$langcache[$uselang]['emailsubject_forumsubscription'] = $userlang->emailsubject_forumsubscription;
$langcache[$uselang]['email_forumsubscription'] = $userlang->email_forumsubscription;
unset($userlang);

						continue;







					}

					}

					$emailsubject = $langcache[$uselang]['emailsubject_forumsubscription'];
$emailmessage = $langcache[$uselang]['email_forumsubscription'];
}
$emailsubject = sprintf($emailsubject, $forum['name']);
$emailmessage = sprintf($emailmessage, $subscribedmember['username'], $thread['username'], $forum['name'], $mybb->settings['bbname'], $thread['subject'], $excerpt, $mybb->settings['bburl'], $this->tid, $thread['fid']);
$new_email = array(
"mailto" => $db->escape_string($subscribedmember['email']),
"mailfrom" => '',
"subject" => $db->escape_string($emailsubject),
"message" => $db->escape_string($emailmessage)
);
$db->insert_query(TABLE_PREFIX."mailqueue", $new_email);
unset($userlang);
$queued_email = 1;
}
// Have one or more emails been queued? Update the queue count
if($queued_email == 1)
{
$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);

























					$done_users[$subscribedmember['uid']] = 1;
// Determine the language pack we'll be using to send this email in and load it if it isn't already.
if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language']))
{
$uselang = $subscribedmember['language'];
}
else if($mybb->settings['bblanguage'])
{
$uselang = $mybb->settings['bblanguage'];
}
else
{
$uselang = "english";
}

if($uselang == $mybb->settings['bblanguage'])
{
$emailsubject = $lang->emailsubject_forumsubscription;
$emailmessage = $lang->email_forumsubscription;
}
else
{
if(!isset($langcache[$uselang]['emailsubject_forumsubscription']))
{
$userlang = new MyLanguage;
$userlang->set_path(MYBB_ROOT."inc/languages");
$userlang->set_language($uselang);
$userlang->load("messages");
$langcache[$uselang]['emailsubject_forumsubscription'] = $userlang->emailsubject_forumsubscription;
$langcache[$uselang]['email_forumsubscription'] = $userlang->email_forumsubscription;
unset($userlang);
}
$emailsubject = $langcache[$uselang]['emailsubject_forumsubscription'];
$emailmessage = $langcache[$uselang]['email_forumsubscription'];
}
$emailsubject = sprintf($emailsubject, $forum['name']);
$emailmessage = sprintf($emailmessage, $subscribedmember['username'], $thread['username'], $forum['name'], $mybb->settings['bbname'], $thread['subject'], $excerpt, $mybb->settings['bburl'], $this->tid, $thread['fid']);
$new_email = array(
"mailto" => $db->escape_string($subscribedmember['email']),
"mailfrom" => '',
"subject" => $db->escape_string($emailsubject),
"message" => $db->escape_string($emailmessage),
"headers" => ''
);
$db->insert_query(TABLE_PREFIX."mailqueue", $new_email);
unset($userlang);
$queued_email = 1;
}
// Have one or more emails been queued? Update the queue count
if($queued_email == 1)
{
$cache->updatemailqueue();
}

			}
}


			}
}


Zeile 1145Zeile 1163
			$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']);












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

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 1158Zeile 1187
			"pid" => $this->pid,
"tid" => $this->tid,
"visible" => $visible

			"pid" => $this->pid,
"tid" => $this->tid,
"visible" => $visible

		);

		);

	}

/**

	}

/**

Zeile 1212Zeile 1241
		if($first_post)
{
$this->tid = $post['tid'];

		if($first_post)
{
$this->tid = $post['tid'];





			if(isset($post['subject']))
{
$this->thread_update_data['subject'] = $db->escape_string($post['subject']);

			if(isset($post['subject']))
{
$this->thread_update_data['subject'] = $db->escape_string($post['subject']);

			}


			}


			if(isset($post['icon']))

			if(isset($post['icon']))

			{

			{

				$this->thread_update_data['icon'] = intval($post['icon']);

				$this->thread_update_data['icon'] = intval($post['icon']);

			}

			}

			if(count($this->thread_update_data) > 0)
{
$plugins->run_hooks_by_ref("datahandler_post_update_thread", $this);

			if(count($this->thread_update_data) > 0)
{
$plugins->run_hooks_by_ref("datahandler_post_update_thread", $this);





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

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

			}
}

// Prepare array for post updating.

			}
}

// Prepare array for post updating.


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


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





		if(isset($post['subject']))

		if(isset($post['subject']))

		{

		{

			$this->post_update_data['subject'] = $db->escape_string($post['subject']);

			$this->post_update_data['subject'] = $db->escape_string($post['subject']);

		}

		}


if(isset($post['message']))
{


if(isset($post['message']))
{

Zeile 1247Zeile 1276
		if(isset($post['icon']))
{
$this->post_update_data['icon'] = intval($post['icon']);

		if(isset($post['icon']))
{
$this->post_update_data['icon'] = intval($post['icon']);

		}


		}


		if(isset($post['options']))
{
if(isset($post['options']['disablesmilies']))

		if(isset($post['options']))
{
if(isset($post['options']['disablesmilies']))

Zeile 1259Zeile 1288
			{
$this->post_update_data['includesig'] = $db->escape_string($post['options']['signature']);
}

			{
$this->post_update_data['includesig'] = $db->escape_string($post['options']['signature']);
}

		}


		}


		// If we need to show the edited by, let's do so.
if(($mybb->settings['showeditedby'] == "yes" && is_moderator($post['fid'], "caneditposts", $post['edit_uid']) != "yes") || ($mybb->settings['showeditedbyadmin'] == "yes" && is_moderator($post['fid'], "caneditposts", $post['edit_uid']) == "yes"))
{
$this->post_update_data['edituid'] = intval($post['edit_uid']);
$this->post_update_data['edittime'] = time();
}

		// If we need to show the edited by, let's do so.
if(($mybb->settings['showeditedby'] == "yes" && is_moderator($post['fid'], "caneditposts", $post['edit_uid']) != "yes") || ($mybb->settings['showeditedbyadmin'] == "yes" && is_moderator($post['fid'], "caneditposts", $post['edit_uid']) == "yes"))
{
$this->post_update_data['edituid'] = intval($post['edit_uid']);
$this->post_update_data['edittime'] = time();
}



		

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

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

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

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

Zeile 1291Zeile 1320
		{
$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']);

	}
}
?>

	}
}
?>