Installer improves

This commit is contained in:
dignajar 2015-08-16 21:24:22 -03:00
parent 9594be73e0
commit 5d70ba3171
10 changed files with 165 additions and 125 deletions

View File

@ -8,6 +8,10 @@ a:hover {
text-decoration: none !important;
}
p {
margin-bottom: 0;
}
/* ----------- FONTS AWESOME ----------- */
.fa-right {
margin-right: 5px;
@ -16,7 +20,7 @@ a:hover {
/* ----------- ----------- */
div.main {
text-align: center;
margin: 30px 0;
margin: 50px 0 0 0;
}
h1.title {
font-weight: lighter;
@ -27,6 +31,10 @@ td {
text-align: center;
}
.boxInstallerForm {
margin-top: 30px !important;
}
.tools-message {
display: block;
position: relative;

View File

@ -23,7 +23,7 @@ define('BLUDIT', true);
// Directory separator
define('DS', DIRECTORY_SEPARATOR);
// PHP paths
// PHP paths for init
define('PATH_ROOT', __DIR__.DS);
define('PATH_BOOT', PATH_ROOT.'kernel'.DS.'boot'.DS);

View File

@ -6,13 +6,14 @@
* Author Diego Najar
* Bludit is opensource software licensed under the MIT license.
*/
// Security constant
define('BLUDIT', true);
// Directory separator
define('DS', DIRECTORY_SEPARATOR);
// PATHs
// PHP paths
define('PATH_ROOT', __DIR__.DS);
define('PATH_CONTENT', PATH_ROOT.'content'.DS);
define('PATH_POSTS', PATH_CONTENT.'posts'.DS);
@ -30,6 +31,9 @@ define('DOMAIN', getenv('HTTP_HOST'));
$base = (dirname(getenv('SCRIPT_NAME'))==DS)?'/':dirname(getenv('SCRIPT_NAME')).'/';
define('HTML_PATH_ROOT', $base);
// Log separator
define('LOG_SEP', ' | ');
// JSON
if(!defined('JSON_PRETTY_PRINT')) {
define('JSON_PRETTY_PRINT', 128);
@ -38,17 +42,18 @@ if(!defined('JSON_PRETTY_PRINT')) {
// Check if JSON encode and decode are enabled.
define('JSON', function_exists('json_encode'));
// Multibyte string / UTF-8
define('MB_STRING', extension_loaded('mbstring'));
// Charset, default UTF-8.
define('CHARSET', 'UTF-8');
// Multibyte string extension loaded.
define('MB_STRING', extension_loaded('mbstring'));
if(MB_STRING)
{
// Tell PHP that we're using UTF-8 strings until the end of the script.
// Set internal character encoding.
mb_internal_encoding(CHARSET);
// Tell PHP that we'll be outputting UTF-8 to the browser.
// Set HTTP output character encoding.
mb_http_output(CHARSET);
}
@ -58,15 +63,16 @@ include(PATH_HELPERS.'valid.class.php');
include(PATH_HELPERS.'text.class.php');
include(PATH_ABSTRACT.'dbjson.class.php');
include(PATH_KERNEL.'dblanguage.class.php');
include(PATH_HELPERS.'log.class.php');
// Load language
$HTTP_ACCEPT_LANGUAGE = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
if (file_exists(PATH_LANGUAGES.$HTTP_ACCEPT_LANGUAGE. '.json')) {
$locale = $HTTP_ACCEPT_LANGUAGE;
} else {
$locale = 'en_US';
$localeFromHTTP = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
if(isset($_GET['language'])) {
$localeFromHTTP = Sanitize::html($_GET['language']);
}
$Language = new dbLanguage($locale);
$Language = new dbLanguage($localeFromHTTP);
// ============================================================================
// FUNCTIONS
@ -152,9 +158,9 @@ function checkSystem()
return $stdOut;
}
function install($adminPassword, $email, $locale)
function install($adminPassword, $email)
{
$Language = new dbLanguage($locale);
global $Language;
$stdOut = array();
@ -230,9 +236,9 @@ function install($adminPassword, $email, $locale)
'title'=>'Bludit',
'slogan'=>'cms',
'description'=>'',
'footer'=>'©2015',
'language'=>$locale,
'locale'=>$locale,
'footer'=>'',
'language'=>$Language->getCurrentLocale(),
'locale'=>$Language->getCurrentLocale(),
'timezone'=>'UTC',
'theme'=>'pure',
'adminTheme'=>'default',
@ -303,10 +309,12 @@ Content:
function checkPOST($args)
{
global $Language;
// Check empty password
if(empty($args['password']))
{
return '<div>The password field is empty</div>';
return '<div>'.$Language->g('The password field is empty').'</div>';
}
// Check invalid email
@ -369,21 +377,37 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
</head>
<body>
<div class="units-row">
<div class="unit-centered unit-60">
<div class="main">
<h1 class="title"><?php echo $Language->get('Bludit Installer') ?></h1>
<p><?php echo $Language->get('Welcome to the Bludit installer') ?></p>
<div class="unit-centered unit-60">
<div class="main">
<?php
$system = checkSystem();
<h1 class="title"><?php echo $Language->get('Bludit Installer') ?></h1>
<p><?php echo $Language->get('Welcome to the Bludit installer') ?></p>
if(empty($system))
{
?>
<?php
<p><?php echo $Language->get('Complete the form, choose a password for the username « admin »') ?></p>
$system = checkSystem();
<div class="unit-centered unit-40">
// Missing requirements
if(!empty($system))
{
echo '<div class="unit-centered unit-50">';
echo '<table class="table-stripped">';
foreach($system as $value) {
echo '<tr><td>'.$value.'</td></tr>';
}
echo '</table>';
echo '</div>';
}
// Second step
elseif(isset($_GET['language']))
{
?>
<p><?php echo $Language->get('Complete the form choose a password for the username admin') ?></p>
<div class="boxInstallerForm unit-centered unit-40">
<?php
if(!empty($error)) {
@ -394,66 +418,68 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
<form id="jsformInstaller" method="post" action="" class="forms" autocomplete="off">
<input type="hidden" name="noCheckEmail" id="jsnoCheckEmail" value="0">
<input type="hidden" name="language" id="jslanguage" value="<?php echo $localeFromHTTP ?>">
<label>
<input type="text" value="admin" disabled="disabled" class="width-100">
</label>
<label>
<input type="text" name="password" id="jspassword" placeholder="<?php echo $Language->get('Password, visible field!') ?>" class="width-100" autocomplete="off" maxlength="100" value="<?php echo isset($_POST['password'])?$_POST['password']:'' ?>">
<input type="text" name="password" id="jspassword" placeholder="<?php echo $Language->get('Password visible field') ?>" class="width-100" autocomplete="off" maxlength="100" value="<?php echo isset($_POST['password'])?$_POST['password']:'' ?>">
</label>
<label>
<input type="text" name="email" id="jsemail" placeholder="<?php echo $Language->get('Email') ?>" class="width-100" autocomplete="off" maxlength="100">
</label>
<p><button class="btn btn-blue width-100"><?php echo $Language->get('Install') ?></button>
</p>
</form>
</div>
<?php
} // END elseif(isset($_GET['language']))
else
{
?>
<p><?php echo $Language->get('Choose your language') ?></p>
<div class="boxInstallerForm unit-centered unit-40">
<form id="jsformLanguage" method="get" action="" class="forms" autocomplete="off">
<label for="jslanguage">
<select id="jslanguage" name="language" class="width-100" onchange="this.form.submit()">
<select id="jslanguage" name="language" class="width-100">
<?php
$htmlOptions = getLanguageList();
foreach($htmlOptions as $locale=>$nativeName) {
echo '<option value="'.$locale.'">'.$nativeName.'</option>';
echo '<option value="'.$locale.'"'.( ($localeFromHTTP===$locale)?' selected="selected"':'').'>'.$nativeName.'</option>';
}
?>
</select>
</label>
<p>
<button class="btn btn-blue width-100"><?php echo $Language->get('Install') ?></button>
<p><button class="btn btn-blue width-100"><?php echo $Language->get('Next') ?></button>
</p>
</form>
</div>
<?php
} // END else
?>
<?php
}
else
{
echo '<div class="unit-centered unit-50">';
echo '<table class="table-stripped">';
</div>
</div>
foreach ($system as $value)
{
echo '<tr><td>'.$value.'</td></tr>';
}
echo '</table>';
echo '</div';
}
?>
</div>
</div>
<script>
$(document).ready(function()
{
$("#jscompleteEmail").on("click", function() {
$("#jsnoCheckEmail").val("1");
if(!$("jspassword").val()) {
$("#jsformInstaller").submit();
}
});
});
</script>
<script>
$(document).ready(function()
{
$("#jscompleteEmail").on("click", function() {
$("#jsnoCheckEmail").val("1");
if(!$("jspassword").val()) {
$("#jsformInstaller").submit();
}
});
});
</script>
</div>
</body>

View File

@ -1,14 +1,16 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// Bludit version
define('BLUDIT_VERSION', 'githubVersion');
define('BLUDIT_CODENAME', '');
define('BLUDIT_RELEASE_DATE', '');
// Debug mode
define('DEBUG_MODE', TRUE);
// Turn off all error reporting
error_reporting(0);
// Turn on all error reporting
error_reporting(0); // Turn off all error reporting
if(DEBUG_MODE)
{
// Turn on all error reporting
ini_set("display_errors", 1);
ini_set('display_startup_errors',1);
ini_set("track_errors", 1);
@ -16,35 +18,31 @@ if(DEBUG_MODE)
error_reporting(E_ALL | E_STRICT | E_NOTICE);
}
// Log separator
define('LOG_SEP', ' | ');
// PHP PATHS
// PHP paths
// PATH_ROOT and PATH_BOOT are defined in index.php
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);
define('PATH_PLUGINS_DATABASES', PATH_CONTENT.'databases'.DS.'plugins'.DS);
define('PATH_UPLOADS', PATH_CONTENT.'uploads'.DS);
define('PATH_ADMIN', PATH_ROOT.'admin'.DS);
define('PATH_ADMIN_THEMES', PATH_ADMIN.'themes'.DS);
define('PATH_ADMIN_CONTROLLERS', PATH_ADMIN.'controllers'.DS);
define('PATH_ADMIN_VIEWS', PATH_ADMIN.'views'.DS);
// Log separator
define('LOG_SEP', ' | ');
// JSON pretty print
if(!defined('JSON_PRETTY_PRINT')) {
define('JSON_PRETTY_PRINT', 128);
@ -56,56 +54,51 @@ define('SALT_LENGTH', 8);
// Page brake string
define('PAGE_BREAK', '<!-- pagebreak -->');
// Bludit version
define('BLUDIT_VERSION', 'githubVersion');
define('BLUDIT_CODENAME', '');
define('BLUDIT_RELEASE_DATE', '');
//
// No parent character
define('NO_PARENT_CHAR', '—');
// Post per page on Manage->Posts
define('POSTS_PER_PAGE_ADMIN', 10);
// Multibyte string / UTF-8
define('MB_STRING', extension_loaded('mbstring'));
// 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.
define('HANDMADE_PUBLISHED', true);
// Charset, default UTF-8.
define('CHARSET', 'UTF-8');
// Multibyte string extension loaded.
define('MB_STRING', extension_loaded('mbstring'));
if(MB_STRING)
{
// Tell PHP that we're using UTF-8 strings until the end of the script.
// Set internal character encoding.
mb_internal_encoding(CHARSET);
// Tell PHP that we'll be outputting UTF-8 to the browser.
// Set HTTP output character encoding.
mb_http_output(CHARSET);
}
// Abstract Classes
// Inclde Abstract Classes
include(PATH_ABSTRACT.'dbjson.class.php');
include(PATH_ABSTRACT.'filecontent.class.php');
include(PATH_ABSTRACT.'plugin.class.php');
// Inclde Classes
include(PATH_KERNEL.'dbposts.class.php');
include(PATH_KERNEL.'dbpages.class.php');
include(PATH_KERNEL.'dbusers.class.php');
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');
// Helpers Classes
// Include Helpers Classes
include(PATH_HELPERS.'text.class.php');
include(PATH_HELPERS.'log.class.php');
include(PATH_HELPERS.'date.class.php');
@ -146,7 +139,7 @@ define('HTML_PATH_ADMIN_ROOT', HTML_PATH_ROOT.'admin/');
define('HTML_PATH_UPLOADS', HTML_PATH_ROOT.'content/uploads/');
define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'plugins/');
// PHP PATHs with dependency
// PHP paths with dependency
define('PATH_THEME', PATH_ROOT.'themes/'.$Site->theme().'/');
// Objects with dependency

View File

@ -5,5 +5,3 @@ if($Url->notFound())
{
header('HTTP/1.0 404 Not Found');
}
?>

View File

@ -4,24 +4,27 @@ class dbLanguage extends dbJSON
{
public $data;
public $db;
public $currentLocale;
function __construct($language)
function __construct($locale)
{
$this->data = array();
$this->db = array();
$this->currentLocale = 'en_US';
// Default language en_US
$filename = PATH_LANGUAGES.'en_US.json';
if(file_exists($filename))
if( Sanitize::pathFile($filename) )
{
$Tmp = new dbJSON($filename, false);
$this->db = array_merge($this->db, $Tmp->db);
}
// User language
$filename = PATH_LANGUAGES.$language.'.json';
if( file_exists($filename) && ($language!=="en_US") )
$filename = PATH_LANGUAGES.$locale.'.json';
if( Sanitize::pathFile($filename) && ($locale!=="en_US") )
{
$this->currentLocale = $locale;
$Tmp = new dbJSON($filename, false);
$this->db = array_merge($this->db, $Tmp->db);
}
@ -30,6 +33,11 @@ class dbLanguage extends dbJSON
unset($this->db['language-data']);
}
public function getCurrentLocale()
{
return $this->currentLocale;
}
// Return the translation, if the translation does'n exist then return the English translation.
public function get($string)
{
@ -73,7 +81,7 @@ class dbLanguage extends dbJSON
return $this->data[$key];
}
return '';
return '';
}
// Returns an array with all dictionaries.

View File

@ -5,14 +5,14 @@ class dbPages extends dbJSON
private $parentKeyList = array();
private $dbFields = array(
'title'=> array('inFile'=>true, 'value'=>''),
'content'=> array('inFile'=>true, 'value'=>''),
'title'=> array('inFile'=>true, 'value'=>''),
'content'=> array('inFile'=>true, 'value'=>''),
'description'=> array('inFile'=>false, 'value'=>''),
'username'=> array('inFile'=>false, 'value'=>''),
'tags'=> array('inFile'=>false, 'value'=>''),
'status'=> array('inFile'=>false, 'value'=>'draft'),
'tags'=> array('inFile'=>false, 'value'=>''),
'status'=> array('inFile'=>false, 'value'=>'draft'),
'unixTimeCreated'=> array('inFile'=>false, 'value'=>0),
'unixTimeModified'=>array('inFile'=>false, 'value'=>0),
'unixTimeModified'=> array('inFile'=>false, 'value'=>0),
'position'=> array('inFile'=>false, 'value'=>0)
);

View File

@ -8,12 +8,7 @@
"email": "",
"website": ""
},
"bludit-installer": "Bludit Installer",
"welcome-to-the-bludit-installer": "Welcome to the Bludit installer",
"complete-the-form,-choose-a-password-for-the-username-«-admin-»": "Complete the form, choose a password for the username « admin »",
"password,-visible-field!": "Password, visible field!",
"install": "Install",
"username": "Username",
"password": "Password",
"confirm-password": "Confirm Password",
@ -149,6 +144,13 @@
"read-the-documentation-for-more-information": "Read the [documentation](http://docs.bludit.com) for more information",
"share-with-your-friends-and-enjoy": "Share with your friends and enjoy",
"the-page-has-not-been-found": "The page has not been found.",
"error": "Error"
"error": "Error",
"bludit-installer": "Bludit Installer",
"welcome-to-the-bludit-installer": "Welcome to the Bludit installer",
"complete-the-form-choose-a-password-for-the-username-admin": "Complete the form, choose a password for the username « admin »",
"password-visible-field": "Password, visible field!",
"install": "Install",
"choose-your-language": "Choose your language",
"next": "Next",
"the-password-field-is-empty": "The password field is empty"
}

View File

@ -144,5 +144,11 @@
"read-the-documentation-for-more-information": "Lea la [documentacion](http://docs.bludit.com) para mas informacion",
"share-with-your-friends-and-enjoy": "Comparti con tus amigos y a disfrutar",
"the-page-has-not-been-found": "La pagina no fue encontrada.",
"error": "Error"
"error": "Error",
"bludit-installer": "Bludit Instalador",
"welcome-to-the-bludit-installer": "Bienvenido al asistente para la instalación de Bludit.",
"complete-the-form-choose-a-password-for-the-username-admin": "Complete el formulario y elija una contraseña para el usuario « admin »",
"password-visible-field": "Contraseña, este campo es visible!",
"install": "Instalar",
"the-password-field-is-empty": "Debe completar el campo contraseña"
}

View File

@ -8,12 +8,7 @@
"email": "",
"website": ""
},
"bludit-installer": "Installation de Bludit",
"welcome-to-the-bludit-installer": "Bienvenue dans lassistant dinstallation de Bludit",
"complete-the-form,-choose-a-password-for-the-username-«-admin-»": "Complétez le formulaire et choisissez un mot de passe pour lutilisateur « admin »",
"password,-visible-field!": "Mot de passe, champ visible !",
"install": "Installer",
"username": "Nom dutilisateur",
"password": "Mot de passe",
"confirm-password": "Confirmation du mot de passe",
@ -40,7 +35,7 @@
"position": "Position",
"save": "Sauvegarder",
"draft": "Brouillon",
"delete": "Supprimer",
"delete": "Supprimer",
"registered": "Inscrit",
"Notifications": "Notifications",
"profile": "Profil",
@ -149,6 +144,10 @@
"read-the-documentation-for-more-information": "Lisez la [documentation](http://docs.bludit.com) pour plus dinformation",
"share-with-your-friends-and-enjoy": "Partagez avec vos amis et apprécier !",
"the-page-has-not-been-found": "La page na pas été trouvée.",
"error": "Erreur"
"error": "Erreur",
"bludit-installer": "Installation de Bludit",
"welcome-to-the-bludit-installer": "Bienvenue dans lassistant dinstallation de Bludit",
"complete-the-form-choose-a-password-for-the-username-admin": "Complétez le formulaire et choisissez un mot de passe pour lutilisateur « admin »",
"password-visible-field": "Mot de passe, champ visible !",
"install": "Installer"
}