Vergleich xmlhttp.php - 1.8.2 - 1.8.5

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 28Zeile 28
// Load MyBB core files
require_once dirname(__FILE__)."/inc/init.php";


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


$shutdown_queries = array();

$shutdown_queries = $shutdown_functions = 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 70Zeile 70
// 1. Check cookies
if(!$mybb->user['uid'] && !empty($mybb->cookies['mybbtheme']))
{

// 1. Check cookies
if(!$mybb->user['uid'] && !empty($mybb->cookies['mybbtheme']))
{

	$mybb->user['style'] = $mybb->cookies['mybbtheme'];

	$mybb->user['style'] = (int)$mybb->cookies['mybbtheme'];

}

// 2. Load style

}

// 2. Load style

Zeile 185Zeile 185

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


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

 

$closed_bypass = array("refresh_captcha", "validate_captcha");

$mybb->input['action'] = $mybb->get_input('action');


$plugins->run_hooks("xmlhttp");


$plugins->run_hooks("xmlhttp");


$mybb->input['action'] = $mybb->get_input('action');














// If the board is closed, the user is not an administrator and they're not trying to login, show the board closed message
if($mybb->settings['boardclosed'] == 1 && $mybb->usergroup['canviewboardclosed'] != 1 && !in_array($mybb->input['action'], $closed_bypass))
{
// Show error
if(!$mybb->settings['boardclosed_reason'])
{
$mybb->settings['boardclosed_reason'] = $lang->boardclosed_reason;
}

$lang->error_boardclosed .= "<br /><em>{$mybb->settings['boardclosed_reason']}</em>";

xmlhttp_error($lang->error_boardclosed);
}


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


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





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


	if($mybb->get_input('getone', 1) == 1)

	if($mybb->get_input('getone', MyBB::INPUT_INT) == 1)

	{
$limit = 1;

	{
$limit = 1;

	}

	}

	else
{
$limit = 15;

	else
{
$limit = 15;

Zeile 222Zeile 238
	);

$plugins->run_hooks("xmlhttp_get_users_start");

	);

$plugins->run_hooks("xmlhttp_get_users_start");





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

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

Zeile 231Zeile 247
		$data = array('id' => $user['username'], 'text' => $user['username']);
}
else

		$data = array('id' => $user['username'], 'text' => $user['username']);
}
else

	{

	{

		$data = array();
while($user = $db->fetch_array($query))
{
$user['username'] = htmlspecialchars_uni($user['username']);
$data[] = array('id' => $user['username'], 'text' => $user['username']);
}

		$data = array();
while($user = $db->fetch_array($query))
{
$user['username'] = htmlspecialchars_uni($user['username']);
$data[] = array('id' => $user['username'], 'text' => $user['username']);
}

	}

$plugins->run_hooks("xmlhttp_get_users_end");

	}

$plugins->run_hooks("xmlhttp_get_users_end");


echo json_encode($data);
exit;


echo json_encode($data);
exit;

Zeile 255Zeile 271
	}

// We're editing a thread subject.

	}

// We're editing a thread subject.

	if($mybb->get_input('tid', 1))

	if($mybb->get_input('tid', MyBB::INPUT_INT))

	{
// Fetch the thread.

	{
// Fetch the thread.

		$thread = get_thread($mybb->get_input('tid', 1));

		$thread = get_thread($mybb->get_input('tid', MyBB::INPUT_INT));

		if(!$thread)

		if(!$thread)

		{

		{

			xmlhttp_error($lang->thread_doesnt_exist);
}


			xmlhttp_error($lang->thread_doesnt_exist);
}


Zeile 303Zeile 319
		else if($forum['open'] == 0 || $forumpermissions['caneditposts'] == 0 || $mybb->user['uid'] != $post['uid'] || $mybb->user['uid'] == 0)
{
xmlhttp_error($lang->no_permission_edit_subject);

		else if($forum['open'] == 0 || $forumpermissions['caneditposts'] == 0 || $mybb->user['uid'] != $post['uid'] || $mybb->user['uid'] == 0)
{
xmlhttp_error($lang->no_permission_edit_subject);

		}

		}

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

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

Zeile 330Zeile 346
		else if(my_strtolower($charset) == "iso-8859-1")
{
$subject = utf8_decode($subject);

		else if(my_strtolower($charset) == "iso-8859-1")
{
$subject = utf8_decode($subject);

		}
}

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

// Set the post data that came from the input to the $post array.
$updatepost = array(
"pid" => $post['pid'],
"tid" => $thread['tid'],
"subject" => $subject,
"edit_uid" => $mybb->user['uid']
);
$posthandler->set_data($updatepost);

// Now let the post handler do all the hard work.
if(!$posthandler->validate_post())
{
$post_errors = $posthandler->get_friendly_errors();
xmlhttp_error($post_errors);
}
// No errors were found, we can call the update method.
else
{
$posthandler->update_post();
if($ismod == true)
{
$modlogdata = array(
"tid" => $thread['tid'],
"fid" => $forum['fid']
);
log_moderator_action($modlogdata, $lang->edited_post);
}





		}
}

// Only edit subject if subject has actually been changed
if($thread['subject'] != $subject)
{
// Set up posthandler.
require_once MYBB_ROOT."inc/datahandlers/post.php";
$posthandler = new PostDataHandler("update");
$posthandler->action = "post";

// Set the post data that came from the input to the $post array.
$updatepost = array(
"pid" => $post['pid'],
"tid" => $thread['tid'],
"subject" => $subject,
"edit_uid" => $mybb->user['uid']
);
$posthandler->set_data($updatepost);

// Now let the post handler do all the hard work.
if(!$posthandler->validate_post())
{
$post_errors = $posthandler->get_friendly_errors();
xmlhttp_error($post_errors);
}
// No errors were found, we can call the update method.
else
{
$posthandler->update_post();
if($ismod == true)
{
$modlogdata = array(
"tid" => $thread['tid'],
"fid" => $forum['fid']
);
log_moderator_action($modlogdata, $lang->edited_post);
}
}

	}

require_once MYBB_ROOT."inc/class_parser.php";

	}

