Advertisement
Guest User

Untitled

a guest
Jul 27th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.54 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * SourceChat - 2014
  5.  * Copyright (C) 2014 Necmi Hasan
  6.  *
  7.  * @author Necmi Hasan necmi.hasan@outlook.com
  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.                 $url = rtrim($route, '/');
  19.                 $url = explode('/', $url);
  20.                 $className = ucfirst($url[0]).'Controller';
  21.                 if(file_exists(PHP_PATH.'controllers/'.ucfirst($url[0]).'Controller.php')) {
  22.                     require PHP_PATH.'controllers/'.ucfirst($url[0]).'Controller.php';
  23.                 } else {
  24.                     require PHP_PATH.'controllers/ErrorController.php';
  25.                     new ErrorController();
  26.                 }
  27.                 $classDefined = new $className;
  28.                 $methodParams = 1;
  29.                 $methodStand = $className;
  30.                 $pageParameters = array();
  31.                 if(isset($url[1])) {
  32.                     if(method_exists($classDefined, $url[1])) {
  33.                         $methodStand = $url[1];
  34.                         $methodParams = 2;
  35.                     }
  36.                 }
  37.                 $classDefined->$methodStand($pageParameters);
  38.         } else {
  39.                 require PHP_PATH.'controllers/IndexController.php';
  40.                 $test = new IndexController();
  41.         }
  42.     }
  43. }
  44.  
  45. $page = null;
  46. if(isset($_GET['page'])) {
  47.     $page = $_GET['page'];
  48. }
  49. new Bootstrap($page);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement