/** * */ function __construct() { // Construct Smarty parent::__construct(); ExceptionLoader::LoadExceptions(); // Do XFrames Stuff try { // Load Config $this->config = parse_ini_file(dirname(__FILE__) . '/../include/config.ini', true); // Load and configure Smarty $this->template_dir = $this->config['Smarty']['templates']; $this->compile_dir = $this->config['Smarty']['compiled']; $this->cache_dir = $this->config['Smarty']['cached']; $this->compile_check = false; $this->force_compile = true; $this->caching = false; $this->assignByRef('XF', $this, true); // Load Theming $this->Theme = new XTheme(); // Verify Config $this->validateConfig(); // Connect to MySQLi $this->mysql = new MySQLi($this->config['MySQL']['host'], $this->config['MySQL']['username'], $this->config['MySQL']['password'], $this->config['MySQL']['database'], $this->config['MySQL']['port']); if ($this->mysql->connect_error) { throw new mysqli_sql_exception($this->mysql->connect_error, $this->mysql->connect_errno); } // Read the navigation $this->loadNavigation(); // Set User object $this->User = new User($this); if (isset($_COOKIE[Auth::Cookie])) { $this->User->AuthByCookie($_COOKIE[Auth::Cookie]); } } catch (mysqli_sql_exception $e) { $this->displayError('mysqlError', $e); } catch (XFrames_Config_Exception $e) { $this->displayError('configError', $e); } catch (Exception $e) { $this->displayError('genericError', $e); } }
<?php /** * Created by PhpStorm. * User: Vilim Stubičan * Date: 17.7.2015. * Time: 13:28 */ class ExceptionLoader { private $directory = ""; private $files = array("PartialException" => "PartialException"); public function ExceptionLoader() { $this->directory = INCLUDE_PATH . "exceptions/"; } public function loadFiles() { foreach ($this->files as $fileName => $filePath) { if (file_exists($this->directory . $filePath . ".php")) { require_once $this->directory . $filePath . ".php"; } } } } $shortcodeLoader = new ExceptionLoader(); $shortcodeLoader->loadFiles();