<php
//-----------------------------
// Defining the links.
//-----------------------------
$home = 'news';
$pages = array(
'home' => array($home, $home),
'news' => array('news', 'news'),
'about' => array('about', 'about'),
'contact' => array('contact', 'contact'),
);
//-------------------------
// Load the module
//-------------------------
if(array_key_exists($_GET['id'], $pages))
{
foreach($pages as $id => $filearray)
{
$file = "modules/".$filearray[0].".php";
if($_GET['id'] == $id && file_exists($file))
{
if (file_exists($file))
{
include $file; // The file has been located and it's being included.
} else {
die(); // The file didn't exist, therefore the script ends.
}
}
}
}
//-----------------------------------------------
// Show the home page
//-----------------------------------------------
else
{
$file = "/modules/" . $home . ".php";
if(file_exists($file))
{
require $file; // The file has been located and it's being included.
}
else
{
die(); // The file didn't exist, therefore the script ends.
}
}
?>