Vergleich xmlhttp.php - 1.6.7 - 1.6.16

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * $Id: xmlhttp.php 5641 2011-10-26 09:36:44Z Tomm $

 * $Id$

 */

/**

 */

/**

Zeile 18Zeile 18
 * This is done to make response times when using XML HTTP Requests faster and
* less intense on the server.
*/

 * This is done to make response times when using XML HTTP Requests faster and
* less intense on the server.
*/

 
define("IN_MYBB", 1);


define("IN_MYBB", 1);


// We don't want visits here showing up on the Who's Online
define("NO_ONLINE", 1);


// We don't want visits here showing up on the Who's Online
define("NO_ONLINE", 1);





define('THIS_SCRIPT', 'xmlhttp.php');

// Load MyBB core files
require_once dirname(__FILE__)."/inc/init.php";

$shutdown_queries = array();

define('THIS_SCRIPT', 'xmlhttp.php');

// Load MyBB core files
require_once dirname(__FILE__)."/inc/init.php";

$shutdown_queries = array();





// Load some of the stock caches we'll be using.
$groupscache = $cache->read("usergroups");


// Load some of the stock caches we'll be using.
$groupscache = $cache->read("usergroups");


Zeile 63Zeile 63
$lang->set_language($mybb->settings['bblanguage']);

if(function_exists('mb_internal_encoding') && !empty($lang->settings['charset']))

$lang->set_language($mybb->settings['bblanguage']);

if(function_exists('mb_internal_encoding') && !empty($lang->settings['charset']))

{

{

	@mb_internal_encoding($lang->settings['charset']);
}


	@mb_internal_encoding($lang->settings['charset']);
}


Zeile 98Zeile 98
		$theme['imglangdir'] = $theme['imgdir'];
}
}

		$theme['imglangdir'] = $theme['imgdir'];
}
}

 

$templatelist = "postbit_editedby,xmlhttp_inline_post_editor,xmlhttp_buddyselect_online,xmlhttp_buddyselect_offline,xmlhttp_buddyselect";
$templates->cache($db->escape_string($templatelist));


if($lang->settings['charset'])


if($lang->settings['charset'])

{

{

	$charset = $lang->settings['charset'];
}
// If not, revert to UTF-8
else
{
$charset = "UTF-8";

	$charset = $lang->settings['charset'];
}
// If not, revert to UTF-8
else
{
$charset = "UTF-8";

}


}


$lang->load("global");
$lang->load("xmlhttp");

$lang->load("global");
$lang->load("xmlhttp");





$plugins->run_hooks("xmlhttp");

// Fetch a list of usernames beginning with a certain string (used for auto completion)
if($mybb->input['action'] == "get_users")

$plugins->run_hooks("xmlhttp");

// Fetch a list of usernames beginning with a certain string (used for auto completion)
if($mybb->input['action'] == "get_users")

{
// If the string is less than 3 characters, quit.
if(my_strlen($mybb->input['query']) < 3)

{
// If the string is less than 3 characters, quit.
if(my_strlen($mybb->input['query']) < 3)

	{
exit;
}

	{
exit;
}

	



	// Send our headers.
header("Content-type: text/plain; charset={$charset}");


	// Send our headers.
header("Content-type: text/plain; charset={$charset}");


	// Sanitize the input.
$mybb->input['query'] = str_replace(array("%", "_"), array("\\%", "\\_"), $mybb->input['query']);


 
	// Query for any matching users.
$query_options = array(
"order_by" => "username",

	// Query for any matching users.
$query_options = array(
"order_by" => "username",

Zeile 136Zeile 136
		"limit_start" => 0,
"limit" => 15
);

		"limit_start" => 0,
"limit" => 15
);

	
$query = $db->simple_select("users", "uid, username", "username LIKE '".$db->escape_string($mybb->input['query'])."%'", $query_options);


$query = $db->simple_select("users", "uid, username", "username LIKE '".$db->escape_string_like($mybb->input['query'])."%'", $query_options);

	while($user = $db->fetch_array($query))
{
$user['username'] = htmlspecialchars_uni($user['username']);
// Send the result to the browser for this user.
echo "<div>\n";
echo "<span class=\"username\">{$user['username']}</span>\n";

	while($user = $db->fetch_array($query))
{
$user['username'] = htmlspecialchars_uni($user['username']);
// Send the result to the browser for this user.
echo "<div>\n";
echo "<span class=\"username\">{$user['username']}</span>\n";

		echo "</div>\n";

		echo "</div>\n";

	}
}
else if($mybb->input['action'] == "get_usergroups")

	}
}
else if($mybb->input['action'] == "get_usergroups")

