Created
February 18, 2013 15:42
-
-
Save erikaheidi/4978299 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* on config.php you put your initialization stuff, like session start and bd connection */ | |
require_once("includes/config.php"); | |
$uri = $_SERVER['REQUEST_URI']; | |
/* default is index */ | |
$pagina = "index"; | |
if($uri != "/") | |
{ | |
/* url parsing */ | |
/* remove url parameters */ | |
$t = explode('?',$uri); | |
/* divide request */ | |
$path = explode("/",$t[0]); | |
$module = strtolower($path[1]); | |
/* an extra check if there's a dir with this name */ | |
if(!is_dir($module)) | |
{ | |
/*verifies if there's a module with this name*/ | |
if(is_dir("modules/$module")) | |
$pagina = $module."/index"; | |
else if(is_file("modules/$module.php")) | |
$pagina = $module; | |
else | |
/* if doesn't, get the 'not found' module */ | |
$pagina = "404"; | |
} | |
} | |
require_once("modules/$pagina.php"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment