Last active
August 29, 2015 14:11
-
-
Save juizmill/ccc13263a867fa77cb15 to your computer and use it in GitHub Desktop.
Arquivo config.php
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 | |
| //Get Route | |
| function getRoute() | |
| { | |
| $current_path = parse_url('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); | |
| return array_filter(explode('/',$current_path['path'])); | |
| } | |
| //Fetch page content | |
| function fetchContent() | |
| { | |
| $routs = include __DIR__.DIRECTORY_SEPARATOR.'rotasValidas.php'; | |
| $route = getRoute(); | |
| if( empty($route) ){ | |
| require_once __DIR__.DIRECTORY_SEPARATOR.'pages/home.php'; | |
| }else{ | |
| if(in_array($route[1], array_keys($routs))){ | |
| require_once __DIR__.DIRECTORY_SEPARATOR.$routs[$route[1]]; | |
| }else{ | |
| http_response_code(404); | |
| require_once __DIR__.DIRECTORY_SEPARATOR.'pages/error.php'; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment