mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-06 13:16:54 +02:00
Monstra General Updates
This commit is contained in:
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Alert
|
||||
{
|
||||
/**
|
||||
@@ -48,7 +45,7 @@ class Alert
|
||||
type: "success",
|
||||
message : "'.$message.'",
|
||||
hideAfter: '.$seconds.'
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
|
||||
@@ -71,9 +68,9 @@ class Alert
|
||||
echo '<script type="text/javascript">
|
||||
Messenger().post({
|
||||
type: "info",
|
||||
message : "'.$message.'",
|
||||
message : "'.$message.'",
|
||||
hideAfter: '.$seconds.'
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
|
||||
@@ -96,10 +93,9 @@ class Alert
|
||||
echo '<script type="text/javascript">
|
||||
Messenger().post({
|
||||
type: "error",
|
||||
message : "'.$message.'",
|
||||
message : "'.$message.'",
|
||||
hideAfter: '.$seconds.'
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,19 +1,11 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* Monstra - Content Management System.
|
||||
* Site: www.mostra.org
|
||||
* Copyright (C) 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -85,7 +77,9 @@ class Monstra
|
||||
* Compress HTML with gzip
|
||||
*/
|
||||
if (MONSTRA_GZIP) {
|
||||
if ( ! ob_start("ob_gzhandler")) ob_start();
|
||||
if (! ob_start("ob_gzhandler")) {
|
||||
ob_start();
|
||||
}
|
||||
} else {
|
||||
ob_start();
|
||||
}
|
||||
@@ -94,16 +88,19 @@ class Monstra
|
||||
* 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');
|
||||
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); }
|
||||
function stripslashesGPC(&$value)
|
||||
{
|
||||
$value = stripslashes($value);
|
||||
}
|
||||
array_walk_recursive($_GET, 'stripslashesGPC');
|
||||
array_walk_recursive($_POST, 'stripslashesGPC');
|
||||
array_walk_recursive($_COOKIE, 'stripslashesGPC');
|
||||
@@ -120,7 +117,7 @@ class Monstra
|
||||
/**
|
||||
* Define Monstra Folder for Gelato Logs
|
||||
*/
|
||||
define ('GELATO_LOGS_PATH', LOGS);
|
||||
define('GELATO_LOGS_PATH', LOGS);
|
||||
|
||||
/**
|
||||
* Include Gelato Library
|
||||
@@ -209,7 +206,11 @@ class Monstra
|
||||
* 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'));
|
||||
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
|
||||
@@ -239,7 +240,9 @@ class Monstra
|
||||
/**
|
||||
* Init site module
|
||||
*/
|
||||
if ( ! BACKEND) Site::init();
|
||||
if (! BACKEND) {
|
||||
Site::init();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,7 +303,6 @@ class Monstra
|
||||
} else {
|
||||
throw new RuntimeException("The pluggable shortcodes.php file does not exist.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,10 +311,18 @@ class Monstra
|
||||
public static function cleanTmp()
|
||||
{
|
||||
// Cleanup minify
|
||||
if (count($files = File::scan(MINIFY, array('css', 'js', 'php'))) > 0) foreach ($files as $file) File::delete(MINIFY . DS . $file);
|
||||
if (count($files = File::scan(MINIFY, array('css', 'js', 'php'))) > 0) {
|
||||
foreach ($files as $file) {
|
||||
File::delete(MINIFY . DS . $file);
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup cache
|
||||
if (count($namespaces = Dir::scan(CACHE)) > 0) foreach ($namespaces as $namespace) Dir::delete(CACHE . DS . $namespace);
|
||||
if (count($namespaces = Dir::scan(CACHE)) > 0) {
|
||||
foreach ($namespaces as $namespace) {
|
||||
Dir::delete(CACHE . DS . $namespace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,8 +332,9 @@ class Monstra
|
||||
*/
|
||||
public static function init()
|
||||
{
|
||||
if ( ! isset(self::$instance)) self::$instance = new Monstra();
|
||||
if (! isset(self::$instance)) {
|
||||
self::$instance = new Monstra();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Option
|
||||
{
|
||||
/**
|
||||
@@ -38,7 +35,9 @@ class Option
|
||||
*/
|
||||
public static function init()
|
||||
{
|
||||
if ( ! isset(self::$instance)) self::$instance = new Option();
|
||||
if (! isset(self::$instance)) {
|
||||
self::$instance = new Option();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
@@ -176,5 +175,4 @@ class Option
|
||||
// Check if option exists
|
||||
return (count(Option::$options->select('[name="'.$option.'"]', null)) > 0) ? true : false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Action
|
||||
{
|
||||
/**
|
||||
@@ -102,23 +99,15 @@ class Action
|
||||
} else {
|
||||
call_user_func_array($action['function'], $args);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ($return) {
|
||||
return call_user_func_array($action['function'], $action['args']);
|
||||
} else {
|
||||
call_user_func_array($action['function'], $action['args']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,15 +1,11 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -17,5 +13,7 @@
|
||||
|
||||
class Backend
|
||||
{
|
||||
public static function main() { }
|
||||
public static function main()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Filter
|
||||
{
|
||||
/**
|
||||
@@ -52,12 +49,12 @@ class Filter
|
||||
|
||||
$args = array_slice(func_get_args(), 2);
|
||||
|
||||
if ( ! isset(Filter::$filters[$filter_name])) {
|
||||
if (! isset(Filter::$filters[$filter_name])) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
foreach (Filter::$filters[$filter_name] as $priority => $functions) {
|
||||
if ( ! is_null($functions)) {
|
||||
if (! is_null($functions)) {
|
||||
foreach ($functions as $function) {
|
||||
$all_args = array_merge(array($value), $args);
|
||||
$function_name = $function['function'];
|
||||
@@ -120,5 +117,4 @@ class Filter
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,27 +1,40 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Frontend
|
||||
{
|
||||
public static function main() { }
|
||||
public static function title() { return ''; }
|
||||
public static function description() { return ''; }
|
||||
public static function keywords() { return ''; }
|
||||
public static function template() { return 'index'; }
|
||||
public static function content() { return ''; }
|
||||
|
||||
public static function main()
|
||||
{
|
||||
}
|
||||
public static function title()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
public static function description()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
public static function keywords()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
public static function template()
|
||||
{
|
||||
return 'index';
|
||||
}
|
||||
public static function content()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class I18n
|
||||
{
|
||||
/**
|
||||
@@ -77,7 +74,9 @@ class I18n
|
||||
*/
|
||||
public static function init($locale)
|
||||
{
|
||||
if ( ! isset(self::$instance)) self::$instance = new I18n($locale);
|
||||
if (! isset(self::$instance)) {
|
||||
self::$instance = new I18n($locale);
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
@@ -116,7 +115,6 @@ class I18n
|
||||
|
||||
// Loop through each installed plugin
|
||||
foreach ($records as $record) {
|
||||
|
||||
if (is_dir(ROOT . DS . dirname($record['location']) . DS . 'languages')) {
|
||||
|
||||
// Init var
|
||||
@@ -127,7 +125,6 @@ class I18n
|
||||
|
||||
// Merge the language strings into the sub table
|
||||
$t = array_merge($t, include ROOT . DS . dirname($record['location']) . DS . 'languages' . DS . $locale . '.lang.php');
|
||||
|
||||
}
|
||||
|
||||
// Append the sub table, preventing less specific language files from overloading more specific files
|
||||
@@ -164,9 +161,12 @@ class I18n
|
||||
$string = (string) $string;
|
||||
|
||||
// Return string
|
||||
if (isset(I18n::$dictionary[$namespace][$string])) return I18n::$dictionary[$namespace][$string]; else return $string;
|
||||
if (isset(I18n::$dictionary[$namespace][$string])) {
|
||||
return I18n::$dictionary[$namespace][$string];
|
||||
} else {
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Javascript
|
||||
{
|
||||
/**
|
||||
@@ -66,7 +63,6 @@ class Javascript
|
||||
|
||||
// Load javascripts
|
||||
if (count(Javascript::$javascripts) > 0) {
|
||||
|
||||
$backend_buffer = '';
|
||||
$backend_regenerate = false;
|
||||
|
||||
@@ -80,8 +76,8 @@ class Javascript
|
||||
|
||||
// Build backend site javascript
|
||||
foreach ($javascripts as $javascript) {
|
||||
if ((file_exists(ROOT . DS . $javascript['file'])) and (($javascript['load'] == 'backend') or ($javascript['load'] == 'both')) ) {
|
||||
if ( ! file_exists($backend_site_js_path) or filemtime(ROOT . DS . $javascript['file']) > filemtime($backend_site_js_path)) {
|
||||
if ((file_exists(ROOT . DS . $javascript['file'])) and (($javascript['load'] == 'backend') or ($javascript['load'] == 'both'))) {
|
||||
if (! file_exists($backend_site_js_path) or filemtime(ROOT . DS . $javascript['file']) > filemtime($backend_site_js_path)) {
|
||||
$backend_regenerate = true;
|
||||
break;
|
||||
}
|
||||
@@ -91,20 +87,19 @@ class Javascript
|
||||
// Regenerate site javascript
|
||||
if ($backend_regenerate) {
|
||||
foreach ($javascripts as $javascript) {
|
||||
if ((file_exists(ROOT . DS . $javascript['file'])) and (($javascript['load'] == 'backend') or ($javascript['load'] == 'both')) ) {
|
||||
if ((file_exists(ROOT . DS . $javascript['file'])) and (($javascript['load'] == 'backend') or ($javascript['load'] == 'both'))) {
|
||||
$backend_buffer .= file_get_contents(ROOT . DS . $javascript['file'])."\n";
|
||||
}
|
||||
}
|
||||
file_put_contents($backend_site_js_path, $backend_buffer);
|
||||
$backend_regenerate = false;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Build frontend site javascript
|
||||
foreach ($javascripts as $javascript) {
|
||||
if ((file_exists(ROOT . DS . $javascript['file'])) and (($javascript['load'] == 'frontend') or ($javascript['load'] == 'both')) ) {
|
||||
if ( ! file_exists($frontend_site_js_path) or filemtime(ROOT . DS . $javascript['file']) > filemtime($frontend_site_js_path)) {
|
||||
if ((file_exists(ROOT . DS . $javascript['file'])) and (($javascript['load'] == 'frontend') or ($javascript['load'] == 'both'))) {
|
||||
if (! file_exists($frontend_site_js_path) or filemtime(ROOT . DS . $javascript['file']) > filemtime($frontend_site_js_path)) {
|
||||
$frontend_regenerate = true;
|
||||
break;
|
||||
}
|
||||
@@ -114,14 +109,13 @@ class Javascript
|
||||
// Regenerate site javascript
|
||||
if ($frontend_regenerate) {
|
||||
foreach ($javascripts as $javascript) {
|
||||
if ((file_exists(ROOT . DS . $javascript['file'])) and (($javascript['load'] == 'frontend') or ($javascript['load'] == 'both')) ) {
|
||||
if ((file_exists(ROOT . DS . $javascript['file'])) and (($javascript['load'] == 'frontend') or ($javascript['load'] == 'both'))) {
|
||||
$frontend_buffer .= file_get_contents(ROOT . DS . $javascript['file'])."\n";
|
||||
}
|
||||
}
|
||||
file_put_contents($frontend_site_js_path, $frontend_buffer);
|
||||
$frontend_regenerate = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Render
|
||||
@@ -136,9 +130,8 @@ class Javascript
|
||||
/**
|
||||
* javascriptVersionIncrement
|
||||
*/
|
||||
public static function javascriptVersionIncrement() {
|
||||
Option::update('javascript_version', (int) Option::get('javascript_version') + 1);
|
||||
public static function javascriptVersionIncrement()
|
||||
{
|
||||
Option::update('javascript_version', (int) Option::get('javascript_version') + 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Navigation
|
||||
{
|
||||
/**
|
||||
@@ -83,7 +80,11 @@ class Navigation
|
||||
foreach ($items as $item) {
|
||||
|
||||
// If current plugin id == selected item id then set class to current
|
||||
if (Request::get('id') == $item['id'] && $item['external'] == false) $class = 'class = "current" '; else $class = '';
|
||||
if (Request::get('id') == $item['id'] && $item['external'] == false) {
|
||||
$class = 'class = "current" ';
|
||||
} else {
|
||||
$class = '';
|
||||
}
|
||||
|
||||
// If current category == item category and navigation type is left them draw this item
|
||||
if ($item['category'] == $category && $item['type'] == Navigation::LEFT) {
|
||||
@@ -133,7 +134,11 @@ class Navigation
|
||||
foreach ($items as $item) {
|
||||
|
||||
// If current plugin id == selected item id then set class to current
|
||||
if (Request::get('id') == $item['id'] && $item['external'] == false) $class = 'class = "current" '; else $class = '';
|
||||
if (Request::get('id') == $item['id'] && $item['external'] == false) {
|
||||
$class = 'class = "current" ';
|
||||
} else {
|
||||
$class = '';
|
||||
}
|
||||
|
||||
// If current category == item category and navigation type is left them draw this item
|
||||
if ($item['category'] == $category && $item['type'] == Navigation::LEFT) {
|
||||
@@ -158,7 +163,6 @@ class Navigation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,7 +183,11 @@ class Navigation
|
||||
foreach ($items as $item) {
|
||||
|
||||
// If current plugin id == selected item id then set class to current
|
||||
if (Request::get('id') == $item['id'] && $item['external'] == false) $class = 'selected = "selected" '; else $class = '';
|
||||
if (Request::get('id') == $item['id'] && $item['external'] == false) {
|
||||
$class = 'selected = "selected" ';
|
||||
} else {
|
||||
$class = '';
|
||||
}
|
||||
|
||||
// If current category == item category and navigation type is left them draw this item
|
||||
if ($item['category'] == $category && $item['type'] == Navigation::LEFT) {
|
||||
@@ -191,5 +199,4 @@ class Navigation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Plugin
|
||||
{
|
||||
/**
|
||||
@@ -45,7 +42,9 @@ class Plugin
|
||||
*/
|
||||
public static function init()
|
||||
{
|
||||
if ( ! isset(self::$instance)) self::$instance = new Plugin();
|
||||
if (! isset(self::$instance)) {
|
||||
self::$instance = new Plugin();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
@@ -102,7 +101,7 @@ class Plugin
|
||||
if (BACKEND) {
|
||||
|
||||
// Plugin admin folder
|
||||
if ( ! empty($alt_folder)) {
|
||||
if (! empty($alt_folder)) {
|
||||
$folder = $alt_folder . DS . strtolower($plug);
|
||||
} else {
|
||||
$folder = strtolower($plug);
|
||||
@@ -157,7 +156,11 @@ class Plugin
|
||||
$id = strtolower(basename($file, '.plugin.php'));
|
||||
|
||||
// Set plugin privilege 'box' if $box is true
|
||||
if ($box) $privilege = 'box'; else $privilege = '';
|
||||
if ($box) {
|
||||
$privilege = 'box';
|
||||
} else {
|
||||
$privilege = '';
|
||||
}
|
||||
|
||||
// Register plugin in global plugins array.
|
||||
Plugin::$plugins[$id] = array(
|
||||
@@ -175,9 +178,8 @@ class Plugin
|
||||
// Example:
|
||||
// www.example.org/guestbook
|
||||
// www.example.org/news
|
||||
if ( ! empty($component)) {
|
||||
if (! empty($component)) {
|
||||
Plugin::$components[] = $component;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Stylesheet
|
||||
{
|
||||
/**
|
||||
@@ -66,7 +63,6 @@ class Stylesheet
|
||||
|
||||
// Load stylesheets
|
||||
if (count(Stylesheet::$stylesheets) > 0) {
|
||||
|
||||
$backend_buffer = '';
|
||||
$backend_regenerate = false;
|
||||
|
||||
@@ -80,8 +76,8 @@ class Stylesheet
|
||||
|
||||
// Build backend site stylesheets
|
||||
foreach ($stylesheets as $stylesheet) {
|
||||
if ((file_exists(ROOT . DS . $stylesheet['file'])) and (($stylesheet['load'] == 'backend') or ($stylesheet['load'] == 'both')) ) {
|
||||
if ( ! file_exists($backend_site_css_path) or filemtime(ROOT . DS . $stylesheet['file']) > filemtime($backend_site_css_path)) {
|
||||
if ((file_exists(ROOT . DS . $stylesheet['file'])) and (($stylesheet['load'] == 'backend') or ($stylesheet['load'] == 'both'))) {
|
||||
if (! file_exists($backend_site_css_path) or filemtime(ROOT . DS . $stylesheet['file']) > filemtime($backend_site_css_path)) {
|
||||
$backend_regenerate = true;
|
||||
break;
|
||||
}
|
||||
@@ -91,7 +87,7 @@ class Stylesheet
|
||||
// Regenerate site stylesheet
|
||||
if ($backend_regenerate) {
|
||||
foreach ($stylesheets as $stylesheet) {
|
||||
if ((file_exists(ROOT . DS . $stylesheet['file'])) and (($stylesheet['load'] == 'backend') or ($stylesheet['load'] == 'both')) ) {
|
||||
if ((file_exists(ROOT . DS . $stylesheet['file'])) and (($stylesheet['load'] == 'backend') or ($stylesheet['load'] == 'both'))) {
|
||||
$backend_buffer .= file_get_contents(ROOT . DS . $stylesheet['file']);
|
||||
}
|
||||
}
|
||||
@@ -99,13 +95,12 @@ class Stylesheet
|
||||
file_put_contents($backend_site_css_path, MinifyCSS::process($backend_buffer));
|
||||
$backend_regenerate = false;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Build frontend site stylesheets
|
||||
foreach ($stylesheets as $stylesheet) {
|
||||
if ((file_exists(ROOT . DS . $stylesheet['file'])) and (($stylesheet['load'] == 'frontend') or ($stylesheet['load'] == 'both')) ) {
|
||||
if ( ! file_exists($frontend_site_css_path) or filemtime(ROOT . DS . $stylesheet['file']) > filemtime($frontend_site_css_path)) {
|
||||
if ((file_exists(ROOT . DS . $stylesheet['file'])) and (($stylesheet['load'] == 'frontend') or ($stylesheet['load'] == 'both'))) {
|
||||
if (! file_exists($frontend_site_css_path) or filemtime(ROOT . DS . $stylesheet['file']) > filemtime($frontend_site_css_path)) {
|
||||
$frontend_regenerate = true;
|
||||
break;
|
||||
}
|
||||
@@ -115,7 +110,7 @@ class Stylesheet
|
||||
// Regenerate site stylesheet
|
||||
if ($frontend_regenerate) {
|
||||
foreach ($stylesheets as $stylesheet) {
|
||||
if ((file_exists(ROOT . DS . $stylesheet['file'])) and (($stylesheet['load'] == 'frontend') or ($stylesheet['load'] == 'both')) ) {
|
||||
if ((file_exists(ROOT . DS . $stylesheet['file'])) and (($stylesheet['load'] == 'frontend') or ($stylesheet['load'] == 'both'))) {
|
||||
$frontend_buffer .= file_get_contents(ROOT . DS . $stylesheet['file']);
|
||||
}
|
||||
}
|
||||
@@ -123,7 +118,6 @@ class Stylesheet
|
||||
file_put_contents($frontend_site_css_path, MinifyCSS::process($frontend_buffer));
|
||||
$frontend_regenerate = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Render
|
||||
@@ -152,8 +146,8 @@ class Stylesheet
|
||||
/**
|
||||
* stylesVersionIncrement
|
||||
*/
|
||||
public static function stylesVersionIncrement() {
|
||||
Option::update('styles_version', (int) Option::get('styles_version') + 1);
|
||||
public static function stylesVersionIncrement()
|
||||
{
|
||||
Option::update('styles_version', (int) Option::get('styles_version') + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class View
|
||||
{
|
||||
/**
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Security
|
||||
{
|
||||
/**
|
||||
@@ -100,7 +97,7 @@ class Security
|
||||
*/
|
||||
public static function encryptPassword($password)
|
||||
{
|
||||
return md5(md5(trim($password) . MONSTRA_PASSWORD_SALT));
|
||||
return md5(md5(trim($password) . MONSTRA_PASSWORD_SALT));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,11 +153,13 @@ class Security
|
||||
}
|
||||
|
||||
// Lowercase
|
||||
if ($lowercase === true) $str = Text::lowercase($str);
|
||||
if ($lowercase === true) {
|
||||
$str = Text::lowercase($str);
|
||||
}
|
||||
|
||||
// Return safe name
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create safe url.
|
||||
@@ -176,9 +175,9 @@ class Security
|
||||
{
|
||||
$url = trim($url);
|
||||
$url = rawurldecode($url);
|
||||
$url = str_replace(array('--','"','!','@','#','$','%','^','*','(',')','+','{','}','|',':','"','<','>',
|
||||
'[',']','\\',';',"'",',','*','+','~','`','laquo','raquo',']>','‘','’','“','”','–','—'),
|
||||
array('-','-','','','','','','','','','','','','','','','','','','','','','','','','','','',''),
|
||||
$url = str_replace(array('--', '"', '!', '@', '#', '$', '%', '^', '*', '(', ')', '+', '{', '}', '|', ':', '"', '<', '>',
|
||||
'[', ']', '\\', ';', "'", ',', '*', '+', '~', '`', 'laquo', 'raquo', ']>', '‘', '’', '“', '”', '–', '—'),
|
||||
array('-', '-', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''),
|
||||
$url);
|
||||
$url = str_replace('--', '-', $url);
|
||||
$url = rtrim($url, "-");
|
||||
@@ -189,7 +188,7 @@ class Security
|
||||
$url = preg_replace('/^\./', '', $url);
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize URL to prevent XSS - Cross-site scripting
|
||||
@@ -237,5 +236,4 @@ class Security
|
||||
// Return safe string
|
||||
return $str;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Shortcode
|
||||
{
|
||||
/**
|
||||
@@ -55,7 +52,9 @@ class Shortcode
|
||||
$shortcode = (string) $shortcode;
|
||||
|
||||
// Add new shortcode
|
||||
if (is_callable($callback_function)) Shortcode::$shortcode_tags[$shortcode] = $callback_function;
|
||||
if (is_callable($callback_function)) {
|
||||
Shortcode::$shortcode_tags[$shortcode] = $callback_function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +72,9 @@ class Shortcode
|
||||
$shortcode = (string) $shortcode;
|
||||
|
||||
// Delete shortcode
|
||||
if (Shortcode::exists($shortcode)) unset(Shortcode::$shortcode_tags[$shortcode]);
|
||||
if (Shortcode::exists($shortcode)) {
|
||||
unset(Shortcode::$shortcode_tags[$shortcode]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +122,9 @@ class Shortcode
|
||||
*/
|
||||
public static function parse($content)
|
||||
{
|
||||
if ( ! Shortcode::$shortcode_tags) return $content;
|
||||
if (! Shortcode::$shortcode_tags) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$shortcodes = implode('|', array_map('preg_quote', array_keys(Shortcode::$shortcode_tags)));
|
||||
$pattern = "/(.?)\{([$shortcodes]+)(.*?)(\/)?\}(?(4)|(?:(.+?)\{\/\s*\\2\s*\}))?(.?)/s";
|
||||
@@ -147,9 +150,9 @@ class Shortcode
|
||||
|
||||
if (preg_match_all('/(\w+) *= *(?:([\'"])(.*?)\\2|([^ "\'>]+))/', $matches[3], $match, PREG_SET_ORDER)) {
|
||||
foreach ($match as $attribute) {
|
||||
if ( ! empty($attribute[4])) {
|
||||
if (! empty($attribute[4])) {
|
||||
$attributes[strtolower($attribute[1])] = $attribute[4];
|
||||
} elseif ( ! empty($attribute[3])) {
|
||||
} elseif (! empty($attribute[3])) {
|
||||
$attributes[strtolower($attribute[1])] = $attribute[3];
|
||||
}
|
||||
}
|
||||
@@ -158,5 +161,4 @@ class Shortcode
|
||||
// Check if this shortcode realy exists then call user function else return empty string
|
||||
return (isset(Shortcode::$shortcode_tags[$shortcode])) ? $prefix . call_user_func(Shortcode::$shortcode_tags[$shortcode], $attributes, $matches[5], $shortcode) . $suffix : '';
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Site
|
||||
{
|
||||
/**
|
||||
@@ -31,7 +28,9 @@ class Site
|
||||
*/
|
||||
public static function init()
|
||||
{
|
||||
if ( ! isset(self::$instance)) self::$instance = new Site();
|
||||
if (! isset(self::$instance)) {
|
||||
self::$instance = new Site();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
@@ -173,20 +172,20 @@ class Site
|
||||
// else return default template: index
|
||||
// also compress template file :)
|
||||
if (File::exists(THEMES_SITE . DS . $current_theme . DS . $template . '.template.php')) {
|
||||
if ( ! file_exists(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php') or
|
||||
if (! file_exists(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php') or
|
||||
filemtime(THEMES_SITE . DS . $current_theme . DS . $template .'.template.php') > filemtime(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php')) {
|
||||
$buffer = file_get_contents(THEMES_SITE. DS . $current_theme . DS . $template .'.template.php');
|
||||
$buffer = MinifyHTML::process($buffer);
|
||||
file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php', $buffer);
|
||||
$buffer = file_get_contents(THEMES_SITE. DS . $current_theme . DS . $template .'.template.php');
|
||||
$buffer = MinifyHTML::process($buffer);
|
||||
file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php', $buffer);
|
||||
}
|
||||
|
||||
return 'minify.'.$template;
|
||||
} else {
|
||||
if ( ! File::exists(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php') or
|
||||
if (! File::exists(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php') or
|
||||
filemtime(THEMES_SITE . DS . $current_theme . DS . 'index.template.php') > filemtime(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php')) {
|
||||
$buffer = file_get_contents(THEMES_SITE . DS . $current_theme . DS . 'index.template.php');
|
||||
$buffer = MinifyHTML::process($buffer);
|
||||
file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php', $buffer);
|
||||
$buffer = file_get_contents(THEMES_SITE . DS . $current_theme . DS . 'index.template.php');
|
||||
$buffer = MinifyHTML::process($buffer);
|
||||
file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php', $buffer);
|
||||
}
|
||||
|
||||
return 'minify.index';
|
||||
@@ -220,5 +219,4 @@ class Site
|
||||
{
|
||||
return __('Powered by', 'system').' <a href="http://monstra.org" target="_blank">Monstra</a> ' . Monstra::VERSION;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Uri
|
||||
{
|
||||
/**
|
||||
@@ -61,7 +58,14 @@ class Uri
|
||||
|
||||
// Ability to pass parameters
|
||||
foreach ($uri as $i => $u) {
|
||||
if (isset($uri[$i])) { $pos = strrpos($uri[$i], "?"); if ($pos === false) { $uri[$i] = Security::sanitizeURL($uri[$i]); } else { $uri[$i] = Security::sanitizeURL(substr($uri[$i], 0, $pos)); } }
|
||||
if (isset($uri[$i])) {
|
||||
$pos = strrpos($uri[$i], "?");
|
||||
if ($pos === false) {
|
||||
$uri[$i] = Security::sanitizeURL($uri[$i]);
|
||||
} else {
|
||||
$uri[$i] = Security::sanitizeURL(substr($uri[$i], 0, $pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return uri segments
|
||||
@@ -99,10 +103,10 @@ class Uri
|
||||
// Get uri segments
|
||||
$uri = Uri::segments();
|
||||
|
||||
if ( ! isset($uri[0])) {
|
||||
if (! isset($uri[0])) {
|
||||
$uri[0] = Uri::$default_component;
|
||||
} else {
|
||||
if ( ! in_array($uri[0], Plugin::$components) ) {
|
||||
if (! in_array($uri[0], Plugin::$components)) {
|
||||
$uri[0] = Uri::$default_component;
|
||||
} else {
|
||||
$uri[0] = $uri[0];
|
||||
@@ -130,18 +134,16 @@ class Uri
|
||||
$uri = Uri::segments();
|
||||
|
||||
// http://site.com/ and http://site.com/index.php same main home pages
|
||||
if ( ! isset($uri[0])) {
|
||||
if (! isset($uri[0])) {
|
||||
$uri[0] = '';
|
||||
}
|
||||
|
||||
// param1/param2
|
||||
if ($uri[0] !== Uri::$default_component) {
|
||||
if (isset($uri[1])) {
|
||||
|
||||
foreach ($uri as $part) {
|
||||
$data[] = $part;
|
||||
}
|
||||
|
||||
} else { // default
|
||||
$data[0] = $uri[0];
|
||||
}
|
||||
@@ -158,5 +160,4 @@ class Uri
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class DB
|
||||
{
|
||||
/**
|
||||
@@ -42,7 +39,9 @@ class DB
|
||||
*/
|
||||
public static function configure($setting, $value)
|
||||
{
|
||||
if (property_exists("db", $setting)) DB::$$setting = $value;
|
||||
if (property_exists("db", $setting)) {
|
||||
DB::$$setting = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +57,9 @@ class DB
|
||||
$db_name = (string) $db_name;
|
||||
|
||||
// Create
|
||||
if (is_dir(DB::$db_dir . '/' . $db_name)) return false;
|
||||
if (is_dir(DB::$db_dir . '/' . $db_name)) {
|
||||
return false;
|
||||
}
|
||||
return mkdir(DB::$db_dir . '/' . $db_name, $chmod);
|
||||
}
|
||||
|
||||
@@ -74,8 +75,18 @@ class DB
|
||||
$db_name = (string) $db_name;
|
||||
|
||||
// Drop
|
||||
if (is_dir(DB::$db_dir . '/' . $db_name)){$ob=scandir(DB::$db_dir . '/' . $db_name); foreach ($ob as $o) {if ($o!='.'&&$o!='..') {if(filetype(DB::$db_dir . '/' . $db_name.'/'.$o)=='dir')DB::drop(DB::$db_dir . '/' . $db_name.'/'.$o); else unlink(DB::$db_dir . '/' . $db_name.'/'.$o);}}}
|
||||
reset($ob); rmdir(DB::$db_dir . '/' . $db_name);
|
||||
if (is_dir(DB::$db_dir . '/' . $db_name)) {
|
||||
$ob=scandir(DB::$db_dir . '/' . $db_name); foreach ($ob as $o) {
|
||||
if ($o!='.'&&$o!='..') {
|
||||
if (filetype(DB::$db_dir . '/' . $db_name.'/'.$o)=='dir') {
|
||||
DB::drop(DB::$db_dir . '/' . $db_name.'/'.$o);
|
||||
} else {
|
||||
unlink(DB::$db_dir . '/' . $db_name.'/'.$o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
reset($ob);
|
||||
rmdir(DB::$db_dir . '/' . $db_name);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class Table
|
||||
{
|
||||
/**
|
||||
@@ -46,7 +43,9 @@ class Table
|
||||
*/
|
||||
public static function configure($setting, $value)
|
||||
{
|
||||
if (property_exists("table", $setting)) Table::$$setting = $value;
|
||||
if (property_exists("table", $setting)) {
|
||||
Table::$$setting = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +112,7 @@ class Table
|
||||
// Redefine vars
|
||||
$table_name = (string) $table_name;
|
||||
|
||||
if ( ! file_exists(Table::$tables_dir . '/' . $table_name . '.table.xml') &&
|
||||
if (! file_exists(Table::$tables_dir . '/' . $table_name . '.table.xml') &&
|
||||
is_dir(dirname(Table::$tables_dir)) &&
|
||||
is_writable(dirname(Table::$tables_dir)) &&
|
||||
isset($fields) &&
|
||||
@@ -121,12 +120,13 @@ class Table
|
||||
|
||||
// Create table fields
|
||||
$_fields = '<fields>';
|
||||
foreach ($fields as $field) $_fields .= "<$field/>";
|
||||
foreach ($fields as $field) {
|
||||
$_fields .= "<$field/>";
|
||||
}
|
||||
$_fields .= '</fields>';
|
||||
|
||||
// Create new table
|
||||
return file_put_contents(Table::$tables_dir . '/' . $table_name . '.table.xml','<?xml version="1.0" encoding="UTF-8"?><root><options><autoincrement>0</autoincrement></options>'.$_fields.'</root>', LOCK_EX);
|
||||
|
||||
return file_put_contents(Table::$tables_dir . '/' . $table_name . '.table.xml', '<?xml version="1.0" encoding="UTF-8"?><root><options><autoincrement>0</autoincrement></options>'.$_fields.'</root>', LOCK_EX);
|
||||
} else {
|
||||
|
||||
// Something wrong... return false
|
||||
@@ -150,7 +150,7 @@ class Table
|
||||
$table_name = (string) $table_name;
|
||||
|
||||
// Drop
|
||||
if ( ! is_dir(Table::$tables_dir . '/' . $table_name . '.table.xml')) {
|
||||
if (! is_dir(Table::$tables_dir . '/' . $table_name . '.table.xml')) {
|
||||
return unlink(Table::$tables_dir . '/' . $table_name . '.table.xml');
|
||||
}
|
||||
|
||||
@@ -260,12 +260,9 @@ class Table
|
||||
|
||||
// Save table
|
||||
return Table::_save($table);
|
||||
|
||||
} else {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,10 +294,8 @@ class Table
|
||||
|
||||
// Save table
|
||||
return Table::_save($table);
|
||||
|
||||
} else {
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,7 +403,6 @@ class Table
|
||||
|
||||
// If exists fields to insert then insert them
|
||||
if (count($fields) !== 0) {
|
||||
|
||||
$table_fields = array_diff_key($field_names, $fields);
|
||||
|
||||
// Defined fields
|
||||
@@ -424,10 +418,8 @@ class Table
|
||||
|
||||
// Save table
|
||||
return Table::_save($this->table);
|
||||
|
||||
} else {
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,12 +466,10 @@ class Table
|
||||
// If row count is null then select only one record
|
||||
// eg: $users->select('[login="admin"]', null);
|
||||
if ($row_count == null) {
|
||||
|
||||
if (isset($tmp[0])) {
|
||||
$_records = $tmp[0];
|
||||
$one_record = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// If row count is 'all' then select all records
|
||||
@@ -496,12 +486,9 @@ class Table
|
||||
|
||||
// If array of fields is exits then get records with this fields only
|
||||
if (count($fields) > 0) {
|
||||
|
||||
if (count($_records) > 0) {
|
||||
|
||||
$count = 0;
|
||||
foreach ($_records as $key => $record) {
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$record_array[$count][$field] = (string) $record->$field;
|
||||
}
|
||||
@@ -515,7 +502,6 @@ class Table
|
||||
}
|
||||
|
||||
$count++;
|
||||
|
||||
}
|
||||
|
||||
// Sort records
|
||||
@@ -527,9 +513,7 @@ class Table
|
||||
} elseif ($offset !== null && is_int($row_count)) {
|
||||
$records = array_slice($records, $offset, $row_count);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Convert from XML object to array
|
||||
@@ -537,7 +521,6 @@ class Table
|
||||
if (! $one_record) {
|
||||
$count = 0;
|
||||
foreach ($_records as $xml_objects) {
|
||||
|
||||
$vars = get_object_vars($xml_objects);
|
||||
|
||||
foreach ($vars as $key => $value) {
|
||||
@@ -562,7 +545,6 @@ class Table
|
||||
} elseif ($offset !== null && is_int($row_count)) {
|
||||
$records = array_slice($records, $offset, $row_count);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Single record
|
||||
@@ -575,7 +557,6 @@ class Table
|
||||
|
||||
// Return records
|
||||
return $records;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -601,7 +582,6 @@ class Table
|
||||
|
||||
// Delete
|
||||
unset($xml_arr[0]);
|
||||
|
||||
}
|
||||
|
||||
// Save table
|
||||
@@ -631,7 +611,6 @@ class Table
|
||||
|
||||
// Delete
|
||||
unset($xml_arr[0]);
|
||||
|
||||
}
|
||||
|
||||
// Save table
|
||||
@@ -690,10 +669,8 @@ class Table
|
||||
|
||||
// Save table
|
||||
return Table::_save($this->table);
|
||||
|
||||
} else {
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -747,16 +724,13 @@ class Table
|
||||
|
||||
// And add new one
|
||||
$xml_arr->addChild($key, XML::safe($value, false));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Save table
|
||||
return Table::_save($this->table);
|
||||
|
||||
} else {
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -801,9 +775,17 @@ class Table
|
||||
protected static function subvalSort($a, $subkey, $order = null)
|
||||
{
|
||||
if (count($a) != 0 || (!empty($a))) {
|
||||
foreach ($a as $k=>$v) $b[$k] = function_exists('mb_strtolower') ? mb_strtolower($v[$subkey]) : strtolower($v[$subkey]);
|
||||
if ($order==null || $order== 'ASC') asort($b); else if ($order == 'DESC') arsort($b);
|
||||
foreach ($b as $key=>$val) $c[] = $a[$key];
|
||||
foreach ($a as $k=>$v) {
|
||||
$b[$k] = function_exists('mb_strtolower') ? mb_strtolower($v[$subkey]) : strtolower($v[$subkey]);
|
||||
}
|
||||
if ($order==null || $order== 'ASC') {
|
||||
asort($b);
|
||||
} elseif ($order == 'DESC') {
|
||||
arsort($b);
|
||||
}
|
||||
foreach ($b as $key=>$val) {
|
||||
$c[] = $a[$key];
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
@@ -872,5 +854,4 @@ class Table
|
||||
// report about errors...
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra Engine
|
||||
* Monstra
|
||||
*
|
||||
* This source file is part of the Monstra Engine. More information,
|
||||
* documentation and tutorials can be found at http://monstra.org
|
||||
*
|
||||
* @package Monstra
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2014 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @package Monstra
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @link http://monstra.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
class XML
|
||||
{
|
||||
/**
|
||||
@@ -52,7 +49,9 @@ class XML
|
||||
} while ($cleaned != $str);
|
||||
|
||||
// htmlspecialchars
|
||||
if ($flag) $str = htmlspecialchars($str, ENT_QUOTES, 'utf-8');
|
||||
if ($flag) {
|
||||
$str = htmlspecialchars($str, ENT_QUOTES, 'utf-8');
|
||||
}
|
||||
|
||||
// Return safe string
|
||||
return $str;
|
||||
@@ -92,5 +91,4 @@ class XML
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ Monstra::$environment = Monstra::PRODUCTION;
|
||||
* Report Errors
|
||||
*/
|
||||
if (Monstra::$environment == Monstra::PRODUCTION) {
|
||||
error_reporting(0);
|
||||
error_reporting(0);
|
||||
} else {
|
||||
error_reporting(-1);
|
||||
}
|
||||
|
@@ -4,4 +4,7 @@
|
||||
* Set meta generator
|
||||
*/
|
||||
Action::add('theme_meta', 'setMetaGenerator');
|
||||
function setMetaGenerator() { echo '<meta name="generator" content="Powered by Monstra '.Monstra::VERSION.'" />'."\n"; }
|
||||
function setMetaGenerator()
|
||||
{
|
||||
echo '<meta name="generator" content="Powered by Monstra '.Monstra::VERSION.'" />'."\n";
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?php defined('MONSTRA_ACCESS') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Monstra CMS Defines
|
||||
* Monstra Defines
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -91,3 +91,4 @@ define('MONSTRA_GZIP', false);
|
||||
//define('MONSTRA_DB_DSN', 'mysql:dbname=monstra;host=localhost;port=3306');
|
||||
//define('MONSTRA_DB_USER', 'root');
|
||||
//define('MONSTRA_DB_PASSWORD', 'password');
|
||||
|
||||
|
@@ -3,7 +3,9 @@
|
||||
/**
|
||||
* Evaluate a string as PHP code
|
||||
*/
|
||||
if (MONSTRA_EVAL_PHP) Filter::add('content', 'evalPHP');
|
||||
if (MONSTRA_EVAL_PHP) {
|
||||
Filter::add('content', 'evalPHP');
|
||||
}
|
||||
function obEval($mathes)
|
||||
{
|
||||
ob_start();
|
||||
@@ -13,7 +15,10 @@ function obEval($mathes)
|
||||
|
||||
return $mathes;
|
||||
}
|
||||
function evalPHP($str) { return preg_replace_callback('/\[php\](.*?)\[\/php\]/ms','obEval', $str); }
|
||||
function evalPHP($str)
|
||||
{
|
||||
return preg_replace_callback('/\[php\](.*?)\[\/php\]/ms', 'obEval', $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shortcode parser filter
|
||||
|
@@ -4,4 +4,7 @@
|
||||
* Add new shortcode {siteurl}
|
||||
*/
|
||||
Shortcode::add('siteurl', 'returnSiteUrl');
|
||||
function returnSiteUrl() { return Option::get('siteurl'); }
|
||||
function returnSiteUrl()
|
||||
{
|
||||
return Option::get('siteurl');
|
||||
}
|
||||
|
Reference in New Issue
Block a user