MyBB Community Forums

Full Version: Looking for piece of php code regarding banned users
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

if a user is banned, then he always goes to the error_nopermission page:

<html>
<head>
<title>{$title}</title>
{$headerinclude}
</head>
<body>
{$header}
<br />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead"><span class="smalltext"><strong>{$title}</strong></span></td>
</tr>
<tr>
<td class="trow1">{$error}</td>
</tr>
</table>
{$footer}
</body>
</html>

Can someone tell me where the php code is located that points to the error template above for banned users?

EDIT: I think I got it now. In inc/functions.php I replaced this:
 
/**
 * Produce a friendly error message page
 *
 * @param string The error message to be shown
 * @param string The title of the message shown in the title of the page and the error table
 */
function error($error="", $title="")
{
	global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb, $plugins;

	$error = $plugins->run_hooks("error", $error);
	if(!$error)
	{
		$error = $lang->unknown_error;
	}

	// AJAX error message?
	if($mybb->input['ajax'])
	{
		// Send our headers.
		@header("Content-type: text/html; charset={$lang->settings['charset']}");
		echo "<error>{$error}</error>\n";
		exit;
	}

	if(!$title)
	{
		$title = $mybb->settings['bbname'];
	}

	$timenow = my_date($mybb->settings['dateformat'], TIME_NOW) . " " . my_date($mybb->settings['timeformat'], TIME_NOW);
	reset_breadcrumb();
	add_breadcrumb($lang->error);
	
	eval("\$errorpage = \"".$templates->get("error")."\";");
	output_page($errorpage);

	exit;
}

with this:

/**
 * Produce a friendly error message page
 *
 * @param string The error message to be shown
 * @param string The title of the message shown in the title of the page and the error table
 */
function error($error="", $title="")
{
	global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb, $plugins;

	$error = $plugins->run_hooks("error", $error);
	if(!$error)
	{
		$error = $lang->unknown_error;
	}

	// AJAX error message?
	if($mybb->input['ajax'])
	{
		// Send our headers.
		@header("Content-type: text/html; charset={$lang->settings['charset']}");
		echo "<error>{$error}</error>\n";
		exit;
	}

	if(!$title)
	{
		$title = $mybb->settings['bbname'];
	}

	$timenow = my_date($mybb->settings['dateformat'], TIME_NOW) . " " . my_date($mybb->settings['timeformat'], TIME_NOW);
	reset_breadcrumb();
	add_breadcrumb($lang->error);
	
	if($mybb->usergroup['isbannedgroup'] == 1)
	{
	eval("\$errorpage = \"".$templates->get("error_banned")."\";");
	output_page($errorpage);
	}
	else
	{
	eval("\$errorpage = \"".$templates->get("error")."\";");
	output_page($errorpage);
	}

	exit;
}

I made an additional template error_banned:
<html>
<head>
<title>{$title}</title>
{$headerinclude}
</head>
<body>
{$header}
<br />

{$footer}
</body>
</html>

Now it works exactly as it should. Can anyone verify if I forgot something?
If you want to edit it, take a look here:

http://yaldaram.com/showthread.php?tid=23
Thanks, but I want to get rid of it/replace it with another template. Editing the language files is not good enough. I need to know the php code and edit it to point to another template Smile
Yeah I wish MyBB would alter the whole error_no_perm system entirely.

I think a hook exists in the function. You could potentially hook into it with a plugin and display your own page easily without core file edits.


HOOK: $plugins->run_hooks("no_permission");
Thanks, but I already edited so much core files to the point that I don't mind editing core files anymore. Can you tell me where and how to edit the right php code to point lets say to the template error_nopermission_banned ? Smile

I edited the first post with my solution Smile