Advertisement
Guest User

Untitled

a guest
Jul 26th, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.51 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * SourceChat - 2014
  5.  * Copyright (C) 2014 Necmi Hasan
  6.  *
  7.  * @author Necmi Hasan [email protected]
  8.  * @copyright 2014, Necmi Hasan
  9.  * @license General Public License
  10.  * @link -
  11.  * @package BootstrapClass
  12.  * @date 26.07.2014
  13.  * */
  14. class Bootstrap {
  15.    
  16.     public function __construct($route) {
  17.         if(!is_null($route)) {
  18.             if(isset($_GET['page'])) {
  19.                 $url = rtrim($route, '/');
  20.                 $url = explode('/', $url);
  21.                 $className = ucfirst($url[0]).'Controller';
  22.                 if(file_exists(PHP_PATH.'controllers/'.ucfirst($url[0]).'Controller.php')) {
  23.                     require PHP_PATH.'controllers/'.$className.'.php';
  24.                 } else {
  25.                     require PHP_PATH.'controllers/ErrorController.php';
  26.                     new ErrorController();
  27.                 }
  28.                 $classDefined = new $className;
  29.                 $methodParams = 1;
  30.                 $methodStand = $className;
  31.                 $pageParameters = array();
  32.                 if(isset($url[1])) {
  33.                     if(method_exists($classDefined, $url[1])) {
  34.                         $methodStand = $url[1];
  35.                         $methodParams = 2;
  36.                     }
  37.                 }
  38.                 $classDefined->$methodStand($pageParameters);
  39.             }
  40.         } else {
  41.                 require PHP_PATH.'controllers/IndexController.php';
  42.                 $test = new IndexController();
  43.             }
  44.     }
  45. }
  46. //DON'T STEAL IT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement