I have made a while loop to take the current page and if it matches a directory it will return that directories contents or if the value is null will return the index or if the page is gibberish it should return a the 404.htm error page.
For the most part this works expect the 404.htm page is always returned, sometimes twice.
/*
The page Location.
*/
$page = explode('/', $_GET['page']);
/*
Load the modules based on page location.
*/
$i = 0;
/* Opens the modules directory */
$modulesDirectory = opendir("../application/modules/");
/* Gets the modules name based on the directory name for each module. */
while ($moduleName = readdir($modulesDirectory))
{
if ($moduleName!= "." && $moduleName!= "..")
{
if ($page[0] == $moduleName)
{
/* If the current page matches a module name, return that module. */
include ("../application/modules/".$moduleName."/".$moduleName.".php");
}
}
else if ($page[0] == '' && $i == 0)
{
/* If the current page is the / then return the bootstrap. */
include ("../application/modules/example_module/example_module.php");
$i++;
}
else if ($page[0] != $moduleName)
{
/* If the current page is not found in the modules return page not found. */
include ("../html/errors/404.htm");
}
}
closedir($modulesDirectory);