/**
  * Execute routes routes
  *
  *  <code>
  *       $m->lauch()
  *  </code>
  * @access  public
  *
  */
 public function lauch()
 {
     // Use the Force...
     include LIBRARIES . '/Force/ClassLoader/ClassLoader.php';
     // Map Classes
     ClassLoader::mapClasses(array('Spyc' => LIBRARIES . '/Spyc/Spyc.php', 'Arr' => LIBRARIES . '/Force/Arr/Arr.php', 'Session' => LIBRARIES . '/Force/Session/Session.php', 'Token' => LIBRARIES . '/Force/Token/Token.php', 'Request' => LIBRARIES . '/Force/Http/Request.php', 'Response' => LIBRARIES . '/Force/Http/Response.php', 'Url' => LIBRARIES . '/Force/Url/Url.php', 'File' => LIBRARIES . '/Force/FileSystem/File.php', 'Dir' => LIBRARIES . '/Force/FileSystem/Dir.php'));
     // Register the ClassLoader to the SPL autoload stack.
     ClassLoader::register();
     // Load config file
     $this->loadConfig();
     // Load language file
     $this->loadLanguage();
     // 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();
     $url = $_SERVER['REQUEST_URI'];
     $base = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']));
     if (strpos($url, $base) === 0) {
         $url = substr($url, strlen($base));
     }
     $url = trim($url, '/');
     foreach ($this->routes as $pattern => $callback) {
         if (preg_match($pattern, $url, $params)) {
             array_shift($params);
             return call_user_func_array($callback, array_values($params));
         }
     }
 }
Example #2
0
 /**
  * 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');
 }
Example #3
0
 /**
  * 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();
     }
 }
Log::configure('path', GELATO_LOGS_PATH);
/**
 * Load Gelato Error Handler
 */
require_once __DIR__ . '/ErrorHandler/ErrorHandler.php';
/**
 * Set Error Handler
 */
set_error_handler('ErrorHandler::error');
/**
 * Set Fatal Error Handler
 */
register_shutdown_function('ErrorHandler::fatal');
/**
 * Set Exception Handler
 */
set_exception_handler('ErrorHandler::exception');
/**
 * Gelato Class Loader
 */
require_once __DIR__ . '/ClassLoader/ClassLoader.php';
/**
 * Map all Gelato Classes
 */
ClassLoader::mapClasses(array('Agent' => __DIR__ . '/Agent/Agent.php', 'Arr' => __DIR__ . '/Arr/Arr.php', 'Cache' => __DIR__ . '/Cache/Cache.php', 'Cookie' => __DIR__ . '/Cookie/Cookie.php', 'Curl' => __DIR__ . '/Curl/Curl.php', 'Date' => __DIR__ . '/Date/Date.php', 'Debug' => __DIR__ . '/Debug/Debug.php', 'File' => __DIR__ . '/FileSystem/File.php', 'Dir' => __DIR__ . '/FileSystem/Dir.php', 'Form' => __DIR__ . '/Form/Form.php', 'Html' => __DIR__ . '/Html/Html.php', 'Image' => __DIR__ . '/Image/Image.php', 'Inflector' => __DIR__ . '/Inflector/Inflector.php', 'MinifyCSS' => __DIR__ . '/Minify/MinifyCSS.php', 'MinifyHTML' => __DIR__ . '/Minify/MinifyHTML.php', 'MinifyJS' => __DIR__ . '/Minify/MinifyJS.php', 'Notification' => __DIR__ . '/Notification/Notification.php', 'Number' => __DIR__ . '/Number/Number.php', 'Registry' => __DIR__ . '/Registry/Registry.php', 'Request' => __DIR__ . '/Http/Request.php', 'Response' => __DIR__ . '/Http/Response.php', 'Token' => __DIR__ . '/Security/Token.php', 'Text' => __DIR__ . '/Text/Text.php', 'Session' => __DIR__ . '/Session/Session.php', 'Url' => __DIR__ . '/Url/Url.php', 'Valid' => __DIR__ . '/Validation/Valid.php', 'Zip' => __DIR__ . '/Zip/Zip.php'));
/**
 * Register Gelato Class Loader
 */
if (GELATO_CLASS_LOADER) {
    ClassLoader::register();
}