Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Working PS3 Jailbreak 3.65 And 3.66
ExtaBit Premium Accounts and Cookies
Steam Wallet Hack - Money Adder & Hack v3
Empires & Allies Hack Cheat Trainer v5.4.1
Eve Onnline 60 Days Time Card Generator v2
Xbox Lve Generator v3
Better way to get content via jQuery $.get()
Free CarTown Blue Points Generator and CarTown Templates
Steam Wallet Hack 2012
Diablo 3 error 37 & error 3006 fix
Popular
XBOX POINTS GENERATOR - MICROSOFT POINTS GENERATOR v1.2012
11 may 2012 premium uploading accounts 100% working
Free Microsoft Points
Free Microsoft Points - Microsoft Points Generator - Xbox Live Codes 2012
Car Town Free Blue Points Hack
Free CarTown Blue Points Generator and CarTown Templates
Free Microsoft Points
Simple Days Purger
Sharecash Downloader Bypass Surveys New 05/2012
PAYPAL REMOVE ACCESS LIMITED ACCOUNT 100% Working
Pastable version of
Router class for determining current Controller
<pre class='prettyprint' language='php'><?php //Instantiate Router instance $router = new Router(); //Register legal Controller class names and their include URLs with Router instance $router->register('GeneralError', 'include/dir/GeneralError.php'); $router->register('MainMenu', 'include/dir/MainMenu.php'); $router->register('GalleryManager', 'include/dir/GalleryManager.php'); //Initiate the Router instance $router->route(); ?> <?php abstract class ARouter { private $legalClassNames = array(); abstract public function route(); abstract protected function defaultRoute(); public function register($className, $includeUrl) { $this->legalClassNames[] = array('className' => $className, 'includeUrl' => $includeUrl); } final protected function isLegal($className) { foreach($this->legalClassNames as $array) { if(in_array($className, $array)) { return true; } } return false; } final protected function includeByClassName($className) { $includeUrl = $this->getIncludeUrlByClassName($className); include $includeUrl; } private function getIncludeUrlByClassName($className) { foreach($this->legalClassNames as $array) { if(in_array($className, $array)) { return $array['includeUrl']; } } return NULL; } } ?> <?php class Router extends ARouter { protected function defaultRoute() { header('Location: index.php?page_name=MainMenu'); } public function route() { if(($_SERVER['REQUEST_METHOD'] == 'POST') || ($_SERVER['REQUEST_METHOD'] == 'GET')) { //Request type is GET or POST $this->getPageName(); } else { //Request type is not GET or POST $this->defaultRoute(); } } protected function getPageName() { if(!isset($_REQUEST['page_name'])) { $this->defaultRoute(); } else if(empty($_REQUEST['page_name'])) { $this->defaultRoute(); } else if(!$this->isLegal($_REQUEST['page_name'])) { $this->defaultRoute(); } else { //Page name is a legal class name $this->initPage($_REQUEST['page_name']); } } private function initPage($className) { $this->includeByClassName($className); $this->page = new $className(); $this->page->init(); } } ?></pre> <a href="http://www.refactormycode.com/codes/1388-router-class-for-determining-current-controller" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>