Browse Source

Utilisation d'une classe pour l'installation

Simounet 2 years ago
parent
commit
2811b3c222
9 changed files with 371 additions and 209 deletions
  1. 61 1
      Configuration.class.php
  2. 200 0
      Install.class.php
  3. 6 1
      Logger.class.php
  4. 76 4
      User.class.php
  5. 24 203
      install.php
  6. 1 0
      locale/en.json
  7. 1 0
      locale/eo.json
  8. 1 0
      locale/es.json
  9. 1 0
      locale/fr.json

+ 61 - 1
Configuration.class.php

@@ -23,6 +23,31 @@ class Configuration extends MysqlEntity{
         'key'
     );
 
+    protected $options = array(
+        'articleDisplayAnonymous' => '0',
+        'articleDisplayAuthor' => '1',
+        'articleDisplayDate' => '1',
+        'articleDisplayFolderSort' => '1',
+        'articleDisplayHomeSort' => '1',
+        'articleDisplayLink' => '1',
+        'articleDisplayMode' => 'summary',
+        'articlePerPages' => '5',
+        'displayOnlyUnreadFeedFolder' => 'false',
+        'feedMaxEvents' => '50',
+        'language' => 'en',
+        'optionFeedIsVerbose' => 1,
+        'paginationScale' => 5,
+        'syncGradCount' => '10',
+        'synchronisationCode' => '',
+        'synchronisationEnableCache' => '0',
+        'synchronisationForceFeed' => '0',
+        'synchronisationType' => 'auto',
+        'theme' => 'marigolds',
+        'root' => '',
+        'cryptographicSalt' => '',
+        'otpEnabled' => 0
+    );
+
     function __construct(){
         parent::__construct();
     }
@@ -62,6 +87,10 @@ class Configuration extends MysqlEntity{
         unset($_SESSION['configuration']);
     }
 
