2014-07-23 15:52:50 +02:00
|
|
|
<?php
|
|
|
|
if (function_exists('opcache_reset')) {
|
|
|
|
opcache_reset();
|
|
|
|
}
|
2016-07-24 11:59:17 +02:00
|
|
|
header("Content-Security-Policy: default-src 'self'");
|
2014-07-23 15:52:50 +02:00
|
|
|
|
|
|
|
define('BCRYPT_COST', 9);
|
|
|
|
|
|
|
|
session_name('FreshRSS');
|
|
|
|
session_set_cookie_params(0, dirname(empty($_SERVER['REQUEST_URI']) ? '/' : dirname($_SERVER['REQUEST_URI'])), null, false, true);
|
|
|
|
session_start();
|
|
|
|
|
2015-11-06 16:54:20 +01:00
|
|
|
Minz_Configuration::register('default_system', join_path(DATA_PATH, 'config.default.php'));
|
|
|
|
Minz_Configuration::register('default_user', join_path(USERS_PATH, '_', 'config.default.php'));
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
if (isset($_GET['step'])) {
|
|
|
|
define('STEP',(int)$_GET['step']);
|
2014-07-23 15:52:50 +02:00
|
|
|
} else {
|
2014-09-27 10:10:43 +02:00
|
|
|
define('STEP', 0);
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
define('SQL_CREATE_DB', 'CREATE DATABASE IF NOT EXISTS %1$s DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
|
|
|
|
|
|
|
|
if (STEP === 3 && isset($_POST['type'])) {
|
|
|
|
$_SESSION['bd_type'] = $_POST['type'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_SESSION['bd_type'])) {
|
|
|
|
switch ($_SESSION['bd_type']) {
|
2014-09-27 10:10:43 +02:00
|
|
|
case 'mysql':
|
|
|
|
include(APP_PATH . '/SQL/install.sql.mysql.php');
|
|
|
|
break;
|
|
|
|
case 'sqlite':
|
|
|
|
include(APP_PATH . '/SQL/install.sql.sqlite.php');
|
|
|
|
break;
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
function param($key, $default = false) {
|
|
|
|
if (isset($_POST[$key])) {
|
|
|
|
return $_POST[$key];
|
|
|
|
} else {
|
|
|
|
return $default;
|
|
|
|
}
|
|
|
|
}
|
2014-07-23 15:52:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
// gestion internationalisation
|
2014-09-27 10:10:43 +02:00
|
|
|
function initTranslate() {
|
2015-02-08 18:55:48 +01:00
|
|
|
Minz_Translate::init();
|
|
|
|
$available_languages = Minz_Translate::availableLanguages();
|
2014-07-23 15:52:50 +02:00
|
|
|
|
2015-02-08 18:55:48 +01:00
|
|
|
if (!isset($_SESSION['language'])) {
|
|
|
|
$_SESSION['language'] = get_best_language();
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
|
|
|
|
2015-02-08 18:55:48 +01:00
|
|
|
if (!in_array($_SESSION['language'], $available_languages)) {
|
|
|
|
$_SESSION['language'] = 'en';
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
2014-09-27 10:10:43 +02:00
|
|
|
|
2015-02-08 18:55:48 +01:00
|
|
|
Minz_Translate::reset($_SESSION['language']);
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
2014-09-27 10:10:43 +02:00
|
|
|
|
2015-02-08 18:55:48 +01:00
|
|
|
function get_best_language() {
|
|
|
|
$accept = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
|
|
|
return strtolower(substr($accept, 0, 2));
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
|
2014-07-23 15:52:50 +02:00
|
|
|
/*** SAUVEGARDES ***/
|
2014-09-27 10:10:43 +02:00
|
|
|
function saveLanguage() {
|
|
|
|
if (!empty($_POST)) {
|
|
|
|
if (!isset($_POST['language'])) {
|
2014-07-23 15:52:50 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$_SESSION['language'] = $_POST['language'];
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
header('Location: index.php?step=1');
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 16:54:20 +01:00
|
|
|
function saveStep1() {
|
|
|
|
if (isset($_POST['freshrss-keep-install']) &&
|
|
|
|
$_POST['freshrss-keep-install'] === '1') {
|
|
|
|
// We want to keep our previous installation of FreshRSS
|
|
|
|
// so we need to make next steps valid by setting $_SESSION vars
|
|
|
|
// with values from the previous installation
|
|
|
|
|
|
|
|
// First, we try to get previous configurations
|
|
|
|
Minz_Configuration::register('system',
|
|
|
|
join_path(DATA_PATH, 'config.php'),
|
|
|
|
join_path(DATA_PATH, 'config.default.php'));
|
|
|
|
$system_conf = Minz_Configuration::get('system');
|
|
|
|
|
|
|
|
$current_user = $system_conf->default_user;
|
|
|
|
Minz_Configuration::register('user',
|
|
|
|
join_path(USERS_PATH, $current_user, 'config.php'),
|
|
|
|
join_path(USERS_PATH, '_', 'config.default.php'));
|
|
|
|
$user_conf = Minz_Configuration::get('user');
|
|
|
|
|
|
|
|
// Then, we set $_SESSION vars
|
|
|
|
$_SESSION['title'] = $system_conf->title;
|
|
|
|
$_SESSION['auth_type'] = $system_conf->auth_type;
|
|
|
|
$_SESSION['old_entries'] = $user_conf->old_entries;
|
|
|
|
$_SESSION['mail_login'] = $user_conf->mail_login;
|
|
|
|
$_SESSION['default_user'] = $current_user;
|
|
|
|
$_SESSION['passwordHash'] = $user_conf->passwordHash;
|
|
|
|
|
|
|
|
$db = $system_conf->db;
|
|
|
|
$_SESSION['bd_type'] = $db['type'];
|
|
|
|
$_SESSION['bd_host'] = $db['host'];
|
|
|
|
$_SESSION['bd_user'] = $db['user'];
|
|
|
|
$_SESSION['bd_password'] = $db['password'];
|
|
|
|
$_SESSION['bd_base'] = $db['base'];
|
|
|
|
$_SESSION['bd_prefix'] = $db['prefix'];
|
|
|
|
$_SESSION['bd_error'] = '';
|
|
|
|
|
|
|
|
header('Location: index.php?step=4');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
function saveStep2() {
|
2015-11-06 16:54:20 +01:00
|
|
|
$user_default_config = Minz_Configuration::get('default_user');
|
2014-09-27 10:10:43 +02:00
|
|
|
if (!empty($_POST)) {
|
2015-11-06 16:54:20 +01:00
|
|
|
$system_default_config = Minz_Configuration::get('default_system');
|
|
|
|
$_SESSION['title'] = $system_default_config->title;
|
|
|
|
$_SESSION['old_entries'] = param('old_entries', $user_default_config->old_entries);
|
2014-09-27 10:10:43 +02:00
|
|
|
$_SESSION['auth_type'] = param('auth_type', 'form');
|
|
|
|
$_SESSION['default_user'] = substr(preg_replace('/[^a-zA-Z0-9]/', '', param('default_user', '')), 0, 16);
|
|
|
|
$_SESSION['mail_login'] = filter_var(param('mail_login', ''), FILTER_VALIDATE_EMAIL);
|
|
|
|
|
|
|
|
$password_plain = param('passwordPlain', false);
|
2016-07-24 11:59:17 +02:00
|
|
|
if ($password_plain !== false && cryptAvailable()) {
|
2014-07-23 15:52:50 +02:00
|
|
|
if (!function_exists('password_hash')) {
|
|
|
|
include_once(LIB_PATH . '/password_compat.php');
|
|
|
|
}
|
2014-09-27 10:10:43 +02:00
|
|
|
$passwordHash = password_hash($password_plain, PASSWORD_BCRYPT, array('cost' => BCRYPT_COST));
|
2014-07-23 15:52:50 +02:00
|
|
|
$passwordHash = preg_replace('/^\$2[xy]\$/', '\$2a\$', $passwordHash); //Compatibility with bcrypt.js
|
|
|
|
$_SESSION['passwordHash'] = $passwordHash;
|
|
|
|
}
|
|
|
|
|
2015-11-06 16:54:20 +01:00
|
|
|
if (empty($_SESSION['old_entries']) ||
|
2014-09-27 10:10:43 +02:00
|
|
|
empty($_SESSION['auth_type']) ||
|
|
|
|
empty($_SESSION['default_user'])) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (($_SESSION['auth_type'] === 'form' && empty($_SESSION['passwordHash'])) ||
|
|
|
|
($_SESSION['auth_type'] === 'persona' && empty($_SESSION['mail_login']))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$_SESSION['salt'] = sha1(uniqid(mt_rand(), true).implode('', stat(__FILE__)));
|
|
|
|
if ((!ctype_digit($_SESSION['old_entries'])) ||($_SESSION['old_entries'] < 1)) {
|
2015-11-06 16:54:20 +01:00
|
|
|
$_SESSION['old_entries'] = $user_default_config->old_entries;
|
2014-09-27 10:10:43 +02:00
|
|
|
}
|
|
|
|
|
2014-07-23 15:52:50 +02:00
|
|
|
$token = '';
|
|
|
|
if ($_SESSION['mail_login']) {
|
|
|
|
$token = sha1($_SESSION['salt'] . $_SESSION['mail_login']);
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
$config_array = array(
|
2014-07-23 15:52:50 +02:00
|
|
|
'language' => $_SESSION['language'],
|
2015-11-06 16:54:20 +01:00
|
|
|
'theme' => $user_default_config->theme,
|
2014-07-23 15:52:50 +02:00
|
|
|
'old_entries' => $_SESSION['old_entries'],
|
|
|
|
'mail_login' => $_SESSION['mail_login'],
|
|
|
|
'passwordHash' => $_SESSION['passwordHash'],
|
|
|
|
'token' => $token,
|
|
|
|
);
|
|
|
|
|
2015-02-08 18:55:48 +01:00
|
|
|
// Create default user files but first, we delete previous data to
|
|
|
|
// avoid access right problems.
|
|
|
|
$user_dir = join_path(USERS_PATH, $_SESSION['default_user']);
|
|
|
|
$user_config_path = join_path($user_dir, 'config.php');
|
|
|
|
|
|
|
|
recursive_unlink($user_dir);
|
|
|
|
mkdir($user_dir);
|
|
|
|
file_put_contents($user_config_path, "<?php\n return " . var_export($config_array, true) . ';');
|
2014-07-23 15:52:50 +02:00
|
|
|
|
|
|
|
if ($_SESSION['mail_login'] != '') {
|
2015-02-08 18:55:48 +01:00
|
|
|
$personaFile = join_path(DATA_PATH, 'persona', $_SESSION['mail_login'] . '.txt');
|
2014-07-23 15:52:50 +02:00
|
|
|
@unlink($personaFile);
|
|
|
|
file_put_contents($personaFile, $_SESSION['default_user']);
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
header('Location: index.php?step=3');
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
function saveStep3() {
|
|
|
|
if (!empty($_POST)) {
|
2014-07-23 15:52:50 +02:00
|
|
|
if ($_SESSION['bd_type'] === 'sqlite') {
|
|
|
|
$_SESSION['bd_base'] = $_SESSION['default_user'];
|
|
|
|
$_SESSION['bd_host'] = '';
|
|
|
|
$_SESSION['bd_user'] = '';
|
|
|
|
$_SESSION['bd_password'] = '';
|
|
|
|
$_SESSION['bd_prefix'] = '';
|
|
|
|
$_SESSION['bd_prefix_user'] = ''; //No prefix for SQLite
|
|
|
|
} else {
|
2014-09-27 10:10:43 +02:00
|
|
|
if (empty($_POST['type']) ||
|
|
|
|
empty($_POST['host']) ||
|
|
|
|
empty($_POST['user']) ||
|
|
|
|
empty($_POST['base'])) {
|
2014-07-23 15:52:50 +02:00
|
|
|
$_SESSION['bd_error'] = 'Missing parameters!';
|
|
|
|
}
|
|
|
|
$_SESSION['bd_base'] = substr($_POST['base'], 0, 64);
|
|
|
|
$_SESSION['bd_host'] = $_POST['host'];
|
|
|
|
$_SESSION['bd_user'] = $_POST['user'];
|
|
|
|
$_SESSION['bd_password'] = $_POST['pass'];
|
|
|
|
$_SESSION['bd_prefix'] = substr($_POST['prefix'], 0, 16);
|
2015-11-06 16:54:20 +01:00
|
|
|
$_SESSION['bd_prefix_user'] = $_SESSION['bd_prefix'] . (empty($_SESSION['default_user']) ? '' : ($_SESSION['default_user'] . '_'));
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
|
|
|
|
2015-11-06 16:54:20 +01:00
|
|
|
// We use dirname to remove the /i part
|
|
|
|
$base_url = dirname(Minz_Request::guessBaseUrl());
|
2015-02-08 18:55:48 +01:00
|
|
|
$config_array = array(
|
|
|
|
'salt' => $_SESSION['salt'],
|
2015-11-06 16:54:20 +01:00
|
|
|
'base_url' => $base_url,
|
2015-02-08 18:55:48 +01:00
|
|
|
'title' => $_SESSION['title'],
|
|
|
|
'default_user' => $_SESSION['default_user'],
|
|
|
|
'auth_type' => $_SESSION['auth_type'],
|
2014-07-23 15:52:50 +02:00
|
|
|
'db' => array(
|
|
|
|
'type' => $_SESSION['bd_type'],
|
|
|
|
'host' => $_SESSION['bd_host'],
|
|
|
|
'user' => $_SESSION['bd_user'],
|
|
|
|
'password' => $_SESSION['bd_password'],
|
|
|
|
'base' => $_SESSION['bd_base'],
|
|
|
|
'prefix' => $_SESSION['bd_prefix'],
|
2015-11-06 16:54:20 +01:00
|
|
|
'pdo_options' => array(),
|
2014-07-23 15:52:50 +02:00
|
|
|
),
|
2015-11-06 16:54:20 +01:00
|
|
|
'pubsubhubbub_enabled' => server_is_public($base_url),
|
2014-07-23 15:52:50 +02:00
|
|
|
);
|
|
|
|
|
2015-02-08 18:55:48 +01:00
|
|
|
@unlink(join_path(DATA_PATH, 'config.php')); //To avoid access-rights problems
|
|
|
|
file_put_contents(join_path(DATA_PATH, 'config.php'), "<?php\n return " . var_export($config_array, true) . ';');
|
2014-07-23 15:52:50 +02:00
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
$res = checkBD();
|
2014-07-23 15:52:50 +02:00
|
|
|
|
|
|
|
if ($res) {
|
|
|
|
$_SESSION['bd_error'] = '';
|
2014-09-27 10:10:43 +02:00
|
|
|
header('Location: index.php?step=4');
|
2014-07-23 15:52:50 +02:00
|
|
|
} elseif (empty($_SESSION['bd_error'])) {
|
|
|
|
$_SESSION['bd_error'] = 'Unknown error!';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
invalidateHttpCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
function newPdo() {
|
|
|
|
switch ($_SESSION['bd_type']) {
|
2014-09-27 10:10:43 +02:00
|
|
|
case 'mysql':
|
|
|
|
$str = 'mysql:host=' . $_SESSION['bd_host'] . ';dbname=' . $_SESSION['bd_base'];
|
|
|
|
$driver_options = array(
|
|
|
|
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case 'sqlite':
|
2015-02-08 18:55:48 +01:00
|
|
|
$str = 'sqlite:' . join_path(USERS_PATH, $_SESSION['default_user'], 'db.sqlite');
|
2014-09-27 10:10:43 +02:00
|
|
|
$driver_options = array(
|
|
|
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
|
|
|
return new PDO($str, $_SESSION['bd_user'], $_SESSION['bd_password'], $driver_options);
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
function deleteInstall() {
|
2015-02-08 18:55:48 +01:00
|
|
|
$res = unlink(join_path(DATA_PATH, 'do-install.txt'));
|
2014-07-23 15:52:50 +02:00
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
if (!$res) {
|
2014-07-23 15:52:50 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
header('Location: index.php');
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*** VÉRIFICATIONS ***/
|
2014-09-27 10:10:43 +02:00
|
|
|
function checkStep() {
|
|
|
|
$s0 = checkStep0();
|
|
|
|
$s1 = checkStep1();
|
|
|
|
$s2 = checkStep2();
|
|
|
|
$s3 = checkStep3();
|
2014-07-23 15:52:50 +02:00
|
|
|
if (STEP > 0 && $s0['all'] != 'ok') {
|
2014-09-27 10:10:43 +02:00
|
|
|
header('Location: index.php?step=0');
|
2014-07-23 15:52:50 +02:00
|
|
|
} elseif (STEP > 1 && $s1['all'] != 'ok') {
|
2014-09-27 10:10:43 +02:00
|
|
|
header('Location: index.php?step=1');
|
2014-07-23 15:52:50 +02:00
|
|
|
} elseif (STEP > 2 && $s2['all'] != 'ok') {
|
2014-09-27 10:10:43 +02:00
|
|
|
header('Location: index.php?step=2');
|
2014-07-23 15:52:50 +02:00
|
|
|
} elseif (STEP > 3 && $s3['all'] != 'ok') {
|
2014-09-27 10:10:43 +02:00
|
|
|
header('Location: index.php?step=3');
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
|
|
|
$_SESSION['actualize_feeds'] = true;
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
function checkStep0() {
|
2015-02-08 18:55:48 +01:00
|
|
|
$languages = Minz_Translate::availableLanguages();
|
2014-09-27 10:10:43 +02:00
|
|
|
$language = isset($_SESSION['language']) &&
|
2015-02-08 18:55:48 +01:00
|
|
|
in_array($_SESSION['language'], $languages);
|
2014-07-23 15:52:50 +02:00
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
return array(
|
2014-07-23 15:52:50 +02:00
|
|
|
'language' => $language ? 'ok' : 'ko',
|
|
|
|
'all' => $language ? 'ok' : 'ko'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
function checkStep1() {
|
2016-07-24 11:59:17 +02:00
|
|
|
$php = version_compare(PHP_VERSION, '5.3.0') >= 0;
|
2015-02-08 18:55:48 +01:00
|
|
|
$minz = file_exists(join_path(LIB_PATH, 'Minz'));
|
2014-09-27 10:10:43 +02:00
|
|
|
$curl = extension_loaded('curl');
|
|
|
|
$pdo_mysql = extension_loaded('pdo_mysql');
|
|
|
|
$pdo_sqlite = extension_loaded('pdo_sqlite');
|
2014-09-21 12:12:35 +02:00
|
|
|
$pdo = $pdo_mysql || $pdo_sqlite;
|
2014-09-27 10:10:43 +02:00
|
|
|
$pcre = extension_loaded('pcre');
|
|
|
|
$ctype = extension_loaded('ctype');
|
2014-07-23 15:52:50 +02:00
|
|
|
$dom = class_exists('DOMDocument');
|
2016-07-24 11:59:17 +02:00
|
|
|
$xml = function_exists('xml_parser_create');
|
|
|
|
$json = function_exists('json_encode');
|
2014-09-27 10:10:43 +02:00
|
|
|
$data = DATA_PATH && is_writable(DATA_PATH);
|
|
|
|
$cache = CACHE_PATH && is_writable(CACHE_PATH);
|
2015-02-08 18:55:48 +01:00
|
|
|
$users = USERS_PATH && is_writable(USERS_PATH);
|
|
|
|
$favicons = is_writable(join_path(DATA_PATH, 'favicons'));
|
|
|
|
$persona = is_writable(join_path(DATA_PATH, 'persona'));
|
2014-09-27 10:10:43 +02:00
|
|
|
$http_referer = is_referer_from_same_domain();
|
|
|
|
|
|
|
|
return array(
|
2014-07-23 15:52:50 +02:00
|
|
|
'php' => $php ? 'ok' : 'ko',
|
|
|
|
'minz' => $minz ? 'ok' : 'ko',
|
|
|
|
'curl' => $curl ? 'ok' : 'ko',
|
2014-09-21 12:12:35 +02:00
|
|
|
'pdo-mysql' => $pdo_mysql ? 'ok' : 'ko',
|
|
|
|
'pdo-sqlite' => $pdo_sqlite ? 'ok' : 'ko',
|
|
|
|
'pdo' => $pdo ? 'ok' : 'ko',
|
2014-07-23 15:52:50 +02:00
|
|
|
'pcre' => $pcre ? 'ok' : 'ko',
|
|
|
|
'ctype' => $ctype ? 'ok' : 'ko',
|
|
|
|
'dom' => $dom ? 'ok' : 'ko',
|
2016-07-24 11:59:17 +02:00
|
|
|
'xml' => $xml ? 'ok' : 'ko',
|
|
|
|
'json' => $json ? 'ok' : 'ko',
|
2014-07-23 15:52:50 +02:00
|
|
|
'data' => $data ? 'ok' : 'ko',
|
|
|
|
'cache' => $cache ? 'ok' : 'ko',
|
2015-02-08 18:55:48 +01:00
|
|
|
'users' => $users ? 'ok' : 'ko',
|
2014-07-23 15:52:50 +02:00
|
|
|
'favicons' => $favicons ? 'ok' : 'ko',
|
|
|
|
'persona' => $persona ? 'ok' : 'ko',
|
2014-09-27 10:10:43 +02:00
|
|
|
'http_referer' => $http_referer ? 'ok' : 'ko',
|
2016-07-24 11:59:17 +02:00
|
|
|
'all' => $php && $minz && $curl && $pdo && $pcre && $ctype && $dom && $xml &&
|
2015-02-08 18:55:48 +01:00
|
|
|
$data && $cache && $users && $favicons && $persona && $http_referer ?
|
2014-09-27 10:10:43 +02:00
|
|
|
'ok' : 'ko'
|
2014-07-23 15:52:50 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-11-06 16:54:20 +01:00
|
|
|
function freshrss_already_installed() {
|
|
|
|
$conf_path = join_path(DATA_PATH, 'config.php');
|
|
|
|
if (!file_exists($conf_path)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// A configuration file already exists, we try to load it.
|
|
|
|
$system_conf = null;
|
|
|
|
try {
|
|
|
|
Minz_Configuration::register('system', $conf_path);
|
|
|
|
$system_conf = Minz_Configuration::get('system');
|
|
|
|
} catch (Minz_FileNotExistException $e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ok, the global conf exists... but what about default user conf?
|
|
|
|
$current_user = $system_conf->default_user;
|
|
|
|
try {
|
|
|
|
Minz_Configuration::register('user', join_path(USERS_PATH, $current_user, 'config.php'));
|
|
|
|
} catch (Minz_FileNotExistException $e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ok, ok, default user exists too!
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
function checkStep2() {
|
2015-11-06 16:54:20 +01:00
|
|
|
$conf = !empty($_SESSION['old_entries']) &&
|
2014-07-23 15:52:50 +02:00
|
|
|
isset($_SESSION['mail_login']) &&
|
|
|
|
!empty($_SESSION['default_user']);
|
2014-09-27 10:10:43 +02:00
|
|
|
|
|
|
|
$form = (
|
|
|
|
isset($_SESSION['auth_type']) &&
|
|
|
|
($_SESSION['auth_type'] != 'form' || !empty($_SESSION['passwordHash']))
|
|
|
|
);
|
|
|
|
|
|
|
|
$persona = (
|
|
|
|
isset($_SESSION['auth_type']) &&
|
|
|
|
($_SESSION['auth_type'] != 'persona' || !empty($_SESSION['mail_login']))
|
|
|
|
);
|
|
|
|
|
2014-07-23 15:52:50 +02:00
|
|
|
$defaultUser = empty($_POST['default_user']) ? null : $_POST['default_user'];
|
|
|
|
if ($defaultUser === null) {
|
|
|
|
$defaultUser = empty($_SESSION['default_user']) ? '' : $_SESSION['default_user'];
|
|
|
|
}
|
2015-02-08 18:55:48 +01:00
|
|
|
$data = is_writable(join_path(USERS_PATH, $defaultUser, 'config.php'));
|
2014-07-23 15:52:50 +02:00
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
return array(
|
2014-07-23 15:52:50 +02:00
|
|
|
'conf' => $conf ? 'ok' : 'ko',
|
2014-09-27 10:10:43 +02:00
|
|
|
'form' => $form ? 'ok' : 'ko',
|
|
|
|
'persona' => $persona ? 'ok' : 'ko',
|
2014-07-23 15:52:50 +02:00
|
|
|
'data' => $data ? 'ok' : 'ko',
|
2014-09-27 10:10:43 +02:00
|
|
|
'all' => $conf && $form && $persona && $data ? 'ok' : 'ko'
|
2014-07-23 15:52:50 +02:00
|
|
|
);
|
|
|
|
}
|
2014-09-27 10:10:43 +02:00
|
|
|
|
|
|
|
function checkStep3() {
|
2015-02-08 18:55:48 +01:00
|
|
|
$conf = is_writable(join_path(DATA_PATH, 'config.php'));
|
2014-07-23 15:52:50 +02:00
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
$bd = isset($_SESSION['bd_type']) &&
|
|
|
|
isset($_SESSION['bd_host']) &&
|
|
|
|
isset($_SESSION['bd_user']) &&
|
|
|
|
isset($_SESSION['bd_password']) &&
|
|
|
|
isset($_SESSION['bd_base']) &&
|
|
|
|
isset($_SESSION['bd_prefix']) &&
|
|
|
|
isset($_SESSION['bd_error']);
|
2014-07-23 15:52:50 +02:00
|
|
|
$conn = empty($_SESSION['bd_error']);
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
return array(
|
2014-07-23 15:52:50 +02:00
|
|
|
'bd' => $bd ? 'ok' : 'ko',
|
|
|
|
'conn' => $conn ? 'ok' : 'ko',
|
|
|
|
'conf' => $conf ? 'ok' : 'ko',
|
|
|
|
'all' => $bd && $conn && $conf ? 'ok' : 'ko'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
function checkBD() {
|
2014-07-23 15:52:50 +02:00
|
|
|
$ok = false;
|
|
|
|
|
|
|
|
try {
|
|
|
|
$str = '';
|
|
|
|
$driver_options = null;
|
|
|
|
switch ($_SESSION['bd_type']) {
|
2014-09-27 10:10:43 +02:00
|
|
|
case 'mysql':
|
|
|
|
$driver_options = array(
|
|
|
|
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
|
|
|
|
);
|
2014-07-23 15:52:50 +02:00
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
try { // on ouvre une connexion juste pour créer la base si elle n'existe pas
|
|
|
|
$str = 'mysql:host=' . $_SESSION['bd_host'] . ';';
|
|
|
|
$c = new PDO($str, $_SESSION['bd_user'], $_SESSION['bd_password'], $driver_options);
|
|
|
|
$sql = sprintf(SQL_CREATE_DB, $_SESSION['bd_base']);
|
|
|
|
$res = $c->query($sql);
|
|
|
|
} catch (PDOException $e) {
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
2014-09-27 10:10:43 +02:00
|
|
|
|
|
|
|
// on écrase la précédente connexion en sélectionnant la nouvelle BDD
|
|
|
|
$str = 'mysql:host=' . $_SESSION['bd_host'] . ';dbname=' . $_SESSION['bd_base'];
|
|
|
|
break;
|
|
|
|
case 'sqlite':
|
2015-02-08 18:55:48 +01:00
|
|
|
$str = 'sqlite:' . join_path(USERS_PATH, $_SESSION['default_user'], 'db.sqlite');
|
2014-09-27 10:10:43 +02:00
|
|
|
$driver_options = array(
|
|
|
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
$c = new PDO($str, $_SESSION['bd_user'], $_SESSION['bd_password'], $driver_options);
|
|
|
|
|
2014-07-23 15:52:50 +02:00
|
|
|
if (defined('SQL_CREATE_TABLES')) {
|
2015-02-08 18:55:48 +01:00
|
|
|
$sql = sprintf(SQL_CREATE_TABLES, $_SESSION['bd_prefix_user'], _t('gen.short.default_category'));
|
2014-07-23 15:52:50 +02:00
|
|
|
$stm = $c->prepare($sql);
|
|
|
|
$ok = $stm->execute();
|
|
|
|
} else {
|
|
|
|
global $SQL_CREATE_TABLES;
|
|
|
|
if (is_array($SQL_CREATE_TABLES)) {
|
|
|
|
$ok = true;
|
|
|
|
foreach ($SQL_CREATE_TABLES as $instruction) {
|
2015-02-08 18:55:48 +01:00
|
|
|
$sql = sprintf($instruction, $_SESSION['bd_prefix_user'], _t('gen.short.default_category'));
|
2014-07-23 15:52:50 +02:00
|
|
|
$stm = $c->prepare($sql);
|
|
|
|
$ok &= $stm->execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
$ok = false;
|
|
|
|
$_SESSION['bd_error'] = $e->getMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$ok) {
|
2015-02-08 18:55:48 +01:00
|
|
|
@unlink(join_path(DATA_PATH, 'config.php'));
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** AFFICHAGE ***/
|
2014-09-27 10:10:43 +02:00
|
|
|
function printStep0() {
|
2015-02-08 18:55:48 +01:00
|
|
|
$actual = Minz_Translate::language();
|
|
|
|
$languages = Minz_Translate::availableLanguages();
|
2014-07-23 15:52:50 +02:00
|
|
|
?>
|
2014-09-27 10:10:43 +02:00
|
|
|
<?php $s0 = checkStep0(); if ($s0['all'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.language.defined'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<form action="index.php?step=0" method="post">
|
2015-02-08 18:55:48 +01:00
|
|
|
<legend><?php echo _t('install.language.choose'); ?></legend>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="form-group">
|
2015-02-08 18:55:48 +01:00
|
|
|
<label class="group-name" for="language"><?php echo _t('install.language'); ?></label>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="group-controls">
|
2015-11-06 16:54:20 +01:00
|
|
|
<select name="language" id="language" tabindex="1" >
|
2015-02-08 18:55:48 +01:00
|
|
|
<?php foreach ($languages as $lang) { ?>
|
|
|
|
<option value="<?php echo $lang; ?>"<?php echo $actual == $lang ? ' selected="selected"' : ''; ?>>
|
|
|
|
<?php echo _t('gen.lang.' . $lang); ?>
|
|
|
|
</option>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group form-actions">
|
|
|
|
<div class="group-controls">
|
2015-11-06 16:54:20 +01:00
|
|
|
<button type="submit" class="btn btn-important" tabindex="2" ><?php echo _t('gen.action.submit'); ?></button>
|
|
|
|
<button type="reset" class="btn" tabindex="3" ><?php echo _t('gen.action.cancel'); ?></button>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php if ($s0['all'] == 'ok') { ?>
|
2015-11-06 16:54:20 +01:00
|
|
|
<a class="btn btn-important next-step" href="?step=1" tabindex="4" ><?php echo _t('install.action.next_step'); ?></a>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2015-02-08 18:55:48 +01:00
|
|
|
// @todo refactor this view with the check_install action
|
2014-09-27 10:10:43 +02:00
|
|
|
function printStep1() {
|
|
|
|
$res = checkStep1();
|
2014-07-23 15:52:50 +02:00
|
|
|
?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<noscript><p class="alert alert-warn"><span class="alert-head"><?php echo _t('gen.short.attention'); ?></span> <?php echo _t('install.javascript_is_better'); ?></p></noscript>
|
2014-07-23 15:52:50 +02:00
|
|
|
|
|
|
|
<?php if ($res['php'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.php.ok', PHP_VERSION); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } else { ?>
|
2016-07-24 11:59:17 +02:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.php.nok', PHP_VERSION, '5.3.0'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php if ($res['minz'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.minz.ok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } else { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.minz.nok', join_path(LIB_PATH, 'Minz')); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
2014-09-21 12:12:35 +02:00
|
|
|
<?php if ($res['pdo'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.pdo.ok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } else { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.pdo.nok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php if ($res['curl'] == 'ok') { ?>
|
|
|
|
<?php $version = curl_version(); ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.curl.ok', $version['version']); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } else { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.curl.nok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
2016-07-24 11:59:17 +02:00
|
|
|
<?php if ($res['json'] == 'ok') { ?>
|
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.json.ok'); ?></p>
|
|
|
|
<?php } else { ?>
|
|
|
|
<p class="alert alert-warn"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.json.nok'); ?></p>
|
|
|
|
<?php } ?>
|
|
|
|
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php if ($res['pcre'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.pcre.ok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } else { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.pcre.nok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php if ($res['ctype'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.ctype.ok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } else { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.ctype.nok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php if ($res['dom'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.dom.ok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } else { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.dom.nok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
2016-07-24 11:59:17 +02:00
|
|
|
<?php if ($res['xml'] == 'ok') { ?>
|
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.xml.ok'); ?></p>
|
|
|
|
<?php } else { ?>
|
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.xml.nok'); ?></p>
|
|
|
|
<?php } ?>
|
|
|
|
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php if ($res['data'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.data.ok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } else { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.data.nok', DATA_PATH); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php if ($res['cache'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.cache.ok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } else { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.cache.nok', CACHE_PATH); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
2015-02-08 18:55:48 +01:00
|
|
|
<?php if ($res['users'] == 'ok') { ?>
|
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.users.ok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } else { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.users.nok', USERS_PATH); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php if ($res['favicons'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.favicons.ok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } else { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.favicons.nok', DATA_PATH . '/favicons'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php if ($res['persona'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.persona.ok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } else { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.persona.nok', DATA_PATH . '/persona'); ?></p>
|
2014-09-27 10:10:43 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php if ($res['http_referer'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.http_referer.ok'); ?></p>
|
2014-09-27 10:10:43 +02:00
|
|
|
<?php } else { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.http_referer.nok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
2015-11-06 16:54:20 +01:00
|
|
|
<?php if (freshrss_already_installed() && $res['all'] == 'ok') { ?>
|
|
|
|
<p class="alert alert-warn"><span class="alert-head"><?php echo _t('gen.short.attention'); ?></span> <?php echo _t('install.check.already_installed'); ?></p>
|
|
|
|
|
|
|
|
<form action="index.php?step=1" method="post">
|
|
|
|
<input type="hidden" name="freshrss-keep-install" value="1" />
|
|
|
|
<button type="submit" class="btn btn-important next-step" tabindex="1" ><?php echo _t('install.action.keep_install'); ?></button>
|
|
|
|
<a class="btn btn-attention next-step confirm" data-str-confirm="<?php echo _t('install.js.confirm_reinstall'); ?>" href="?step=2" tabindex="2" ><?php echo _t('install.action.reinstall'); ?></a>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<?php } elseif ($res['all'] == 'ok') { ?>
|
|
|
|
<a class="btn btn-important next-step" href="?step=2" tabindex="1" ><?php echo _t('install.action.next_step'); ?></a>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } else { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><?php echo _t('install.action.fix_errors_before'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
function printStep2() {
|
2015-11-06 16:54:20 +01:00
|
|
|
$user_default_config = Minz_Configuration::get('default_user');
|
2014-07-23 15:52:50 +02:00
|
|
|
?>
|
2014-09-27 10:10:43 +02:00
|
|
|
<?php $s2 = checkStep2(); if ($s2['all'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.conf.ok'); ?></p>
|
2014-09-27 10:10:43 +02:00
|
|
|
<?php } elseif (!empty($_POST)) { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><?php echo _t('install.fix_errors_before'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<form action="index.php?step=2" method="post">
|
2015-02-08 18:55:48 +01:00
|
|
|
<legend><?php echo _t('install.conf'); ?></legend>
|
2014-07-23 15:52:50 +02:00
|
|
|
|
|
|
|
<div class="form-group">
|
2015-02-08 18:55:48 +01:00
|
|
|
<label class="group-name" for="old_entries"><?php echo _t('install.delete_articles_after'); ?></label>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="group-controls">
|
2015-11-06 16:54:20 +01:00
|
|
|
<input type="number" id="old_entries" name="old_entries" required="required" min="1" max="1200" value="<?php echo isset($_SESSION['old_entries']) ? $_SESSION['old_entries'] : $user_default_config->old_entries; ?>" tabindex="2" /> <?php echo _t('gen.date.month'); ?>
|
2014-07-23 15:52:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2015-02-08 18:55:48 +01:00
|
|
|
<label class="group-name" for="default_user"><?php echo _t('install.default_user'); ?></label>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="group-controls">
|
2015-11-06 16:54:20 +01:00
|
|
|
<input type="text" id="default_user" name="default_user" required="required" size="16" maxlength="16" pattern="[0-9a-zA-Z]{1,16}" value="<?php echo isset($_SESSION['default_user']) ? $_SESSION['default_user'] : ''; ?>" placeholder="<?php echo httpAuthUser() == '' ? 'alice' : httpAuthUser(); ?>" tabindex="3" />
|
2014-07-23 15:52:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2015-02-08 18:55:48 +01:00
|
|
|
<label class="group-name" for="auth_type"><?php echo _t('install.auth.type'); ?></label>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="group-controls">
|
2016-07-24 11:59:17 +02:00
|
|
|
<select id="auth_type" name="auth_type" required="required" tabindex="4">
|
2014-09-27 10:10:43 +02:00
|
|
|
<?php
|
|
|
|
function no_auth($auth_type) {
|
|
|
|
return !in_array($auth_type, array('form', 'persona', 'http_auth', 'none'));
|
|
|
|
}
|
|
|
|
$auth_type = isset($_SESSION['auth_type']) ? $_SESSION['auth_type'] : '';
|
|
|
|
?>
|
2016-07-24 11:59:17 +02:00
|
|
|
<option value="form"<?php echo $auth_type === 'form' || (no_auth($auth_type) && cryptAvailable()) ? ' selected="selected"' : '', cryptAvailable() ? '' : ' disabled="disabled"'; ?>><?php echo _t('install.auth.form'); ?></option>
|
2015-02-08 18:55:48 +01:00
|
|
|
<option value="persona"<?php echo $auth_type === 'persona' ? ' selected="selected"' : ''; ?>><?php echo _t('install.auth.persona'); ?></option>
|
|
|
|
<option value="http_auth"<?php echo $auth_type === 'http_auth' ? ' selected="selected"' : '', httpAuthUser() == '' ? ' disabled="disabled"' : ''; ?>><?php echo _t('install.auth.http'); ?>(REMOTE_USER = '<?php echo httpAuthUser(); ?>')</option>
|
2016-07-24 11:59:17 +02:00
|
|
|
<option value="none"<?php echo $auth_type === 'none' || (no_auth($auth_type) && !cryptAvailable()) ? ' selected="selected"' : ''; ?>><?php echo _t('install.auth.none'); ?></option>
|
2014-07-23 15:52:50 +02:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2015-02-08 18:55:48 +01:00
|
|
|
<label class="group-name" for="passwordPlain"><?php echo _t('install.auth.password_form'); ?></label>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="group-controls">
|
2014-09-27 10:10:43 +02:00
|
|
|
<div class="stick">
|
2015-11-06 16:54:20 +01:00
|
|
|
<input type="password" id="passwordPlain" name="passwordPlain" pattern=".{7,}" autocomplete="off" <?php echo $auth_type === 'form' ? ' required="required"' : ''; ?> tabindex="5" />
|
2014-09-27 10:10:43 +02:00
|
|
|
<a class="btn toggle-password" data-toggle="passwordPlain"><?php echo FreshRSS_Themes::icon('key'); ?></a>
|
|
|
|
</div>
|
2015-02-08 18:55:48 +01:00
|
|
|
<?php echo _i('help'); ?> <?php echo _t('install.auth.password_format'); ?>
|
|
|
|
<noscript><b><?php echo _t('gen.js.should_be_activated'); ?></b></noscript>
|
2014-07-23 15:52:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2015-02-08 18:55:48 +01:00
|
|
|
<label class="group-name" for="mail_login"><?php echo _t('install.auth.email_persona'); ?></label>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="group-controls">
|
2015-11-06 16:54:20 +01:00
|
|
|
<input type="email" id="mail_login" name="mail_login" value="<?php echo isset($_SESSION['mail_login']) ? $_SESSION['mail_login'] : ''; ?>" placeholder="alice@example.net" <?php echo $auth_type === 'persona' ? ' required="required"' : ''; ?> tabindex="6"/>
|
2015-02-08 18:55:48 +01:00
|
|
|
<noscript><b><?php echo _t('gen.js.should_be_activated'); ?></b></noscript>
|
2014-07-23 15:52:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group form-actions">
|
|
|
|
<div class="group-controls">
|
2015-11-06 16:54:20 +01:00
|
|
|
<button type="submit" class="btn btn-important" tabindex="7" ><?php echo _t('gen.action.submit'); ?></button>
|
|
|
|
<button type="reset" class="btn" tabindex="8" ><?php echo _t('gen.action.cancel'); ?></button>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php if ($s2['all'] == 'ok') { ?>
|
2015-11-06 16:54:20 +01:00
|
|
|
<a class="btn btn-important next-step" href="?step=3" tabindex="9" ><?php echo _t('install.action.next_step'); ?></a>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
function printStep3() {
|
2015-11-06 16:54:20 +01:00
|
|
|
$system_default_config = Minz_Configuration::get('default_system');
|
2014-07-23 15:52:50 +02:00
|
|
|
?>
|
2014-09-27 10:10:43 +02:00
|
|
|
<?php $s3 = checkStep3(); if ($s3['all'] == 'ok') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.bdd.conf.ok'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } elseif ($s3['conn'] == 'ko') { ?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.bdd.conf.ko'),(empty($_SESSION['bd_error']) ? '' : ' : ' . $_SESSION['bd_error']); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<form action="index.php?step=3" method="post">
|
2015-02-08 18:55:48 +01:00
|
|
|
<legend><?php echo _t('install.bdd.conf'); ?></legend>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="form-group">
|
2015-02-08 18:55:48 +01:00
|
|
|
<label class="group-name" for="type"><?php echo _t('install.bdd.type'); ?></label>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="group-controls">
|
2016-07-24 11:59:17 +02:00
|
|
|
<select name="type" id="type" tabindex="1">
|
2014-09-21 12:12:35 +02:00
|
|
|
<?php if (extension_loaded('pdo_mysql')) {?>
|
2014-07-23 15:52:50 +02:00
|
|
|
<option value="mysql"
|
2014-09-27 10:10:43 +02:00
|
|
|
<?php echo(isset($_SESSION['bd_type']) && $_SESSION['bd_type'] === 'mysql') ? 'selected="selected"' : ''; ?>>
|
2014-07-23 15:52:50 +02:00
|
|
|
MySQL
|
|
|
|
</option>
|
2014-09-21 12:12:35 +02:00
|
|
|
<?php }?>
|
|
|
|
<?php if (extension_loaded('pdo_sqlite')) {?>
|
2014-07-23 15:52:50 +02:00
|
|
|
<option value="sqlite"
|
2014-09-27 10:10:43 +02:00
|
|
|
<?php echo(isset($_SESSION['bd_type']) && $_SESSION['bd_type'] === 'sqlite') ? 'selected="selected"' : ''; ?>>
|
2014-07-23 15:52:50 +02:00
|
|
|
SQLite
|
|
|
|
</option>
|
2014-09-21 12:12:35 +02:00
|
|
|
<?php }?>
|
2014-07-23 15:52:50 +02:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="mysql">
|
|
|
|
<div class="form-group">
|
2015-02-08 18:55:48 +01:00
|
|
|
<label class="group-name" for="host"><?php echo _t('install.bdd.host'); ?></label>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="group-controls">
|
2015-11-06 16:54:20 +01:00
|
|
|
<input type="text" id="host" name="host" pattern="[0-9A-Za-z_.-]{1,64}" value="<?php echo isset($_SESSION['bd_host']) ? $_SESSION['bd_host'] : $system_default_config->db['host']; ?>" tabindex="2" />
|
2014-07-23 15:52:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2015-02-08 18:55:48 +01:00
|
|
|
<label class="group-name" for="user"><?php echo _t('install.bdd.username'); ?></label>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="group-controls">
|
2015-11-06 16:54:20 +01:00
|
|
|
<input type="text" id="user" name="user" maxlength="16" pattern="[0-9A-Za-z_.-]{1,16}" value="<?php echo isset($_SESSION['bd_user']) ? $_SESSION['bd_user'] : ''; ?>" tabindex="3" />
|
2014-07-23 15:52:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2015-02-08 18:55:48 +01:00
|
|
|
<label class="group-name" for="pass"><?php echo _t('install.bdd.password'); ?></label>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="group-controls">
|
2015-11-06 16:54:20 +01:00
|
|
|
<input type="password" id="pass" name="pass" value="<?php echo isset($_SESSION['bd_password']) ? $_SESSION['bd_password'] : ''; ?>" tabindex="4" />
|
2014-07-23 15:52:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2015-02-08 18:55:48 +01:00
|
|
|
<label class="group-name" for="base"><?php echo _t('install.bdd'); ?></label>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="group-controls">
|
2015-11-06 16:54:20 +01:00
|
|
|
<input type="text" id="base" name="base" maxlength="64" pattern="[0-9A-Za-z_]{1,64}" value="<?php echo isset($_SESSION['bd_base']) ? $_SESSION['bd_base'] : ''; ?>" tabindex="5" />
|
2014-07-23 15:52:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2015-02-08 18:55:48 +01:00
|
|
|
<label class="group-name" for="prefix"><?php echo _t('install.bdd.prefix'); ?></label>
|
2014-07-23 15:52:50 +02:00
|
|
|
<div class="group-controls">
|
2015-11-06 16:54:20 +01:00
|
|
|
<input type="text" id="prefix" name="prefix" maxlength="16" pattern="[0-9A-Za-z_]{1,16}" value="<?php echo isset($_SESSION['bd_prefix']) ? $_SESSION['bd_prefix'] : $system_default_config->db['prefix']; ?>" tabindex="6" />
|
2014-07-23 15:52:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group form-actions">
|
|
|
|
<div class="group-controls">
|
2015-11-06 16:54:20 +01:00
|
|
|
<button type="submit" class="btn btn-important" tabindex="7" ><?php echo _t('gen.action.submit'); ?></button>
|
|
|
|
<button type="reset" class="btn" tabindex="8" ><?php echo _t('gen.action.cancel'); ?></button>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php if ($s3['all'] == 'ok') { ?>
|
2015-11-06 16:54:20 +01:00
|
|
|
<a class="btn btn-important next-step" href="?step=4" tabindex="9" ><?php echo _t('install.action.next_step'); ?></a>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php } ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
function printStep4() {
|
2014-07-23 15:52:50 +02:00
|
|
|
?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-success"><span class="alert-head"><?php echo _t('install.congratulations'); ?></span> <?php echo _t('install.ok'); ?></p>
|
2015-11-06 16:54:20 +01:00
|
|
|
<a class="btn btn-important next-step" href="?step=5" tabindex="1"><?php echo _t('install.action.finish'); ?></a>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
function printStep5() {
|
2014-07-23 15:52:50 +02:00
|
|
|
?>
|
2015-02-08 18:55:48 +01:00
|
|
|
<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.not_deleted', DATA_PATH . '/do-install.txt'); ?></p>
|
2014-07-23 15:52:50 +02:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2014-09-27 10:10:43 +02:00
|
|
|
initTranslate();
|
2014-07-23 15:52:50 +02:00
|
|
|
|
2015-02-08 18:55:48 +01:00
|
|
|
checkStep();
|
|
|
|
|
2014-07-23 15:52:50 +02:00
|
|
|
switch (STEP) {
|
|
|
|
case 0:
|
|
|
|
default:
|
2014-09-27 10:10:43 +02:00
|
|
|
saveLanguage();
|
2014-07-23 15:52:50 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2015-11-06 16:54:20 +01:00
|
|
|
saveStep1();
|
2014-07-23 15:52:50 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2014-09-27 10:10:43 +02:00
|
|
|
saveStep2();
|
2014-07-23 15:52:50 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2014-09-27 10:10:43 +02:00
|
|
|
saveStep3();
|
2014-07-23 15:52:50 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
case 5:
|
2014-09-27 10:10:43 +02:00
|
|
|
deleteInstall();
|
2014-07-23 15:52:50 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
2016-07-24 11:59:17 +02:00
|
|
|
<html>
|
2014-07-23 15:52:50 +02:00
|
|
|
<head>
|
2016-07-24 11:59:17 +02:00
|
|
|
<meta charset="UTF-8" />
|
|
|
|
<meta name="viewport" content="initial-scale=1.0" />
|
2015-02-08 18:55:48 +01:00
|
|
|
<title><?php echo _t('install.title'); ?></title>
|
2016-07-24 11:59:17 +02:00
|
|
|
<link rel="stylesheet" href="../themes/base-theme/template.css?<?php echo @filemtime(PUBLIC_PATH . '/themes/base-theme/template.css'); ?>" />
|
|
|
|
<link rel="stylesheet" href="../themes/Origine/origine.css?<?php echo @filemtime(PUBLIC_PATH . '/themes/Origine/origine.css'); ?>" />
|
|
|
|
<meta name="robots" content="noindex,nofollow" />
|
2014-07-23 15:52:50 +02:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div class="header">
|
|
|
|
<div class="item title">
|
2015-02-08 18:55:48 +01:00
|
|
|
<h1><a href="index.php"><?php echo _t('install.title'); ?></a></h1>
|
|
|
|
<h2><?php echo _t('install.step', STEP); ?></h2>
|
2014-07-23 15:52:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="global">
|
|
|
|
<ul class="nav nav-list aside">
|
2015-02-08 18:55:48 +01:00
|
|
|
<li class="nav-header"><?php echo _t('install.steps'); ?></li>
|
|
|
|
<li class="item<?php echo STEP == 0 ? ' active' : ''; ?>"><a href="?step=0"><?php echo _t('install.language'); ?></a></li>
|
|
|
|
<li class="item<?php echo STEP == 1 ? ' active' : ''; ?>"><a href="?step=1"><?php echo _t('install.check'); ?></a></li>
|
|
|
|
<li class="item<?php echo STEP == 2 ? ' active' : ''; ?>"><a href="?step=2"><?php echo _t('install.conf'); ?></a></li>
|
|
|
|
<li class="item<?php echo STEP == 3 ? ' active' : ''; ?>"><a href="?step=3"><?php echo _t('install.bdd.conf'); ?></a></li>
|
2015-11-06 16:54:20 +01:00
|
|
|
<li class="item<?php echo STEP == 4 ? ' active' : ''; ?>"><a href="?step=4"><?php echo _t('install.this_is_the_end'); ?></a></li>
|
2014-07-23 15:52:50 +02:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<div class="post">
|
|
|
|
<?php
|
|
|
|
switch (STEP) {
|
|
|
|
case 0:
|
|
|
|
default:
|
2014-09-27 10:10:43 +02:00
|
|
|
printStep0();
|
2014-07-23 15:52:50 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2014-09-27 10:10:43 +02:00
|
|
|
printStep1();
|
2014-07-23 15:52:50 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2014-09-27 10:10:43 +02:00
|
|
|
printStep2();
|
2014-07-23 15:52:50 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2014-09-27 10:10:43 +02:00
|
|
|
printStep3();
|
2014-07-23 15:52:50 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2014-09-27 10:10:43 +02:00
|
|
|
printStep4();
|
2014-07-23 15:52:50 +02:00
|
|
|
break;
|
|
|
|
case 5:
|
2014-09-27 10:10:43 +02:00
|
|
|
printStep5();
|
2014-07-23 15:52:50 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-07-24 11:59:17 +02:00
|
|
|
<script src="../scripts/install.js?<?php echo @filemtime(PUBLIC_PATH . '/scripts/install.js'); ?>"></script>
|
2014-07-23 15:52:50 +02:00
|
|
|
</body>
|
|
|
|
</html>
|