require_once MYBB_ROOT."inc/class_parser.php";

Zeile 387Zeile 407
else if($mybb->input['action'] == "edit_post")
{
// Fetch the post from the database.

else if($mybb->input['action'] == "edit_post")
{
// Fetch the post from the database.

	$post = get_post($mybb->get_input('pid', 1));

	$post = get_post($mybb->get_input('pid', MyBB::INPUT_INT));


// No result, die.
if(!$post)


// No result, die.
if(!$post)

	{

	{

		xmlhttp_error($lang->post_doesnt_exist);
}

		xmlhttp_error($lang->post_doesnt_exist);
}





	// 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 thread associated with this post.
$thread = get_thread($post['tid']);

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





	// Missing thread, invalid forum? Error.
if(!$thread || !$forum || $forum['type'] != "f")
{

	// Missing thread, invalid forum? Error.
if(!$thread || !$forum || $forum['type'] != "f")
{

Zeile 409Zeile 429

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


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





	$plugins->run_hooks("xmlhttp_edit_post_start");

// If this user is not a moderator with "caneditposts" permissions.

	$plugins->run_hooks("xmlhttp_edit_post_start");

// If this user is not a moderator with "caneditposts" permissions.

Zeile 426Zeile 446
			xmlhttp_error($lang->no_permission_edit_post);
}
// If we're past the edit time limit - don't allow editing.

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

		else if($mybb->usergroup['edittimelimit'] != 0 && $post['dateline'] < (TIME_NOW-($mybb->usergroup['edittimelimit']*60)))

		{

		{

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

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

			xmlhttp_error($lang->edit_time_limit);
}
// User can't edit unapproved post

			xmlhttp_error($lang->edit_time_limit);
}
// User can't edit unapproved post

Zeile 449Zeile 469
	if($mybb->get_input('do') == "get_post")
{
// Send our headers.

	if($mybb->get_input('do') == "get_post")
{
// Send our headers.

		//header("Content-type: text/xml; charset={$charset}");
header("Content-type: text/html; charset={$charset}");

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

		header("Content-type: application/json; charset={$charset}");





// Send the contents of the post.


// Send the contents of the post.

		echo $post['message'];

		echo json_encode($post['message']);

		exit;
}
else if($mybb->get_input('do') == "update_post")

		exit;
}
else if($mybb->get_input('do') == "update_post")

Zeile 648Zeile 665

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


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

	{
$from_tid = "p.tid != '".$mybb->get_input('tid', 1)."' AND ";

	{
$from_tid = "p.tid != '".$mybb->get_input('tid', MyBB::INPUT_INT)."' AND ";

	}
else
{

	}
else
{

Zeile 725Zeile 742
	$query = $db->simple_select("captcha", "imagestring", "imagehash='$imagehash'");
if($db->num_rows($query) == 0)
{

	$query = $db->simple_select("captcha", "imagestring", "imagehash='$imagehash'");
if($db->num_rows($query) == 0)
{

		echo $lang->captcha_valid_not_exists;

		echo json_encode($lang->captcha_valid_not_exists);

		exit;
}
$imagestring = $db->fetch_field($query, 'imagestring');

		exit;
}
$imagestring = $db->fetch_field($query, 'imagestring');

Zeile 750Zeile 767
	
$sid = $db->escape_string($mybb->get_input('question_id'));
$query = $db->query("

	
$sid = $db->escape_string($mybb->get_input('question_id'));
$query = $db->query("

		SELECT q.*, s.sid

		SELECT q.qid, s.sid

		FROM ".TABLE_PREFIX."questionsessions s
LEFT JOIN ".TABLE_PREFIX."questions q ON (q.qid=s.qid)
WHERE q.active='1' AND s.sid='{$sid}'
");

		FROM ".TABLE_PREFIX."questionsessions s
LEFT JOIN ".TABLE_PREFIX."questions q ON (q.qid=s.qid)
WHERE q.active='1' AND s.sid='{$sid}'
");

 
	

	if($db->num_rows($query) == 0)

	if($db->num_rows($query) == 0)

	{
xmlhttp_error($lang->answer_valid_not_exists);
}

$qsession = $db->fetch_array($query);

	{
xmlhttp_error($lang->answer_valid_not_exists);
}

$qsession = $db->fetch_array($query);

	
// Delete previous question session
$db->delete_query("questionsessions", "sid='$sid'");

	
// Delete previous question session
$db->delete_query("questionsessions", "sid='$sid'");

	
require_once MYBB_ROOT."inc/functions_user.php";

$sid = generate_question();

	
require_once MYBB_ROOT."inc/functions_user.php";

$sid = generate_question($qsession['qid']);

	$query = $db->query("
SELECT q.question, s.sid
FROM ".TABLE_PREFIX."questionsessions s
LEFT JOIN ".TABLE_PREFIX."questions q ON (q.qid=s.qid)
WHERE q.active='1' AND s.sid='{$sid}' AND q.qid!='{$qsession['qid']}'
");

	$query = $db->query("
SELECT q.question, s.sid
FROM ".TABLE_PREFIX."questionsessions s
LEFT JOIN ".TABLE_PREFIX."questions q ON (q.qid=s.qid)
WHERE q.active='1' AND s.sid='{$sid}' AND q.qid!='{$qsession['qid']}'
");

 
	
$plugins->run_hooks("xmlhttp_refresh_question");


	if($db->num_rows($query) > 0)

	if($db->num_rows($query) > 0)

	{

	{

		$question = $db->fetch_array($query);

		$question = $db->fetch_array($query);

 
		
echo json_encode(array("question" => htmlspecialchars_uni($question['question']), 'sid' => htmlspecialchars_uni($question['sid'])));
exit;
}
else
{
xmlhttp_error($lang->answer_valid_not_exists);

	}

	}

	
$plugins->run_hooks("xmlhttp_refresh_question");

echo json_encode(array("question" => htmlspecialchars_uni($question['question']), 'sid' => htmlspecialchars_uni($question['sid'])));
exit;

 
}
elseif($mybb->input['action'] == "validate_question" && $mybb->settings['securityquestion'])
{

}
elseif($mybb->input['action'] == "validate_question" && $mybb->settings['securityquestion'])
{

Zeile 796Zeile 819
		LEFT JOIN ".TABLE_PREFIX."questions q ON (q.qid=s.qid)
WHERE q.active='1' AND s.sid='{$sid}'
");

		LEFT JOIN ".TABLE_PREFIX."questions q ON (q.qid=s.qid)
WHERE q.active='1' AND s.sid='{$sid}'
");

 
	

	if($db->num_rows($query) == 0)
{

	if($db->num_rows($query) == 0)
{

		echo $lang->answer_valid_not_exists;

		echo json_encode($lang->answer_valid_not_exists);

		exit;
}
else

		exit;
}
else

Zeile 863Zeile 887
	$username = $mybb->get_input('username');

// Fix bad characters

	$username = $mybb->get_input('username');

// Fix bad characters

	$username = trim($username);

	$username = trim_blank_chrs($username);

	$username = str_replace(array(unichr(160), unichr(173), unichr(0xCA), dec_to_utf8(8238), dec_to_utf8(8237), dec_to_utf8(8203)), array(" ", "-", "", "", "", ""), $username);

// Remove multiple spaces from the username

	$username = str_replace(array(unichr(160), unichr(173), unichr(0xCA), dec_to_utf8(8238), dec_to_utf8(8237), dec_to_utf8(8203)), array(" ", "-", "", "", "", ""), $username);

// Remove multiple spaces from the username

Zeile 873Zeile 897

if(empty($username))
{


if(empty($username))
{

		echo $lang->banned_characters_username;

		echo json_encode($lang->banned_characters_username);

		exit;
}


		exit;
}


Zeile 881Zeile 905
	$banned_username = is_banned_username($username, true);
if($banned_username)
{

	$banned_username = is_banned_username($username, true);
if($banned_username)
{

		echo $lang->banned_username;

		echo json_encode($lang->banned_username);

		exit;
}

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

		exit;
}

// 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 || !validate_utf8_string($username, false, false))

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

	{

	{

		echo $lang->banned_characters_username;

		echo json_encode($lang->banned_characters_username);

		exit;
}


		exit;
}


Zeile 941Zeile 965
	}
else
{

	}
else
{

		$lang->invalid_username = htmlspecialchars_uni($lang->sprintf($lang->invalid_username, htmlspecialchars_uni($username)));
echo $lang->invalid_username;

		$lang->invalid_username = $lang->sprintf($lang->invalid_username, htmlspecialchars_uni($username));
echo json_encode($lang->invalid_username);

		exit;
}
}

		exit;
}
}