<?php
// Assign the requested page to a shorter variable for simplicity.
// The value of $_GET["page"] will be obtained from index.php?page=RIGHT_HERE
$p = $_GET["page"];
// Check for bad requests. This is a security measure.
if (strpos($p,"..")) {
// A bad request has been made, exit immediately. Do not proceed with the inclusion.
die("Bad page request");
}
// File to include. If $p is empty, fall back to
// main.php. THIS FILE MUST EXIST.
$p = trim($p); // trim whitespace
if (empty($p)) $p = "main.php";
else {
$p .= '.php';
if (!file_exists($p)) $p = '404.php';
}
$content_file=$p;
// Set styles
$s = $_GET["style"]; // Get style variable
if (strpos($s,"..")) { die ("Bad page request"); } // Security measure
$s = trim($s); // trim whitespace
if (empty($s)) $s = "default.css"; // If empty then default to default.css
else {
$s .= '.css';
if (!file_exists($s)) $s = 'print.css'; // if style file does not exist set style to print.css
}
$style=$s;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="application/xhtml+xml ;" />
<meta http-equiv="Content-Language" content="en-us" />
<link <?php echo "href=\"$style\"" ?> type="text/css" rel="stylesheet" />
<title><?=$title ?></title>
</head>
<body>
<div id="pageholder">
<div id="header"><?php include("header.php"); ?></div>
<div id="menu_container"><?php include("menu.php"); ?></div>
<div id="content_container"><div id="content_container_body"><?php include($content_file); ?></div></div>
<div id="footer"><?php include("footer.php"); ?></div>
</div>
</body>
</html>