- Messages
- 5,257
- Reaction score
- 97
- Points
- 48
cp.php:
includes.php:
There is an error in function callback() - it can find $page->error correctly, but not $page->header() or $page->footer(). Does anyone know why this is? It does not display any errors, just a blank page.
~Callum
PHP:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
function callback($buffer)
{
global $page;
if ($page->error)
{
$code = $page->header("Error");
$code .= $page->error;
$code .= $page->footer();
return $code;
}
else return $buffer;
}
ob_start("callback");
include("inc/includes.php");
$module_id = request_var('m', (int) 1);
$sql = "SELECT * FROM `base11_modules` WHERE `display` = 1 AND `id` = $module_id";
$result = $conn->query($sql);
$result->setFetchMode(PDO::FETCH_OBJ);
if (!$result->rowCount())
$page->error("404 Error - Page not found");
while ($row = $result->fetch())
{
if ($error) break;
$page->tab_id = $row->id;
if ($u->perms($row->perms))
{
include("modules/".$row->location.".php");
break;
}
else
{
$page->error("You do not have sufficient permissions to view this page.");
}
}
$page->footer();
ob_end_flush();
?>
includes.php:
PHP:
class body
{
function __construct()
{
$this->template = "../template/current/";
if (!file_exists($this->template))
$this->template = "template/current/";
$link = "../";
if (!file_exists($link."inc/includes.php"))
$link = "./";
$this->link = $link;
$this->hasheader = 0;
$this->error = 0;
}
function error($error)
{
$this->error = $error;
}
function display($page)
{
if ($page == "header")
$this->header($title);
else
{
$link = "../";
if (!file_exists($link."inc/includes.php"))
$link = "./";
$page = file_get_contents($this->template."pages/".$page.".html");
echo $this->parse(0, $page);
}
}
function find()
{
return array_keys($this->replace());
}
function footer()
{
if ($this->hasheader)
$this->display("footer");
die();
}
function header($title="None Specified")
{
$page = file_get_contents($this->template."pages/header.html");
echo $this->parse($title, $page);
$this->hasheader = 1;
}
function parse($title, $page)
{
return preg_replace($this->find(), $this->replace($title), $page);
}
function replace($title=0)
{
global $conn, $u;
$result = $conn->query("SELECT * FROM `base11_modules` WHERE `display` = 1 AND `parent` = 0 ORDER BY `order`");
$result->setFetchMode(PDO::FETCH_OBJ);
while ($row = $result->fetch())
{
if ($u->perms($row->perms))
{
if ($row->id == $this->tab_id) $navlinks_a[] = '<b><a href="' .$this->url("cp.php?m=".$row->id, 0). '">' .$row->name. '</a></b>';
else $navlinks_a[] = '<a href="' .$this->url("cp.php?m=".$row->id, 0). '">' .$row->name. '</a>';
}
}
$navlinks_count = count($navlinks_a);
$this_count = 0;
foreach ($navlinks_a as $value)
{
$navlinks .= $value;
$this_count++;
if ($this_count < $navlinks_count)
{
$navlinks .= " • ";
}
}
$replace = array(
'/{PAGE_TITLE}/' => $title,
'/{BIG_TITLE}/' => "Base 11 Studios • ".$title,
'/{NAV_LINKS}/' => $navlinks,
'/{CSS_LOC}/' => $this->template."css/style.css",
'/{CSS_DIR}/' => $this->template."css/",
'/{IMG_DIR}/' => $this->template."images/",
);
return $replace;
}
function url($text, $m=1)
{
$text = append_sid($text);
if ($m) $text .= "&m=".$this->tab_id;
return $text;
}
}
$page = new body;
?>
There is an error in function callback() - it can find $page->error correctly, but not $page->header() or $page->footer(). Does anyone know why this is? It does not display any errors, just a blank page.
~Callum