//include page
$punc = array("!","£","$","%","^","&","*","(",")",",",".","'",'"',";",":"); //clean page value
$pg = str_replace($punc, "", $_GET['pg']);
if($pg == NULL || $pg == "" || $pg == "0"){ //if the $pg is NULL, has no value or = 0 then set the script to open that page
$page = 'pages/index.php';
}
elseif(file_exists("pages/"."$pg".".php")){ //else, check if the file exists, if it does set the script to open that page
$page = 'pages/'."$pg".'.php';
}
else{ //if the file does not exist then open error 404.
$topmessage = "
Sorry, we can't seem to find the page you are looking for. Please try navigating to it using the links below.
";
$page="pages/index.php";
}
//open the page, read the data split it
$fh = fopen($page, 'r');
$data = fread($fh, filesize($page));
fclose($fh);
list($meta, $page_title, $breadcrumbs, $nav, $content_1, $content_2) = explode("-*-*-", $data);
?>
404 error page
if (trim($meta) == "default meta" || trim($meta) == "" || trim($meta) == null){
}else{
echo $meta;
}?>