Guest User

Untitled

a guest
Aug 20th, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. <?php
  2. /*
  3. * The ____ _ _
  4. * | _ \| | | |
  5. * | |_) | |_ _ ___| |__ ___ _ __ _ __ _ _
  6. * | _ <| | | | |/ _ \ '_ \ / _ \ '__| '__| | | |
  7. * | |_) | | |_| | __/ |_) | __/ | | | | |_| |
  8. * |____/|_|\__,_|\___|_.__/ \___|_| |_| \__, |
  9. * __/ |
  10. * |___/ CMS
  11. * @author Caglar <[email protected]>
  12. * @copyright 2015 Caglar
  13. */
  14.  
  15.  
  16.  
  17. namespace System;
  18. use System\View\View;
  19. use System\Common\Configuration;
  20. use System\Common\Server;
  21. use Application\Models\User\Object as User;
  22. use PDO;
  23.  
  24. class Bootstrap {
  25. public $connection, $cfg, $server, $user;
  26. private $controller, $action, $query, $page;
  27.  
  28. public function __construct($connection, $data) {
  29. $this->connection = $connection;
  30. $this->cfg = new Configuration($this->connection);
  31. $this->server = new Server($this->connection);
  32. $this->user = new User($this->connection);
  33.  
  34. $this->controller = $data[0];
  35. $this->action = $data[1];
  36. $this->prepare();
  37. }
  38.  
  39. public function prepare() {
  40. if(isset($_GET["p"])) {
  41. $params = array();
  42. $params = explode("/", $_GET["p"]);
  43. $this->controller = ucwords($params[0]);
  44.  
  45. if(isset($params[1]) && !empty($params[1])) { $this->action = $params[1]; }
  46. if(isset($params[2]) && !empty($params[2])) { $this->query = $params[2]; }
  47. }
  48.  
  49. $this->page = $this->controller;
  50. $this->create();
  51. }
  52.  
  53. public function create() {
  54. $this->controller = ucfirst($this->controller);
  55.  
  56. $plugins = [];
  57. $isPlugin = false;
  58.  
  59. $sth = $this->connection->get()->query("SELECT * FROM `BB_Plugins` WHERE `Activated` = 'true' ORDER BY Importend DESC");
  60. while($obj = $sth->fetch(PDO::FETCH_ASSOC)) {
  61. $plugins[$obj["Namespace"]] = $plugins[$obj["Namespace"]] = array("Name" => $obj["Name"], "Author" => $obj["Author"]);
  62. }
  63.  
  64. if(!defined("LICENSE") || LICENSE !== strtoupper(sha1(md5(sha1($_SERVER["SERVER_NAME"])) * 60 * 60 * 3600))) {
  65. if(file_exists("{$_SERVER["DOCUMENT_ROOT"]}/Exceptions/License.Exception")) {
  66. die(file_get_contents("{$_SERVER["DOCUMENT_ROOT"]}/Exceptions/License.Exception"));
  67. } else {
  68. die("Ungültige Lizenz");
  69. }
  70. }
  71.  
  72. if(!array_key_exists($this->controller, $plugins)) {
  73. $this->controller = "Error";
  74. $this->action = "Index";
  75. $this->page = $this->controller;
  76. require_once("./Application/Controllers//{$this->controller}.php");
  77. $obj = "\Application\Controllers\\{$this->controller}";
  78. } else {
  79. $isPlugin = true;
  80. $this->controller = ucfirst($this->controller);
  81. $obj = "\Application\Plugins\\{$plugins[$this->controller]["Author"]}\\{$this->controller}\\Plugin";
  82. }
  83.  
  84. $load = new $obj(array($this->controller, ucfirst($this->action), $plugins, $isPlugin, $this->connection, $this->cfg, $this->server, $this->user));
  85.  
  86. if(method_exists($load, $this->action)) {
  87. $load->{$this->action}($this->query);
  88. } else {
  89. header("Location: http://{$_SERVER["HTTP_HOST"]}/error");
  90. }
  91. }
  92. }
  93. ?>
Advertisement
Add Comment
Please, Sign In to add comment