From 8c2c5d287d5ac08aa9d0a3fb3d353ea7a18c92c3 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 14 Apr 2013 18:57:47 +0200 Subject: Fix issue #43 : création d'un installateur MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/configuration/application.ini | 13 - public/data/Configuration.array.php | 23 -- public/index.php | 26 +- public/install.php | 486 ++++++++++++++++++++++++++++++++++++ public/theme/global.css | 16 +- 5 files changed, 516 insertions(+), 48 deletions(-) delete mode 100644 app/configuration/application.ini delete mode 100644 public/data/Configuration.array.php create mode 100755 public/install.php diff --git a/app/configuration/application.ini b/app/configuration/application.ini deleted file mode 100644 index 2beb60324..000000000 --- a/app/configuration/application.ini +++ /dev/null @@ -1,13 +0,0 @@ -[general] -environment = "development" -use_url_rewriting = false -sel_application = "flux rss lalala ~~~" - -base_url = "/~marien/rss/public" ; pas de slash à la fin /!\ -title = "FreshRSS" - -[db] -host = "localhost" -user = "bd" -password = "bede" -base = "marienfr_rss" diff --git a/public/data/Configuration.array.php b/public/data/Configuration.array.php deleted file mode 100644 index ce5a1a8ee..000000000 --- a/public/data/Configuration.array.php +++ /dev/null @@ -1,23 +0,0 @@ - 20, - 'default_view' => 'not_read', - 'display_posts' => 'no', - 'sort_order' => 'low_to_high', - 'old_entries' => 3, - 'mail_login' => '', - 'shortcuts' => array ( - 'mark_read' => 'r', - 'mark_favorite' => 'f', - 'go_website' => 'space', - 'next_entry' => 'j', - 'prev_entry' => 'k', - 'next_page' => 'right', - 'prev_page' => 'left', - ), - 'mark_when' => array ( - 'article' => 'yes', - 'site' => 'yes', - 'page' => 'no', - ), -); diff --git a/public/index.php b/public/index.php index 330843719..4e39d028e 100755 --- a/public/index.php +++ b/public/index.php @@ -25,16 +25,20 @@ define ('APP_PATH', realpath (PUBLIC_PATH . '/../app')); define ('LOG_PATH', realpath (PUBLIC_PATH . '/../log')); define ('CACHE_PATH', realpath (PUBLIC_PATH . '/../cache')); -set_include_path (get_include_path () - . PATH_SEPARATOR - . LIB_PATH - . PATH_SEPARATOR - . LIB_PATH . '/minz' - . PATH_SEPARATOR - . APP_PATH); +if (file_exists (PUBLIC_PATH . '/install.php')) { + include ('install.php'); +} else { + set_include_path (get_include_path () + . PATH_SEPARATOR + . LIB_PATH + . PATH_SEPARATOR + . LIB_PATH . '/minz' + . PATH_SEPARATOR + . APP_PATH); -require (APP_PATH . '/App_FrontController.php'); + require (APP_PATH . '/App_FrontController.php'); -$front_controller = new App_FrontController (); -$front_controller->init (); -$front_controller->run (); + $front_controller = new App_FrontController (); + $front_controller->init (); + $front_controller->run (); +} diff --git a/public/install.php b/public/install.php new file mode 100755 index 000000000..512e4b5d5 --- /dev/null +++ b/public/install.php @@ -0,0 +1,486 @@ + $val) { + if (is_array ($val)) { + writeLine ($f, '\'' . $key . '\' => array ('); + writeArray ($f, $val); + writeLine ($f, '),'); + } else { + writeLine ($f, '\'' . $key . '\' => \'' . $val . '\','); + } + } +} + +/*** SAUVEGARDES ***/ +function saveStep2 () { + if (!empty ($_POST)) { + if (empty ($_POST['sel']) || + empty ($_POST['title']) || + empty ($_POST['old_entries'])) { + return false; + } + + $_SESSION['sel'] = $_POST['sel']; + $_SESSION['base_url'] = $_POST['base_url']; + $_SESSION['title'] = $_POST['title']; + $_SESSION['old_entries'] = $_POST['old_entries']; + if (!is_int (intval ($_SESSION['old_entries'])) || + $_SESSION['old_entries'] < 1) { + $_SESSION['old_entries'] = 3; + } + $_SESSION['mail_login'] = $_POST['mail_login']; + + $file_data = PUBLIC_PATH . '/data/Configuration.array.php'; + + $conf = array ( + 'posts_per_page' => 20, + 'default_view' => 'not_read', + 'display_posts' => 'no', + 'sort_order' => 'low_to_high', + 'old_entries' => $_SESSION['old_entries'], + 'mail_login' => $_SESSION['mail_login'], + 'shortcuts' => array ( + 'mark_read' => 'r', + 'mark_favorite' => 'f', + 'go_website' => 'space', + 'next_entry' => 'j', + 'prev_entry' => 'k', + 'next_page' => 'right', + 'prev_page' => 'left', + ), + 'mark_when' => array ( + 'article' => 'yes', + 'site' => 'yes', + 'page' => 'no', + ), + ); + $f = fopen ($file_data, 'w'); + writeLine ($f, ' 1 && checkStep1 ()['all'] != 'ok') { + header ('Location: index.php?step=1'); + } elseif (STEP > 2 && checkStep2 ()['all'] != 'ok') { + header ('Location: index.php?step=2'); + } elseif (STEP > 3 && checkStep3 ()['all'] != 'ok') { + header ('Location: index.php?step=3'); + } +} +function checkStep1 () { + $php = version_compare (PHP_VERSION, '5.1.0') >= 0; + $minz = file_exists (LIB_PATH . '/minz'); + $curl = extension_loaded ('curl'); + $pdo = extension_loaded ('pdo_mysql'); + $cache = CACHE_PATH && is_writable (CACHE_PATH); + $conf = APP_PATH && is_writable (APP_PATH . '/configuration'); + $data = is_writable (PUBLIC_PATH . '/data'); + + return array ( + 'php' => $php ? 'ok' : 'ko', + 'minz' => $minz ? 'ok' : 'ko', + 'curl' => $curl ? 'ok' : 'ko', + 'pdo-mysql' => $pdo ? 'ok' : 'ko', + 'cache' => $cache ? 'ok' : 'ko', + 'configuration' => $conf ? 'ok' : 'ko', + 'data' => $data ? 'ok' : 'ko', + 'all' => $php && $minz && $curl && $pdo && $cache && $conf && $data ? 'ok' : 'ko' + ); +} +function checkStep2 () { + $conf = isset ($_SESSION['sel']) && + isset ($_SESSION['base_url']) && + isset ($_SESSION['title']) && + isset ($_SESSION['old_entries']) && + isset ($_SESSION['mail_login']); + $data = file_exists (PUBLIC_PATH . '/data/Configuration.array.php'); + + return array ( + 'conf' => $conf ? 'ok' : 'ko', + 'data' => $data ? 'ok' : 'ko', + 'all' => $conf && $data ? 'ok' : 'ko' + ); +} +function checkStep3 () { + $conf = file_exists (APP_PATH . '/configuration/application.ini'); + $bd = isset ($_SESSION['bd_host']) && + isset ($_SESSION['bd_user']) && + isset ($_SESSION['bd_pass']) && + isset ($_SESSION['bd_name']); + + return array ( + 'bd' => $bd ? 'ok' : 'ko', + 'conf' => $conf ? 'ok' : 'ko', + 'all' => $bd && $conf ? 'ok' : 'ko' + ); +} +function checkBD () { + $error = false; + + try { + $c = new PDO ('mysql:host=' . $_SESSION['bd_host'] . ';dbname=' . $_SESSION['bd_name'], + $_SESSION['bd_user'], + $_SESSION['bd_pass']); + + $res = $c->query (SQL_REQ); + + if (!$res) { + $error = true; + } + } catch (PDOException $e) { + $error = true; + } + + if ($error && file_exists (APP_PATH . '/configuration/application.ini')) { + unlink (APP_PATH . '/configuration/application.ini'); + } + + return !$error; +} + +/*** AFFICHAGE ***/ +function printStep1 () { + $res = checkStep1 (); +?> + + + +

