MyBB Community Forums

Full Version: Forum Password
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all !
I have a problem with forum password in subforum.
I did update from 1.2.9 to 1.2.12, on some forums it was password access. After update, forum with password works well but subforum with password has problem with access it always says "Wrong password" when I enter the password. Even I deleted password in Admin CP and subforum has no any password it in any case says - "Wrong Password" and has no access to the subforum.
Who knows what is it?
The solution is
http://community.mybboard.net/showthread.php?tid=26494

the fix;

Open ./inc/functions.php
Find


PHP Code:

if($forum_cache[$parent_id]['password'] != "")
{
check_forum_password($parent_id, $fid);
}


Change into


PHP Code:

if($forum_cache[$parent_id]['password'] != "")
{
check_forum_password($fid, $parent_id);
}
That fix is incorrect. Replace the old function check_forum_password with this:

/**
 * Check the password given on a certain forum for validity
 *
 * @param int The forum ID
 * @param boolean The Parent ID
 */
function check_forum_password($fid, $pid=0)
{
	global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;
	
	$showform = true;
	
	if(!is_array($forum_cache))
	{
		$forum_cache = cache_forums();
		if(!$forum_cache)
		{
			return false;
		}
	}

	// Loop through each of parent forums to ensure we have a password for them too
	$parents = explode(',', $forum_cache[$fid]['parentlist']);
	rsort($parents);
	if(!empty($parents))
	{
		foreach($parents as $parent_id)
		{
			if($parent_id == $fid || $parent_id == $pid)
			{
				continue;
			}
			
			if($forum_cache[$parent_id]['password'] != "")
			{
				check_forum_password($parent_id, $fid);
			}
		}
	}
	
	$password = $forum_cache[$fid]['password'];
	if($password)
	{
		if($mybb->input['pwverify'])
		{
			if($password == $mybb->input['pwverify'])
			{
				my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);
				$showform = false;
			}
			else
			{
				eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");
				$showform = true;
			}
		}
		else
		{
			if(!$_COOKIE['forumpass'][$fid] || ($_COOKIE['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $_COOKIE['forumpass'][$fid]))
			{
				$showform = true;
			}
			else
			{
				$showform = false;
			}
		}
	}
	else
	{
		$showform = false;
	}

	if($showform)
	{
		$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
		eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
		output_page($pwform);
		exit;
	}
}