install.php 36 KB

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