2015-03-08 18:02:59 +01:00
|
|
|
<?php
|
2015-07-15 02:07:07 +02:00
|
|
|
|
|
|
|
/*
|
2016-01-21 02:46:13 +01:00
|
|
|
* Bludit
|
2016-02-14 17:45:33 +01:00
|
|
|
* https://www.bludit.com
|
2015-07-15 02:07:07 +02:00
|
|
|
* Author Diego Najar
|
|
|
|
* Bludit is opensource software licensed under the MIT license.
|
|
|
|
*/
|
2015-08-17 02:24:22 +02:00
|
|
|
|
2015-11-09 00:26:19 +01:00
|
|
|
// Check PHP version
|
|
|
|
if(version_compare(phpversion(), '5.3', '<')) {
|
|
|
|
exit('Current PHP version '.phpversion().', you need > 5.3. (ERR_202)');
|
|
|
|
}
|
|
|
|
|
2017-01-10 17:43:38 +01:00
|
|
|
// Check PHP modules
|
|
|
|
if(!extension_loaded('mbstring')) {
|
|
|
|
exit('PHP module mbstring is not installed. Check the requirements.');
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!extension_loaded('json')) {
|
|
|
|
exit('PHP module json is not installed. Check the requirements.');
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!extension_loaded('gd')) {
|
|
|
|
exit('PHP module gd is not installed. Check the requirements.');
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!extension_loaded('dom')) {
|
|
|
|
exit('PHP module dom is not installed. Check the requirements.');
|
|
|
|
}
|
|
|
|
|
2015-05-05 03:00:01 +02:00
|
|
|
// Security constant
|
2015-03-08 18:02:59 +01:00
|
|
|
define('BLUDIT', true);
|
2015-08-17 02:24:22 +02:00
|
|
|
|
2015-06-22 00:01:07 +02:00
|
|
|
// Directory separator
|
|
|
|
define('DS', DIRECTORY_SEPARATOR);
|
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
// PHP paths
|
2015-08-04 05:10:12 +02:00
|
|
|
define('PATH_ROOT', __DIR__.DS);
|
2016-01-21 01:29:01 +01:00
|
|
|
define('PATH_CONTENT', PATH_ROOT.'bl-content'.DS);
|
|
|
|
define('PATH_KERNEL', PATH_ROOT.'bl-kernel'.DS);
|
|
|
|
define('PATH_LANGUAGES', PATH_ROOT.'bl-languages'.DS);
|
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
define('PATH_UPLOADS', PATH_CONTENT.'uploads'.DS);
|
2016-05-26 23:48:41 +02:00
|
|
|
define('PATH_TMP', PATH_CONTENT.'tmp'.DS);
|
2015-08-04 05:10:12 +02:00
|
|
|
define('PATH_PAGES', PATH_CONTENT.'pages'.DS);
|
|
|
|
define('PATH_DATABASES', PATH_CONTENT.'databases'.DS);
|
|
|
|
define('PATH_PLUGINS_DATABASES',PATH_CONTENT.'databases'.DS.'plugins'.DS);
|
2016-01-21 01:29:01 +01:00
|
|
|
|
|
|
|
define('PATH_UPLOADS_PROFILES', PATH_UPLOADS.'profiles'.DS);
|
|
|
|
define('PATH_UPLOADS_THUMBNAILS',PATH_UPLOADS.'thumbnails'.DS);
|
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
define('PATH_HELPERS', PATH_KERNEL.'helpers'.DS);
|
|
|
|
define('PATH_ABSTRACT', PATH_KERNEL.'abstract'.DS);
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2016-02-20 17:16:31 +01:00
|
|
|
// Protecting against Symlink attacks.
|
|
|
|
define('CHECK_SYMBOLIC_LINKS', TRUE);
|
|
|
|
|
2016-07-17 01:19:10 +02:00
|
|
|
// Filename for posts and pages
|
2017-07-15 15:47:37 +02:00
|
|
|
define('FILENAME', 'index.txt');
|
2016-07-17 01:19:10 +02:00
|
|
|
|
2016-01-17 22:11:20 +01:00
|
|
|
// Domain and protocol
|
|
|
|
define('DOMAIN', $_SERVER['HTTP_HOST']);
|
|
|
|
|
|
|
|
if(!empty($_SERVER['HTTPS'])) {
|
|
|
|
define('PROTOCOL', 'https://');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
define('PROTOCOL', 'http://');
|
|
|
|
}
|
|
|
|
|
2016-01-21 01:29:01 +01:00
|
|
|
// Base URL
|
2016-01-17 22:11:20 +01:00
|
|
|
// 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-11-16 05:20:58 +01:00
|
|
|
|
|
|
|
if($base!=DS) {
|
2016-01-17 22:11:20 +01:00
|
|
|
$base = trim($base, '/');
|
|
|
|
$base = '/'.$base.'/';
|
2015-11-16 05:20:58 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Workaround for Windows Web Servers
|
|
|
|
$base = '/';
|
|
|
|
}
|
|
|
|
|
2015-05-15 00:07:45 +02:00
|
|
|
define('HTML_PATH_ROOT', $base);
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
// Log separator
|
|
|
|
define('LOG_SEP', ' | ');
|
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
// JSON
|
2015-05-15 00:07:45 +02:00
|
|
|
if(!defined('JSON_PRETTY_PRINT')) {
|
|
|
|
define('JSON_PRETTY_PRINT', 128);
|
|
|
|
}
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2015-08-26 05:42:32 +02:00
|
|
|
// Database format date
|
2016-01-08 00:43:09 +01:00
|
|
|
define('DB_DATE_FORMAT', 'Y-m-d H:i:s');
|
2015-08-26 05:42:32 +02:00
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
// Charset, default UTF-8.
|
2015-08-07 04:13:55 +02:00
|
|
|
define('CHARSET', 'UTF-8');
|
|
|
|
|
2017-09-04 23:09:45 +02:00
|
|
|
define('DEFAULT_LANGUAGE_FILE', 'en.json');
|
|
|
|
|
2016-07-26 01:40:51 +02:00
|
|
|
// Set internal character encoding.
|
|
|
|
mb_internal_encoding(CHARSET);
|
2015-08-17 02:24:22 +02:00
|
|
|
|
2016-07-26 01:40:51 +02:00
|
|
|
// Set HTTP output character encoding.
|
|
|
|
mb_http_output(CHARSET);
|
2015-08-07 04:13:55 +02:00
|
|
|
|
2015-10-26 02:11:46 +01:00
|
|
|
// --- PHP Classes ---
|
2016-01-21 01:29:01 +01:00
|
|
|
|
|
|
|
include(PATH_ABSTRACT.'dbjson.class.php');
|
2015-08-04 05:10:12 +02:00
|
|
|
include(PATH_HELPERS.'sanitize.class.php');
|
|
|
|
include(PATH_HELPERS.'valid.class.php');
|
2015-08-07 04:13:55 +02:00
|
|
|
include(PATH_HELPERS.'text.class.php');
|
2015-08-17 02:24:22 +02:00
|
|
|
include(PATH_HELPERS.'log.class.php');
|
2015-08-26 05:42:32 +02:00
|
|
|
include(PATH_HELPERS.'date.class.php');
|
2016-01-21 01:29:01 +01:00
|
|
|
include(PATH_KERNEL.'dblanguage.class.php');
|
2015-08-04 05:10:12 +02:00
|
|
|
|
2016-02-10 02:10:12 +01:00
|
|
|
// --- LANGUAGE and LOCALE ---
|
2015-08-17 02:24:22 +02:00
|
|
|
|
2016-02-10 02:10:12 +01:00
|
|
|
// Language from the URI
|
2017-09-04 23:09:45 +02:00
|
|
|
$languageFromHTTP = 'en_US';
|
|
|
|
$localeFromHTTP = 'en_US';
|
|
|
|
|
|
|
|
if (isset($_GET['language'])) {
|
|
|
|
$languageFromHTTP = Sanitize::html($_GET['language']);
|
|
|
|
} else {
|
|
|
|
// Try to detect the language browser
|
|
|
|
$languageFromHTTP = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
|
|
|
|
|
2016-02-10 02:10:12 +01:00
|
|
|
// Try to detect the locale
|
2017-09-04 23:09:45 +02:00
|
|
|
if (function_exists('locale_accept_from_http')) {
|
2016-02-10 02:10:12 +01:00
|
|
|
$localeFromHTTP = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
|
|
}
|
2016-01-17 01:11:58 +01:00
|
|
|
}
|
|
|
|
|
2016-02-10 02:10:12 +01:00
|
|
|
// Get language file
|
2017-09-04 23:09:45 +02:00
|
|
|
$Language = new dbLanguage('en_US');
|
2015-08-16 12:34:53 +02:00
|
|
|
|
2016-02-10 02:10:12 +01:00
|
|
|
// Set locale
|
2015-10-26 02:11:46 +01:00
|
|
|
setlocale(LC_ALL, $localeFromHTTP);
|
|
|
|
|
|
|
|
// --- TIMEZONE ---
|
|
|
|
|
|
|
|
// Check if timezone is defined in php.ini
|
2015-10-24 01:23:33 +02:00
|
|
|
$iniDate = ini_get('date.timezone');
|
|
|
|
if(empty($iniDate)) {
|
2016-02-10 02:10:12 +01:00
|
|
|
// Timezone not defined in php.ini, then set UTC as default.
|
2015-10-24 01:23:33 +02:00
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
}
|
|
|
|
|
2015-05-15 00:07:45 +02:00
|
|
|
// ============================================================================
|
|
|
|
// FUNCTIONS
|
|
|
|
// ============================================================================
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2015-10-26 02:11:46 +01:00
|
|
|
// Returns an array with all languages
|
2015-08-04 05:10:12 +02:00
|
|
|
function getLanguageList()
|
|
|
|
{
|
|
|
|
$files = glob(PATH_LANGUAGES.'*.json');
|
|
|
|
|
|
|
|
$tmp = array();
|
2017-05-17 18:48:51 +02:00
|
|
|
foreach($files as $file) {
|
2015-08-04 05:10:12 +02:00
|
|
|
$t = new dbJSON($file, false);
|
|
|
|
$native = $t->db['language-data']['native'];
|
|
|
|
$locale = basename($file, '.json');
|
|
|
|
$tmp[$locale] = $native;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $tmp;
|
|
|
|
}
|
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
// Check if Bludit is installed
|
2015-08-04 05:10:12 +02:00
|
|
|
function alreadyInstalled() {
|
2015-05-15 00:07:45 +02:00
|
|
|
return file_exists(PATH_DATABASES.'site.php');
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
// Check the system, permissions, php version, modules, etc.
|
|
|
|
// Returns an array with the problems otherwise empty array.
|
2015-05-15 00:07:45 +02:00
|
|
|
function checkSystem()
|
2015-05-05 03:00:01 +02:00
|
|
|
{
|
2015-08-04 05:10:12 +02:00
|
|
|
$stdOut = array();
|
|
|
|
$dirpermissions = 0755;
|
|
|
|
|
2016-08-31 02:57:24 +02:00
|
|
|
// Check .htaccess file for different webservers
|
2017-05-17 18:48:51 +02:00
|
|
|
if( !file_exists(PATH_ROOT.'.htaccess') ) {
|
2015-10-24 01:23:33 +02:00
|
|
|
|
2016-08-31 02:57:24 +02:00
|
|
|
if ( !isset($_SERVER['SERVER_SOFTWARE']) ||
|
|
|
|
stripos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false ||
|
|
|
|
stripos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false
|
|
|
|
) {
|
|
|
|
$errorText = 'Missing file, upload the file .htaccess (ERR_201)';
|
|
|
|
error_log($errorText, 0);
|
|
|
|
|
|
|
|
$tmp['title'] = 'File .htaccess';
|
|
|
|
$tmp['errorText'] = $errorText;
|
|
|
|
array_push($stdOut, $tmp);
|
|
|
|
}
|
2015-08-04 05:10:12 +02:00
|
|
|
}
|
|
|
|
|
2016-01-17 01:11:58 +01:00
|
|
|
// Try to create the directory content
|
|
|
|
@mkdir(PATH_CONTENT, $dirpermissions, true);
|
|
|
|
|
|
|
|
// Check if the directory content is writeable.
|
2017-05-17 18:48:51 +02:00
|
|
|
if(!is_writable(PATH_CONTENT)) {
|
2015-08-04 05:10:12 +02:00
|
|
|
$errorText = 'Writing test failure, check directory content permissions. (ERR_205)';
|
|
|
|
error_log($errorText, 0);
|
2015-10-24 01:23:33 +02:00
|
|
|
|
|
|
|
$tmp['title'] = 'PHP permissions';
|
|
|
|
$tmp['errorText'] = $errorText;
|
|
|
|
array_push($stdOut, $tmp);
|
2015-08-04 05:10:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $stdOut;
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
// Installation function
|
2016-02-10 02:10:12 +01:00
|
|
|
function install($adminPassword, $email, $timezone)
|
2015-05-15 00:07:45 +02:00
|
|
|
{
|
2015-08-17 02:24:22 +02:00
|
|
|
global $Language;
|
2015-08-07 04:13:55 +02:00
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
$stdOut = array();
|
|
|
|
|
2016-02-26 16:32:18 +01:00
|
|
|
if( !date_default_timezone_set($timezone) ) {
|
2016-02-10 02:10:12 +01:00
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
}
|
2015-10-24 22:43:50 +02:00
|
|
|
|
|
|
|
$currentDate = Date::current(DB_DATE_FORMAT);
|
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Create directories
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// 7=read,write,execute | 5=read,execute
|
|
|
|
$dirpermissions = 0755;
|
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
if(!mkdir(PATH_PAGES.'welcome', $dirpermissions, true)) {
|
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_PAGES.'welcome';
|
2015-08-04 05:10:12 +02:00
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
if(!mkdir(PATH_PAGES.'about', $dirpermissions, true)) {
|
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_PAGES.'about';
|
2015-08-04 05:10:12 +02:00
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
if(!mkdir(PATH_PLUGINS_DATABASES.'pages', $dirpermissions, true)) {
|
2015-08-31 03:18:06 +02:00
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_PLUGINS_DATABASES.'pages';
|
2015-08-04 05:10:12 +02:00
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
if(!mkdir(PATH_PLUGINS_DATABASES.'simplemde', $dirpermissions, true)) {
|
2016-01-03 22:04:54 +01:00
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_PLUGINS_DATABASES.'simplemde';
|
2015-08-31 03:18:06 +02:00
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
if(!mkdir(PATH_PLUGINS_DATABASES.'tags', $dirpermissions, true)) {
|
2015-08-31 03:18:06 +02:00
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_PLUGINS_DATABASES.'tags';
|
2015-08-29 07:02:09 +02:00
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
if(!mkdir(PATH_PLUGINS_DATABASES.'about', $dirpermissions, true)) {
|
2015-11-16 05:20:58 +01:00
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_PLUGINS_DATABASES.'about';
|
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
if(!mkdir(PATH_UPLOADS_PROFILES, $dirpermissions, true)) {
|
2015-11-16 05:20:58 +01:00
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_UPLOADS_PROFILES;
|
2015-08-04 05:10:12 +02:00
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
if(!mkdir(PATH_UPLOADS_THUMBNAILS, $dirpermissions, true)) {
|
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_UPLOADS_THUMBNAILS;
|
2016-05-26 23:48:41 +02:00
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
if(!mkdir(PATH_TMP, $dirpermissions, true)) {
|
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_TMP;
|
2016-01-03 22:04:54 +01:00
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Create files
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
$dataHead = "<?php defined('BLUDIT') or die('Bludit CMS.'); ?>".PHP_EOL;
|
|
|
|
|
|
|
|
// File pages.php
|
|
|
|
$data = array(
|
2015-11-17 03:45:03 +01:00
|
|
|
'about'=>array(
|
2017-05-17 18:48:51 +02:00
|
|
|
'description'=>$Language->get('About your site or yourself'),
|
|
|
|
'username'=>'admin',
|
|
|
|
'tags'=>array(),
|
2017-07-15 15:47:37 +02:00
|
|
|
'status'=>'fixed',
|
2017-05-17 18:48:51 +02:00
|
|
|
'date'=>$currentDate,
|
|
|
|
'dateModified'=>'',
|
2017-05-30 20:28:55 +02:00
|
|
|
'allowComments'=>true,
|
2017-05-17 18:48:51 +02:00
|
|
|
'position'=>2,
|
|
|
|
'coverImage'=>'',
|
|
|
|
'md5file'=>'',
|
|
|
|
'category'=>'',
|
|
|
|
'uuid'=>md5(uniqid())
|
|
|
|
),
|
|
|
|
'welcome'=>array(
|
|
|
|
'description'=>$Language->get('Welcome to Bludit'),
|
|
|
|
'username'=>'admin',
|
|
|
|
'tags'=>array('bludit'=>'Bludit','cms'=>'CMS','flat-files'=>'Flat files'),
|
|
|
|
'status'=>'published',
|
|
|
|
'date'=>$currentDate,
|
|
|
|
'dateModified'=>'',
|
2017-05-30 20:28:55 +02:00
|
|
|
'allowComments'=>true,
|
2017-05-17 18:48:51 +02:00
|
|
|
'position'=>1,
|
|
|
|
'coverImage'=>'',
|
|
|
|
'md5file'=>'',
|
2017-07-15 21:28:54 +02:00
|
|
|
'category'=>'general',
|
2017-05-17 18:48:51 +02:00
|
|
|
'uuid'=>md5(uniqid())
|
2015-08-04 05:10:12 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
file_put_contents(PATH_DATABASES.'pages.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
|
|
|
|
|
|
|
// File site.php
|
2017-05-30 20:28:55 +02:00
|
|
|
|
|
|
|
// If the website is not installed inside a folder the URL not need finish with /
|
|
|
|
// Example (root): https://domain.com
|
|
|
|
// Example (inside a folder): https://domain.com/folder/
|
|
|
|
if(HTML_PATH_ROOT=='/') {
|
|
|
|
$siteUrl = PROTOCOL.DOMAIN;
|
|
|
|
} else {
|
|
|
|
$siteUrl = PROTOCOL.DOMAIN.HTML_PATH_ROOT;
|
|
|
|
}
|
2015-08-04 05:10:12 +02:00
|
|
|
$data = array(
|
2015-11-16 05:20:58 +01:00
|
|
|
'title'=>'BLUDIT',
|
|
|
|
'slogan'=>'CMS',
|
2015-08-04 05:10:12 +02:00
|
|
|
'description'=>'',
|
2015-11-16 05:20:58 +01:00
|
|
|
'footer'=>'Copyright © '.Date::current('Y'),
|
2017-09-04 23:09:45 +02:00
|
|
|
'language'=>$Language->locale(),
|
|
|
|
'locale'=>$Language->locale(),
|
2015-10-24 01:23:33 +02:00
|
|
|
'timezone'=>$timezone,
|
2017-07-15 15:47:37 +02:00
|
|
|
'theme'=>'kernel-panic',
|
2015-08-04 05:10:12 +02:00
|
|
|
'adminTheme'=>'default',
|
|
|
|
'homepage'=>'',
|
2017-05-31 20:17:21 +02:00
|
|
|
'itemsPerPage'=>6,
|
2015-08-04 05:10:12 +02:00
|
|
|
'uriPage'=>'/',
|
|
|
|
'uriTag'=>'/tag/',
|
2017-05-03 21:10:03 +02:00
|
|
|
'uriCategory'=>'/category/',
|
2017-05-30 20:28:55 +02:00
|
|
|
'url'=>$siteUrl,
|
2015-10-24 01:23:33 +02:00
|
|
|
'emailFrom'=>'no-reply@'.DOMAIN
|
2015-08-04 05:10:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
file_put_contents(PATH_DATABASES.'site.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
|
|
|
|
2015-10-30 23:44:12 +01:00
|
|
|
// File users.php
|
2017-05-21 22:01:44 +02:00
|
|
|
$salt = uniqid();
|
2015-08-04 05:10:12 +02:00
|
|
|
$passwordHash = sha1($adminPassword.$salt);
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
'admin'=>array(
|
2015-11-16 05:20:58 +01:00
|
|
|
'firstName'=>$Language->get('Administrator'),
|
2015-08-04 05:10:12 +02:00
|
|
|
'lastName'=>'',
|
|
|
|
'role'=>'admin',
|
|
|
|
'password'=>$passwordHash,
|
|
|
|
'salt'=>$salt,
|
|
|
|
'email'=>$email,
|
2016-10-11 03:39:17 +02:00
|
|
|
'registered'=>$currentDate,
|
2016-10-12 03:33:52 +02:00
|
|
|
'tokenEmail'=>'',
|
|
|
|
'tokenEmailTTL'=>'2009-03-15 14:00',
|
|
|
|
'twitter'=>'',
|
|
|
|
'facebook'=>'',
|
|
|
|
'googlePlus'=>'',
|
|
|
|
'instagram'=>''
|
2015-08-04 05:10:12 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
file_put_contents(PATH_DATABASES.'users.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
|
|
|
|
2017-05-19 00:45:14 +02:00
|
|
|
// File syslog.php
|
|
|
|
$data = array(
|
|
|
|
array(
|
|
|
|
'date'=>$currentDate,
|
|
|
|
'dictionaryKey'=>'welcome-to-bludit',
|
2017-05-19 21:12:20 +02:00
|
|
|
'notes'=>'',
|
2017-05-19 00:45:14 +02:00
|
|
|
'idExecution'=>uniqid(),
|
2017-05-19 21:12:20 +02:00
|
|
|
'method'=>'POST',
|
|
|
|
'username'=>'admin'
|
2017-05-19 00:45:14 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
file_put_contents(PATH_DATABASES.'syslog.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
|
|
|
|
2015-08-18 04:02:19 +02:00
|
|
|
// File security.php
|
|
|
|
$data = array(
|
|
|
|
'minutesBlocked'=>5,
|
|
|
|
'numberFailuresAllowed'=>10,
|
|
|
|
'blackList'=>array()
|
|
|
|
);
|
|
|
|
|
|
|
|
file_put_contents(PATH_DATABASES.'security.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
|
|
|
|
2017-04-26 18:56:10 +02:00
|
|
|
// File categories.php
|
2017-05-04 21:32:18 +02:00
|
|
|
$data = array(
|
2017-07-15 21:28:54 +02:00
|
|
|
'general'=>array('name'=>'General', 'list'=>array()),
|
|
|
|
'music'=>array('name'=>'Music', 'list'=>array()),
|
|
|
|
'videos'=>array('name'=>'Videos', 'list'=>array())
|
2017-05-04 21:32:18 +02:00
|
|
|
);
|
2017-04-26 18:56:10 +02:00
|
|
|
file_put_contents(PATH_DATABASES.'categories.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
|
|
|
|
2015-08-31 03:18:06 +02:00
|
|
|
// File tags.php
|
2017-05-17 18:48:51 +02:00
|
|
|
$data = array(
|
|
|
|
'bludit'=>array('name'=>'Bludit', 'list'=>array('welcome')),
|
|
|
|
'cms'=>array('name'=>'CMS', 'list'=>array('welcome')),
|
|
|
|
'flat-files'=>array('name'=>'Flat files', 'list'=>array('welcome'))
|
2015-08-04 05:10:12 +02:00
|
|
|
);
|
2017-05-17 18:48:51 +02:00
|
|
|
file_put_contents(PATH_DATABASES.'tags.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
2015-08-31 03:18:06 +02:00
|
|
|
|
|
|
|
// File plugins/pages/db.php
|
|
|
|
file_put_contents(
|
|
|
|
PATH_PLUGINS_DATABASES.'pages'.DS.'db.php',
|
|
|
|
$dataHead.json_encode(
|
|
|
|
array(
|
|
|
|
'position'=>0,
|
|
|
|
'homeLink'=>true,
|
2017-05-30 21:54:09 +02:00
|
|
|
'label'=>$Language->get('Pages'),
|
|
|
|
'amountOfItems'=>5
|
2015-08-31 03:18:06 +02:00
|
|
|
),
|
|
|
|
JSON_PRETTY_PRINT),
|
|
|
|
LOCK_EX
|
|
|
|
);
|
2015-08-04 05:10:12 +02:00
|
|
|
|
2015-11-16 05:20:58 +01:00
|
|
|
// File plugins/about/db.php
|
|
|
|
file_put_contents(
|
|
|
|
PATH_PLUGINS_DATABASES.'about'.DS.'db.php',
|
|
|
|
$dataHead.json_encode(
|
|
|
|
array(
|
|
|
|
'position'=>0,
|
|
|
|
'label'=>$Language->get('About'),
|
2015-11-17 03:45:03 +01:00
|
|
|
'text'=>$Language->get('this-is-a-brief-description-of-yourself-our-your-site')
|
2015-11-16 05:20:58 +01:00
|
|
|
),
|
|
|
|
JSON_PRETTY_PRINT),
|
|
|
|
LOCK_EX
|
|
|
|
);
|
|
|
|
|
2016-01-03 22:04:54 +01:00
|
|
|
// File plugins/simplemde/db.php
|
2015-08-29 07:02:09 +02:00
|
|
|
file_put_contents(
|
2016-01-03 22:04:54 +01:00
|
|
|
PATH_PLUGINS_DATABASES.'simplemde'.DS.'db.php',
|
2015-08-29 07:02:09 +02:00
|
|
|
$dataHead.json_encode(
|
|
|
|
array(
|
2015-09-04 02:46:17 +02:00
|
|
|
'position'=>0,
|
2016-01-03 22:04:54 +01:00
|
|
|
'tabSize'=>4,
|
|
|
|
'toolbar'=>'"bold", "italic", "heading", "|", "quote", "unordered-list", "|", "link", "image", "code", "horizontal-rule", "|", "preview", "side-by-side", "fullscreen", "guide"'
|
2015-08-29 07:02:09 +02:00
|
|
|
),
|
|
|
|
JSON_PRETTY_PRINT),
|
|
|
|
LOCK_EX
|
|
|
|
);
|
|
|
|
|
2015-08-31 03:18:06 +02:00
|
|
|
// File plugins/tags/db.php
|
|
|
|
file_put_contents(
|
|
|
|
PATH_PLUGINS_DATABASES.'tags'.DS.'db.php',
|
|
|
|
$dataHead.json_encode(
|
|
|
|
array(
|
|
|
|
'position'=>0,
|
|
|
|
'label'=>$Language->get('Tags')
|
|
|
|
),
|
|
|
|
JSON_PRETTY_PRINT),
|
|
|
|
LOCK_EX
|
2015-08-29 07:02:09 +02:00
|
|
|
);
|
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
// File for about page
|
2017-07-15 15:47:37 +02:00
|
|
|
$data = 'Title: '.$Language->get('About').PHP_EOL.'Content: '.PHP_EOL.$Language->get('installer-page-about-content');
|
2016-07-17 01:19:10 +02:00
|
|
|
file_put_contents(PATH_PAGES.'about'.DS.FILENAME, $data, LOCK_EX);
|
2015-11-16 05:20:58 +01:00
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
// File for welcome page
|
2016-01-17 22:11:20 +01:00
|
|
|
$text1 = Text::replaceAssoc(
|
|
|
|
array(
|
|
|
|
'{{ADMIN_AREA_LINK}}'=>PROTOCOL.DOMAIN.HTML_PATH_ROOT.'admin'
|
|
|
|
),
|
|
|
|
$Language->get('Manage your Bludit from the admin panel')
|
|
|
|
);
|
|
|
|
|
2017-05-17 18:48:51 +02:00
|
|
|
$data = 'Title: '.$Language->get('Welcome').'
|
2015-05-07 03:00:01 +02:00
|
|
|
Content:
|
|
|
|
|
2015-11-16 05:20:58 +01:00
|
|
|
## '.$Language->get('Whats next').'
|
2016-01-17 22:11:20 +01:00
|
|
|
- '.$text1.'
|
2015-11-01 01:50:43 +01:00
|
|
|
- '.$Language->get('Follow Bludit on').' [Twitter](https://twitter.com/bludit) / [Facebook](https://www.facebook.com/bluditcms) / [Google+](https://plus.google.com/+Bluditcms)
|
2015-11-16 05:20:58 +01:00
|
|
|
- '.$Language->get('Chat with developers and users on Gitter').'
|
2015-08-07 04:13:55 +02:00
|
|
|
- '.$Language->get('Visit the support forum').'
|
|
|
|
- '.$Language->get('Read the documentation for more information').'
|
|
|
|
- '.$Language->get('Share with your friends and enjoy');
|
2015-05-07 03:00:01 +02:00
|
|
|
|
2017-05-19 00:45:14 +02:00
|
|
|
file_put_contents(PATH_PAGES.'welcome'.DS.FILENAME, $data, LOCK_EX);
|
2015-08-04 05:10:12 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-26 02:11:46 +01:00
|
|
|
// Check form's parameters and finish Bludit installation.
|
2015-08-07 00:56:52 +02:00
|
|
|
function checkPOST($args)
|
2015-08-04 05:10:12 +02:00
|
|
|
{
|
2015-08-17 02:24:22 +02:00
|
|
|
global $Language;
|
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
// Check empty password
|
2017-05-17 18:48:51 +02:00
|
|
|
if( strlen($args['password']) < 6 ) {
|
2015-10-30 23:44:12 +01:00
|
|
|
return '<div>'.$Language->g('Password must be at least 6 characters long').'</div>';
|
2015-08-04 05:10:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sanitize email
|
2015-08-07 00:56:52 +02:00
|
|
|
$email = sanitize::email($args['email']);
|
2015-05-15 00:07:45 +02:00
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
// Install Bludit
|
2015-10-24 01:23:33 +02:00
|
|
|
install($args['password'], $email, $args['timezone']);
|
2015-08-04 05:10:12 +02:00
|
|
|
|
|
|
|
return true;
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
|
|
|
|
2016-10-10 23:08:00 +02:00
|
|
|
function redirect($url) {
|
|
|
|
if(!headers_sent()) {
|
|
|
|
header("Location:".$url, TRUE, 302);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit('<meta http-equiv="refresh" content="0; url="'.$url.'">');
|
|
|
|
}
|
|
|
|
|
2015-05-15 00:07:45 +02:00
|
|
|
// ============================================================================
|
|
|
|
// MAIN
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
$error = '';
|
|
|
|
|
|
|
|
if( alreadyInstalled() ) {
|
2017-05-17 18:48:51 +02:00
|
|
|
exit('Bludit is already installed');
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
|
|
|
|
2016-10-10 23:08:00 +02:00
|
|
|
if( isset($_GET['demo']) ) {
|
|
|
|
install('demo123', '', 'UTC');
|
|
|
|
redirect(HTML_PATH_ROOT);
|
|
|
|
}
|
2015-08-04 05:10:12 +02:00
|
|
|
|
2016-10-10 23:08:00 +02:00
|
|
|
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
|
|
|
|
$error = checkPOST($_POST);
|
|
|
|
if($error===true) {
|
|
|
|
redirect(HTML_PATH_ROOT);
|
2015-08-04 05:10:12 +02:00
|
|
|
}
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
2015-10-24 01:23:33 +02:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html class="uk-height-1-1 uk-notouch">
|
2015-05-15 00:07:45 +02:00
|
|
|
<head>
|
2015-08-18 04:02:19 +02:00
|
|
|
<meta charset="<?php echo CHARSET ?>">
|
2015-08-04 05:10:12 +02:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
2015-05-15 00:07:45 +02:00
|
|
|
|
2015-08-16 12:34:53 +02:00
|
|
|
<title><?php echo $Language->get('Bludit Installer') ?></title>
|
2015-05-15 00:07:45 +02:00
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
<!-- Favicon -->
|
2017-07-22 14:21:13 +02:00
|
|
|
<link rel="shortcut icon" type="image/x-icon" href="bl-kernel/admin/themes/default/img/favicon.png?version=<?php echo time() ?>">
|
2015-05-15 00:07:45 +02:00
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
<!-- CSS -->
|
2017-07-13 20:06:39 +02:00
|
|
|
<link rel="stylesheet" type="text/css" href="bl-kernel/admin/themes/default/css/uikit/uikit.almost-flat.min.css?version=<?php echo time() ?>">
|
|
|
|
<link rel="stylesheet" type="text/css" href="bl-kernel/admin/themes/default/css/installer.css?version=<?php echo time() ?>">
|
2017-08-06 22:09:24 +02:00
|
|
|
<link rel="stylesheet" type="text/css" href="bl-kernel/css/font-awesome/css/font-awesome.min.css?version=<?php echo time() ?>">
|
2015-10-24 01:23:33 +02:00
|
|
|
|
|
|
|
<!-- Javascript -->
|
2017-07-13 20:06:39 +02:00
|
|
|
<script charset="utf-8" src="bl-kernel/js/jquery.min.js?version=<?php echo time() ?>"></script>
|
|
|
|
<script charset="utf-8" src="bl-kernel/admin/themes/default/js/uikit/uikit.min.js?version=<?php echo time() ?>"></script>
|
|
|
|
<script charset="utf-8" src="bl-kernel/admin/themes/default/js/jstz.min.js?version=<?php echo time() ?>"></script>
|
2015-10-24 01:23:33 +02:00
|
|
|
</head>
|
|
|
|
<body class="uk-height-1-1">
|
|
|
|
<div class="uk-vertical-align uk-text-center uk-height-1-1">
|
|
|
|
<div class="uk-vertical-align-middle">
|
2015-08-17 02:24:22 +02:00
|
|
|
<h1 class="title"><?php echo $Language->get('Bludit Installer') ?></h1>
|
2015-10-24 01:23:33 +02:00
|
|
|
<div class="content">
|
2015-08-04 05:10:12 +02:00
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
<?php
|
2015-10-24 01:23:33 +02:00
|
|
|
$system = checkSystem();
|
2015-08-17 02:24:22 +02:00
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
// Missing requirements
|
2017-05-17 18:48:51 +02:00
|
|
|
if(!empty($system)) {
|
|
|
|
foreach($system as $values) {
|
2015-10-24 01:23:33 +02:00
|
|
|
echo '<div class="uk-panel">';
|
|
|
|
echo '<div class="uk-panel-badge uk-badge uk-badge-danger">FAIL</div>';
|
|
|
|
echo '<h3 class="uk-panel-title">'.$values['title'].'</h3>';
|
|
|
|
echo $values['errorText'];
|
|
|
|
echo '</div>';
|
|
|
|
}
|
2015-08-17 02:24:22 +02:00
|
|
|
}
|
2015-10-24 01:23:33 +02:00
|
|
|
// Second step
|
|
|
|
elseif(isset($_GET['language']))
|
|
|
|
{
|
2015-08-17 02:24:22 +02:00
|
|
|
?>
|
|
|
|
<p><?php echo $Language->get('Complete the form choose a password for the username admin') ?></p>
|
2015-08-04 05:10:12 +02:00
|
|
|
|
|
|
|
<?php
|
|
|
|
if(!empty($error)) {
|
2015-10-24 01:23:33 +02:00
|
|
|
echo '<div class="uk-alert uk-alert-danger">'.$error.'</div>';
|
2015-08-04 05:10:12 +02:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
<form id="jsformInstaller" class="uk-form uk-form-stacked" method="post" action="" autocomplete="off">
|
2017-07-13 20:06:39 +02:00
|
|
|
<input type="hidden" name="timezone" id="jstimezone" value="UTC">
|
2015-10-24 01:23:33 +02:00
|
|
|
|
|
|
|
<div class="uk-form-row">
|
2015-10-24 17:32:26 +02:00
|
|
|
<input type="text" value="admin" class="uk-width-1-1 uk-form-large" disabled>
|
2015-10-24 01:23:33 +02:00
|
|
|
</div>
|
2015-08-05 02:04:06 +02:00
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
<div class="uk-form-row">
|
2015-10-24 17:32:26 +02:00
|
|
|
<input name="password" id="jspassword" type="password" class="uk-width-1-1 uk-form-large" value="<?php echo isset($_POST['password'])?$_POST['password']:'' ?>" placeholder="<?php echo $Language->get('Password') ?>">
|
2015-10-24 01:23:33 +02:00
|
|
|
</div>
|
2015-08-04 05:10:12 +02:00
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
<div class="uk-form-row">
|
2015-10-24 17:32:26 +02:00
|
|
|
<input name="email" id="jsemail" type="text" class="uk-width-1-1 uk-form-large" placeholder="<?php echo $Language->get('Email') ?>" autocomplete="off" maxlength="100">
|
2015-10-24 01:23:33 +02:00
|
|
|
</div>
|
2015-08-04 05:10:12 +02:00
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
<div class="uk-form-row">
|
|
|
|
<button type="submit" class="uk-width-1-1 uk-button uk-button-primary uk-button-large"><?php $Language->p('Install') ?></button>
|
2015-08-17 02:24:22 +02:00
|
|
|
</div>
|
2015-10-24 01:23:33 +02:00
|
|
|
|
|
|
|
</form>
|
2015-10-24 17:32:26 +02:00
|
|
|
|
|
|
|
<div id="jsshowPassword"><i class="uk-icon-eye"></i> <?php $Language->p('Show password') ?></div>
|
2015-08-17 02:24:22 +02:00
|
|
|
<?php
|
2015-10-24 01:23:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-17 02:24:22 +02:00
|
|
|
?>
|
|
|
|
<p><?php echo $Language->get('Choose your language') ?></p>
|
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
<form class="uk-form" method="get" action="" autocomplete="off">
|
2015-08-17 02:24:22 +02:00
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
<div class="uk-form-row">
|
|
|
|
<select id="jslanguage" name="language" class="uk-width-1-1">
|
2015-08-04 05:10:12 +02:00
|
|
|
<?php
|
|
|
|
$htmlOptions = getLanguageList();
|
|
|
|
foreach($htmlOptions as $locale=>$nativeName) {
|
2015-08-17 02:24:22 +02:00
|
|
|
echo '<option value="'.$locale.'"'.( ($localeFromHTTP===$locale)?' selected="selected"':'').'>'.$nativeName.'</option>';
|
2015-08-04 05:10:12 +02:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</select>
|
2015-10-24 01:23:33 +02:00
|
|
|
</div>
|
2015-08-04 05:10:12 +02:00
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
<div class="uk-form-row">
|
|
|
|
<button type="submit" class="uk-width-1-1 uk-button uk-button-primary uk-button-large"><?php $Language->p('Next') ?></button>
|
2015-08-04 05:10:12 +02:00
|
|
|
</div>
|
2015-10-24 01:23:33 +02:00
|
|
|
|
|
|
|
</form>
|
2015-08-17 02:24:22 +02:00
|
|
|
<?php
|
2015-10-24 01:23:33 +02:00
|
|
|
}
|
2015-08-17 02:24:22 +02:00
|
|
|
?>
|
2015-10-24 01:23:33 +02:00
|
|
|
</div>
|
2015-08-17 02:24:22 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2015-08-04 05:10:12 +02:00
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
<script>
|
|
|
|
$(document).ready(function()
|
|
|
|
{
|
2016-02-10 02:10:12 +01:00
|
|
|
// Timezone
|
|
|
|
var timezone = jstz.determine();
|
|
|
|
$("#jstimezone").val( timezone.name() );
|
2015-10-24 01:23:33 +02:00
|
|
|
|
|
|
|
// Show password
|
|
|
|
$("#jsshowPassword").on("click", function() {
|
|
|
|
var input = document.getElementById("jspassword");
|
|
|
|
|
|
|
|
if(input.getAttribute("type")=="text") {
|
|
|
|
input.setAttribute("type", "password");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
input.setAttribute("type", "text");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
});
|
|
|
|
</script>
|
2015-08-04 05:10:12 +02:00
|
|
|
|
2015-05-15 00:07:45 +02:00
|
|
|
</body>
|
2017-05-03 21:10:03 +02:00
|
|
|
</html>
|