install.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041
  1. <?php
  2. if (function_exists('opcache_reset')) {
  3. opcache_reset();
  4. }
  5. require('../../constants.php');
  6. const BCRYPT_COST = 9;
  7. include(LIB_PATH . '/lib_rss.php');
  8. session_name('FreshRSS');
  9. session_set_cookie_params(0, dirname(empty($_SERVER['REQUEST_URI']) ? '/' : dirname($_SERVER['REQUEST_URI'])), null, false, true);
  10. session_start();
  11. if (isset ($_GET['step'])) {
  12. define ('STEP', $_GET['step']);
  13. } else {
  14. define ('STEP', 1);
  15. }
  16. define('SQL_CREATE_DB', 'CREATE DATABASE IF NOT EXISTS %1$s DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
  17. include(APP_PATH . '/sql.php');
  18. //<updates>
  19. define('SQL_SHOW_TABLES', 'SHOW tables;');
  20. define('SQL_BACKUP006', 'RENAME TABLE `%1$scategory` TO `%1$scategory006`, `%1$sfeed` TO `%1$sfeed006`, `%1$sentry` TO `%1$sentry006`;');
  21. define('SQL_SHOW_COLUMNS_UPDATEv006', 'SHOW columns FROM `%1$sentry006` LIKE "id2";');
  22. define('SQL_UPDATEv006', '
  23. ALTER TABLE `%1$scategory006` ADD id2 SMALLINT;
  24. SET @i = 0;
  25. UPDATE `%1$scategory006` SET id2=(@i:=@i+1) ORDER BY id;
  26. ALTER TABLE `%1$sfeed006` ADD id2 SMALLINT, ADD category2 SMALLINT;
  27. SET @i = 0;
  28. UPDATE `%1$sfeed006` SET id2=(@i:=@i+1) ORDER BY name;
  29. UPDATE `%1$sfeed006` f
  30. INNER JOIN `%1$scategory006` c ON f.category = c.id
  31. SET f.category2 = c.id2;
  32. INSERT IGNORE INTO `%2$scategory` (name, color)
  33. SELECT name, color
  34. FROM `%1$scategory006`
  35. ORDER BY id2;
  36. INSERT IGNORE INTO `%2$sfeed` (url, category, name, website, description, priority, pathEntries, httpAuth, keep_history)
  37. SELECT url, category2, name, website, description, priority, pathEntries, httpAuth, IF(keep_history = 1, -1, -2)
  38. FROM `%1$sfeed006`
  39. ORDER BY id2;
  40. ALTER TABLE `%1$sentry006` ADD id2 bigint;
  41. UPDATE `%1$sentry006` SET id2 = ((date * 1000000) + (rand() * 100000000));
  42. INSERT IGNORE INTO `%2$sentry` (id, guid, title, author, link, date, is_read, is_favorite, id_feed, tags)
  43. SELECT e0.id2, e0.guid, e0.title, e0.author, e0.link, e0.date, e0.is_read, e0.is_favorite, f0.id2, e0.tags
  44. FROM `%1$sentry006` e0
  45. INNER JOIN `%1$sfeed006` f0 ON e0.id_feed = f0.id;
  46. ');
  47. define('SQL_CONVERT_SELECTv006', '
  48. SELECT e0.id2, e0.content
  49. FROM `%1$sentry006` e0
  50. INNER JOIN `%2$sentry` e1 ON e0.id2 = e1.id
  51. WHERE e1.content_bin IS NULL');
  52. define('SQL_CONVERT_UPDATEv006', 'UPDATE `%1$sentry` SET content_bin=COMPRESS(?) WHERE id=?;');
  53. define('SQL_DROP_BACKUPv006', 'DROP TABLE IF EXISTS `%1$sentry006`, `%1$sfeed006`, `%1$scategory006`;');
  54. define('SQL_UPDATE_CACHED_VALUES', '
  55. UPDATE `%1$sfeed` f
  56. INNER JOIN (
  57. SELECT e.id_feed,
  58. COUNT(CASE WHEN e.is_read = 0 THEN 1 END) AS nbUnreads,
  59. COUNT(e.id) AS nbEntries
  60. FROM `%1$sentry` e
  61. GROUP BY e.id_feed
  62. ) x ON x.id_feed=f.id
  63. SET f.cache_nbEntries=x.nbEntries, f.cache_nbUnreads=x.nbUnreads
  64. ');
  65. define('SQL_UPDATE_HISTORYv007b', 'UPDATE `%1$sfeed` SET keep_history = CASE WHEN keep_history = 0 THEN -2 WHEN keep_history = 1 THEN -1 ELSE keep_history END;');
  66. //</updates>
  67. // gestion internationalisation
  68. $translates = array ();
  69. $actual = 'en';
  70. function initTranslate () {
  71. global $translates;
  72. global $actual;
  73. $actual = isset($_SESSION['language']) ? $_SESSION['language'] : getBetterLanguage('en');
  74. $file = APP_PATH . '/i18n/' . $actual . '.php';
  75. if (file_exists($file)) {
  76. $translates = array_merge($translates, include($file));
  77. }
  78. $file = APP_PATH . '/i18n/install.' . $actual . '.php';
  79. if (file_exists($file)) {
  80. $translates = array_merge($translates, include($file));
  81. }
  82. }
  83. function getBetterLanguage ($fallback) {
  84. $available = availableLanguages ();
  85. $accept = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  86. $language = strtolower (substr ($accept, 0, 2));
  87. if (isset ($available[$language])) {
  88. return $language;
  89. } else {
  90. return $fallback;
  91. }
  92. }
  93. function availableLanguages () {
  94. return array (
  95. 'en' => 'English',
  96. 'fr' => 'Français'
  97. );
  98. }
  99. function _t ($key) {
  100. global $translates;
  101. $translate = $key;
  102. if (isset ($translates[$key])) {
  103. $translate = $translates[$key];
  104. }
  105. $args = func_get_args ();
  106. unset($args[0]);
  107. return vsprintf ($translate, $args);
  108. }
  109. /*** SAUVEGARDES ***/
  110. function saveLanguage () {
  111. if (!empty ($_POST)) {
  112. if (!isset ($_POST['language'])) {
  113. return false;
  114. }
  115. $_SESSION['language'] = $_POST['language'];
  116. header ('Location: index.php?step=1');
  117. }
  118. }
  119. function saveStep2 () {
  120. if (!empty ($_POST)) {
  121. if (empty ($_POST['title']) ||
  122. empty ($_POST['old_entries']) ||
  123. empty ($_POST['auth_type']) ||
  124. empty ($_POST['default_user'])) {
  125. return false;
  126. }
  127. $_SESSION['salt'] = sha1(uniqid(mt_rand(), true).implode('', stat(__FILE__)));
  128. $_SESSION['title'] = substr(trim($_POST['title']), 0, 25);
  129. $_SESSION['old_entries'] = $_POST['old_entries'];
  130. if ((!ctype_digit($_SESSION['old_entries'])) || ($_SESSION['old_entries'] < 1)) {
  131. $_SESSION['old_entries'] = 3;
  132. }
  133. $_SESSION['mail_login'] = filter_var($_POST['mail_login'], FILTER_VALIDATE_EMAIL);
  134. $_SESSION['default_user'] = substr(preg_replace('/[^a-zA-Z0-9]/', '', $_POST['default_user']), 0, 16);
  135. $_SESSION['auth_type'] = $_POST['auth_type'];
  136. if (!empty($_POST['passwordPlain'])) {
  137. $passwordHash = password_hash($_POST['passwordPlain'], PASSWORD_BCRYPT, array('cost' => BCRYPT_COST));
  138. $passwordHash = preg_replace('/^\$2[xy]\$/', '\$2a\$', $passwordHash); //Compatibility with bcrypt.js
  139. $_SESSION['passwordHash'] = $passwordHash;
  140. }
  141. $token = '';
  142. if ($_SESSION['mail_login']) {
  143. $token = sha1($_SESSION['salt'] . $_SESSION['mail_login']);
  144. }
  145. $config_array = array (
  146. 'language' => $_SESSION['language'],
  147. 'theme' => $_SESSION['theme'],
  148. 'old_entries' => $_SESSION['old_entries'],
  149. 'mail_login' => $_SESSION['mail_login'],
  150. 'passwordHash' => $_SESSION['passwordHash'],
  151. 'token' => $token,
  152. );
  153. $configPath = DATA_PATH . '/' . $_SESSION['default_user'] . '_user.php';
  154. @unlink($configPath); //To avoid access-rights problems
  155. file_put_contents($configPath, "<?php\n return " . var_export($config_array, true) . ';');
  156. if ($_SESSION['mail_login'] != '') {
  157. $personaFile = DATA_PATH . '/persona/' . $_SESSION['mail_login'] . '.txt';
  158. @unlink($personaFile);
  159. file_put_contents($personaFile, $_SESSION['default_user']);
  160. }
  161. header ('Location: index.php?step=3');
  162. }
  163. }
  164. function saveStep3 () {
  165. if (!empty ($_POST)) {
  166. if (empty ($_POST['type']) ||
  167. empty ($_POST['host']) ||
  168. empty ($_POST['user']) ||
  169. empty ($_POST['base'])) {
  170. $_SESSION['bd_error'] = 'Missing parameters!';
  171. }
  172. $_SESSION['bd_type'] = isset ($_POST['type']) ? $_POST['type'] : 'mysql';
  173. $_SESSION['bd_host'] = $_POST['host'];
  174. $_SESSION['bd_user'] = $_POST['user'];
  175. $_SESSION['bd_password'] = $_POST['pass'];
  176. $_SESSION['bd_base'] = substr($_POST['base'], 0, 64);
  177. $_SESSION['bd_prefix'] = substr($_POST['prefix'], 0, 16);
  178. $_SESSION['bd_prefix_user'] = $_SESSION['bd_prefix'] . (empty($_SESSION['default_user']) ? '' : ($_SESSION['default_user'] . '_'));
  179. $ini_array = array(
  180. 'general' => array(
  181. 'environment' => empty($_SESSION['environment']) ? 'production' : $_SESSION['environment'],
  182. 'use_url_rewriting' => false,
  183. 'salt' => $_SESSION['salt'],
  184. 'base_url' => '',
  185. 'title' => $_SESSION['title'],
  186. 'default_user' => $_SESSION['default_user'],
  187. 'auth_type' => $_SESSION['auth_type'],
  188. 'allow_anonymous' => isset($_SESSION['allow_anonymous']) ? $_SESSION['allow_anonymous'] : false,
  189. ),
  190. 'db' => array(
  191. 'type' => $_SESSION['bd_type'],
  192. 'host' => $_SESSION['bd_host'],
  193. 'user' => $_SESSION['bd_user'],
  194. 'password' => $_SESSION['bd_password'],
  195. 'base' => $_SESSION['bd_base'],
  196. 'prefix' => $_SESSION['bd_prefix'],
  197. ),
  198. );
  199. @unlink(DATA_PATH . '/config.php'); //To avoid access-rights problems
  200. file_put_contents(DATA_PATH . '/config.php', "<?php\n return " . var_export($ini_array, true) . ';');
  201. if (file_exists(DATA_PATH . '/config.php') && file_exists(DATA_PATH . '/application.ini')) {
  202. @unlink(DATA_PATH . '/application.ini'); //v0.6
  203. }
  204. $res = checkBD ();
  205. if ($res) {
  206. $_SESSION['bd_error'] = '';
  207. header ('Location: index.php?step=4');
  208. } elseif (empty($_SESSION['bd_error'])) {
  209. $_SESSION['bd_error'] = 'Unknown error!';
  210. }
  211. }
  212. invalidateHttpCache();
  213. }
  214. function updateDatabase($perform = false) {
  215. $needs = array('bd_type', 'bd_host', 'bd_base', 'bd_user', 'bd_password', 'bd_prefix', 'bd_prefix_user');
  216. foreach ($needs as $need) {
  217. if (!isset($_SESSION[$need])) {
  218. return false;
  219. }
  220. }
  221. try {
  222. $str = '';
  223. switch ($_SESSION['bd_type']) {
  224. case 'mysql':
  225. $str = 'mysql:host=' . $_SESSION['bd_host'] . ';dbname=' . $_SESSION['bd_base'];
  226. $driver_options = array(
  227. PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
  228. );
  229. break;
  230. case 'sqlite':
  231. $str = 'sqlite:' . DATA_PATH . $_SESSION['bd_base'] . '.sqlite';
  232. $driver_options = null;
  233. break;
  234. default:
  235. return false;
  236. }
  237. $c = new PDO($str, $_SESSION['bd_user'], $_SESSION['bd_password'], $driver_options);
  238. $stm = $c->prepare(SQL_SHOW_TABLES);
  239. $stm->execute();
  240. $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);
  241. if (!in_array($_SESSION['bd_prefix'] . 'entry006', $res)) {
  242. return false;
  243. }
  244. $sql = sprintf(SQL_SHOW_COLUMNS_UPDATEv006, $_SESSION['bd_prefix']);
  245. $stm = $c->prepare($sql);
  246. $stm->execute();
  247. $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);
  248. if (!in_array('id2', $res)) {
  249. if (!$perform) {
  250. return true;
  251. }
  252. $sql = sprintf(SQL_UPDATEv006, $_SESSION['bd_prefix'], $_SESSION['bd_prefix_user']);
  253. $stm = $c->prepare($sql, array(PDO::ATTR_EMULATE_PREPARES => true));
  254. $stm->execute();
  255. }
  256. $sql = sprintf(SQL_UPDATE_HISTORYv007b, $_SESSION['bd_prefix_user']);
  257. $stm = $c->prepare($sql);
  258. $stm->execute();
  259. $sql = sprintf(SQL_UPDATE_CACHED_VALUES, $_SESSION['bd_prefix_user']);
  260. $stm = $c->prepare($sql);
  261. $stm->execute();
  262. $sql = sprintf(SQL_CONVERT_SELECTv006, $_SESSION['bd_prefix'], $_SESSION['bd_prefix_user']);
  263. if (!$perform) {
  264. $sql .= ' LIMIT 1';
  265. }
  266. $stm = $c->prepare($sql);
  267. $stm->execute();
  268. if (!$perform) {
  269. $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);
  270. return count($res) > 0;
  271. } else {
  272. @set_time_limit(300);
  273. }
  274. $c2 = new PDO($str, $_SESSION['bd_user'], $_SESSION['bd_password'], $driver_options);
  275. $sql = sprintf(SQL_CONVERT_UPDATEv006, $_SESSION['bd_prefix_user']);
  276. $stm2 = $c2->prepare($sql);
  277. while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {
  278. $id = $row['id2'];
  279. $content = unserialize(gzinflate(base64_decode($row['content'])));
  280. $stm2->execute(array($content, $id));
  281. }
  282. return true;
  283. } catch (PDOException $e) {
  284. return false;
  285. }
  286. return false;
  287. }
  288. function deleteInstall () {
  289. $res = unlink (INDEX_PATH . '/install.php');
  290. if ($res) {
  291. header ('Location: index.php');
  292. }
  293. $needs = array('bd_type', 'bd_host', 'bd_base', 'bd_user', 'bd_password', 'bd_prefix');
  294. foreach ($needs as $need) {
  295. if (!isset($_SESSION[$need])) {
  296. return false;
  297. }
  298. }
  299. try {
  300. switch ($_SESSION['bd_type']) {
  301. case 'mysql':
  302. $str = 'mysql:host=' . $_SESSION['bd_host'] . ';dbname=' . $_SESSION['bd_base'];
  303. $driver_options = array(
  304. PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
  305. );
  306. break;
  307. case 'sqlite':
  308. $str = 'sqlite:' . DATA_PATH . $_SESSION['bd_base'] . '.sqlite';
  309. $driver_options = null;
  310. break;
  311. default:
  312. return false;
  313. }
  314. $c = new PDO($str, $_SESSION['bd_user'], $_SESSION['bd_password'], $driver_options);
  315. $sql = sprintf(SQL_DROP_BACKUPv006, $_SESSION['bd_prefix']);
  316. $stm = $c->prepare($sql);
  317. $stm->execute();
  318. return true;
  319. } catch (PDOException $e) {
  320. return false;
  321. }
  322. return false;
  323. }
  324. function moveOldFiles() {
  325. $mvs = array(
  326. '/app/configuration/application.ini' => '/data/application.ini', //v0.6
  327. '/public/data/Configuration.array.php' => '/data/Configuration.array.php', //v0.6
  328. );
  329. $ok = true;
  330. foreach ($mvs as $fFrom => $fTo) {
  331. if (file_exists(FRESHRSS_PATH . $fFrom)) {
  332. if (copy(FRESHRSS_PATH . $fFrom, FRESHRSS_PATH . $fTo)) {
  333. @unlink(FRESHRSS_PATH . $fFrom);
  334. } else {
  335. $ok = false;
  336. }
  337. }
  338. }
  339. return $ok;
  340. }
  341. function delTree($dir) { //http://php.net/rmdir#110489
  342. if (!is_dir($dir)) {
  343. return true;
  344. }
  345. $files = array_diff(scandir($dir), array('.', '..'));
  346. foreach ($files as $file) {
  347. $f = $dir . '/' . $file;
  348. if (is_dir($f)) {
  349. @chmod($f, 0777);
  350. delTree($f);
  351. }
  352. else unlink($f);
  353. }
  354. return rmdir($dir);
  355. }
  356. /*** VÉRIFICATIONS ***/
  357. function checkStep () {
  358. $s0 = checkStep0 ();
  359. $s1 = checkStep1 ();
  360. $s2 = checkStep2 ();
  361. $s3 = checkStep3 ();
  362. if (STEP > 0 && $s0['all'] != 'ok') {
  363. header ('Location: index.php?step=0');
  364. } elseif (STEP > 1 && $s1['all'] != 'ok') {
  365. header ('Location: index.php?step=1');
  366. } elseif (STEP > 2 && $s2['all'] != 'ok') {
  367. header ('Location: index.php?step=2');
  368. } elseif (STEP > 3 && $s3['all'] != 'ok') {
  369. header ('Location: index.php?step=3');
  370. }
  371. $_SESSION['actualize_feeds'] = true;
  372. }
  373. function checkStep0 () {
  374. moveOldFiles();
  375. if (file_exists(DATA_PATH . '/config.php')) {
  376. $ini_array = include(DATA_PATH . '/config.php');
  377. } elseif (file_exists(DATA_PATH . '/application.ini')) { //v0.6
  378. $ini_array = parse_ini_file(DATA_PATH . '/application.ini', true);
  379. $ini_array['general']['title'] = empty($ini_array['general']['title']) ? '' : stripslashes($ini_array['general']['title']);
  380. } else {
  381. $ini_array = null;
  382. }
  383. if ($ini_array) {
  384. $ini_general = isset($ini_array['general']) ? $ini_array['general'] : null;
  385. if ($ini_general) {
  386. $keys = array('environment', 'salt', 'title', 'default_user', 'allow_anonymous', 'auth_type');
  387. foreach ($keys as $key) {
  388. if ((empty($_SESSION[$key])) && isset($ini_general[$key])) {
  389. $_SESSION[$key] = $ini_general[$key];
  390. }
  391. }
  392. }
  393. $ini_db = isset($ini_array['db']) ? $ini_array['db'] : null;
  394. if ($ini_db) {
  395. $keys = array('type', 'host', 'user', 'password', 'base', 'prefix');
  396. foreach ($keys as $key) {
  397. if ((!isset($_SESSION['bd_' . $key])) && isset($ini_db[$key])) {
  398. $_SESSION['bd_' . $key] = $ini_db[$key];
  399. }
  400. }
  401. }
  402. }
  403. if (isset($_SESSION['default_user']) && file_exists(DATA_PATH . '/' . $_SESSION['default_user'] . '_user.php')) {
  404. $userConfig = include(DATA_PATH . '/' . $_SESSION['default_user'] . '_user.php');
  405. } elseif (file_exists(DATA_PATH . '/Configuration.array.php')) {
  406. $userConfig = include(DATA_PATH . '/Configuration.array.php'); //v0.6
  407. if (empty($_SESSION['auth_type'])) {
  408. $_SESSION['auth_type'] = empty($userConfig['mail_login']) ? 'none' : 'persona';
  409. }
  410. if (!isset($_SESSION['allow_anonymous'])) {
  411. $_SESSION['allow_anonymous'] = empty($userConfig['anon_access']) ? false : ($userConfig['anon_access'] === 'yes');
  412. }
  413. } else {
  414. $userConfig = array();
  415. }
  416. if (empty($_SESSION['auth_type'])) { //v0.7b
  417. $_SESSION['auth_type'] = '';
  418. }
  419. $keys = array('language', 'theme', 'old_entries', 'mail_login', 'passwordHash');
  420. foreach ($keys as $key) {
  421. if ((!isset($_SESSION[$key])) && isset($userConfig[$key])) {
  422. $_SESSION[$key] = $userConfig[$key];
  423. }
  424. }
  425. $languages = availableLanguages ();
  426. $language = isset ($_SESSION['language']) &&
  427. isset ($languages[$_SESSION['language']]);
  428. if (empty($_SESSION['passwordHash'])) { //v0.7b
  429. $_SESSION['passwordHash'] = '';
  430. }
  431. if (empty($_SESSION['theme'])) {
  432. $_SESSION['theme'] = 'Origine';
  433. } else {
  434. switch (strtolower($_SESSION['theme'])) {
  435. case 'default': //v0.7b
  436. $_SESSION['theme'] = 'Origine';
  437. break;
  438. case 'flat-design': //v0.7b
  439. $_SESSION['theme'] = 'Flat';
  440. break;
  441. case 'default_dark': //v0.7b
  442. $_SESSION['theme'] = 'Dark';
  443. break;
  444. }
  445. }
  446. return array (
  447. 'language' => $language ? 'ok' : 'ko',
  448. 'all' => $language ? 'ok' : 'ko'
  449. );
  450. }
  451. function checkStep1 () {
  452. $php = version_compare (PHP_VERSION, '5.2.0') >= 0;
  453. $minz = file_exists (LIB_PATH . '/Minz');
  454. $curl = extension_loaded ('curl');
  455. $pdo = extension_loaded ('pdo_mysql');
  456. $pcre = extension_loaded ('pcre');
  457. $ctype = extension_loaded ('ctype');
  458. $dom = class_exists('DOMDocument');
  459. $data = DATA_PATH && is_writable (DATA_PATH);
  460. $cache = CACHE_PATH && is_writable (CACHE_PATH);
  461. $log = LOG_PATH && is_writable (LOG_PATH);
  462. $favicons = is_writable (DATA_PATH . '/favicons');
  463. $persona = is_writable (DATA_PATH . '/persona');
  464. return array (
  465. 'php' => $php ? 'ok' : 'ko',
  466. 'minz' => $minz ? 'ok' : 'ko',
  467. 'curl' => $curl ? 'ok' : 'ko',
  468. 'pdo-mysql' => $pdo ? 'ok' : 'ko',
  469. 'pcre' => $pcre ? 'ok' : 'ko',
  470. 'ctype' => $ctype ? 'ok' : 'ko',
  471. 'dom' => $dom ? 'ok' : 'ko',
  472. 'data' => $data ? 'ok' : 'ko',
  473. 'cache' => $cache ? 'ok' : 'ko',
  474. 'log' => $log ? 'ok' : 'ko',
  475. 'favicons' => $favicons ? 'ok' : 'ko',
  476. 'persona' => $persona ? 'ok' : 'ko',
  477. 'all' => $php && $minz && $curl && $pdo && $pcre && $ctype && $dom && $data && $cache && $log && $favicons && $persona ? 'ok' : 'ko'
  478. );
  479. }
  480. function checkStep2 () {
  481. $conf = !empty($_SESSION['salt']) &&
  482. !empty($_SESSION['title']) &&
  483. !empty($_SESSION['old_entries']) &&
  484. isset($_SESSION['mail_login']) &&
  485. !empty($_SESSION['default_user']);
  486. $defaultUser = empty($_POST['default_user']) ? null : $_POST['default_user'];
  487. if ($defaultUser === null) {
  488. $defaultUser = empty($_SESSION['default_user']) ? '' : $_SESSION['default_user'];
  489. }
  490. $data = is_writable(DATA_PATH . '/' . $defaultUser . '_user.php');
  491. if ($data) {
  492. @unlink(DATA_PATH . '/Configuration.array.php'); //v0.6
  493. }
  494. return array (
  495. 'conf' => $conf ? 'ok' : 'ko',
  496. 'data' => $data ? 'ok' : 'ko',
  497. 'all' => $conf && $data ? 'ok' : 'ko'
  498. );
  499. }
  500. function checkStep3 () {
  501. $conf = is_writable(DATA_PATH . '/config.php');
  502. $bd = isset ($_SESSION['bd_type']) &&
  503. isset ($_SESSION['bd_host']) &&
  504. isset ($_SESSION['bd_user']) &&
  505. isset ($_SESSION['bd_password']) &&
  506. isset ($_SESSION['bd_base']) &&
  507. isset ($_SESSION['bd_prefix']) &&
  508. isset ($_SESSION['bd_error']);
  509. $conn = empty($_SESSION['bd_error']);
  510. return array (
  511. 'bd' => $bd ? 'ok' : 'ko',
  512. 'conn' => $conn ? 'ok' : 'ko',
  513. 'conf' => $conf ? 'ok' : 'ko',
  514. 'all' => $bd && $conn && $conf ? 'ok' : 'ko'
  515. );
  516. }
  517. function checkBD () {
  518. $ok = false;
  519. try {
  520. $str = '';
  521. $driver_options = null;
  522. switch ($_SESSION['bd_type']) {
  523. case 'mysql':
  524. $driver_options = array(
  525. PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
  526. );
  527. try { // on ouvre une connexion juste pour créer la base si elle n'existe pas
  528. $str = 'mysql:host=' . $_SESSION['bd_host'] . ';';
  529. $c = new PDO ($str, $_SESSION['bd_user'], $_SESSION['bd_password'], $driver_options);
  530. $sql = sprintf (SQL_CREATE_DB, $_SESSION['bd_base']);
  531. $res = $c->query ($sql);
  532. } catch (PDOException $e) {
  533. }
  534. // on écrase la précédente connexion en sélectionnant la nouvelle BDD
  535. $str = 'mysql:host=' . $_SESSION['bd_host'] . ';dbname=' . $_SESSION['bd_base'];
  536. break;
  537. case 'sqlite':
  538. $str = 'sqlite:' . DATA_PATH . $_SESSION['bd_base'] . '.sqlite';
  539. break;
  540. default:
  541. return false;
  542. }
  543. $c = new PDO ($str, $_SESSION['bd_user'], $_SESSION['bd_password'], $driver_options);
  544. $stm = $c->prepare(SQL_SHOW_TABLES);
  545. $stm->execute();
  546. $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);
  547. if (in_array($_SESSION['bd_prefix'] . 'entry', $res) && !in_array($_SESSION['bd_prefix'] . 'entry006', $res)) {
  548. $sql = sprintf(SQL_BACKUP006, $_SESSION['bd_prefix']); //v0.6
  549. $res = $c->query($sql); //Backup tables
  550. }
  551. $sql = sprintf(SQL_CREATE_TABLES, $_SESSION['bd_prefix_user']);
  552. $stm = $c->prepare($sql, array(PDO::ATTR_EMULATE_PREPARES => true));
  553. $values = array(
  554. 'catName' => _t('default_category'),
  555. );
  556. $ok = $stm->execute($values);
  557. } catch (PDOException $e) {
  558. $ok = false;
  559. $_SESSION['bd_error'] = $e->getMessage();
  560. }
  561. if (!$ok) {
  562. @unlink(DATA_PATH . '/config.php');
  563. }
  564. return $ok;
  565. }
  566. /*** AFFICHAGE ***/
  567. function printStep0 () {
  568. global $actual;
  569. ?>
  570. <?php $s0 = checkStep0 (); if ($s0['all'] == 'ok') { ?>
  571. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('language_defined'); ?></p>
  572. <?php } ?>
  573. <form action="index.php?step=0" method="post">
  574. <legend><?php echo _t ('choose_language'); ?></legend>
  575. <div class="form-group">
  576. <label class="group-name" for="language"><?php echo _t ('language'); ?></label>
  577. <div class="group-controls">
  578. <select name="language" id="language">
  579. <?php $languages = availableLanguages (); ?>
  580. <?php foreach ($languages as $short => $lib) { ?>
  581. <option value="<?php echo $short; ?>"<?php echo $actual == $short ? ' selected="selected"' : ''; ?>><?php echo $lib; ?></option>
  582. <?php } ?>
  583. </select>
  584. </div>
  585. </div>
  586. <div class="form-group form-actions">
  587. <div class="group-controls">
  588. <button type="submit" class="btn btn-important"><?php echo _t ('save'); ?></button>
  589. <button type="reset" class="btn"><?php echo _t ('cancel'); ?></button>
  590. <?php if ($s0['all'] == 'ok') { ?>
  591. <a class="btn btn-important next-step" href="?step=1"><?php echo _t ('next_step'); ?></a>
  592. <?php } ?>
  593. </div>
  594. </div>
  595. </form>
  596. <?php
  597. }
  598. function printStep1 () {
  599. $res = checkStep1 ();
  600. ?>
  601. <noscript><p class="alert alert-warn"><span class="alert-head"><?php echo _t ('attention'); ?></span> <?php echo _t ('javascript_is_better'); ?></p></noscript>
  602. <?php if ($res['php'] == 'ok') { ?>
  603. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('php_is_ok', PHP_VERSION); ?></p>
  604. <?php } else { ?>
  605. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('php_is_nok', PHP_VERSION, '5.1.0'); ?></p>
  606. <?php } ?>
  607. <?php if ($res['minz'] == 'ok') { ?>
  608. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('minz_is_ok'); ?></p>
  609. <?php } else { ?>
  610. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('minz_is_nok', LIB_PATH . '/Minz'); ?></p>
  611. <?php } ?>
  612. <?php if ($res['pdo-mysql'] == 'ok') { ?>
  613. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('pdomysql_is_ok'); ?></p>
  614. <?php } else { ?>
  615. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('pdomysql_is_nok'); ?></p>
  616. <?php } ?>
  617. <?php if ($res['curl'] == 'ok') { ?>
  618. <?php $version = curl_version(); ?>
  619. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('curl_is_ok', $version['version']); ?></p>
  620. <?php } else { ?>
  621. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('curl_is_nok'); ?></p>
  622. <?php } ?>
  623. <?php if ($res['pcre'] == 'ok') { ?>
  624. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('pcre_is_ok'); ?></p>
  625. <?php } else { ?>
  626. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('pcre_is_nok'); ?></p>
  627. <?php } ?>
  628. <?php if ($res['ctype'] == 'ok') { ?>
  629. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('ctype_is_ok'); ?></p>
  630. <?php } else { ?>
  631. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('ctype_is_nok'); ?></p>
  632. <?php } ?>
  633. <?php if ($res['dom'] == 'ok') { ?>
  634. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('dom_is_ok'); ?></p>
  635. <?php } else { ?>
  636. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('dom_is_nok'); ?></p>
  637. <?php } ?>
  638. <?php if ($res['data'] == 'ok') { ?>
  639. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('data_is_ok'); ?></p>
  640. <?php } else { ?>
  641. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', DATA_PATH); ?></p>
  642. <?php } ?>
  643. <?php if ($res['cache'] == 'ok') { ?>
  644. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('cache_is_ok'); ?></p>
  645. <?php } else { ?>
  646. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', CACHE_PATH); ?></p>
  647. <?php } ?>
  648. <?php if ($res['log'] == 'ok') { ?>
  649. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('log_is_ok'); ?></p>
  650. <?php } else { ?>
  651. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', LOG_PATH); ?></p>
  652. <?php } ?>
  653. <?php if ($res['favicons'] == 'ok') { ?>
  654. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('favicons_is_ok'); ?></p>
  655. <?php } else { ?>
  656. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', DATA_PATH . '/favicons'); ?></p>
  657. <?php } ?>
  658. <?php if ($res['persona'] == 'ok') { ?>
  659. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('persona_is_ok'); ?></p>
  660. <?php } else { ?>
  661. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', DATA_PATH . '/persona'); ?></p>
  662. <?php } ?>
  663. <?php if ($res['all'] == 'ok') { ?>
  664. <a class="btn btn-important next-step" href="?step=2"><?php echo _t ('next_step'); ?></a>
  665. <?php } else { ?>
  666. <p class="alert alert-error"><?php echo _t ('fix_errors_before'); ?></p>
  667. <?php } ?>
  668. <?php
  669. }
  670. function printStep2 () {
  671. ?>
  672. <?php $s2 = checkStep2 (); if ($s2['all'] == 'ok') { ?>
  673. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('general_conf_is_ok'); ?></p>
  674. <?php } ?>
  675. <form action="index.php?step=2" method="post">
  676. <legend><?php echo _t ('general_configuration'); ?></legend>
  677. <div class="form-group">
  678. <label class="group-name" for="title"><?php echo _t ('title'); ?></label>
  679. <div class="group-controls">
  680. <input type="text" id="title" name="title" value="<?php echo isset ($_SESSION['title']) ? $_SESSION['title'] : _t ('freshrss'); ?>" />
  681. </div>
  682. </div>
  683. <div class="form-group">
  684. <label class="group-name" for="old_entries"><?php echo _t ('delete_articles_every'); ?></label>
  685. <div class="group-controls">
  686. <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'] : '3'; ?>" /> <?php echo _t ('month'); ?>
  687. </div>
  688. </div>
  689. <div class="form-group">
  690. <label class="group-name" for="default_user"><?php echo _t ('default_user'); ?></label>
  691. <div class="group-controls">
  692. <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() == '' ? 'user1' : httpAuthUser(); ?>" />
  693. </div>
  694. </div>
  695. <div class="form-group">
  696. <label class="group-name" for="auth_type"><?php echo _t('auth_type'); ?></label>
  697. <div class="group-controls">
  698. <select id="auth_type" name="auth_type" required="required">
  699. <option value=""></option>
  700. <option value="form"<?php echo $_SESSION['auth_type'] === 'form' ? ' selected="selected"' : '', version_compare(PHP_VERSION, '5.3', '<') ? ' disabled="disabled"' : ''; ?>><?php echo _t('auth_form'); ?></option>
  701. <option value="persona"<?php echo $_SESSION['auth_type'] === 'persona' ? ' selected="selected"' : ''; ?>><?php echo _t('auth_persona'); ?></option>
  702. <option value="http_auth"<?php echo $_SESSION['auth_type'] === 'http_auth' ? ' selected="selected"' : '', httpAuthUser() == '' ? ' disabled="disabled"' : ''; ?>><?php echo _t('http_auth'); ?> (REMOTE_USER = '<?php echo httpAuthUser(); ?>')</option>
  703. <option value="none"<?php echo $_SESSION['auth_type'] === 'none' ? ' selected="selected"' : ''; ?>><?php echo _t('auth_none'); ?></option>
  704. </select>
  705. </div>
  706. </div>
  707. <div class="form-group">
  708. <label class="group-name" for="passwordPlain"><?php echo _t('password_form'); ?></label>
  709. <div class="group-controls">
  710. <input type="password" id="passwordPlain" name="passwordPlain" pattern=".{7,}" autocomplete="off" />
  711. <noscript><b><?php echo _t('javascript_should_be_activated'); ?></b></noscript>
  712. </div>
  713. </div>
  714. <div class="form-group">
  715. <label class="group-name" for="mail_login"><?php echo _t ('persona_connection_email'); ?></label>
  716. <div class="group-controls">
  717. <input type="email" id="mail_login" name="mail_login" value="<?php echo isset ($_SESSION['mail_login']) ? $_SESSION['mail_login'] : ''; ?>" placeholder="alice@example.net" />
  718. <noscript><b><?php echo _t ('javascript_should_be_activated'); ?></b></noscript>
  719. </div>
  720. </div>
  721. <div class="form-group form-actions">
  722. <div class="group-controls">
  723. <button type="submit" class="btn btn-important"><?php echo _t ('save'); ?></button>
  724. <button type="reset" class="btn"><?php echo _t ('cancel'); ?></button>
  725. <?php if ($s2['all'] == 'ok') { ?>
  726. <a class="btn btn-important next-step" href="?step=3"><?php echo _t ('next_step'); ?></a>
  727. <?php } ?>
  728. </div>
  729. </div>
  730. </form>
  731. <?php
  732. }
  733. function printStep3 () {
  734. ?>
  735. <?php $s3 = checkStep3 (); if ($s3['all'] == 'ok') { ?>
  736. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('bdd_conf_is_ok'); ?></p>
  737. <?php } elseif ($s3['conn'] == 'ko') { ?>
  738. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('bdd_conf_is_ko'), (empty($_SESSION['bd_error']) ? '' : ' : ' . $_SESSION['bd_error']); ?></p>
  739. <?php } ?>
  740. <form action="index.php?step=3" method="post">
  741. <legend><?php echo _t ('bdd_configuration'); ?></legend>
  742. <div class="form-group">
  743. <label class="group-name" for="type"><?php echo _t ('bdd_type'); ?></label>
  744. <div class="group-controls">
  745. <select name="type" id="type">
  746. <option value="mysql"
  747. <?php echo (isset($_SESSION['bd_type']) && $_SESSION['bd_type'] === 'mysql') ? 'selected="selected"' : ''; ?>>
  748. MySQL
  749. </option>
  750. <!-- TODO : l'utilisation de SQLite n'est pas encore possible. Pour tester tout de même, décommentez ce bloc
  751. <option value="sqlite"
  752. <?php echo (isset($_SESSION['bd_type']) && $_SESSION['bd_type'] === 'sqlite') ? 'selected="selected"' : ''; ?>>
  753. SQLite
  754. </option>-->
  755. </select>
  756. </div>
  757. </div>
  758. <div class="form-group">
  759. <label class="group-name" for="host"><?php echo _t ('host'); ?></label>
  760. <div class="group-controls">
  761. <input type="text" id="host" name="host" pattern="[0-9A-Za-z_.-]{1,64}" value="<?php echo isset ($_SESSION['bd_host']) ? $_SESSION['bd_host'] : 'localhost'; ?>" />
  762. </div>
  763. </div>
  764. <div class="form-group">
  765. <label class="group-name" for="user"><?php echo _t ('username'); ?></label>
  766. <div class="group-controls">
  767. <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'] : ''; ?>" />
  768. </div>
  769. </div>
  770. <div class="form-group">
  771. <label class="group-name" for="pass"><?php echo _t ('password'); ?></label>
  772. <div class="group-controls">
  773. <input type="password" id="pass" name="pass" value="<?php echo isset ($_SESSION['bd_password']) ? $_SESSION['bd_password'] : ''; ?>" />
  774. </div>
  775. </div>
  776. <div class="form-group">
  777. <label class="group-name" for="base"><?php echo _t ('bdd'); ?></label>
  778. <div class="group-controls">
  779. <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'] : ''; ?>" placeholder="freshrss" />
  780. </div>
  781. </div>
  782. <div class="form-group">
  783. <label class="group-name" for="prefix"><?php echo _t ('prefix'); ?></label>
  784. <div class="group-controls">
  785. <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'] : 'freshrss_'; ?>" />
  786. </div>
  787. </div>
  788. <div class="form-group form-actions">
  789. <div class="group-controls">
  790. <button type="submit" class="btn btn-important"><?php echo _t ('save'); ?></button>
  791. <button type="reset" class="btn"><?php echo _t ('cancel'); ?></button>
  792. <?php if ($s3['all'] == 'ok') { ?>
  793. <a class="btn btn-important next-step" href="?step=4"><?php echo _t ('next_step'); ?></a>
  794. <?php } ?>
  795. </div>
  796. </div>
  797. </form>
  798. <?php
  799. }
  800. function printStep4 () {
  801. ?>
  802. <form action="index.php?step=4" method="post">
  803. <legend><?php echo _t ('version_update'); ?></legend>
  804. <div class="form-group form-actions">
  805. <div class="group-controls">
  806. <?php if (updateDatabase(false)) { ?>
  807. <input type="hidden" name="updateDatabase" value="1" />
  808. <button type="submit" class="btn btn-important"><?php echo _t ('update_start'); ?></button>
  809. <p><?php echo _t ('update_long'); ?></p>
  810. <?php } else { ?>
  811. <a class="btn btn-important next-step" href="?step=5"><?php echo _t ('next_step'); ?></a>
  812. <?php } ?>
  813. </div>
  814. </div>
  815. </form>
  816. <?php
  817. }
  818. function printStep5 () {
  819. ?>
  820. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('congratulations'); ?></span> <?php echo _t ('installation_is_ok'); ?></p>
  821. <a class="btn btn-important next-step" href="?step=6"><?php echo _t ('finish_installation'); ?></a>
  822. <?php
  823. }
  824. function printStep6 () {
  825. ?>
  826. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('oops'); ?></span> <?php echo _t ('install_not_deleted', INDEX_PATH . '/install.php'); ?></p>
  827. <?php
  828. }
  829. checkStep ();
  830. initTranslate ();
  831. switch (STEP) {
  832. case 0:
  833. default:
  834. saveLanguage ();
  835. break;
  836. case 1:
  837. break;
  838. case 2:
  839. saveStep2 ();
  840. break;
  841. case 3:
  842. saveStep3 ();
  843. break;
  844. case 4:
  845. if (!empty($_POST['updateDatabase'])) {
  846. updateDatabase(true);
  847. }
  848. break;
  849. case 5:
  850. break;
  851. case 6:
  852. deleteInstall ();
  853. break;
  854. }
  855. ?>
  856. <!DOCTYPE html>
  857. <html lang="fr">
  858. <head>
  859. <meta charset="utf-8">
  860. <meta name="viewport" content="initial-scale=1.0">
  861. <title><?php echo _t ('freshrss_installation'); ?></title>
  862. <link rel="stylesheet" type="text/css" media="all" href="../themes/Origine/global.css" />
  863. <link rel="stylesheet" type="text/css" media="all" href="../themes/Origine/freshrss.css" />
  864. </head>
  865. <body>
  866. <div class="header">
  867. <div class="item title">
  868. <h1><a href="index.php"><?php echo _t ('freshrss'); ?></a></h1>
  869. <h2><?php echo _t ('installation_step', STEP); ?></h2>
  870. </div>
  871. </div>
  872. <div id="global">
  873. <ul class="nav nav-list aside">
  874. <li class="nav-header"><?php echo _t ('steps'); ?></li>
  875. <li class="item<?php echo STEP == 0 ? ' active' : ''; ?>"><a href="?step=0"><?php echo _t ('language'); ?></a></li>
  876. <li class="item<?php echo STEP == 1 ? ' active' : ''; ?>"><a href="?step=1"><?php echo _t ('checks'); ?></a></li>
  877. <li class="item<?php echo STEP == 2 ? ' active' : ''; ?>"><a href="?step=2"><?php echo _t ('general_configuration'); ?></a></li>
  878. <li class="item<?php echo STEP == 3 ? ' active' : ''; ?>"><a href="?step=3"><?php echo _t ('bdd_configuration'); ?></a></li>
  879. <li class="item<?php echo STEP == 4 ? ' active' : ''; ?>"><a href="?step=4"><?php echo _t ('version_update'); ?></a></li>
  880. <li class="item<?php echo STEP == 5 ? ' active' : ''; ?>"><a href="?step=5"><?php echo _t ('this_is_the_end'); ?></a></li>
  881. </ul>
  882. <div class="post">
  883. <?php
  884. switch (STEP) {
  885. case 0:
  886. default:
  887. printStep0 ();
  888. break;
  889. case 1:
  890. printStep1 ();
  891. break;
  892. case 2:
  893. printStep2 ();
  894. break;
  895. case 3:
  896. printStep3 ();
  897. break;
  898. case 4:
  899. printStep4 ();
  900. break;
  901. case 5:
  902. printStep5 ();
  903. break;
  904. case 6:
  905. printStep6 ();
  906. break;
  907. }
  908. ?>
  909. </div>
  910. </div>
  911. </body>
  912. </html>