Ok ! Votre version de PHP est la et est compatible avec FreshRSS

+ +

Arf ! Votre version de PHP est la . Vous devriez avoir au moins la version 5.1.0

+ + + +

Ok ! Vous disposez du framework Minz

+ +

Arf ! Vous ne disposez pas de la librairie Minz. Vous devriez exécuter le script build.sh ou bien la télécharger sur Github et installer dans le répertoire le contenu de son répertoire /lib.

+ + + + +

Ok ! Vous disposez de cURL dans sa version

+ +

Arf ! Vous ne disposez pas de cURL

+ + + +

Ok ! Vous disposez de PDO et de son driver pour MySQL

+ +

Arf ! Vous ne disposez pas de PDO ou de son driver pour MySQL

+ + + +

Ok ! Les droits sur le répertoire de cache sont bons

+ +

Arf ! Veuillez vérifier les droits sur le répertoire . Le serveur HTTP doit être capable d'écrire dedans

+ + + +

Ok ! Les droits sur le répertoire de configuration sont bons

+ +

Arf ! Veuillez vérifier les droits sur le répertoire . Le serveur HTTP doit être capable d'écrire dedans

+ + + +

Ok ! Les droits sur le répertoire de data sont bons

+ +

Arf ! Veuillez vérifier les droits sur le répertoire . Le serveur HTTP doit être capable d'écrire dedans

