MyBB Community Forums

Full Version: Error Pages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Since I'm solely using MyBB on one of the websites, it makes sense to integrate the error pages with the forum as a whole. I have just one problem; the error pages work great if you're under the /forum directory (where MyBB is installed). Anywhere outside that directory, something is not linking right to allow you to be "logged in" on the error page.

PHP File
<?php

define('IN_MYBB', 1);
require "./forum/global.php";
global $db;

add_breadcrumb("404 Error - Document Not Found", "404.php"); // (2)

$url = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$date = new DateTime();
$timeStamp = $date->format('m-d-Y H:i:s');

eval("\$errorPage = \"".$templates->get("404")."\";");
output_page($errorPage);
?>

Template
<html>
<head>
<title>404 Error - Document Not Found</title>
{$headerinclude}
</head>
<body>
{$header}

<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder tfixed clear">
<tr>
<td class="thead">
<div>
<strong>404 Error - Document Not Found</strong><br />
</div>
</td>
</tr>
<tr>
<td id="posts_container">
<div id="posts">
<div class="post" style=""><br />
<div class="post_content ">
<div class="post_head">
<span class="post_date">{$timeStamp}</span>
</div>

<div class="post_body scaleimages">
The requested object or URL, <b><a href="{$url}">{$url}</a></b> was not found on this server.

The link you followed is either outdated, inaccurate, or the server has been instructed not to let you have it.<P>

Please inform the administrator of the referring page, <b><a href="{$url}">{$url}</a></b>.
</div>
</div>
</div>
</div>
<br />
</td>
</tr>
</table>
<br class="clear" />
{$usersbrowsing}
{$footer}
</body>
</html>
I don't really understand your issue - do you mean that the header shows you as a guest? If that's the case, you most likely limited your cookies to the forum directory in MyBB's ACP. Go to ACP -> Configuration -> Site Details and change the Cookie Path to /

And some other problems I noticed:
- {$usersbrowsing} is undefined
- $url is not secured and can lead to self-XSS attacks
Yes, I did do that to fix it (cookie url from /forum/ to /).
I haven't been on in the past few days to update this post.