Skip to content

Instantly share code, notes, and snippets.

@erikaheidi
Created February 18, 2013 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikaheidi/4978299 to your computer and use it in GitHub Desktop.
Save erikaheidi/4978299 to your computer and use it in GitHub Desktop.
<?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