install.php 36 KB

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