From 5d70ba31711f59efc7227b760e6d1b0d96110f04 Mon Sep 17 00:00:00 2001 From: dignajar Date: Sun, 16 Aug 2015 21:24:22 -0300 Subject: [PATCH] Installer improves --- admin/themes/default/css/installer.css | 10 +- index.php | 2 +- install.php | 154 +++++++++++++++---------- kernel/boot/init.php | 51 ++++---- kernel/boot/rules/99.header.php | 2 - kernel/dblanguage.class.php | 18 ++- kernel/dbpages.class.php | 10 +- languages/en_US.json | 18 +-- languages/es_AR.json | 8 +- languages/fr_FR.json | 17 ++- 10 files changed, 165 insertions(+), 125 deletions(-) diff --git a/admin/themes/default/css/installer.css b/admin/themes/default/css/installer.css index 988fe753..153f0e5f 100644 --- a/admin/themes/default/css/installer.css +++ b/admin/themes/default/css/installer.css @@ -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; diff --git a/index.php b/index.php index 75f5d69e..6fee318f 100644 --- a/index.php +++ b/index.php @@ -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); diff --git a/install.php b/install.php index 7897f835..00dd9d6b 100755 --- a/install.php +++ b/install.php @@ -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 '
The password field is empty
'; + return '
'.$Language->g('The password field is empty').'
'; } // Check invalid email @@ -369,21 +377,37 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
-
-
-

get('Bludit Installer') ?>

-

get('Welcome to the Bludit installer') ?>

+
+
- get('Bludit Installer') ?> +

get('Welcome to the Bludit installer') ?>

- if(empty($system)) - { - ?> + get('Complete the form, choose a password for the username « admin »') ?>

+ $system = checkSystem(); -
+ // Missing requirements + if(!empty($system)) + { + echo '
'; + echo ''; + + foreach($system as $value) { + echo ''; + } + + echo '
'.$value.'
'; + echo '
'; + } + // Second step + elseif(isset($_GET['language'])) + { + + ?> +

get('Complete the form choose a password for the username admin') ?>

+ +
+ +

+

+ +
+ +

get('Choose your language') ?>

+ +
+ +
+ -

- +

+ - '; - echo ''; + + - foreach ($system as $value) - { - echo ''; - } - - echo '
'.$value.'
'; - echo ' -
-
- - +
diff --git a/kernel/boot/init.php b/kernel/boot/init.php index 08f30f4b..09814485 100644 --- a/kernel/boot/init.php +++ b/kernel/boot/init.php @@ -1,14 +1,16 @@ '); -// 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 diff --git a/kernel/boot/rules/99.header.php b/kernel/boot/rules/99.header.php index d67de305..27df4585 100644 --- a/kernel/boot/rules/99.header.php +++ b/kernel/boot/rules/99.header.php @@ -5,5 +5,3 @@ if($Url->notFound()) { header('HTTP/1.0 404 Not Found'); } - -?> diff --git a/kernel/dblanguage.class.php b/kernel/dblanguage.class.php index 4ec34ee2..7da6c0fa 100644 --- a/kernel/dblanguage.class.php +++ b/kernel/dblanguage.class.php @@ -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. diff --git a/kernel/dbpages.class.php b/kernel/dbpages.class.php index 1f47d0e4..70bd7f74 100644 --- a/kernel/dbpages.class.php +++ b/kernel/dbpages.class.php @@ -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) ); diff --git a/languages/en_US.json b/languages/en_US.json index 2e7e3dad..4b703101 100755 --- a/languages/en_US.json +++ b/languages/en_US.json @@ -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" } \ No newline at end of file diff --git a/languages/es_AR.json b/languages/es_AR.json index 8fa3d00f..58fe0dba 100755 --- a/languages/es_AR.json +++ b/languages/es_AR.json @@ -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" } \ No newline at end of file diff --git a/languages/fr_FR.json b/languages/fr_FR.json index a4faffd0..7ccc65ce 100755 --- a/languages/fr_FR.json +++ b/languages/fr_FR.json @@ -8,12 +8,7 @@ "email": "", "website": "" }, - - "bludit-installer": "Installation de Bludit", - "welcome-to-the-bludit-installer": "Bienvenue dans l’assistant d’installation de Bludit", - "complete-the-form,-choose-a-password-for-the-username-«-admin-»": "Complétez le formulaire et choisissez un mot de passe pour l’utilisateur « admin »", - "password,-visible-field!": "Mot de passe, champ visible !", - "install": "Installer", + "username": "Nom d’utilisateur", "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 d’information", "share-with-your-friends-and-enjoy": "Partagez avec vos amis et apprécier !", "the-page-has-not-been-found": "La page n’a pas été trouvée.", - "error": "Erreur" - + "error": "Erreur", + "bludit-installer": "Installation de Bludit", + "welcome-to-the-bludit-installer": "Bienvenue dans l’assistant d’installation de Bludit", + "complete-the-form-choose-a-password-for-the-username-admin": "Complétez le formulaire et choisissez un mot de passe pour l’utilisateur « admin »", + "password-visible-field": "Mot de passe, champ visible !", + "install": "Installer" } \ No newline at end of file