+ + + + Passer à l'étape suivante + + Veuillez corriger les erreurs avant de passer à l'étape suivante. + + + +

Ok ! La configuration générale a été enregistrée.

+ + +
+ Configuration générale +
+ +
+ Vous devriez changer cette valeur par n'importe quelle autre +
+
+ + +
+ +
+ Laissez tel quel dans le doute +
+
+ +
+ +
+ +
+
+ +
+ +
+ mois +
+
+ +
+ +
+ + +
+
+ +
+
+ + + + Passer à l'étape suivante + +
+
+
+ + +

Ok ! La configuration de la base de données a été enregistrée.

+ + +
+ Configuration de la base de données +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ + + + Passer à l'étape suivante + +
+
+
+ +

Félicitations ! L'installation s'est bien passée. Il faut maintenant supprimer le fichier install.php pour pouvoir accéder à FreshRSS... ou simplement cliquer sur le bouton ci-dessous ;)

+ Terminer l'installation + +

Oups ! Quelque chose s'est mal passé, vous devriez supprimer le fichier à la main.

+ + + + + + + Installation - FreshRSS + + + + + +
+
+

FreshRSS

+

Installation - étape

+
+
+ +
+ + +
+ +
+
+ + + diff --git a/public/theme/global.css b/public/theme/global.css index e4c503dfc..c08463b8b 100644 --- a/public/theme/global.css +++ b/public/theme/global.css @@ -400,13 +400,27 @@ input, select, textarea { border-radius: 5px; color: #aaa; text-shadow: 0 0 1px #eee; - box-shadow: 1px 1px 3px #aaa inset; } .alert .alert-head { margin: 0; font-weight: bold; font-size: 110%; } + .alert.alert-warn { + background: #ffe; + border: 1px solid #eeb; + color: #c95; + } + .alert.alert-success { + background: #dfd; + border: 1px solid #cec; + color: #484; + } + .alert.alert-error { + background: #fdd; + border: 1px solid #ecc; + color: #844; + } /* ICONES */ .icon { -- cgit v1.2.3