Zeile 154Zeile 154
	{
exit;
}

	{
exit;
}

	



	// Send our headers.
header("Content-type: text/plain; charset={$charset}");

// Sanitize the input.
$mybb->input['query'] = str_replace(array("%", "_"), array("\\%", "\\_"), $mybb->input['query']);

	// Send our headers.
header("Content-type: text/plain; charset={$charset}");

// Sanitize the input.
$mybb->input['query'] = str_replace(array("%", "_"), array("\\%", "\\_"), $mybb->input['query']);

	



	// Query for any matching usergroups.
$query_options = array(
"order_by" => "title",

	// Query for any matching usergroups.
$query_options = array(
"order_by" => "title",

Zeile 168Zeile 168
		"limit_start" => 0,
"limit" => 15
);

		"limit_start" => 0,
"limit" => 15
);

	



	$query = $db->simple_select("usergroups", "gid, title", "title LIKE '".$db->escape_string($mybb->input['query'])."%'", $query_options);
while($group = $db->fetch_array($query))
{

	$query = $db->simple_select("usergroups", "gid, title", "title LIKE '".$db->escape_string($mybb->input['query'])."%'", $query_options);
while($group = $db->fetch_array($query))
{

Zeile 187Zeile 187
	{
xmlhttp_error($lang->invalid_post_code);
}

	{
xmlhttp_error($lang->invalid_post_code);
}

	



	// Editing a post subject.
if($mybb->input['pid'])
{
// Fetch the post from the database.
$post = get_post($mybb->input['pid']);

	// Editing a post subject.
if($mybb->input['pid'])
{
// Fetch the post from the database.
$post = get_post($mybb->input['pid']);

		



		// No result, die.
if(!$post['pid'])
{
xmlhttp_error($lang->post_doesnt_exist);
}

		// No result, die.
if(!$post['pid'])
{
xmlhttp_error($lang->post_doesnt_exist);
}

		



		// Fetch the thread associated with this post.
$thread = get_thread($post['tid']);
}

		// Fetch the thread associated with this post.
$thread = get_thread($post['tid']);
}

	



	// We're editing a thread subject.
else if($mybb->input['tid'])

	// We're editing a thread subject.
else if($mybb->input['tid'])

	{

	{

		// Fetch the thread.
$thread = get_thread($mybb->input['tid']);

		// Fetch the thread.
$thread = get_thread($mybb->input['tid']);

		



		// Fetch some of the information from the first post of this thread.
$query_options = array(
"order_by" => "dateline",

		// Fetch some of the information from the first post of this thread.
$query_options = array(
"order_by" => "dateline",

Zeile 226Zeile 226
	{
xmlhttp_error($lang->thread_doesnt_exist);
}

	{
xmlhttp_error($lang->thread_doesnt_exist);
}

	



	// Fetch forum permissions.
$forumpermissions = forum_permissions($forum['fid']);

	// Fetch forum permissions.
$forumpermissions = forum_permissions($forum['fid']);

	



	// If this user is not a moderator with "caneditposts" permissions.
if(!is_moderator($forum['fid'], "caneditposts"))

	// If this user is not a moderator with "caneditposts" permissions.
if(!is_moderator($forum['fid'], "caneditposts"))

	{

	{

		// Thread is closed - no editing allowed.
if($thread['closed'] == 1)
{

		// Thread is closed - no editing allowed.
if($thread['closed'] == 1)
{

Zeile 254Zeile 254
	else
{
$ismod = true;

	else
{
$ismod = true;

	}

	}

	$subject = $mybb->input['value'];
if(my_strtolower($charset) != "utf-8")
{

	$subject = $mybb->input['value'];
if(my_strtolower($charset) != "utf-8")
{

Zeile 270Zeile 270
		{
$subject = utf8_decode($subject);
}

		{
$subject = utf8_decode($subject);
}

	}	


	}


	// Set up posthandler.
require_once MYBB_ROOT."inc/datahandlers/post.php";
$posthandler = new PostDataHandler("update");

	// Set up posthandler.
require_once MYBB_ROOT."inc/datahandlers/post.php";
$posthandler = new PostDataHandler("update");

Zeile 301Zeile 301
		{
$modlogdata = array(
"tid" => $thread['tid'],

		{
$modlogdata = array(
"tid" => $thread['tid'],

				"pid" => $post['pid'],

 
				"fid" => $forum['fid']
);
log_moderator_action($modlogdata, $lang->edited_post);
}
}

				"fid" => $forum['fid']
);
log_moderator_action($modlogdata, $lang->edited_post);
}
}

	



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

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





	// Send our headers.
header("Content-type: text/plain; charset={$charset}");

	// Send our headers.
header("Content-type: text/plain; charset={$charset}");

	



	$mybb->input['value'] = $parser->parse_badwords($mybb->input['value']);

	$mybb->input['value'] = $parser->parse_badwords($mybb->input['value']);

	



	// Spit the subject back to the browser.
echo substr($mybb->input['value'], 0, 120); // 120 is the varchar length for the subject column

	// Spit the subject back to the browser.
echo substr($mybb->input['value'], 0, 120); // 120 is the varchar length for the subject column

	



	// Close the connection.
exit;
}
else if($mybb->input['action'] == "edit_post")

	// Close the connection.
exit;
}
else if($mybb->input['action'] == "edit_post")

{	

{

	// Fetch the post from the database.
$post = get_post($mybb->input['pid']);

	// Fetch the post from the database.
$post = get_post($mybb->input['pid']);

		



	// No result, die.
if(!$post['pid'])
{
xmlhttp_error($lang->post_doesnt_exist);
}

	// No result, die.
if(!$post['pid'])
{
xmlhttp_error($lang->post_doesnt_exist);
}

	



	// Fetch the thread associated with this post.
$thread = get_thread($post['tid']);


	// Fetch the thread associated with this post.
$thread = get_thread($post['tid']);


Zeile 344Zeile 343
	{
xmlhttp_error($lang->thread_doesnt_exist);
}

	{
xmlhttp_error($lang->thread_doesnt_exist);
}

	



	// Fetch forum permissions.
$forumpermissions = forum_permissions($forum['fid']);

	// Fetch forum permissions.
$forumpermissions = forum_permissions($forum['fid']);

	



	// If this user is not a moderator with "caneditposts" permissions.
if(!is_moderator($forum['fid'], "caneditposts"))
{

	// If this user is not a moderator with "caneditposts" permissions.
if(!is_moderator($forum['fid'], "caneditposts"))
{

Zeile 367Zeile 366
			$lang->edit_time_limit = $lang->sprintf($lang->edit_time_limit, $mybb->settings['edittimelimit']);
xmlhttp_error($lang->edit_time_limit);
}

			$lang->edit_time_limit = $lang->sprintf($lang->edit_time_limit, $mybb->settings['edittimelimit']);
xmlhttp_error($lang->edit_time_limit);
}

	}

// Forum is closed - no editing allowed (for anyone)
if($forum['open'] == 0)
{
xmlhttp_error($lang->no_permission_edit_post);
}

		// User can't edit unapproved post
if($post['visible'] == 0)
{
xmlhttp_error($lang->post_moderation);
}







 
		// Forum is closed - no editing allowed
if($forum['open'] == 0)
{
xmlhttp_error($lang->no_permission_edit_post);
}
}

	if($mybb->input['do'] == "get_post")
{
// Send our headers.
header("Content-type: text/xml; charset={$charset}");

	if($mybb->input['do'] == "get_post")
{
// Send our headers.
header("Content-type: text/xml; charset={$charset}");

		



		$post['message'] = htmlspecialchars_uni($post['message']);

		$post['message'] = htmlspecialchars_uni($post['message']);

		



		// Send the contents of the post.
eval("\$inline_editor = \"".$templates->get("xmlhttp_inline_post_editor")."\";");
echo "<?xml version=\"1.0\" encoding=\"{$charset}\"?".">";

		// Send the contents of the post.
eval("\$inline_editor = \"".$templates->get("xmlhttp_inline_post_editor")."\";");
echo "<?xml version=\"1.0\" encoding=\"{$charset}\"?".">";

Zeile 412Zeile 415
				$message = utf8_decode($message);
}
}

				$message = utf8_decode($message);
}
}

		



		// Set up posthandler.
require_once MYBB_ROOT."inc/datahandlers/post.php";
$posthandler = new PostDataHandler("update");

		// Set up posthandler.
require_once MYBB_ROOT."inc/datahandlers/post.php";
$posthandler = new PostDataHandler("update");

Zeile 438Zeile 441
		{
$postinfo = $posthandler->update_post();
$visible = $postinfo['visible'];

		{
$postinfo = $posthandler->update_post();
$visible = $postinfo['visible'];

			if($visible == 0 && !is_moderator())

			if($visible == 0 && !is_moderator($post['fid']))

			{
echo "<p>\n";
echo $lang->post_moderation;

			{
echo "<p>\n";
echo $lang->post_moderation;

Zeile 449Zeile 452

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


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

		



		$parser_options = array(
"allow_html" => $forum['allowhtml'],
"allow_mycode" => $forum['allowmycode'],

		$parser_options = array(
"allow_html" => $forum['allowhtml'],
"allow_mycode" => $forum['allowmycode'],

Zeile 459Zeile 462
			"me_username" => $post['username'],
"filter_badwords" => 1
);

			"me_username" => $post['username'],
"filter_badwords" => 1
);

		



		if($post['smilieoff'] == 1)
{
$parser_options['allow_smilies'] = 0;
}

		if($post['smilieoff'] == 1)
{
$parser_options['allow_smilies'] = 0;
}

	



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

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

		



		// Now lets fetch all of the attachments for these posts.
$query = $db->simple_select("attachments", "*", "pid='{$post['pid']}'");
while($attachment = $db->fetch_array($query))
{
$attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
}

		// Now lets fetch all of the attachments for these posts.
$query = $db->simple_select("attachments", "*", "pid='{$post['pid']}'");
while($attachment = $db->fetch_array($query))
{
$attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
}

		



		require_once MYBB_ROOT."inc/functions_post.php";

		require_once MYBB_ROOT."inc/functions_post.php";

		



		get_post_attachments($post['pid'], $post);

// Figure out if we need to show an "edited by" message

		get_post_attachments($post['pid'], $post);

// Figure out if we need to show an "edited by" message

Zeile 488Zeile 491
			$post['editedprofilelink'] = build_profile_link($mybb->user['username'], $mybb->user['uid']);
eval("\$editedmsg = \"".$templates->get("postbit_editedby")."\";");
}

			$post['editedprofilelink'] = build_profile_link($mybb->user['username'], $mybb->user['uid']);
eval("\$editedmsg = \"".$templates->get("postbit_editedby")."\";");
}

		



		// Send our headers.
header("Content-type: text/plain; charset={$charset}");

		// Send our headers.
header("Content-type: text/plain; charset={$charset}");

		echo "<p>\n";
echo $post['message'];
echo "</p>\n";

		echo $post['message']."\n";



		if($editedmsg)
{
echo str_replace(array("\r", "\n"), "", "<editedmsg>{$editedmsg}</editedmsg>");

		if($editedmsg)
{
echo str_replace(array("\r", "\n"), "", "<editedmsg>{$editedmsg}</editedmsg>");

Zeile 510Zeile 511
	}
// Divide up the cookie using our delimeter
$multiquoted = explode("|", $mybb->cookies['multiquote']);

	}
// Divide up the cookie using our delimeter
$multiquoted = explode("|", $mybb->cookies['multiquote']);

	



	// No values - exit
if(!is_array($multiquoted))
{
exit;
}

	// No values - exit
if(!is_array($multiquoted))
{
exit;
}

	



	// Loop through each post ID and sanitize it before querying
foreach($multiquoted as $post)

	// Loop through each post ID and sanitize it before querying
foreach($multiquoted as $post)

	{

	{

		$quoted_posts[$post] = intval($post);
}

		$quoted_posts[$post] = intval($post);
}





	// Join the post IDs back together
$quoted_posts = implode(",", $quoted_posts);

	// Join the post IDs back together
$quoted_posts = implode(",", $quoted_posts);

	



	// Fetch unviewable forums
$unviewable_forums = get_unviewable_forums();
if($unviewable_forums)

	// Fetch unviewable forums
$unviewable_forums = get_unviewable_forums();
if($unviewable_forums)

Zeile 533Zeile 534
		$unviewable_forums = "AND t.fid NOT IN ({$unviewable_forums})";
}
$message = '';

		$unviewable_forums = "AND t.fid NOT IN ({$unviewable_forums})";
}
$message = '';

	



	// Are we loading all quoted posts or only those not in the current thread?
if(!$mybb->input['load_all'])
{

	// Are we loading all quoted posts or only those not in the current thread?
if(!$mybb->input['load_all'])
{

Zeile 542Zeile 543
	else
{
$from_tid = '';

	else
{
$from_tid = '';

	}

	}


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


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

Zeile 556Zeile 557
		LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE {$from_tid}p.pid IN ($quoted_posts) {$unviewable_forums}

		LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE {$from_tid}p.pid IN ($quoted_posts) {$unviewable_forums}

 
		ORDER BY p.dateline

	");
while($quoted_post = $db->fetch_array($query))
{

	");
while($quoted_post = $db->fetch_array($query))
{

Zeile 563Zeile 565
		{
continue;
}

		{
continue;
}

		



		$message .= parse_quoted_message($quoted_post, false);

		$message .= parse_quoted_message($quoted_post, false);

	}

	}

	if($mybb->settings['maxquotedepth'] != '0')
{
$message = remove_message_quotes($message);
}

	if($mybb->settings['maxquotedepth'] != '0')
{
$message = remove_message_quotes($message);
}

	



	// Send our headers.
header("Content-type: text/plain; charset={$charset}");
echo $message;

	// Send our headers.
header("Content-type: text/plain; charset={$charset}");
echo $message;

	exit;	

	exit;

}
else if($mybb->input['action'] == "refresh_captcha")
{

}
else if($mybb->input['action'] == "refresh_captcha")
{

Zeile 661Zeile 663
		echo "<fail>{$lang->banned_characters_username}</fail>";
exit;
}

		echo "<fail>{$lang->banned_characters_username}</fail>";
exit;
}

	



	// Check if the username belongs to the list of banned usernames.
$banned_username = is_banned_username($username, true);
if($banned_username)
{
echo "<fail>{$lang->banned_username}</fail>";

	// Check if the username belongs to the list of banned usernames.
$banned_username = is_banned_username($username, true);
if($banned_username)
{
echo "<fail>{$lang->banned_username}</fail>";

		exit;

		exit;

	}

// Check for certain characters in username (<, >, &, and slashes)

	}

// Check for certain characters in username (<, >, &, and slashes)

	if(strpos($username, "<") !== false || strpos($username, ">") !== false || strpos($username, "&") !== false || my_strpos($username, "\\") !== false || strpos($username, ";") !== false)

	if(strpos($username, "<") !== false || strpos($username, ">") !== false || strpos($username, "&") !== false || my_strpos($username, "\\") !== false || strpos($username, ";") !== false || !validate_utf8_string($username, false, false))

	{
echo "<fail>{$lang->banned_characters_username}</fail>";
exit;
}

	{
echo "<fail>{$lang->banned_characters_username}</fail>";
exit;
}





	// Check if the username is actually already in use
$query = $db->simple_select("users", "uid", "LOWER(username)='".$db->escape_string(my_strtolower($username))."'");
$user = $db->fetch_array($query);

	// Check if the username is actually already in use
$query = $db->simple_select("users", "uid", "LOWER(username)='".$db->escape_string(my_strtolower($username))."'");
$user = $db->fetch_array($query);

Zeile 685Zeile 687
	{
$lang->username_taken = $lang->sprintf($lang->username_taken, htmlspecialchars_uni($username));
echo "<fail>{$lang->username_taken}</fail>";

	{
$lang->username_taken = $lang->sprintf($lang->username_taken, htmlspecialchars_uni($username));
echo "<fail>{$lang->username_taken}</fail>";

		exit;		

		exit;

	}
else
{

	}
else
{

Zeile 740Zeile 742
			"order_by" => "username",
"order_dir" => "asc"
);

			"order_by" => "username",
"order_dir" => "asc"
);

		$timecut = TIME_NOW - $mybb->settings['wolcutoff'];		

		$timecut = TIME_NOW - $mybb->settings['wolcutoff'];

		$query = $db->simple_select("users", "uid, username, usergroup, displaygroup, lastactive, lastvisit, invisible", "uid IN ({$mybb->user['buddylist']})", $query_options);
$online = array();
$offline = array();

		$query = $db->simple_select("users", "uid, username, usergroup, displaygroup, lastactive, lastvisit, invisible", "uid IN ({$mybb->user['buddylist']})", $query_options);
$online = array();
$offline = array();

Zeile 776Zeile 778
function xmlhttp_error($message)
{
global $charset;

function xmlhttp_error($message)
{
global $charset;

	



	// Send our headers.
header("Content-type: text/xml; charset={$charset}");

	// Send our headers.
header("Content-type: text/xml; charset={$charset}");

	



	// Send the error message.
echo "<error>".$message."</error>";

	// Send the error message.
echo "<error>".$message."</error>";

	



	// Exit
exit;
}

	// Exit
exit;
}