mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-05 04:37:51 +02:00
General Core Improvments
This commit is contained in:
@@ -4,4 +4,4 @@
|
||||
* Set meta generator
|
||||
*/
|
||||
Action::add('theme_header', 'setMetaGenerator');
|
||||
function setMetaGenerator() { echo '<meta name="generator" content="Powered by Monstra '.MONSTRA_VERSION.'" />'; }
|
||||
function setMetaGenerator() { echo '<meta name="generator" content="Powered by Monstra '.Core::VERSION.'" />'; }
|
@@ -5,32 +5,6 @@
|
||||
* Monstra CMS Defines
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Set gzip output
|
||||
*/
|
||||
define('MONSTRA_GZIP', false);
|
||||
|
||||
/**
|
||||
* Set gzip styles
|
||||
*/
|
||||
define('MONSTRA_GZIP_STYLES', false);
|
||||
|
||||
/**
|
||||
* Set Monstra version
|
||||
*/
|
||||
define('MONSTRA_VERSION', '2.0.1');
|
||||
|
||||
/**
|
||||
* Set Monstra version id
|
||||
*/
|
||||
define('MONSTRA_VERSION_ID', 20001);
|
||||
|
||||
/**
|
||||
* Set Monstra site url
|
||||
*/
|
||||
define('MONSTRA_SITEURL', 'http://monstra.org');
|
||||
|
||||
/**
|
||||
* The filesystem path to the 'monstra' folder
|
||||
*/
|
||||
@@ -109,11 +83,6 @@
|
||||
* The filesystem path to the 'uploads' folder
|
||||
*/
|
||||
define('UPLOADS', ROOT . DS . 'public' . DS . 'uploads');
|
||||
|
||||
/**
|
||||
* Set login sleep value
|
||||
*/
|
||||
define('MONSTRA_LOGIN_SLEEP', 1);
|
||||
|
||||
/**
|
||||
* Set password salt
|
||||
@@ -136,9 +105,9 @@
|
||||
define('CHECK_MONSTRA_VERSION', true);
|
||||
|
||||
/**
|
||||
* Monstra CMS mobile detection
|
||||
* Set gzip output
|
||||
*/
|
||||
define('MONSTRA_MOBILE', true);
|
||||
define('MONSTRA_GZIP', false);
|
||||
|
||||
/**
|
||||
* Monstra database settings
|
||||
|
8
monstra/boot/shortcodes.php
Normal file
8
monstra/boot/shortcodes.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Add new shortcode {siteurl}
|
||||
*/
|
||||
Shortcode::add('siteurl', 'returnSiteUrl');
|
||||
function returnSiteUrl() { return Option::get('siteurl'); }
|
@@ -19,12 +19,6 @@
|
||||
Core::$environment = Core::PRODUCTION;
|
||||
|
||||
|
||||
/**
|
||||
* Include defines
|
||||
*/
|
||||
include ROOT . DS . 'monstra' . DS . 'boot' . DS . 'defines.php';
|
||||
|
||||
|
||||
/**
|
||||
* Monstra requires PHP 5.2.0 or greater
|
||||
*/
|
||||
@@ -43,38 +37,6 @@
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize core
|
||||
*/
|
||||
|
@@ -71,6 +71,38 @@
|
||||
*/
|
||||
protected function __construct() {
|
||||
|
||||
// Load core defines
|
||||
Core::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');
|
||||
}
|
||||
|
||||
// Error handling for Developers only.
|
||||
if (Core::$environment != Core::PRODUCTION) {
|
||||
|
||||
@@ -129,11 +161,8 @@
|
||||
// Load Shortcodes API module
|
||||
require_once(ENGINE . DS . 'shortcodes.php');
|
||||
|
||||
// Load default filters
|
||||
require_once(BOOT . DS . 'filters.php');
|
||||
|
||||
// Load default hooks
|
||||
require_once(BOOT . DS . 'hooks.php');
|
||||
// Load default
|
||||
Core::loadPluggable();
|
||||
|
||||
// Init I18n
|
||||
I18n::init(Option::get('language'));
|
||||
@@ -163,6 +192,81 @@
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load Defines
|
||||
*/
|
||||
protected static function loadDefines() {
|
||||
|
||||
$environments = array(1 => 'production',
|
||||
2 => 'staging',
|
||||
3 => 'testing',
|
||||
4 => 'development');
|
||||
|
||||
$root_defines = ROOT . DS . 'boot' . DS . 'defines.php';
|
||||
$environment_defines = ROOT . DS . 'boot' . DS . $environments[Core::$environment] . DS . 'defines.php';
|
||||
$monstra_defines = ROOT . DS . 'monstra' . DS . 'boot' . DS . 'defines.php';
|
||||
|
||||
|
||||
if (file_exists($root_defines)) {
|
||||
include $root_defines;
|
||||
} elseif(file_exists($environment_defines)) {
|
||||
include $environment_defines;
|
||||
} elseif(file_exists($monstra_defines)) {
|
||||
include $monstra_defines;
|
||||
} else {
|
||||
throw new RuntimeException("The defines file does not exist.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load Pluggable
|
||||
*/
|
||||
protected static function loadPluggable() {
|
||||
|
||||
$environments = array(1 => 'production',
|
||||
2 => 'staging',
|
||||
3 => 'testing',
|
||||
4 => 'development');
|
||||
|
||||
$root_pluggable = ROOT . DS . 'boot';
|
||||
$environment_pluggable = ROOT . DS . 'boot' . DS . $environments[Core::$environment];
|
||||
$monstra_pluggable = ROOT . DS . 'monstra' . DS . 'boot';
|
||||
|
||||
|
||||
if (file_exists($root_pluggable . DS . 'filters.php')) {
|
||||
include $root_pluggable . DS . 'filters.php';
|
||||
} elseif(file_exists($environment_pluggable . DS . 'filters.php')) {
|
||||
include $environment_pluggable . DS . 'filters.php';
|
||||
} elseif(file_exists($monstra_pluggable . DS . 'filters.php')) {
|
||||
include $monstra_pluggable . DS . 'filters.php';
|
||||
} else {
|
||||
throw new RuntimeException("The pluggable file does not exist.");
|
||||
}
|
||||
|
||||
if (file_exists($root_pluggable . DS . 'actions.php')) {
|
||||
include $root_pluggable . DS . 'actions.php';
|
||||
} elseif(file_exists($environment_pluggable . DS . 'actions.php')) {
|
||||
include $environment_pluggable . DS . 'actions.php';
|
||||
} elseif(file_exists($monstra_pluggable . DS . 'actions.php')) {
|
||||
include $monstra_pluggable . DS . 'actions.php';
|
||||
} else {
|
||||
throw new RuntimeException("The pluggable file does not exist.");
|
||||
}
|
||||
|
||||
if (file_exists($root_pluggable . DS . 'shortcodes.php')) {
|
||||
include $root_pluggable . DS . 'shortcodes.php';
|
||||
} elseif(file_exists($environment_pluggable . DS . 'shortcodes.php')) {
|
||||
include $environment_pluggable . DS . 'shortcodes.php';
|
||||
} elseif(file_exists($monstra_pluggable . DS . 'shortcodes.php')) {
|
||||
include $monstra_pluggable . DS . 'shortcodes.php';
|
||||
} else {
|
||||
throw new RuntimeException("The pluggable file does not exist.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exception Handler
|
||||
*
|
||||
@@ -367,6 +471,7 @@
|
||||
highlight_string('<?php ' . str_replace('/*', '#$@r4!/*', $string), true));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert errors not caught by the errorHandler to ErrorExceptions.
|
||||
|
@@ -221,12 +221,7 @@
|
||||
* @return string
|
||||
*/
|
||||
public static function powered() {
|
||||
return __('Powered by', 'system').' <a href="' . MONSTRA_SITEURL . '" target="_blank">Monstra</a> ' . MONSTRA_VERSION;
|
||||
return __('Powered by', 'system').' <a href="http://monstra.org" target="_blank">Monstra</a> ' . Core::VERSION;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Add new shortcode {siteurl}
|
||||
Shortcode::add('siteurl', 'returnSiteUrl');
|
||||
function returnSiteUrl() { return Option::get('siteurl'); }
|
||||
}
|
Reference in New Issue
Block a user