2015-03-08 18:02:59 +01:00
|
|
|
<?php
|
2015-07-15 02:07:07 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Bludit
|
|
|
|
* http://www.bludit.com
|
|
|
|
* Author Diego Najar
|
|
|
|
* Bludit is opensource software licensed under the MIT license.
|
|
|
|
*/
|
2015-08-17 02:24:22 +02:00
|
|
|
|
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);
|
|
|
|
define('PATH_CONTENT', PATH_ROOT.'content'.DS);
|
|
|
|
define('PATH_POSTS', PATH_CONTENT.'posts'.DS);
|
|
|
|
define('PATH_UPLOADS', PATH_CONTENT.'uploads'.DS);
|
|
|
|
define('PATH_PAGES', PATH_CONTENT.'pages'.DS);
|
|
|
|
define('PATH_DATABASES', PATH_CONTENT.'databases'.DS);
|
|
|
|
define('PATH_PLUGINS_DATABASES',PATH_CONTENT.'databases'.DS.'plugins'.DS);
|
|
|
|
define('PATH_KERNEL', PATH_ROOT.'kernel'.DS);
|
|
|
|
define('PATH_HELPERS', PATH_KERNEL.'helpers'.DS);
|
|
|
|
define('PATH_LANGUAGES', PATH_ROOT.'languages'.DS);
|
|
|
|
define('PATH_ABSTRACT', PATH_KERNEL.'abstract'.DS);
|
|
|
|
define('DOMAIN', getenv('HTTP_HOST'));
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2015-06-22 02:19:41 +02:00
|
|
|
// HTML PATHs
|
|
|
|
$base = (dirname(getenv('SCRIPT_NAME'))==DS)?'/':dirname(getenv('SCRIPT_NAME')).'/';
|
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-07 00:56:52 +02:00
|
|
|
// Check if JSON encode and decode are enabled.
|
|
|
|
define('JSON', function_exists('json_encode'));
|
|
|
|
|
2015-08-26 05:42:32 +02:00
|
|
|
// Database format date
|
|
|
|
define('DB_DATE_FORMAT', 'Y-m-d H:i');
|
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
// Charset, default UTF-8.
|
2015-08-07 04:13:55 +02:00
|
|
|
define('CHARSET', 'UTF-8');
|
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
// Multibyte string extension loaded.
|
|
|
|
define('MB_STRING', extension_loaded('mbstring'));
|
|
|
|
|
2015-08-07 04:13:55 +02:00
|
|
|
if(MB_STRING)
|
|
|
|
{
|
2015-08-17 02:24:22 +02:00
|
|
|
// Set internal character encoding.
|
2015-08-07 04:13:55 +02:00
|
|
|
mb_internal_encoding(CHARSET);
|
|
|
|
|
2015-08-17 02:24:22 +02:00
|
|
|
// Set HTTP output character encoding.
|
2015-08-07 04:13:55 +02:00
|
|
|
mb_http_output(CHARSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
// PHP Classes
|
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-04 05:10:12 +02:00
|
|
|
include(PATH_ABSTRACT.'dbjson.class.php');
|
2015-08-07 04:13:55 +02:00
|
|
|
include(PATH_KERNEL.'dblanguage.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');
|
2015-08-04 05:10:12 +02:00
|
|
|
|
2015-08-31 03:18:06 +02:00
|
|
|
// Try to detect language from HTTP
|
2015-08-28 01:18:03 +02:00
|
|
|
$explode = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
|
|
$localeFromHTTP = empty($explode[0])?'en_US':str_replace('-', '_', $explode[0]);
|
2015-08-17 02:24:22 +02:00
|
|
|
|
|
|
|
if(isset($_GET['language'])) {
|
|
|
|
$localeFromHTTP = Sanitize::html($_GET['language']);
|
2015-08-16 14:33:33 +02:00
|
|
|
}
|
2015-08-17 02:24:22 +02:00
|
|
|
|
|
|
|
$Language = new dbLanguage($localeFromHTTP);
|
2015-08-16 12:34:53 +02:00
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
// Timezone
|
|
|
|
$iniDate = ini_get('date.timezone');
|
|
|
|
if(empty($iniDate)) {
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Locales
|
|
|
|
setlocale(LC_ALL, $localeFromHTTP);
|
|
|
|
|
2015-05-15 00:07:45 +02:00
|
|
|
// ============================================================================
|
|
|
|
// FUNCTIONS
|
|
|
|
// ============================================================================
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
function getLanguageList()
|
|
|
|
{
|
|
|
|
$files = glob(PATH_LANGUAGES.'*.json');
|
|
|
|
|
|
|
|
$tmp = array();
|
|
|
|
|
|
|
|
foreach($files as $file)
|
|
|
|
{
|
|
|
|
$t = new dbJSON($file, false);
|
|
|
|
$native = $t->db['language-data']['native'];
|
|
|
|
$locale = basename($file, '.json');
|
|
|
|
$tmp[$locale] = $native;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate a random string.
|
2015-05-15 00:07:45 +02:00
|
|
|
// Thanks, http://stackoverflow.com/questions/4356289/php-random-string-generator
|
|
|
|
function getRandomString($length = 10) {
|
|
|
|
return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
// Check if Bludit is installed.
|
|
|
|
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;
|
|
|
|
$phpModules = array();
|
|
|
|
|
|
|
|
if(function_exists('get_loaded_extensions')) {
|
|
|
|
$phpModules = get_loaded_extensions();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!version_compare(phpversion(), '5.3', '>='))
|
|
|
|
{
|
|
|
|
$errorText = 'Current PHP version '.phpversion().', you need > 5.3. (ERR_202)';
|
|
|
|
error_log($errorText, 0);
|
2015-10-24 01:23:33 +02:00
|
|
|
|
|
|
|
$tmp['title'] = 'PHP version';
|
|
|
|
$tmp['errorText'] = $errorText;
|
|
|
|
array_push($stdOut, $tmp);
|
2015-08-04 05:10:12 +02:00
|
|
|
|
|
|
|
return $stdOut;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!file_exists(PATH_ROOT.'.htaccess'))
|
|
|
|
{
|
|
|
|
$errorText = 'Missing file, upload the file .htaccess (ERR_201)';
|
|
|
|
error_log($errorText, 0);
|
2015-10-24 01:23:33 +02:00
|
|
|
|
|
|
|
$tmp['title'] = 'File .htaccess';
|
|
|
|
$tmp['errorText'] = $errorText;
|
|
|
|
array_push($stdOut, $tmp);
|
2015-08-04 05:10:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!in_array('dom', $phpModules))
|
|
|
|
{
|
|
|
|
$errorText = 'PHP module DOM is not installed. (ERR_203)';
|
|
|
|
error_log($errorText, 0);
|
2015-10-24 01:23:33 +02:00
|
|
|
|
|
|
|
$tmp['title'] = 'PHP module';
|
|
|
|
$tmp['errorText'] = $errorText;
|
|
|
|
array_push($stdOut, $tmp);
|
2015-08-04 05:10:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!in_array('json', $phpModules))
|
|
|
|
{
|
|
|
|
$errorText = 'PHP module JSON is not installed. (ERR_204)';
|
|
|
|
error_log($errorText, 0);
|
2015-10-24 01:23:33 +02:00
|
|
|
|
|
|
|
$tmp['title'] = 'PHP module';
|
|
|
|
$tmp['errorText'] = $errorText;
|
|
|
|
array_push($stdOut, $tmp);
|
2015-08-04 05:10:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!is_writable(PATH_CONTENT))
|
|
|
|
{
|
|
|
|
$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
|
|
|
}
|
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
function install($adminPassword, $email, $timezoneOffset)
|
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();
|
|
|
|
|
2015-08-26 05:42:32 +02:00
|
|
|
$currentDate = Date::current(DB_DATE_FORMAT);
|
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
$timezone = timezone_name_from_abbr("", $timezoneOffset, 0);
|
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Create directories
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// 7=read,write,execute | 5=read,execute
|
|
|
|
$dirpermissions = 0755;
|
|
|
|
$firstPostSlug = 'first-post';
|
|
|
|
|
|
|
|
if(!mkdir(PATH_POSTS.$firstPostSlug, $dirpermissions, true))
|
|
|
|
{
|
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_POSTS.$firstPostSlug;
|
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!mkdir(PATH_PAGES.'error', $dirpermissions, true))
|
|
|
|
{
|
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_PAGES.'error';
|
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-08-29 07:02:09 +02:00
|
|
|
if(!mkdir(PATH_PLUGINS_DATABASES.'simplemde', $dirpermissions, true))
|
|
|
|
{
|
2015-08-31 03:18:06 +02:00
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_PLUGINS_DATABASES.'simplemde';
|
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!mkdir(PATH_PLUGINS_DATABASES.'tags', $dirpermissions, true))
|
|
|
|
{
|
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_PLUGINS_DATABASES.'tags';
|
2015-08-29 07:02:09 +02:00
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
if(!mkdir(PATH_UPLOADS, $dirpermissions, true))
|
|
|
|
{
|
|
|
|
$errorText = 'Error when trying to created the directory=>'.PATH_UPLOADS;
|
|
|
|
error_log($errorText, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Create files
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
$dataHead = "<?php defined('BLUDIT') or die('Bludit CMS.'); ?>".PHP_EOL;
|
|
|
|
|
|
|
|
// File pages.php
|
|
|
|
$data = array(
|
|
|
|
'error'=>array(
|
|
|
|
'description'=>'Error page',
|
|
|
|
'username'=>'admin',
|
2015-09-18 05:24:10 +02:00
|
|
|
'tags'=>array(),
|
2015-08-04 05:10:12 +02:00
|
|
|
'status'=>'published',
|
2015-08-26 05:42:32 +02:00
|
|
|
'date'=>$currentDate,
|
2015-08-04 05:10:12 +02:00
|
|
|
'position'=>0
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
file_put_contents(PATH_DATABASES.'pages.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
|
|
|
|
|
|
|
// File posts.php
|
|
|
|
$data = array(
|
|
|
|
$firstPostSlug=>array(
|
|
|
|
'description'=>'Welcome to Bludit',
|
|
|
|
'username'=>'admin',
|
|
|
|
'status'=>'published',
|
2015-09-18 05:24:10 +02:00
|
|
|
'tags'=>array('bludit'=>'Bludit','cms'=>'CMS','flat-files'=>'Flat files'),
|
2015-10-24 01:23:33 +02:00
|
|
|
'allowComments'=>'false',
|
2015-08-26 05:42:32 +02:00
|
|
|
'date'=>$currentDate
|
2015-08-04 05:10:12 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
file_put_contents(PATH_DATABASES.'posts.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
|
|
|
|
|
|
|
// File site.php
|
|
|
|
$data = array(
|
|
|
|
'title'=>'Bludit',
|
|
|
|
'slogan'=>'cms',
|
|
|
|
'description'=>'',
|
2015-08-28 01:18:03 +02:00
|
|
|
'footer'=>Date::current('Y'),
|
2015-08-17 02:24:22 +02:00
|
|
|
'language'=>$Language->getCurrentLocale(),
|
|
|
|
'locale'=>$Language->getCurrentLocale(),
|
2015-10-24 01:23:33 +02:00
|
|
|
'timezone'=>$timezone,
|
2015-08-04 05:10:12 +02:00
|
|
|
'theme'=>'pure',
|
|
|
|
'adminTheme'=>'default',
|
|
|
|
'homepage'=>'',
|
|
|
|
'postsperpage'=>'6',
|
|
|
|
'uriPost'=>'/post/',
|
|
|
|
'uriPage'=>'/',
|
|
|
|
'uriTag'=>'/tag/',
|
2015-09-10 04:33:31 +02:00
|
|
|
'url'=>'http://'.DOMAIN.HTML_PATH_ROOT,
|
2015-10-24 01:23:33 +02:00
|
|
|
'cliMode'=>'true',
|
|
|
|
'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);
|
|
|
|
|
|
|
|
$salt = getRandomString();
|
|
|
|
$passwordHash = sha1($adminPassword.$salt);
|
|
|
|
|
|
|
|
// File users.php
|
|
|
|
$data = array(
|
|
|
|
'admin'=>array(
|
|
|
|
'firstName'=>'',
|
|
|
|
'lastName'=>'',
|
|
|
|
'twitter'=>'',
|
|
|
|
'role'=>'admin',
|
|
|
|
'password'=>$passwordHash,
|
|
|
|
'salt'=>$salt,
|
|
|
|
'email'=>$email,
|
2015-08-26 05:42:32 +02:00
|
|
|
'registered'=>$currentDate
|
2015-08-04 05:10:12 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
file_put_contents(PATH_DATABASES.'users.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);
|
|
|
|
|
2015-08-31 03:18:06 +02:00
|
|
|
// File tags.php
|
|
|
|
file_put_contents(
|
|
|
|
PATH_DATABASES.'tags.php',
|
|
|
|
$dataHead.json_encode(
|
|
|
|
array(
|
|
|
|
'postsIndex'=>array(
|
|
|
|
'bludit'=>array('name'=>'Bludit', 'posts'=>array('first-post')),
|
2015-09-18 05:24:10 +02:00
|
|
|
'cms'=>array('name'=>'CMS', 'posts'=>array('first-post')),
|
|
|
|
'flat-files'=>array('name'=>'Flat files', 'posts'=>array('first-post'))
|
2015-08-31 03:18:06 +02:00
|
|
|
),
|
|
|
|
'pagesIndex'=>array()
|
|
|
|
),
|
|
|
|
JSON_PRETTY_PRINT),
|
|
|
|
LOCK_EX
|
2015-08-04 05:10:12 +02:00
|
|
|
);
|
|
|
|
|
2015-08-31 03:18:06 +02:00
|
|
|
|
|
|
|
// PLUGINS
|
|
|
|
|
|
|
|
// File plugins/pages/db.php
|
|
|
|
file_put_contents(
|
|
|
|
PATH_PLUGINS_DATABASES.'pages'.DS.'db.php',
|
|
|
|
$dataHead.json_encode(
|
|
|
|
array(
|
|
|
|
'position'=>0,
|
|
|
|
'homeLink'=>true,
|
|
|
|
'label'=>$Language->get('Pages')
|
|
|
|
),
|
|
|
|
JSON_PRETTY_PRINT),
|
|
|
|
LOCK_EX
|
|
|
|
);
|
2015-08-04 05:10:12 +02:00
|
|
|
|
2015-08-29 07:02:09 +02:00
|
|
|
// File plugins/simplemde/db.php
|
|
|
|
file_put_contents(
|
|
|
|
PATH_PLUGINS_DATABASES.'simplemde'.DS.'db.php',
|
|
|
|
$dataHead.json_encode(
|
|
|
|
array(
|
2015-09-04 02:46:17 +02:00
|
|
|
'position'=>0,
|
|
|
|
'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
|
|
|
);
|
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
// File index.txt for error page
|
2015-08-07 04:13:55 +02:00
|
|
|
$data = 'Title: '.$Language->get('Error').'
|
|
|
|
Content: '.$Language->get('The page has not been found');
|
2015-08-04 05:10:12 +02:00
|
|
|
|
|
|
|
file_put_contents(PATH_PAGES.'error'.DS.'index.txt', $data, LOCK_EX);
|
|
|
|
|
|
|
|
// File index.txt for welcome post
|
2015-08-07 04:13:55 +02:00
|
|
|
$data = 'Title: '.$Language->get('First post').'
|
2015-05-07 03:00:01 +02:00
|
|
|
Content:
|
|
|
|
|
2015-08-29 07:02:09 +02:00
|
|
|
## '.$Language->get('Congratulations you have successfully installed your Bludit').'
|
2015-05-15 00:07:45 +02:00
|
|
|
|
2015-08-29 07:02:09 +02:00
|
|
|
### '.$Language->get('Whats next').'
|
2015-08-07 04:13:55 +02:00
|
|
|
- '.$Language->get('Manage your Bludit from the admin panel').'
|
|
|
|
- '.$Language->get('Follow Bludit on').' [Twitter](https://twitter.com/bludit) / [Facebook](https://www.facebook.com/pages/Bludit/239255789455913) / [Google+](https://plus.google.com/+Bluditcms)
|
|
|
|
- '.$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
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
file_put_contents(PATH_POSTS.$firstPostSlug.DS.'index.txt', $data, LOCK_EX);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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
|
2015-08-07 00:56:52 +02:00
|
|
|
if(empty($args['password']))
|
2015-08-04 05:10:12 +02:00
|
|
|
{
|
2015-08-17 02:24:22 +02:00
|
|
|
return '<div>'.$Language->g('The password field is empty').'</div>';
|
2015-08-04 05:10:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check invalid email
|
2015-08-07 00:56:52 +02:00
|
|
|
if( !Valid::email($args['email']) && ($args['noCheckEmail']=='0') )
|
2015-08-04 05:10:12 +02:00
|
|
|
{
|
2015-08-17 04:33:49 +02:00
|
|
|
return '<div>'.$Language->g('Your email address is invalid').'</div><div id="jscompleteEmail">'.$Language->g('Proceed anyway').'</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
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// MAIN
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-08-04 05:10:12 +02:00
|
|
|
$error = '';
|
|
|
|
|
|
|
|
if( alreadyInstalled() ) {
|
|
|
|
exit('Bludit already installed');
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|
|
|
{
|
2015-08-04 05:10:12 +02:00
|
|
|
$error = checkPOST($_POST);
|
|
|
|
|
|
|
|
if($error===true)
|
|
|
|
{
|
|
|
|
if(!headers_sent())
|
|
|
|
{
|
|
|
|
header("Location:".HTML_PATH_ROOT, TRUE, 302);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit('<meta http-equiv="refresh" content="0; url="'.HTML_PATH_ROOT.'">');
|
|
|
|
}
|
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-04 05:10:12 +02:00
|
|
|
<base href="admin/themes/default/">
|
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 -->
|
|
|
|
<link rel="shortcut icon" type="image/x-icon" href="./img/favicon.png">
|
2015-05-15 00:07:45 +02:00
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
<!-- CSS -->
|
|
|
|
<link rel="stylesheet" type="text/css" href="./css/uikit.almost-flat.min.css">
|
|
|
|
<link rel="stylesheet" type="text/css" href="./css/installer.css">
|
|
|
|
<link rel="stylesheet" type="text/css" href="./css/form-password.almost-flat.min.css">
|
|
|
|
|
|
|
|
<!-- Javascript -->
|
|
|
|
<script charset="utf-8" src="./js/jquery.min.js"></script>
|
|
|
|
<script charset="utf-8" src="./js/uikit.min.js"></script>
|
|
|
|
<script charset="utf-8" src="./js/form-password.min.js"></script>
|
2015-08-04 05:10:12 +02:00
|
|
|
|
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
|
|
|
|
if(!empty($system))
|
|
|
|
{
|
|
|
|
foreach($system as $values)
|
|
|
|
{
|
|
|
|
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">
|
2015-08-05 02:04:06 +02:00
|
|
|
<input type="hidden" name="noCheckEmail" id="jsnoCheckEmail" value="0">
|
2015-10-24 01:23:33 +02:00
|
|
|
<input type="hidden" name="timezone" id="jstimezone" value="0">
|
|
|
|
|
|
|
|
<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()
|
|
|
|
{
|
2015-10-24 01:23:33 +02:00
|
|
|
// Set timezone
|
|
|
|
var timezoneOffset = -(new Date().getTimezoneOffset() * 60);
|
|
|
|
$("#jstimezone").val(timezoneOffset);
|
|
|
|
|
|
|
|
// Proceed without email field.
|
|
|
|
$("#jscompleteEmail").on("click", function() {
|
|
|
|
|
2015-10-24 17:32:26 +02:00
|
|
|
console.log("Click proceed anyway");
|
|
|
|
|
2015-10-24 01:23:33 +02:00
|
|
|
$("#jsnoCheckEmail").val("1");
|
|
|
|
|
2015-10-24 17:32:26 +02:00
|
|
|
$("#jsformInstaller").submit();
|
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>
|
2015-06-22 00:01:07 +02:00
|
|
|
</html>
|