Vergleich xmlhttp.php - 1.6.10 - 1.6.13

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
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);

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

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

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


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

 

$shutdown_queries = array();



$shutdown_queries = array();


Zeile 74Zeile 71
if(isset($mybb->user['style']) && intval($mybb->user['style']) != 0)
{
$loadstyle = "tid='".$mybb->user['style']."'";

if(isset($mybb->user['style']) && intval($mybb->user['style']) != 0)
{
$loadstyle = "tid='".$mybb->user['style']."'";

}
else
{

}
else
{

	$loadstyle = "def=1";
}

	$loadstyle = "def=1";
}





// Load basic theme information that we could be needing.
$query = $db->simple_select("themes", "name, tid, properties", $loadstyle);
$theme = $db->fetch_array($query);

// Load basic theme information that we could be needing.
$query = $db->simple_select("themes", "name, tid, properties", $loadstyle);
$theme = $db->fetch_array($query);

Zeile 87Zeile 84

// Set the appropriate image language directory for this theme.
if(!empty($mybb->user['language']) && is_dir($theme['imgdir'].'/'.$mybb->user['language']))


// Set the appropriate image language directory for this theme.
if(!empty($mybb->user['language']) && is_dir($theme['imgdir'].'/'.$mybb->user['language']))

{

{

	$theme['imglangdir'] = $theme['imgdir'].'/'.$mybb->user['language'];
}
else

	$theme['imglangdir'] = $theme['imgdir'].'/'.$mybb->user['language'];
}
else

Zeile 101Zeile 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'])
{
$charset = $lang->settings['charset'];
}
// If not, revert to UTF-8


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

else
{

else
{

	$charset = "UTF-8";
}

	$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 the string is less than 3 characters, quit.

	if(my_strlen($mybb->input['query']) < 3)
{
exit;
}

	if(my_strlen($mybb->input['query']) < 3)
{
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 for any matching users.

	$query_options = array(

	$query_options = array(

		"order_by" => "username",
"order_dir" => "asc",
"limit_start" => 0,
"limit" => 15
);

		"order_by" => "username",
"order_dir" => "asc",
"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']);

	while($user = $db->fetch_array($query))
{
$user['username'] = htmlspecialchars_uni($user['username']);

Zeile 157Zeile 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 171Zeile 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 190Zeile 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 229Zeile 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 257Zeile 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 273Zeile 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 310Zeile 307
			log_moderator_action($modlogdata, $lang->edited_post);
}
}

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





	// Fetch the specific forum this thread/post is in.
$forum = get_forum($thread['fid']);

	// Fetch the specific forum this thread/post is in.
$forum = get_forum($thread['fid']);





	// Missing thread, invalid forum? Error.
if(!$thread['tid'] || !$forum['fid'] || $forum['type'] != "f")
{
xmlhttp_error($lang->thread_doesnt_exist);
}

	// Missing thread, invalid forum? Error.
if(!$thread['tid'] || !$forum['fid'] || $forum['type'] != "f")
{
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 361Zeile 358
		}
// Forum is not open, user doesn't have permission to edit, or author doesn't match this user - don't allow editing.
else if($forum['open'] == 0 || $forumpermissions['caneditposts'] == 0 || $mybb->user['uid'] != $post['uid'] || $mybb->user['uid'] == 0 || $mybb->user['suspendposting'] == 1)

		}
// Forum is not open, user doesn't have permission to edit, or author doesn't match this user - don't allow editing.
else if($forum['open'] == 0 || $forumpermissions['caneditposts'] == 0 || $mybb->user['uid'] != $post['uid'] || $mybb->user['uid'] == 0 || $mybb->user['suspendposting'] == 1)

		{

		{

			xmlhttp_error($lang->no_permission_edit_post);

			xmlhttp_error($lang->no_permission_edit_post);

		}

		}

		// If we're past the edit time limit - don't allow editing.
else if($mybb->settings['edittimelimit'] != 0 && $post['dateline'] < (TIME_NOW-($mybb->settings['edittimelimit']*60)))
{

		// If we're past the edit time limit - don't allow editing.
else if($mybb->settings['edittimelimit'] != 0 && $post['dateline'] < (TIME_NOW-($mybb->settings['edittimelimit']*60)))
{

Zeile 372Zeile 369
		}
// User can't edit unapproved post
if($post['visible'] == 0)

		}
// User can't edit unapproved post
if($post['visible'] == 0)

		{

		{

			xmlhttp_error($lang->post_moderation);

			xmlhttp_error($lang->post_moderation);

 
		}

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

		}
}

		}
}


// Forum is closed - no editing allowed (for anyone)
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 408Zeile 404
		if(my_strtolower($charset) != "utf-8")
{
if(function_exists("iconv"))

		if(my_strtolower($charset) != "utf-8")
{
if(function_exists("iconv"))

			{

			{

				$message = iconv($charset, "UTF-8//IGNORE", $message);

				$message = iconv($charset, "UTF-8//IGNORE", $message);

			}

			}

			else if(function_exists("mb_convert_encoding"))

			else if(function_exists("mb_convert_encoding"))

			{

			{

				$message = @mb_convert_encoding($message, $charset, "UTF-8");
}
else if(my_strtolower($charset) == "iso-8859-1")
{
$message = utf8_decode($message);

				$message = @mb_convert_encoding($message, $charset, "UTF-8");
}
else if(my_strtolower($charset) == "iso-8859-1")
{
$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 457Zeile 453

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 467Zeile 463
			"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);


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


// Figure out if we need to show an "edited by" message
// Only show if at least one of "showeditedby" or "showeditedbyadmin" is enabled


// Figure out if we need to show an "edited by" message
// Only show if at least one of "showeditedby" or "showeditedbyadmin" is enabled

Zeile 496Zeile 492
			$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}");
echo $post['message']."\n";

		// Send our headers.
header("Content-type: text/plain; charset={$charset}");
echo $post['message']."\n";

Zeile 516Zeile 512
	}
// 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 539Zeile 535
		$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'])

	{

	{

		$from_tid = "p.tid != '".intval($mybb->input['tid'])."' AND ";

		$from_tid = "p.tid != '".intval($mybb->input['tid'])."' AND ";

	}

	}

	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 570Zeile 566
		{
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 668Zeile 664
		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 692Zeile 688
	{
$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 747Zeile 743
			"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 783Zeile 779
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;
}