2015-05-05 03:00:01 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
// Bludit version
|
2018-03-06 00:02:02 +01:00
|
|
|
define('BLUDIT_VERSION', '2.3-beta-2');
|
2018-02-25 21:10:28 +01:00
|
|
|
define('BLUDIT_CODENAME', '');
|
2018-03-06 00:02:02 +01:00
|
|
|
define('BLUDIT_RELEASE_DATE', '2018-03-06');
|
|
|
|
define('BLUDIT_BUILD', '20180306');
|
2015-08-17 02:24:22 +02:00
|
|
|
|
2015-07-26 19:41:40 +02:00
|
|
|
// Debug mode
|
2017-05-16 00:46:20 +02:00
|
|
|
// Change to FALSE, for prevent warning or errors on browser
|
2015-07-26 19:35:29 +02:00
|
|
|
define('DEBUG_MODE', TRUE);
|
2015-08-17 02:24:22 +02:00
|
|
|
error_reporting(0); // Turn off all error reporting
|
2017-10-04 00:00:54 +02:00
|
|
|
if (DEBUG_MODE) {
|
2015-08-17 02:24:22 +02:00
|
|
|
// Turn on all error reporting
|
2015-07-26 19:35:29 +02:00
|
|
|
ini_set("display_errors", 1);
|
|
|
|
ini_set('display_startup_errors',1);
|
|
|
|
ini_set("track_errors", 1);
|
|
|
|
ini_set("html_errors", 1);
|
|
|
|
error_reporting(E_ALL | E_STRICT | E_NOTICE);
|
|
|
|
}
|
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
// PHP paths
|
2015-06-22 00:01:07 +02:00
|
|
|
// PATH_ROOT and PATH_BOOT are defined in index.php
|
2016-01-21 01:29:01 +01:00
|
|
|
define('PATH_LANGUAGES', PATH_ROOT.'bl-languages'.DS);
|
|
|
|
define('PATH_THEMES', PATH_ROOT.'bl-themes'.DS);
|
|
|
|
define('PATH_PLUGINS', PATH_ROOT.'bl-plugins'.DS);
|
|
|
|
define('PATH_KERNEL', PATH_ROOT.'bl-kernel'.DS);
|
|
|
|
define('PATH_CONTENT', PATH_ROOT.'bl-content'.DS);
|
|
|
|
|
2015-08-03 02:49:12 +02:00
|
|
|
define('PATH_ABSTRACT', PATH_KERNEL.'abstract'.DS);
|
|
|
|
define('PATH_RULES', PATH_KERNEL.'boot'.DS.'rules'.DS);
|
|
|
|
define('PATH_HELPERS', PATH_KERNEL.'helpers'.DS);
|
|
|
|
define('PATH_AJAX', PATH_KERNEL.'ajax'.DS);
|
|
|
|
define('PATH_JS', PATH_KERNEL.'js'.DS);
|
2017-07-13 00:44:39 +02:00
|
|
|
define('PATH_CSS', PATH_KERNEL.'css'.DS);
|
2016-01-21 01:29:01 +01:00
|
|
|
|
2015-08-03 02:49:12 +02:00
|
|
|
define('PATH_PAGES', PATH_CONTENT.'pages'.DS);
|
|
|
|
define('PATH_DATABASES', PATH_CONTENT.'databases'.DS);
|
2015-06-22 00:01:07 +02:00
|
|
|
define('PATH_PLUGINS_DATABASES', PATH_CONTENT.'databases'.DS.'plugins'.DS);
|
2015-12-28 23:28:42 +01:00
|
|
|
define('PATH_TMP', PATH_CONTENT.'tmp'.DS);
|
2015-08-03 02:49:12 +02:00
|
|
|
define('PATH_UPLOADS', PATH_CONTENT.'uploads'.DS);
|
2016-01-21 01:29:01 +01:00
|
|
|
|
2015-11-15 22:37:34 +01:00
|
|
|
define('PATH_UPLOADS_PROFILES', PATH_UPLOADS.'profiles'.DS);
|
2015-12-28 23:28:42 +01:00
|
|
|
define('PATH_UPLOADS_THUMBNAILS', PATH_UPLOADS.'thumbnails'.DS);
|
2016-01-21 01:29:01 +01:00
|
|
|
|
2015-11-15 22:37:34 +01:00
|
|
|
define('PATH_ADMIN', PATH_KERNEL.'admin'.DS);
|
2015-08-03 02:49:12 +02:00
|
|
|
define('PATH_ADMIN_THEMES', PATH_ADMIN.'themes'.DS);
|
2015-06-22 00:01:07 +02:00
|
|
|
define('PATH_ADMIN_CONTROLLERS', PATH_ADMIN.'controllers'.DS);
|
2015-08-03 02:49:12 +02:00
|
|
|
define('PATH_ADMIN_VIEWS', PATH_ADMIN.'views'.DS);
|
2015-06-22 00:01:07 +02:00
|
|
|
|
2017-05-03 21:10:03 +02:00
|
|
|
define('DEBUG_FILE', PATH_CONTENT.'debug.txt');
|
|
|
|
|
2017-05-08 21:26:06 +02:00
|
|
|
// PAGES DATABASE
|
|
|
|
define('DB_PAGES', PATH_DATABASES.'pages.php');
|
2017-05-09 00:24:15 +02:00
|
|
|
define('DB_SITE', PATH_DATABASES.'site.php');
|
2017-05-12 20:18:44 +02:00
|
|
|
define('DB_CATEGORIES', PATH_DATABASES.'categories.php');
|
2017-05-16 00:46:20 +02:00
|
|
|
define('DB_TAGS', PATH_DATABASES.'tags.php');
|
2017-05-19 00:45:14 +02:00
|
|
|
define('DB_SYSLOG', PATH_DATABASES.'syslog.php');
|
2017-06-28 00:31:40 +02:00
|
|
|
define('DB_USERS', PATH_DATABASES.'users.php');
|
2017-07-16 00:42:37 +02:00
|
|
|
define('DB_SECURITY', PATH_DATABASES.'security.php');
|
2017-05-09 00:24:15 +02:00
|
|
|
|
2015-05-15 00:07:45 +02:00
|
|
|
// JSON pretty print
|
|
|
|
if(!defined('JSON_PRETTY_PRINT')) {
|
|
|
|
define('JSON_PRETTY_PRINT', 128);
|
|
|
|
}
|
|
|
|
|
2017-12-10 22:14:12 +01:00
|
|
|
// User environment variables
|
|
|
|
include(PATH_KERNEL.'boot'.DS.'variables.php');
|
2017-10-13 00:15:13 +02:00
|
|
|
|
2017-05-16 00:46:20 +02:00
|
|
|
// Set internal character encoding
|
2016-07-26 01:40:51 +02:00
|
|
|
mb_internal_encoding(CHARSET);
|
2015-08-17 02:24:22 +02:00
|
|
|
|
2017-05-16 00:46:20 +02:00
|
|
|
// Set HTTP output character encoding
|
2016-07-26 01:40:51 +02:00
|
|
|
mb_http_output(CHARSET);
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
// Inclde Abstract Classes
|
2015-05-05 03:00:01 +02:00
|
|
|
include(PATH_ABSTRACT.'dbjson.class.php');
|
2017-05-16 00:46:20 +02:00
|
|
|
include(PATH_ABSTRACT.'dblist.class.php');
|
2015-05-05 03:00:01 +02:00
|
|
|
include(PATH_ABSTRACT.'plugin.class.php');
|
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
// Inclde Classes
|
2015-05-05 03:00:01 +02:00
|
|
|
include(PATH_KERNEL.'dbpages.class.php');
|
|
|
|
include(PATH_KERNEL.'dbusers.class.php');
|
2015-08-29 07:02:09 +02:00
|
|
|
include(PATH_KERNEL.'dbtags.class.php');
|
2015-05-05 03:00:01 +02:00
|
|
|
include(PATH_KERNEL.'dblanguage.class.php');
|
|
|
|
include(PATH_KERNEL.'dbsite.class.php');
|
2017-03-26 20:51:32 +02:00
|
|
|
include(PATH_KERNEL.'dbcategories.class.php');
|
2017-05-19 00:45:14 +02:00
|
|
|
include(PATH_KERNEL.'dbsyslog.class.php');
|
2015-05-05 03:00:01 +02:00
|
|
|
include(PATH_KERNEL.'page.class.php');
|
2017-12-18 23:49:53 +01:00
|
|
|
include(PATH_KERNEL.'category.class.php');
|
|
|
|
include(PATH_KERNEL.'tag.class.php');
|
2015-12-31 19:47:34 +01:00
|
|
|
include(PATH_KERNEL.'user.class.php');
|
2015-05-05 03:00:01 +02:00
|
|
|
include(PATH_KERNEL.'url.class.php');
|
|
|
|
include(PATH_KERNEL.'login.class.php');
|
|
|
|
include(PATH_KERNEL.'parsedown.class.php');
|
2015-08-18 04:02:19 +02:00
|
|
|
include(PATH_KERNEL.'security.class.php');
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2016-05-29 19:21:11 +02:00
|
|
|
// Include functions
|
|
|
|
include(PATH_KERNEL.'functions.php');
|
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
// Include Helpers Classes
|
2015-05-05 03:00:01 +02:00
|
|
|
include(PATH_HELPERS.'text.class.php');
|
|
|
|
include(PATH_HELPERS.'log.class.php');
|
|
|
|
include(PATH_HELPERS.'date.class.php');
|
|
|
|
include(PATH_HELPERS.'theme.class.php');
|
|
|
|
include(PATH_HELPERS.'session.class.php');
|
|
|
|
include(PATH_HELPERS.'redirect.class.php');
|
|
|
|
include(PATH_HELPERS.'sanitize.class.php');
|
2015-08-04 05:10:12 +02:00
|
|
|
include(PATH_HELPERS.'valid.class.php');
|
2015-10-20 05:14:28 +02:00
|
|
|
include(PATH_HELPERS.'email.class.php');
|
2015-05-05 03:00:01 +02:00
|
|
|
include(PATH_HELPERS.'filesystem.class.php');
|
|
|
|
include(PATH_HELPERS.'alert.class.php');
|
2015-07-20 05:14:12 +02:00
|
|
|
include(PATH_HELPERS.'paginator.class.php');
|
2015-11-14 17:47:26 +01:00
|
|
|
include(PATH_HELPERS.'image.class.php');
|
2017-06-28 00:31:40 +02:00
|
|
|
include(PATH_HELPERS.'tcp.class.php');
|
2017-10-13 23:38:24 +02:00
|
|
|
include(PATH_HELPERS.'dom.class.php');
|
2017-11-08 00:00:48 +01:00
|
|
|
include(PATH_HELPERS.'cookie.class.php');
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2017-10-04 00:00:54 +02:00
|
|
|
if (file_exists(PATH_KERNEL.'bludit.pro.php')) {
|
2017-06-29 22:13:25 +02:00
|
|
|
include(PATH_KERNEL.'bludit.pro.php');
|
|
|
|
}
|
|
|
|
|
2015-05-05 03:00:01 +02:00
|
|
|
// Session
|
|
|
|
Session::start();
|
2017-10-04 00:00:54 +02:00
|
|
|
if (Session::started()===false) {
|
2017-05-16 00:46:20 +02:00
|
|
|
exit('Bludit CMS. Session initialization failure.');
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Objects
|
2018-01-25 23:58:42 +01:00
|
|
|
$dbPages = new dbPages();
|
|
|
|
$dbUsers = new dbUsers();
|
|
|
|
$dbTags = new dbTags();
|
|
|
|
$dbCategories = new dbCategories();
|
|
|
|
$site = $Site = new dbSite();
|
|
|
|
$url = $Url = new Url();
|
|
|
|
$parsedown = $Parsedown = new Parsedown();
|
|
|
|
$security = $Security = new Security();
|
|
|
|
$syslog = $Syslog = new dbSyslog();
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2016-01-21 01:29:01 +01:00
|
|
|
// --- Relative paths ---
|
|
|
|
// This paths are relative for the user / web browsing.
|
|
|
|
|
|
|
|
// Base URL
|
2015-12-09 01:56:31 +01:00
|
|
|
// The user can define the base URL.
|
|
|
|
// Left empty if you want to Bludit try to detect the base URL.
|
|
|
|
$base = '';
|
|
|
|
|
2017-10-04 00:00:54 +02:00
|
|
|
if (!empty($_SERVER['DOCUMENT_ROOT']) && !empty($_SERVER['SCRIPT_NAME']) && empty($base)) {
|
2015-12-09 01:56:31 +01:00
|
|
|
$base = str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_NAME']);
|
|
|
|
$base = dirname($base);
|
2017-10-04 00:00:54 +02:00
|
|
|
} elseif (empty($base)) {
|
2015-12-09 01:56:31 +01:00
|
|
|
$base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
|
|
|
|
$base = dirname($base);
|
|
|
|
}
|
2015-09-18 02:37:14 +02:00
|
|
|
|
2017-09-05 23:46:45 +02:00
|
|
|
if (strpos($_SERVER['REQUEST_URI'], $base)!==0) {
|
|
|
|
$base = '/';
|
|
|
|
} elseif ($base!=DS) {
|
2015-12-09 01:56:31 +01:00
|
|
|
$base = trim($base, '/');
|
|
|
|
$base = '/'.$base.'/';
|
2017-09-05 23:46:45 +02:00
|
|
|
} else {
|
2015-11-14 00:41:30 +01:00
|
|
|
// Workaround for Windows Web Servers
|
|
|
|
$base = '/';
|
|
|
|
}
|
2015-09-18 02:37:14 +02:00
|
|
|
|
2016-01-21 01:29:01 +01:00
|
|
|
define('HTML_PATH_ROOT', $base);
|
|
|
|
define('HTML_PATH_THEMES', HTML_PATH_ROOT.'bl-themes/');
|
|
|
|
define('HTML_PATH_THEME', HTML_PATH_THEMES.$Site->theme().'/');
|
2015-08-03 02:49:12 +02:00
|
|
|
define('HTML_PATH_THEME_CSS', HTML_PATH_THEME.'css/');
|
|
|
|
define('HTML_PATH_THEME_JS', HTML_PATH_THEME.'js/');
|
2015-09-13 03:06:20 +02:00
|
|
|
define('HTML_PATH_THEME_IMG', HTML_PATH_THEME.'img/');
|
2017-07-30 14:25:16 +02:00
|
|
|
define('HTML_PATH_ADMIN_ROOT', HTML_PATH_ROOT.ADMIN_URI_FILTER.'/');
|
2016-01-21 01:29:01 +01:00
|
|
|
define('HTML_PATH_ADMIN_THEME', HTML_PATH_ROOT.'bl-kernel/admin/themes/'.$Site->adminTheme().'/');
|
2015-11-15 22:37:34 +01:00
|
|
|
define('HTML_PATH_ADMIN_THEME_JS', HTML_PATH_ADMIN_THEME.'js/');
|
|
|
|
define('HTML_PATH_ADMIN_THEME_CSS', HTML_PATH_ADMIN_THEME.'css/');
|
2015-11-17 04:21:39 +01:00
|
|
|
define('HTML_PATH_ADMIN_THEME_IMG', HTML_PATH_ADMIN_THEME.'img/');
|
2017-07-13 00:44:39 +02:00
|
|
|
define('HTML_PATH_CORE_JS', HTML_PATH_ROOT.'bl-kernel/js/');
|
|
|
|
define('HTML_PATH_CORE_CSS', HTML_PATH_ROOT.'bl-kernel/css/');
|
2017-11-16 23:22:55 +01:00
|
|
|
define('HTML_PATH_CONTENT', HTML_PATH_ROOT.'bl-content/');
|
2016-01-21 01:29:01 +01:00
|
|
|
define('HTML_PATH_UPLOADS', HTML_PATH_ROOT.'bl-content/uploads/');
|
2015-11-15 22:37:34 +01:00
|
|
|
define('HTML_PATH_UPLOADS_PROFILES', HTML_PATH_UPLOADS.'profiles/');
|
2015-12-28 23:28:42 +01:00
|
|
|
define('HTML_PATH_UPLOADS_THUMBNAILS', HTML_PATH_UPLOADS.'thumbnails/');
|
2016-01-21 01:29:01 +01:00
|
|
|
define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'bl-plugins/');
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2017-05-30 21:54:09 +02:00
|
|
|
// --- Objects with dependency ---
|
2018-01-25 23:58:42 +01:00
|
|
|
$language = $Language = new dbLanguage( $Site->language() );
|
|
|
|
$login = $Login = new Login( $dbUsers );
|
2017-05-30 21:54:09 +02:00
|
|
|
$Url->checkFilters( $Site->uriFilters() );
|
|
|
|
|
|
|
|
// --- CONSTANTS with dependency ---
|
|
|
|
|
2017-06-04 21:08:31 +02:00
|
|
|
// Tag URI filter
|
|
|
|
define('TAG_URI_FILTER', $Url->filters('tag'));
|
|
|
|
|
|
|
|
// Category URI filter
|
|
|
|
define('CATEGORY_URI_FILTER', $Url->filters('category'));
|
|
|
|
|
|
|
|
// Page URI filter
|
|
|
|
define('PAGE_URI_FILTER', $Url->filters('page'));
|
|
|
|
|
2017-09-15 20:02:53 +02:00
|
|
|
// Blog URI filter
|
|
|
|
define('BLOG_URI_FILTER', $Url->filters('blog'));
|
|
|
|
|
2017-06-04 21:08:31 +02:00
|
|
|
// Content order by: date / position
|
|
|
|
define('ORDER_BY', $Site->orderBy());
|
|
|
|
|
2016-01-21 01:29:01 +01:00
|
|
|
// --- PHP paths with dependency ---
|
2017-05-16 00:46:20 +02:00
|
|
|
// This paths are absolutes for the OS
|
2016-05-18 04:36:23 +02:00
|
|
|
define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$Site->theme().DS);
|
2017-05-16 00:46:20 +02:00
|
|
|
define('THEME_DIR_PHP', THEME_DIR.'php'.DS);
|
|
|
|
define('THEME_DIR_CSS', THEME_DIR.'css'.DS);
|
|
|
|
define('THEME_DIR_JS', THEME_DIR.'js'.DS);
|
|
|
|
define('THEME_DIR_IMG', THEME_DIR.'img'.DS);
|
|
|
|
define('THEME_DIR_LANG', THEME_DIR.'languages'.DS);
|
2016-05-18 04:36:23 +02:00
|
|
|
|
2016-01-11 23:51:00 +01:00
|
|
|
// --- Absolute paths with domain ---
|
2016-01-21 01:29:01 +01:00
|
|
|
// This paths are absolutes for the user / web browsing.
|
2016-01-11 23:51:00 +01:00
|
|
|
define('DOMAIN', $Site->domain());
|
2017-06-04 21:08:31 +02:00
|
|
|
define('DOMAIN_BASE', DOMAIN.HTML_PATH_ROOT);
|
2017-07-13 00:44:39 +02:00
|
|
|
define('DOMAIN_CORE_JS', DOMAIN.HTML_PATH_CORE_JS);
|
|
|
|
define('DOMAIN_CORE_CSS', DOMAIN.HTML_PATH_CORE_CSS);
|
2017-05-30 20:28:55 +02:00
|
|
|
define('DOMAIN_THEME', DOMAIN.HTML_PATH_THEME);
|
2016-01-11 23:51:00 +01:00
|
|
|
define('DOMAIN_THEME_CSS', DOMAIN.HTML_PATH_THEME_CSS);
|
|
|
|
define('DOMAIN_THEME_JS', DOMAIN.HTML_PATH_THEME_JS);
|
|
|
|
define('DOMAIN_THEME_IMG', DOMAIN.HTML_PATH_THEME_IMG);
|
|
|
|
define('DOMAIN_UPLOADS', DOMAIN.HTML_PATH_UPLOADS);
|
|
|
|
define('DOMAIN_UPLOADS_PROFILES', DOMAIN.HTML_PATH_UPLOADS_PROFILES);
|
|
|
|
define('DOMAIN_UPLOADS_THUMBNAILS', DOMAIN.HTML_PATH_UPLOADS_THUMBNAILS);
|
2017-11-16 23:22:55 +01:00
|
|
|
define('DOMAIN_PLUGINS', DOMAIN.HTML_PATH_PLUGINS);
|
|
|
|
define('DOMAIN_CONTENT', DOMAIN.HTML_PATH_CONTENT);
|
2016-01-11 23:51:00 +01:00
|
|
|
|
2017-10-13 00:15:13 +02:00
|
|
|
define('DOMAIN_ADMIN', DOMAIN_BASE.ADMIN_URI_FILTER);
|
|
|
|
|
2017-06-04 21:08:31 +02:00
|
|
|
define('DOMAIN_TAGS', Text::addSlashes(DOMAIN_BASE.TAG_URI_FILTER, false, true));
|
2017-06-09 20:30:13 +02:00
|
|
|
define('DOMAIN_CATEGORIES', Text::addSlashes(DOMAIN_BASE.CATEGORY_URI_FILTER, false, true));
|
|
|
|
define('DOMAIN_PAGES', Text::addSlashes(DOMAIN_BASE.PAGE_URI_FILTER, false, true));
|
2017-09-15 20:02:53 +02:00
|
|
|
define('DOMAIN_BLOG', Text::addSlashes(DOMAIN_BASE.BLOG_URI_FILTER, false, true));
|
2017-05-17 00:04:53 +02:00
|
|
|
|
2017-05-19 00:45:14 +02:00
|
|
|
$ADMIN_CONTROLLER = '';
|
2017-05-17 18:48:51 +02:00
|
|
|
$ADMIN_VIEW = '';
|
2017-05-19 00:45:14 +02:00
|
|
|
$ID_EXECUTION = uniqid(); // string 13 characters long
|
2017-05-21 22:01:44 +02:00
|
|
|
$WHERE_AM_I = $Url->whereAmI();
|
2017-05-17 18:48:51 +02:00
|
|
|
|
2017-06-04 21:08:31 +02:00
|
|
|
// --- Objects shortcuts ---
|
2018-01-25 23:58:42 +01:00
|
|
|
$L = $language;
|
2017-06-04 21:08:31 +02:00
|
|
|
|
2017-05-16 00:46:20 +02:00
|
|
|
// DEBUG: Print constants
|
|
|
|
// $arr = array_filter(get_defined_constants(), 'is_string');
|
|
|
|
// echo json_encode($arr);
|
2017-07-02 18:55:27 +02:00
|
|
|
// exit;
|