+    protected function createSynchronisationCode() {
+        return substr(sha1(rand(0,30).time().rand(0,30)),0,10);
+    }
+
     public function add($key,$value){
         $config = new Configuration();
         $config->setKey($key);
@@ -71,6 +100,37 @@ class Configuration extends MysqlEntity{
         unset($_SESSION['configuration']);
     }
 
+    public function setDefaults() {
+        foreach($this->options as $option => $defaultValue) {
+            switch($option) {
+                case 'language':
+                    $value = isset($_POST['install_changeLngLeed']) ? $_POST['install_changeLngLeed'] : $defaultValue;
+                    break;
+                case 'theme':
+                    $value = isset($_POST['template']) ? $_POST['template'] : $defaultValue;
+                    break;
+                case 'synchronisationCode':
+                    $value = $this->createSynchronisationCode();
+                    break;
+                case 'root':
+                    $root = $_POST['root'];
+                    $value = (substr($root, strlen($root)-1)=='/'?$root:$root.'/');
+                    break;
+                case 'cryptographicSalt':
+                    $value = $this->generateSalt();
+                    break;
+                default:
+                    $value = $defaultValue;
+                    break;
+            }
+            $this->add($option, $value);
+        }
+    }
+
+    protected function generateSalt() {
+        return ''.mt_rand().mt_rand();
+    }
+
     function getId(){
         return $this->id;
     }
@@ -96,4 +156,4 @@ class Configuration extends MysqlEntity{
 
 }
 
-?>
+?>

+ 200 - 0
Install.class.php

@@ -0,0 +1,200 @@
+<?php
+
+class Install {
+
+    const DEFAULT_TABLES_PREFIX = 'leed__';
+    const CONSTANT_FILE = 'constant.php';
+    public $finished = false;
+    public $logs = array(
+        'errors' => array(),
+        'notices' => array()
+    );
+    public $options = array(
+        'user' => array(
+            'login' => "",
+            'password' => ""
+        ),
+        'db' => array(
+            'mysqlBase' => "",
+            'mysqlHost' => "",
+            'mysqlLogin' => "",
+            'mysqlMdp' => "",
+            'mysqlPrefix' => self::DEFAULT_TABLES_PREFIX
+        )
+    );
+    protected $salt;
+
+
+    public function __construct() {
+        require_once('Logger.class.php');
+        $this->logger = new Logger('install');
+    }
+
+    protected function overrideDefaultValues($_) {
+        foreach ($this->options as $type => $options) {
+            foreach ($options as $var => $defaultValue) {
+                if (!empty($_[$var])) {
+                    $val = $type === 'db' ? str_replace("'", "\'", $_[$var]) : Functions::secure($_[$var]);
+                    $this->options[$type][$var] = $val;
+                }
+            }
+        }
+    }
+
+    public function launch($_, $installActionName) {
+        $this->checkFunctionsExists();
+        if(!isset($_[$installActionName])) {
+            return false;
+        }
+        $this->overrideDefaultValues($_);
+        $this->checkLoginPassword();
+        $this->checkdb();
+        if(!$this->hasErrors()) {
+            $this->createConstantFile();
+
+            require_once('constant.php');
+            require_once('MysqlEntity.class.php');
+            class_exists('Update') or require_once('Update.class.php');
+            Update::ExecutePatch(true);
+            require_once('Feed.class.php');
+            require_once('Event.class.php');
+            require_once('User.class.php');
+            require_once('Folder.class.php');
+            require_once('Configuration.class.php');
+
+            $this->createConfig();
+            $this->createUser();
+            $this->setFinished(true);
+            $this->logger->destroy();
+        }
+    }
+
+    public function getDefaultRoot() {
+        $urlParts = explode('/', $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
+        array_pop($urlParts);
+        return implode('/', $urlParts);
+    }
+
+    protected function createConstantFile() {
+        $constant = "<?php
+define('VERSION_NUMBER','1.6');
+define('VERSION_NAME','Dev');
+
+//Host de Mysql, le plus souvent localhost ou 127.0.0.1
+define('MYSQL_HOST','{$this->options['db']['mysqlHost']}');
+//Identifiant MySQL
+define('MYSQL_LOGIN','{$this->options['db']['mysqlLogin']}');
+//mot de passe MySQL
+define('MYSQL_MDP','{$this->options['db']['mysqlMdp']}');
+//Nom de la base MySQL ou se trouvera leed
+define('MYSQL_BDD','{$this->options['db']['mysqlBase']}');
+//Prefix des noms des tables leed pour les bases de données uniques
+define('MYSQL_PREFIX','{$this->options['db']['mysqlPrefix']}');
+?>";
+
+        file_put_contents(self::CONSTANT_FILE, $constant);
+        if (!is_readable(self::CONSTANT_FILE))
+            die('"'.self::CONSTANT_FILE.'" not found!');
+    }
+
+    protected function createConfig() {
+        $configurationManager = new Configuration();
+        if ($configurationManager->tableExists()) {
+            $configurationManager->truncate();
+        }
+        $configurationManager->create();
+        $configurationManager->setDefaults();
+        $this->salt = $configurationManager->get('cryptographicSalt');
+    }
+
+    protected function createUser() {
+        $userManager = new User();
+        if ($userManager->tableExists()) {
+            $userManager->truncate();
+        }
+        $userManager->create();
+        $userManager->add($this->options['user']['login'], $this->options['user']['password'], $this->salt, $this->logger);
+        $_SESSION['currentUser'] = serialize($userManager->get($this->options['user']['login']));
+    }
+
+    protected function checkLoginPassword() {
+        if(
+            empty($this->options['user']['password'])
+            || empty($this->options['user']['login'])
+        ) {
+            $this->logs['errors'][] = _t('INSTALL_ERROR_USERPWD');
+            return false;
+        }
+        return true;
+    }
+
+    protected function checkDb() {
+        if(
+            empty($this->options['db']['mysqlHost'])
+            || empty($this->options['db']['mysqlLogin'])
+            || empty($this->options['db']['mysqlBase'])
+        ) {
+            $this->logs['errors'][] = _t('INSTALL_ERROR_DB_INFOS');
+            return false;
+        }
+        if (!Functions::testDb(
+            $this->options['db']['mysqlHost'], $this->options['db']['mysqlLogin'], $this->options['db']['mysqlMdp'], $this->options['db']['mysqlBase']
+        )) {
+            $this->logs['errors'][] = _t('INSTALL_ERROR_CONNEXION');
+        } else {
+            $this->logs['notices'][] = _t('INSTALL_INFO_CONNEXION');
+        }
+        return true;
+    }
+
+    public function hasErrors() {
+        return count($this->logs['errors']) > 0;
+    }
+
+    public function checkFunctionsExists() {
+        if(!is_writable('./')){
+            $this->logs['errors'][] = _t('INSTALL_ERROR_RIGHT', array(str_replace(basename(__FILE__),'',__FILE__)));
+        }else{
+            $this->logs['notices'][] = _t('INSTALL_INFO_RIGHT');
+        }
+        if (!@function_exists('mysqli_connect')){
+            $this->logs['errors'][] = _t('INSTALL_ERROR_MYSQLICONNECT');
+        }else{
+            $this->logs['notices'][] = _t('INSTALL_INFO_MYSQLICONNECT');
+        }
+        if (!@function_exists('file_get_contents')){
+            $this->logs['errors'][] =  _t('INSTALL_ERROR_FILEGET');
+        }else{
+            $this->logs['notices'][] = _t('INSTALL_INFO_FILEGET');
+        }
+        if (!@function_exists('file_put_contents')){
+            $this->logs['errors'][] = _t('INSTALL_ERROR_FILEPUT');
+        }else{
+            $this->logs['notices'][] = _t('INSTALL_INFO_FILEPUT');
+        }
+        if (!@function_exists('curl_exec')){
+            $this->logs['errors'][] = _t('INSTALL_ERROR_CURL');
+        }else{
+            $this->logs['notices'][] = _t('INSTALL_INFO_CURL');
+        }
+        if (@version_compare(PHP_VERSION, '5.1.0') <= 0){
+            $this->logs['errors'][] = _t('INSTALL_ERROR_PHPV', array(PHP_VERSION));
+        }else{
+            $this->logs['notices'][] = _t('INSTALL_INFO_PHPV', array(PHP_VERSION));
+        }
+        if(ini_get('safe_mode') && ini_get('max_execution_time')!=0){
+            $this->logs['errors'][] = _t('INSTALL_ERROR_SAFEMODE');
+        }else{
+            $this->logs['notices'][] = _t('INSTALL_INFO_SAFEMODE');
+        }
+    }
+
+    public function setFinished($finished) {
+        $this->finished = $finished;
+
+    }
+
+    public function getFinished() {
+        return $this->finished;
+    }
+}

+ 6 - 1
Logger.class.php

@@ -25,7 +25,7 @@ class Logger {
         return $logs;
     }
 
-    protected function destroy(){
+    public function destroy(){
         unset($_SESSION[self::LOGGER_IDENTIFIER][$this->getName()]);
     }
 
@@ -37,6 +37,11 @@ class Logger {
         }
     }
 
+    public function hasLogs()
+    {
+        return count($this->logs) > 0;
+    }
+
     public function setName($name)
     {
         $this->name = $name;

+ 76 - 4
User.class.php

@@ -85,6 +85,82 @@ class User extends MysqlEntity{
         return sha1($this->password.$this->login);
     }
 
+    public function add($login = false, $password = false, $salt = false, $logger = false) {
+        if(!$logger) {
+            require_once('Logger.class.php');
+            $logger = new Logger('settings');
+        }
+        if(empty($login)) {
+            $logger->appendLogs(_t("USER_ADD_MISSING_LOGIN"));
+        }
+        $existingUser = $this->load(array('login' => $login));
+        if($existingUser instanceof User) {
+            $logger->appendLogs(_t("USER_ADD_DUPLICATE"));
+            $logger->save();
+            return false;
+        }
+        if(empty($password)) {
+            $logger->appendLogs(_t("USER_ADD_MISSING_PASSWORD"));
+        }
+        if($logger->hasLogs()) {
+            $logger->save();
+            return false;
+        }
+        $this->setLogin($login);
+        $this->setPassword($password, $salt);
+        $this->save();
+        $this->createSideTables($login);
+        $logger->appendLogs(_t("USER_ADD_OK"). ' '.$login);
+        $logger->save();
+        return true;
+    }
+
+    public function remove($userId) {
+        require_once('Logger.class.php');
+        $logger = new Logger('settings');
+        if(empty($userId)) {
+            $logger->appendLogs(_t("USER_DEL_MISSING_ID"));
+            $logger->save();
+            return false;
+        }
+        $user = $this->load(array('id' => $userId));
+        if(!$user) {
+            $logger->appendLogs(_t("USER_DEL_UNKNOWN_ID").' '.$userId);
+            $logger->save();
+            return false;
+        }
+        $this->setLogin($user->getLogin());
+        $this->deleteSideTables();
+        $this->delete(array('id' => $userId));
+        $logger->appendLogs(_t("USER_DEL_OK").$user->getLogin());
+        $logger->save();
+        return true;
+    }
+
+    protected function createSideTables() {
+        $this->manageSideTables();
+    }
+
+    protected function deleteSideTables() {
+        $this->manageSideTables('remove');
+    }
+
+    protected function manageSideTables($action = 'add') {
+        $actionMethod = $action === 'add' ? 'create' : 'destroy';
+        $feedManager = new Feed();
+        $feedManager->$actionMethod();
+        $eventManager = new Event();
+        $eventManager->$actionMethod();
+        $folderManager = new Folder();
+        $folderManager->$actionMethod();
+        if($action === 'add' && $folderManager->rowCount() === '0') {
+            $folderManager->setName(_t('GENERAL_FOLDER'));
+            $folderManager->setParent(-1);
+            $folderManager->setIsopen(1);
+            $folderManager->save();
+        }
+    }
+
     static function existAuthToken($auth=null){
         $result = false;
         $userManager = new User();
@@ -147,10 +223,6 @@ class User extends MysqlEntity{
         return sha1($password.$salt);
     }
 
-    static function generateSalt() {
-        return ''.mt_rand().mt_rand();
-    }
-
 }
 
 ?>

+ 24 - 203
install.php

@@ -7,9 +7,10 @@
  */
 
 require_once('Functions.class.php');
+require_once('Install.class.php');
 require_once('i18n.php');
 global $i18n;
-$install_terminee=false;
+$install = new Install();
 
 /* Prend le choix de langue de l'utilisateur, soit :
  * - lorsqu'il vient de changer la langue du sélecteur ($lang)
@@ -31,11 +32,6 @@ if (file_exists('constant.php')) {
     die(_t('ALREADY_INSTALLED'));
 }
 
-/* Nombres de thèmes disponibles
- * 0 - Pas possible, car il y aura au moins Marigolds
- * 1 - Indique le thème (Marigolds), mais ne permet pas la modification
- * 2 - Indique un thème et permet la sélection. Marigolds est mis en premier. 
- */
 define('DEFAULT_TEMPLATE', 'marigolds');
 $templates = scandir('templates');
 if (!in_array(DEFAULT_TEMPLATE, $templates)) die('Missing default template : '.DEFAULT_TEMPLATE);
@@ -51,189 +47,9 @@ session_start();
 
 // Protection des variables
 $_ = array_merge($_GET, $_POST);
-$whiteList = array(
-    /* La liste blanche recense les variables ne devant pas être passées via
-       la sécurisation, mais simplement échappées pour Php. */
-    'mysqlHost', 'mysqlLogin', 'mysqlMdp', 'mysqlBase', 'mysqlPrefix',
-);
-foreach($_ as $key=>&$val){
- $val = in_array($key, $whiteList)
-    ? str_replace("'", "\'", $val)
-    : Functions::secure($val);
-}
+$installActionName = 'installButton';
+$install->launch($_, $installActionName);
 
-// Valeurs par défaut, remplacées si une autre valeur est saisie.
-foreach (array('login','mysqlBase','mysqlHost','mysqlLogin','mysqlMdp','mysqlPrefix','password','root') as $var) {
-    /* Initalise les variables avec le contenu des champs
-     * pour rappeler les valeurs déjà saisies. */
-    if (!empty($_[$var]))
-        $$var = $_[$var];
-    else
-        $$var = '';
-}
-if (empty($root)) {
-    // Ne peut être vide, alors on met la valeur par défaut
-    $root = str_replace(
-        basename(__FILE__),
-        '',
-        $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']
-    );
-}
-if (!isset($_['mysqlPrefix'])) {
-    // Le formulaire n'étant pas soumis, on met cette valeur par défaut.
-    $mysqlPrefix = 'leed__'; // séparation en groupe de tables PhpMyAdmin
-}
-
-$lib_errors = _t('ERROR');
-$lib_success = _t('SUCCESS');
-
-if(isset($_['installButton'])){
-    if (empty($_['password']) || empty($_['login'])) {
-        $test[$lib_errors][] = _t('INSTALL_ERROR_USERPWD');
-    }
-    if (!Functions::testDb(
-        $_['mysqlHost'], $_['mysqlLogin'], $_['mysqlMdp'], $_['mysqlBase']
-    )) {
-        $test[$lib_errors][] = _t('INSTALL_ERROR_CONNEXION');
-    } else {
-        $test[$lib_success][] = _t('INSTALL_INFO_CONNEXION');
-    }
-}
-if(!is_writable('./')){
-    $test[$lib_errors][]=_t('INSTALL_ERROR_RIGHT', array(str_replace(basename(__FILE__),'',__FILE__)));
-}else{
-    $test[$lib_success][]=_t('INSTALL_INFO_RIGHT');
-}
-if (!@function_exists('mysqli_connect')){
-    $test[$lib_errors][] = _t('INSTALL_ERROR_MYSQLICONNECT');
-}else{
-    $test[$lib_success][] = _t('INSTALL_INFO_MYSQLICONNECT');
-}
-if (!@function_exists('file_get_contents')){
-    $test[$lib_errors][] =  _t('INSTALL_ERROR_FILEGET');
-}else{
-    $test[$lib_success][] = _t('INSTALL_INFO_FILEGET');
-}
-if (!@function_exists('file_put_contents')){
-    $test[$lib_errors][] = _t('INSTALL_ERROR_FILEPUT');
-}else{
-    $test[$lib_success][] = _t('INSTALL_INFO_FILEPUT');
-}
-if (!@function_exists('curl_exec')){
-    $test[$lib_errors][] = _t('INSTALL_ERROR_CURL');
-}else{
-    $test[$lib_success][] = _t('INSTALL_INFO_CURL');
-}
-if (@version_compare(PHP_VERSION, '5.5.0') <= 0){
-    $test[$lib_errors][] = _t('INSTALL_ERROR_PHPV', array(PHP_VERSION));
-}else{
-    $test[$lib_success][] = _t('INSTALL_INFO_PHPV', array(PHP_VERSION));
-}
-if(ini_get('safe_mode') && ini_get('max_execution_time')!=0){
-    $test[$lib_errors][] = _t('INSTALL_ERROR_SAFEMODE');
-}else{
-    $test[$lib_success][] = _t('INSTALL_INFO_SAFEMODE');
-}
-
-if (isset($_['installButton']) && empty($test[$lib_errors])) { // Pas d'erreur, l'installation peut se faire.
-    $constant = "<?php
-    define('VERSION_NUMBER','1.6');
-    define('VERSION_NAME','Dev');
-
-    //Host de Mysql, le plus souvent localhost ou 127.0.0.1
-    define('MYSQL_HOST','{$mysqlHost}');
-    //Identifiant MySQL
-    define('MYSQL_LOGIN','{$mysqlLogin}');
-    //mot de passe MySQL
-    define('MYSQL_MDP','{$mysqlMdp}');
-    //Nom de la base MySQL ou se trouvera leed
-    define('MYSQL_BDD','{$mysqlBase}');
-    //Prefix des noms des tables leed pour les bases de données uniques
-    define('MYSQL_PREFIX','{$mysqlPrefix}');
-?>";
-
-    file_put_contents('constant.php', $constant);
-    if (!is_readable('constant.php'))
-        die('"constant.php" not found!');
-
-    require_once('constant.php');
-    require_once('MysqlEntity.class.php');
-    class_exists('Update') or require_once('Update.class.php');
-    Update::ExecutePatch(true);
-    require_once('Feed.class.php');
-    require_once('Event.class.php');
-
-    require_once('User.class.php');
-    require_once('Folder.class.php');
-    require_once('Configuration.class.php');
-
-    $cryptographicSalt = User::generateSalt();
-    $synchronisationCode = substr(sha1(rand(0,30).time().rand(0,30)),0,10);
-    $root = (substr($_['root'], strlen($_['root'])-1)=='/'?$_['root']:$_['root'].'/');
-
-    // DOSSIERS À CONSERVER TELS QUELS, SI DÉJÀ EXISTANTS
-    $feedManager = new Feed(); $feedManager->create();
-    $eventManager = new Event(); $eventManager->create();
-
-    // COMPTE ADMINISTRATEUR, RÀZ SI NÉCESSAIRE
-    $userManager = new User();
-    if ($userManager->tableExists()) {
-        // Suppose qu'il n'y a qu'un seul utilisateur
-        $userManager->truncate();
-    }
-    $userManager->create();
-    $admin = new User();
-    $admin->setLogin($_['login']);
-    $admin->setPassword($_['password'],$cryptographicSalt);
-    $admin->save();
-    $_SESSION['currentUser'] = serialize($admin);
-
-    // DOSSIERS DE FLUX, RECRÉE LE DOSSIER GÉNÉRAL SI NÉCESSAIRE
-    $folderManager = new Folder();
-    $folderManager->create();
-    if ($folderManager->rowCount()==0) {
-        //Création du dossier général
-        $folder = new Folder();
-        $folder->setName(_t('GENERAL_FOLDER'));
-        $folder->setParent(-1);
-        $folder->setIsopen(1);
-        $folder->save();
-    }
-
-    // REMET À ZÉRO LA CONFIGURATION
-    $configurationManager = new Configuration();
-    if ($configurationManager->tableExists()) {
-        $configurationManager->truncate();
-    }
-    $configurationManager->create();
-    $configurationManager->add('articleDisplayAnonymous','0');
-    $configurationManager->add('articleDisplayAuthor','1');
-    $configurationManager->add('articleDisplayDate','1');
-    $configurationManager->add('articleDisplayFolderSort','1');
-    $configurationManager->add('articleDisplayHomeSort','1');
-    $configurationManager->add('articleDisplayLink','1');
-    $configurationManager->add('articleDisplayMode','summary');
-    $configurationManager->add('articlePerPages','5');
-    $configurationManager->add('cryptographicSalt', $cryptographicSalt);
-    $configurationManager->add('displayOnlyUnreadFeedFolder','false');
-    $configurationManager->add('feedMaxEvents','50');
-    $configurationManager->add('language', $_POST['install_changeLngLeed']);
-    $configurationManager->add('optionFeedIsVerbose',1);
-    $configurationManager->add('paginationScale',5);
-    $configurationManager->add('syncGradCount','10');
-    $configurationManager->add('synchronisationCode',$synchronisationCode);
-    $configurationManager->add('synchronisationEnableCache','0');
-    $configurationManager->add('synchronisationForceFeed','0');
-    $configurationManager->add('synchronisationType','auto');
-    $selectedTemplate = isset($_POST['template']) ? $_POST['template'] : DEFAULT_TEMPLATE;
-    $configurationManager->add('theme', $selectedTemplate);
-    $configurationManager->add('root',$root);
-
-    $install_terminee=true;
-} /* Ci-dessous, on y va si :
-- la page est simplement affichée, sans avoir été validée
-- le formulaire est soumis, mais l'installation ne peut se faire
-*/
 ?>
 <!doctype html>
 <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
@@ -300,14 +116,14 @@ if (isset($_['installButton']) && empty($test[$lib_errors])) { // Pas d'erreur,
         </header>
     </div>
     <?php
-    if ($install_terminee){
+    if ($install->getFinished()){
         echo '<div id="main-container">
                 <div id="main" class="wrapper clearfix">
                     <div id="menuBar"></div>
                         <h1>'._t('INSTALL_TITLE_END').'</h1>
                         <span>'._t('INSTALL_END').'</span>
                         <hr>
-                        <button id="installButton" name="installButton" onclick="document.location.href=\'settings.php#preferenceBloc\'">'._t('INSTALL_BTN_END').'</button>
+                        <button id="installButton" name="<?php echo $installActionName; ?>" onclick="document.location.href=\'settings.php#preferenceBloc\'">'._t('INSTALL_BTN_END').'</button>
               ';
         // écriture des balises de fin et ne pas faire la suite
         echo '</div>
@@ -330,12 +146,17 @@ if (isset($_['installButton']) && empty($test[$lib_errors])) { // Pas d'erreur,
             <h3 class="left"><?php echo _t('INSTALL_PRE_REQUIS') ?></h3>
             <ul class="clear" style="margin:0">
             <?php
-                foreach($test as $type=>$messages){
+                foreach($install->logs as $type => $messages){
+                    if(empty($messages)) {
+                        continue;
+                    }
                     $class = 'message ';
-                    $class .= $lib_errors==$type ? 'messageError':'messageSuccess';
-                    echo "<li class='$class'>$type&nbsp;:\n<ul>";
+                    $class .= $type === 'errors' ? 'messageError':'messageSuccess';
+                    $label = $type === 'errors' ? _t('ERROR') : _t('SUCCESS');
+                    echo "<li class='$class'>$label&nbsp;:<ul>";
+
                     foreach ($messages as $message){
-                        echo "<li>$message</li>\n";
+                        echo "<li>$message</li>";
                     }
                     echo "</ul></li>";
                 }
@@ -371,44 +192,44 @@ if (isset($_['installButton']) && empty($test[$lib_errors])) { // Pas d'erreur,
             </li>
             <li>
                 <span><?php echo _t('PROJECT_ROOT') ?></span>
-                <input type="text" name="root" value="<?php echo $root; ?>">
+                <input type="text" name="root" value="<?php echo $install->getDefaultRoot(); ?>">
             </li>
         </ul>
         <h2><?php echo _t('INSTALL_TAB_BDD') ?></h2>
         <ul>
             <li>
                 <span><?php echo _t('INSTALL_HOST') ?></span>
-                <input type="text" name="mysqlHost" value="<?php echo $mysqlHost; ?>" placeholder="<?php echo _t('INSTALL_COMMENT_HOST') ?>">
+                <input type="text" name="mysqlHost" value="<?php echo $install->options['db']['mysqlHost']; ?>" placeholder="<?php echo _t('INSTALL_COMMENT_HOST') ?>">
             </li>
             <li>
                 <span><?php echo _t('LOGIN') ?></span>
-                <input type="text" name="mysqlLogin" value="<?php echo $mysqlLogin; ?>">
+                <input type="text" name="mysqlLogin" value="<?php echo $install->options['db']['mysqlLogin']; ?>">
             </li>
             <li>
                 <span><?php echo _t('PASSWORD') ?></span>
-                <input type="text" autocomplete="off" name="mysqlMdp" value="<?php echo $mysqlMdp; ?>" placeholder="<?php echo _t('INSTALL_DISPLAY_CLEAR') ?>">
+                <input type="text" autocomplete="off" name="mysqlMdp" value="<?php echo $install->options['db']['mysqlMdp']; ?>" placeholder="<?php echo _t('INSTALL_DISPLAY_CLEAR') ?>">
             </li>
             <li>
                 <span><?php echo _t('INSTALL_BDD') ?></span>
-                <input type="text" name="mysqlBase" value="<?php echo $mysqlBase; ?>" placeholder="<?php echo _t('INSTALL_COMMENT_BDD') ?>">
+                <input type="text" name="mysqlBase" value="<?php echo $install->options['db']['mysqlBase']; ?>" placeholder="<?php echo _t('INSTALL_COMMENT_BDD') ?>">
             </li>
             <li>
                 <span><?php echo _t('INSTALL_PREFIX_TABLE') ?></span>
-                <input type="text" name="mysqlPrefix" value="<?php echo $mysqlPrefix; ?>">
+                <input type="text" name="mysqlPrefix" value="<?php echo $install->options['db']['mysqlPrefix']; ?>">
             </li>
         </ul>
         <h2><?php echo _t('INSTALL_TAB_ADMIN') ?></h2>
         <ul>
             <li>
                 <span><?php echo _t('LOGIN') ?></span>
-                <input type="text" name="login" value="<?php echo $login; ?>" placeholder="<?php echo _t('LOGIN') ?>">
+                <input type="text" name="login" value="<?php echo $install->options['user']['login']; ?>" placeholder="<?php echo _t('LOGIN') ?>">
             </li>
             <li>
                 <span><?php echo _t('PASSWORD') ?></span>
-                <input type="text" autocomplete="off" name="password" value="<?php echo $password; ?>" placeholder="<?php echo _t('INSTALL_DISPLAY_CLEAR') ?>">
+                <input type="text" autocomplete="off" name="password" value="<?php echo $install->options['user']['password']; ?>" placeholder="<?php echo _t('INSTALL_DISPLAY_CLEAR') ?>">
             </li>
         </ul>
-        <button id="installButton" name="installButton"><?php echo _t('INSTALL_BTN') ?></button>
+        <button id="installButton" name="<?php echo $installActionName; ?>"><?php echo _t('INSTALL_BTN') ?></button>
     </form>
 </div>
 <div id="footer-container">

+ 1 - 0
locale/en.json

@@ -29,6 +29,7 @@
  "INSTALL_ERROR_FILEGET":"The required function 'file_get_contents' is inaccessible on your server, check your version of PHP.",
  "INSTALL_ERROR_FILEPUT":"The required 'file_put_contents' is inaccessible on your server, check your version of PHP.",
  "INSTALL_ERROR_MYSQLICONNECT":"The required function 'mysqli_connect' is inaccessible on your server, check your MySql installation.",
+ "INSTALL_ERROR_DB_INFOS":"The 'host', 'username' and 'base' fields about your database are required.",
  "INSTALL_ERROR_PHPV":"Your PHP version ($1) is too old, it is possible that some features script include malfunctions.",
  "INSTALL_ERROR_RIGHT":"Can't write in Leed directory, please add write permissions on the entire folder (sudo chmod 777 -R $1, think about shielding permissions later)",
  "INSTALL_ERROR_SAFEMODE":"The script can not manage the timeout alone because your safe mode is enabled,<br/>in your PHP configuration file, set the max_execution_time variable to 0 or disable safemode.",

+ 1 - 0
locale/eo.json

@@ -29,6 +29,7 @@
  "INSTALL_ERROR_FILEGET":"La funkcio nepra 'file_get_contents' ne akceseblas ĉe via servilo, kontrolu vian version de PHP.",
  "INSTALL_ERROR_FILEPUT":"La funkcio nepra 'file_put_contents' ne akceseblas ĉe via servilo, kontrolu vian version de PHP.",
  "INSTALL_ERROR_MYSQLICONNECT":"La funkcio nepra 'mysqli_connect' ne akceseblas ĉe via servilo, kontrolu vian version de MySql.",
+ "INSTALL_ERROR_DB_INFOS":"",
  "INSTALL_ERROR_PHPV":"Via versio de PHP ($1) estas tro malnova, eblas ke funkcioj misfunkcias.",
  "INSTALL_ERROR_RIGHT":"Ne eblas skribi en la dosierujon Leed, bonvolu aldoni permesojn por skribi sur la tuta dosierujo (sudo chmod 777 -R $1, pripensu finagordi la permesoj poste)",
  "INSTALL_ERROR_SAFEMODE":"La skripto ne povas mastrumi la tempolimo mem ĉar via safe mode estas aktivita en via agorda dosiero de PHP, ŝalti la variablon max_execution_time al 0 aŭ malŝalti la safemode.",

+ 1 - 0
locale/es.json

@@ -29,6 +29,7 @@
  "INSTALL_ERROR_FILEGET":"Se necesita la función 'file_get_contents' pero no es disponible sobre el servidor. Verificar su versión de PHP.",
  "INSTALL_ERROR_FILEPUT":"Se necesita la función 'file_put_contents' pero no es disponible sobre el servidor. Verificar su versión de PHP.",
  "INSTALL_ERROR_MYSQLICONNECT":"Se necesita la función 'mysqli_connect' pero no es disponible sobre el servidor. Verificar su versión de PHP.",
+ "INSTALL_ERROR_DB_INFOS":"Se necesitan los campos 'huésped', 'login' y 'base' en cuanto a vuestra base de datos.",
  "INSTALL_ERROR_PHPV":"Su versión de PHP ($1) es demasiada antigua, se puede que algunas funcionalidades del script no funcionan.",
  "INSTALL_ERROR_RIGHT":"No se puede escribir en el directorio de Leed. Añadir los permisos para escribir sobre todo el directorio (sudo chmod 777 -R $1, pensar a modificarlo de nuevo por medida se seguridad después de la instalación)",
  "INSTALL_ERROR_SAFEMODE":"El script no puede administrar el timeout solo ya que el safe mode está activado,<br/> en su archivo de configuración de PHP, poner la variable max_execution_time a 0 o desactivar el safe mode.",

+ 1 - 0
locale/fr.json

@@ -29,6 +29,7 @@
  "INSTALL_ERROR_FILEGET":"La fonction requise 'file_get_contents' est inaccessible sur votre serveur, vérifiez votre version de PHP.",
  "INSTALL_ERROR_FILEPUT":"La fonction requise 'file_put_contents' est inaccessible sur votre serveur, vérifiez votre version de PHP.",
  "INSTALL_ERROR_MYSQLICONNECT":"La fonction requise 'mysqli_connect' est inaccessible sur votre serveur, vérifiez votre installation de MySql.",
+ "INSTALL_ERROR_DB_INFOS":"Les champs 'hôte', 'identifiant' et 'base' concerant votre base de données sont requis.",
  "INSTALL_ERROR_PHPV":"Votre version de PHP ($1) est trop ancienne, il est possible que certaines fonctionnalités du script comportent des dysfonctionnements.",
  "INSTALL_ERROR_RIGHT":"Écriture impossible dans le répertoire Leed, veuillez ajouter les permissions en écriture sur tout le dossier (sudo chmod 777 -R $1, pensez à blinder les permissions par la suite)",
  "INSTALL_ERROR_SAFEMODE":"Le script ne peut pas gérer le timeout tout seul car votre safe mode est activé,<br/> dans votre fichier de configuration PHP, mettez la variable max_execution_time à 0 ou désactivez le safemode.",