bludit/kernel/boot/init.php

224 lines
7.0 KiB
PHP
Raw Normal View History

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
define('BLUDIT_VERSION', 'githubVersion');
define('BLUDIT_CODENAME', '');
define('BLUDIT_RELEASE_DATE', '');
define('BLUDIT_BUILD', '20151119');
2015-08-17 02:24:22 +02:00
2015-07-26 19:41:40 +02:00
// Debug mode
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
2015-07-26 19:35:29 +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
2015-08-03 02:49:12 +02:00
define('PATH_LANGUAGES', PATH_ROOT.'languages'.DS);
define('PATH_THEMES', PATH_ROOT.'themes'.DS);
define('PATH_PLUGINS', PATH_ROOT.'plugins'.DS);
define('PATH_KERNEL', PATH_ROOT.'kernel'.DS);
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);
define('PATH_CONTENT', PATH_ROOT.'content'.DS);
define('PATH_POSTS', PATH_CONTENT.'posts'.DS);
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);
define('PATH_TMP', PATH_CONTENT.'tmp'.DS);
2015-08-03 02:49:12 +02:00
define('PATH_UPLOADS', PATH_CONTENT.'uploads'.DS);
2015-11-15 22:37:34 +01:00
define('PATH_UPLOADS_PROFILES', PATH_UPLOADS.'profiles'.DS);
define('PATH_UPLOADS_THUMBNAILS', PATH_UPLOADS.'thumbnails'.DS);
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
2015-08-17 02:24:22 +02:00
// Log separator
define('LOG_SEP', ' | ');
2015-05-15 00:07:45 +02:00
// JSON pretty print
if(!defined('JSON_PRETTY_PRINT')) {
define('JSON_PRETTY_PRINT', 128);
}
2015-11-07 01:23:50 +01:00
// Alert status ok
define('ALERT_STATUS_OK', 0);
// Alert status fail
define('ALERT_STATUS_FAIL', 1);
// Salt length
define('THUMBNAILS_WIDTH', 400);
define('THUMBNAILS_HEIGHT', 400);
define('THUMBNAILS_AMOUNT', 6);
2015-05-15 00:07:45 +02:00
// Salt length
define('SALT_LENGTH', 8);
2015-07-14 04:16:28 +02:00
// Page brake string
2015-07-26 02:25:13 +02:00
define('PAGE_BREAK', '<!-- pagebreak -->');
2015-07-14 04:16:28 +02:00
2015-10-31 23:54:42 +01:00
// No parent character, md5('No parent')
define('NO_PARENT_CHAR', '3849abb4cb7abd24c2d8dac17b216f17');
2015-05-05 03:00:01 +02:00
2015-07-24 05:28:25 +02:00
// Post per page on Manage->Posts
define('POSTS_PER_PAGE_ADMIN', 10);
2015-05-05 03:00:01 +02:00
// Check if JSON encode and decode are enabled.
define('JSON', function_exists('json_encode'));
// TRUE if new posts hand-made set published, or FALSE for draft.
2015-08-26 05:42:32 +02:00
define('CLI_STATUS', 'published');
// Database format date
define('DB_DATE_FORMAT', 'Y-m-d H:i:s');
2015-05-05 03:00:01 +02:00
// Date format for Dashboard schedule posts
2015-10-22 05:14:22 +02:00
define('SCHEDULED_DATE_FORMAT', 'd M - h:i a');
2015-10-20 05:14:28 +02:00
// Token time to live for login via email. The offset is defined by http://php.net/manual/en/datetime.modify.php
2015-10-24 01:23:33 +02:00
define('TOKEN_EMAIL_TTL', '+15 minutes');
2015-10-20 05:14:28 +02:00
2015-08-17 02:24:22 +02:00
// Charset, default UTF-8.
2015-06-26 06:31:53 +02:00
define('CHARSET', 'UTF-8');
// Directory permissions
define('DIR_PERMISSIONS', 0755);
2015-08-17 02:24:22 +02:00
// Multibyte string extension loaded.
define('MB_STRING', extension_loaded('mbstring'));
2015-05-05 03:00:01 +02:00
if(MB_STRING)
{
2015-08-17 02:24:22 +02:00
// Set internal character encoding.
2015-06-26 06:31:53 +02:00
mb_internal_encoding(CHARSET);
2015-05-05 03:00:01 +02:00
2015-08-17 02:24:22 +02:00
// Set HTTP output character encoding.
2015-06-26 06:31:53 +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');
include(PATH_ABSTRACT.'filecontent.class.php');
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.'dbposts.class.php');
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');
include(PATH_KERNEL.'post.class.php');
include(PATH_KERNEL.'page.class.php');
include(PATH_KERNEL.'url.class.php');
include(PATH_KERNEL.'login.class.php');
include(PATH_KERNEL.'parsedown.class.php');
2015-11-16 09:47:43 +01:00
include(PATH_KERNEL.'parsedownextra.class.php');
2015-08-18 04:02:19 +02:00
include(PATH_KERNEL.'security.class.php');
2015-05-05 03:00:01 +02:00
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');
include(PATH_HELPERS.'image.class.php');
2015-05-05 03:00:01 +02:00
// Session
Session::start();
if(Session::started()===false) {
Log::set('init.php'.LOG_SEP.'Error occurred when trying to start the session.');
exit('Bludit CMS. Failed to start session.');
}
// Objects
$dbPosts = new dbPosts();
$dbPages = new dbPages();
$dbUsers = new dbUsers();
2015-08-29 07:02:09 +02:00
$dbTags = new dbTags();
2015-05-05 03:00:01 +02:00
$Site = new dbSite();
$Url = new Url();
2015-11-16 09:47:43 +01:00
$Parsedown = new ParsedownExtra();
2015-08-18 04:02:19 +02:00
$Security = new Security();
2015-05-05 03:00:01 +02:00
2015-12-09 01:56:31 +01:00
// HTML PATHS
// The user can define the base URL.
// Left empty if you want to Bludit try to detect the base URL.
$base = '';
if( !empty($_SERVER['DOCUMENT_ROOT']) && !empty($_SERVER['SCRIPT_NAME']) && empty($base) ) {
$base = str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_NAME']);
$base = dirname($base);
}
elseif( empty($base) ) {
$base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$base = dirname($base);
}
2015-09-18 02:37:14 +02:00
if($base!=DS) {
2015-12-09 01:56:31 +01:00
$base = trim($base, '/');
$base = '/'.$base.'/';
2015-09-18 02:37:14 +02:00
}
else {
// Workaround for Windows Web Servers
$base = '/';
}
2015-09-18 02:37:14 +02:00
2015-06-22 02:19:41 +02:00
define('HTML_PATH_ROOT', $base);
2015-05-05 03:00:01 +02:00
2015-09-13 03:06:20 +02:00
// Paths for themes
2015-05-05 03:00:01 +02:00
define('HTML_PATH_THEMES', HTML_PATH_ROOT.'themes/');
define('HTML_PATH_THEME', HTML_PATH_ROOT.'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/');
2015-08-03 02:49:12 +02:00
define('HTML_PATH_ADMIN_ROOT', HTML_PATH_ROOT.'admin/');
2015-11-15 22:37:34 +01:00
define('HTML_PATH_ADMIN_THEME', HTML_PATH_ROOT.'kernel/admin/themes/'.$Site->adminTheme().'/');
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/');
2015-11-15 22:37:34 +01:00
2015-07-24 05:28:25 +02:00
define('HTML_PATH_UPLOADS', HTML_PATH_ROOT.'content/uploads/');
2015-11-15 22:37:34 +01:00
define('HTML_PATH_UPLOADS_PROFILES', HTML_PATH_UPLOADS.'profiles/');
define('HTML_PATH_UPLOADS_THUMBNAILS', HTML_PATH_UPLOADS.'thumbnails/');
2015-07-29 04:30:41 +02:00
define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'plugins/');
2015-05-05 03:00:01 +02:00
2015-09-22 01:37:04 +02:00
define('JQUERY', HTML_PATH_ADMIN_THEME_JS.'jquery.min.js');
2015-08-17 02:24:22 +02:00
// PHP paths with dependency
define('PATH_THEME', PATH_ROOT.'themes'.DS.$Site->theme().DS);
2015-09-18 02:37:14 +02:00
define('PATH_THEME_PHP', PATH_THEME.'php'.DS);
2015-09-24 02:13:52 +02:00
define('PATH_THEME_CSS', PATH_THEME.'css'.DS);
define('PATH_THEME_JS', PATH_THEME.'js'.DS);
define('PATH_THEME_IMG', PATH_THEME.'img'.DS);
define('PATH_THEME_LANG', PATH_THEME.'languages'.DS);
2015-08-02 04:47:45 +02:00
2015-11-30 01:45:30 +01:00
// --- Objects with dependency ---
2015-05-05 03:00:01 +02:00
$Language = new dbLanguage( $Site->locale() );
$Login = new Login( $dbUsers );
$Url->checkFilters( $Site->uriFilters() );
2015-11-30 01:45:30 +01:00
// --- Objects shortcuts ---
2015-05-15 00:07:45 +02:00
$L = $Language;