/** * Protected Construct */ protected function __construct() { /** * Load core defines */ Monstra::loadDefines(); /** * Compress HTML with gzip */ if (MONSTRA_GZIP) { if (!ob_start("ob_gzhandler")) { ob_start(); } } else { ob_start(); } /** * Send default header and set internal encoding */ header('Content-Type: text/html; charset=UTF-8'); function_exists('mb_language') and mb_language('uni'); function_exists('mb_regex_encoding') and mb_regex_encoding('UTF-8'); function_exists('mb_internal_encoding') and mb_internal_encoding('UTF-8'); /** * Gets the current configuration setting of magic_quotes_gpc * and kill magic quotes */ if (get_magic_quotes_gpc()) { function stripslashesGPC(&$value) { $value = stripslashes($value); } array_walk_recursive($_GET, 'stripslashesGPC'); array_walk_recursive($_POST, 'stripslashesGPC'); array_walk_recursive($_COOKIE, 'stripslashesGPC'); array_walk_recursive($_REQUEST, 'stripslashesGPC'); } /** * Set Gelato Display Errors to False for Production environment. */ if (Monstra::$environment == Monstra::PRODUCTION) { define('GELATO_DEVELOPMENT', false); } /** * Define Monstra Folder for Gelato Logs */ define('GELATO_LOGS_PATH', LOGS); /** * Include Gelato Library */ include ROOT . DS . 'libraries' . DS . 'Gelato' . DS . 'Gelato.php'; /** * Map Monstra Engine Directory */ ClassLoader::directory(ROOT . DS . 'engine' . DS); /** * Map all Monstra Classes */ ClassLoader::mapClasses(array('Security' => ROOT . DS . 'engine' . DS . 'Security.php', 'Uri' => ROOT . DS . 'engine' . DS . 'Uri.php', 'Site' => ROOT . DS . 'engine' . DS . 'Site.php', 'Alert' => ROOT . DS . 'engine' . DS . 'Alert.php', 'XML' => ROOT . DS . 'engine' . DS . 'Xmldb' . DS . 'XML.php', 'DB' => ROOT . DS . 'engine' . DS . 'Xmldb' . DS . 'DB.php', 'Table' => ROOT . DS . 'engine' . DS . 'Xmldb' . DS . 'Table.php', 'Plugin' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Plugin.php', 'Frontend' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Frontend.php', 'Backend' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Backend.php', 'Action' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Action.php', 'Filter' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Filter.php', 'View' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'View.php', 'I18n' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'I18n.php', 'Stylesheet' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Stylesheet.php', 'Javascript' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Javascript.php', 'Navigation' => ROOT . DS . 'engine' . DS . 'Plugin' . DS . 'Navigation.php', 'Option' => ROOT . DS . 'engine' . DS . 'Option.php', 'Shortcode' => ROOT . DS . 'engine' . DS . 'Shortcode.php', 'ORM' => ROOT . DS . 'libraries' . DS . 'Idiorm' . DS . 'ORM.php', 'PHPMailer' => ROOT . DS . 'libraries' . DS . 'PHPMailer' . DS . 'PHPMailer.php')); /** * Start session */ Session::start(); /** * Init Idiorm */ if (defined('MONSTRA_DB_DSN')) { ORM::configure(MONSTRA_DB_DSN); ORM::configure('username', MONSTRA_DB_USER); ORM::configure('password', MONSTRA_DB_PASSWORD); ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); } /** * Auto cleanup if DEVELOPMENT environment */ if (Monstra::$environment == Monstra::DEVELOPMENT) { Monstra::cleanTmp(); } /** * Set Cache dir */ Cache::configure('cache_dir', CACHE); /** * Init Options API module */ Option::init(); /** * Set default timezone */ @ini_set('date.timezone', Option::get('timezone')); if (function_exists('date_default_timezone_set')) { date_default_timezone_set(Option::get('timezone')); } else { putenv('TZ=' . Option::get('timezone')); } /** * Sanitize URL to prevent XSS - Cross-site scripting */ Security::runSanitizeURL(); /** * Load default */ Monstra::loadPluggable(); /** * Init I18n */ I18n::init(Option::get('language')); /** * Init Plugins API */ Plugin::init(); /** * Init Notification service */ Notification::init(); /** * Init site module */ if (!BACKEND) { Site::init(); } }
/** * Constructor. * * @access protected */ protected function __construct() { // Use the Force... include LIBRARIES_PATH . '/Force/ClassLoader/ClassLoader.php'; // Map Classes ClassLoader::mapClasses(array('Spyc' => LIBRARIES_PATH . '/Spyc/Spyc.php', 'Arr' => LIBRARIES_PATH . '/Force/Arr/Arr.php', 'Session' => LIBRARIES_PATH . '/Force/Session/Session.php', 'Token' => LIBRARIES_PATH . '/Force/Token/Token.php', 'Request' => LIBRARIES_PATH . '/Force/Http/Request.php', 'Response' => LIBRARIES_PATH . '/Force/Http/Response.php', 'Url' => LIBRARIES_PATH . '/Force/Url/Url.php', 'File' => LIBRARIES_PATH . '/Force/FileSystem/File.php', 'Dir' => LIBRARIES_PATH . '/Force/FileSystem/Dir.php', 'Shortcode' => LIBRARIES_PATH . '/Force/Shortcode/Shortcode.php', 'Parsedown' => LIBRARIES_PATH . '/Parsedown/Parsedown.php', 'ParsedownExtra' => LIBRARIES_PATH . '/Parsedown/ParsedownExtra.php')); // Map Fenom Template Engine folder ClassLoader::directory(LIBRARIES_PATH . '/Fenom/'); // Register the ClassLoader to the SPL autoload stack. ClassLoader::register(); // Load config file static::loadConfig(); // Set default timezone @ini_set('date.timezone', static::$site['timezone']); if (function_exists('date_default_timezone_set')) { date_default_timezone_set(static::$site['timezone']); } else { putenv('TZ=' . static::$site['timezone']); } // Sanitize URL to prevent XSS - Cross-site scripting Url::runSanitizeURL(); // Send default header and set internal encoding header('Content-Type: text/html; charset=' . static::$site['charset']); function_exists('mb_language') and mb_language('uni'); function_exists('mb_regex_encoding') and mb_regex_encoding(static::$site['charset']); function_exists('mb_internal_encoding') and mb_internal_encoding(static::$site['charset']); // Gets the current configuration setting of magic_quotes_gpc and kill magic quotes if (get_magic_quotes_gpc()) { function stripslashesGPC(&$value) { $value = stripslashes($value); } array_walk_recursive($_GET, 'stripslashesGPC'); array_walk_recursive($_POST, 'stripslashesGPC'); array_walk_recursive($_COOKIE, 'stripslashesGPC'); array_walk_recursive($_REQUEST, 'stripslashesGPC'); } // Start the session Session::start(); // Load Plugins static::loadPlugins(); static::runAction('plugins_loaded'); // Get page for current requested url Morfy::$page = static::getPage(Url::getUriString()); // Load template static::runAction('before_render'); static::loadPageTemplate(Morfy::$page); static::runAction('after_render'); }