Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * The ____ _ _
- * | _ \| | | |
- * | |_) | |_ _ ___| |__ ___ _ __ _ __ _ _
- * | _ <| | | | |/ _ \ '_ \ / _ \ '__| '__| | | |
- * | |_) | | |_| | __/ |_) | __/ | | | | |_| |
- * |____/|_|\__,_|\___|_.__/ \___|_| |_| \__, |
- * __/ |
- * |___/ CMS
- * @author Caglar <[email protected]>
- * @copyright 2015 Caglar
- */
- namespace System;
- use System\View\View;
- use System\Common\Configuration;
- use System\Common\Server;
- use Application\Models\User\Object as User;
- use PDO;
- class Bootstrap {
- public $connection, $cfg, $server, $user;
- private $controller, $action, $query, $page;
- public function __construct($connection, $data) {
- $this->connection = $connection;
- $this->cfg = new Configuration($this->connection);
- $this->server = new Server($this->connection);
- $this->user = new User($this->connection);
- $this->controller = $data[0];
- $this->action = $data[1];
- $this->prepare();
- }
- public function prepare() {
- if(isset($_GET["p"])) {
- $params = array();
- $params = explode("/", $_GET["p"]);
- $this->controller = ucwords($params[0]);
- if(isset($params[1]) && !empty($params[1])) { $this->action = $params[1]; }
- if(isset($params[2]) && !empty($params[2])) { $this->query = $params[2]; }
- }
- $this->page = $this->controller;
- $this->create();
- }
- public function create() {
- $this->controller = ucfirst($this->controller);
- $plugins = [];
- $isPlugin = false;
- $sth = $this->connection->get()->query("SELECT * FROM `BB_Plugins` WHERE `Activated` = 'true' ORDER BY Importend DESC");
- while($obj = $sth->fetch(PDO::FETCH_ASSOC)) {
- $plugins[$obj["Namespace"]] = $plugins[$obj["Namespace"]] = array("Name" => $obj["Name"], "Author" => $obj["Author"]);
- }
- if(!defined("LICENSE") || LICENSE !== strtoupper(sha1(md5(sha1($_SERVER["SERVER_NAME"])) * 60 * 60 * 3600))) {
- if(file_exists("{$_SERVER["DOCUMENT_ROOT"]}/Exceptions/License.Exception")) {
- die(file_get_contents("{$_SERVER["DOCUMENT_ROOT"]}/Exceptions/License.Exception"));
- } else {
- die("Ungültige Lizenz");
- }
- }
- if(!array_key_exists($this->controller, $plugins)) {
- $this->controller = "Error";
- $this->action = "Index";
- $this->page = $this->controller;
- require_once("./Application/Controllers//{$this->controller}.php");
- $obj = "\Application\Controllers\\{$this->controller}";
- } else {
- $isPlugin = true;
- $this->controller = ucfirst($this->controller);
- $obj = "\Application\Plugins\\{$plugins[$this->controller]["Author"]}\\{$this->controller}\\Plugin";
- }
- $load = new $obj(array($this->controller, ucfirst($this->action), $plugins, $isPlugin, $this->connection, $this->cfg, $this->server, $this->user));
- if(method_exists($load, $this->action)) {
- $load->{$this->action}($this->query);
- } else {
- header("Location: http://{$_SERVER["HTTP_HOST"]}/error");
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment