Install: Redirections between Install and Index

This commit is contained in:
Olivier PEREZ 2015-09-03 08:03:37 +02:00
parent a7727d8523
commit 254512c55a
7 changed files with 33 additions and 27 deletions

View File

@ -20,23 +20,9 @@
use Framadate\Services\InstallService; use Framadate\Services\InstallService;
use Framadate\Utils; use Framadate\Utils;
// Define values in place of config.php (that does not exists yet)
const NOMAPPLICATION = 'Framadate';
const DEFAULT_LANGUAGE = 'fr';
const IMAGE_TITRE = 'images/logo-framadate.png';
const LOG_FILE = 'admin/stdout.log';
$ALLOWED_LANGUAGES = [
'fr' => 'Français',
'en' => 'English',
'es' => 'Español',
'de' => 'Deutsch',
'it' => 'Italiano',
];
require_once '../app/inc/init.php'; require_once '../app/inc/init.php';
define('CONF_FILENAME', ROOT_DIR . '/app/inc/config.php');
if (file_exists(CONF_FILENAME)) { if (is_file(CONF_FILENAME)) {
header(('Location: ' . Utils::get_server_name())); header(('Location: ' . Utils::get_server_name()));
exit; exit;
} }
@ -48,7 +34,7 @@ if (!empty($_POST)) {
$result = $installService->install($_POST, $smarty); $result = $installService->install($_POST, $smarty);
if ($result['status'] === 'OK') { if ($result['status'] === 'OK') {
header(('Location: ' . Utils::get_server_name() . '/admin/migration.php')); header(('Location: ' . Utils::get_server_name() . 'admin/migration.php'));
exit; exit;
} else { } else {
$error = __('Error', $result['code']); $error = __('Error', $result['code']);

View File

@ -75,7 +75,7 @@ class Utils {
<script type="text/javascript" src="' . self::get_server_name() . 'js/bootstrap-datepicker.js"></script> <script type="text/javascript" src="' . self::get_server_name() . 'js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="' . self::get_server_name() . 'js/locales/bootstrap-datepicker.' . $locale . '.js"></script> <script type="text/javascript" src="' . self::get_server_name() . 'js/locales/bootstrap-datepicker.' . $locale . '.js"></script>
<script type="text/javascript" src="' . self::get_server_name() . 'js/core.js"></script>'; <script type="text/javascript" src="' . self::get_server_name() . 'js/core.js"></script>';
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/nav/nav.js")) { if (is_file($_SERVER['DOCUMENT_ROOT'] . "/nav/nav.js")) {
echo '<script src="/nav/nav.js" id="nav_js" type="text/javascript" charset="utf-8"></script><!-- /Framanav -->'; echo '<script src="/nav/nav.js" id="nav_js" type="text/javascript" charset="utf-8"></script><!-- /Framanav -->';
} }

View File

@ -32,17 +32,31 @@ if (ini_get('date.timezone') == '') {
} }
define('ROOT_DIR', __DIR__ . '/../../'); define('ROOT_DIR', __DIR__ . '/../../');
define('CONF_FILENAME', ROOT_DIR . '/app/inc/config.php');
require_once __DIR__ . '/constants.php'; if (is_file(CONF_FILENAME)) {
@include_once __DIR__ . '/config.php';
require_once __DIR__ . '/i18n.php';
// Smarty require_once __DIR__ . '/constants.php';
require_once __DIR__ . '/smarty.php'; @include_once __DIR__ . '/config.php';
// Connection to database // Connection to database
if (is_file(__DIR__ . '/config.php')) {
$connect = new FramaDB(DB_CONNECTION_STRING, DB_USER, DB_PASSWORD); $connect = new FramaDB(DB_CONNECTION_STRING, DB_USER, DB_PASSWORD);
RepositoryFactory::init($connect); RepositoryFactory::init($connect);
$err = 0;
} else {
define('NOMAPPLICATION', 'Framadate');
define('DEFAULT_LANGUAGE', 'fr');
define('IMAGE_TITRE', 'images/logo-framadate.png');
define('LOG_FILE', 'admin/stdout.log');
$ALLOWED_LANGUAGES = [
'fr' => 'Français',
'en' => 'English',
'es' => 'Español',
'de' => 'Deutsch',
'it' => 'Italiano',
];
} }
$err = 0;
require_once __DIR__ . '/i18n.php';
// Smarty
require_once __DIR__ . '/smarty.php';

View File

@ -29,7 +29,7 @@ $smarty->assign('APPLICATION_NAME', NOMAPPLICATION);
$smarty->assign('SERVER_URL', Utils::get_server_name()); $smarty->assign('SERVER_URL', Utils::get_server_name());
$smarty->assign('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']); $smarty->assign('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
$smarty->assign('TITLE_IMAGE', IMAGE_TITRE); $smarty->assign('TITLE_IMAGE', IMAGE_TITRE);
$smarty->assign('use_nav_js', file_exists($_SERVER['DOCUMENT_ROOT'] . '/nav/nav.js')); $smarty->assign('use_nav_js', is_file($_SERVER['DOCUMENT_ROOT'] . '/nav/nav.js'));
$smarty->assign('locale', $locale); $smarty->assign('locale', $locale);
$smarty->assign('langs', $ALLOWED_LANGUAGES); $smarty->assign('langs', $ALLOWED_LANGUAGES);
$smarty->assign('date_format', $date_format); $smarty->assign('date_format', $date_format);

View File

@ -32,7 +32,7 @@ $pollService = new PollService($connect, $logService);
$mailService = new MailService($config['use_smtp']); $mailService = new MailService($config['use_smtp']);
$purgeService = new PurgeService($connect, $logService); $purgeService = new PurgeService($connect, $logService);
if (file_exists('bandeaux_local.php')) { if (is_file('bandeaux_local.php')) {
include_once('bandeaux_local.php'); include_once('bandeaux_local.php');
} else { } else {
include_once('bandeaux.php'); include_once('bandeaux.php');

View File

@ -18,9 +18,15 @@
*/ */
use Framadate\Services\PollService; use Framadate\Services\PollService;
use Framadate\Utils;
include_once __DIR__ . '/app/inc/init.php'; include_once __DIR__ . '/app/inc/init.php';
if (!is_file(CONF_FILENAME)) {
header(('Location: ' . Utils::get_server_name() . 'admin/install.php'));
exit;
}
/* SERVICES */ /* SERVICES */
/* -------- */ /* -------- */
$logService = '\Framadate\Services\LogService'; $logService = '\Framadate\Services\LogService';