install.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. <?php
  2. session_start ();
  3. if (isset ($_GET['step'])) {
  4. define ('STEP', $_GET['step']);
  5. } else {
  6. define ('STEP', 1);
  7. }
  8. define ('SQL_REQ', 'CREATE TABLE IF NOT EXISTS `category` (
  9. `id` varchar(6) NOT NULL,
  10. `name` varchar(255) NOT NULL,
  11. `color` varchar(7) NOT NULL,
  12. PRIMARY KEY (`id`)
  13. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  14. CREATE TABLE IF NOT EXISTS `entry` (
  15. `id` varchar(6) NOT NULL,
  16. `guid` text NOT NULL,
  17. `title` varchar(255) NOT NULL,
  18. `author` varchar(255) NOT NULL,
  19. `content` text NOT NULL,
  20. `link` text NOT NULL,
  21. `date` int(11) NOT NULL,
  22. `is_read` int(11) NOT NULL,
  23. `is_favorite` int(11) NOT NULL,
  24. `is_public` int(1) NOT NULL,
  25. `id_feed` varchar(6) NOT NULL,
  26. `annotation` text NOT NULL,
  27. `tags` text NOT NULL,
  28. `lastUpdate` int(11) NOT NULL,
  29. PRIMARY KEY (`id`),
  30. KEY `id_feed` (`id_feed`)
  31. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  32. CREATE TABLE IF NOT EXISTS `feed` (
  33. `id` varchar(6) NOT NULL,
  34. `url` text NOT NULL,
  35. `category` varchar(6) DEFAULT \'000000\',
  36. `name` varchar(255) NOT NULL,
  37. `website` text NOT NULL,
  38. `description` text NOT NULL,
  39. `lastUpdate` int(11) NOT NULL,
  40. `priority` int(2) NOT NULL DEFAULT \'10\',
  41. `pathEntries` varchar(500) DEFAULT NULL,
  42. `httpAuth` varchar(500) DEFAULT NULL,
  43. `error` int(1) NOT NULL DEFAULT \'0\',
  44. PRIMARY KEY (`id`),
  45. KEY `category` (`category`)
  46. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  47. ALTER TABLE `entry`
  48. ADD CONSTRAINT `entry_ibfk_1` FOREIGN KEY (`id_feed`) REFERENCES `feed` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  49. ALTER TABLE `feed`
  50. ADD CONSTRAINT `feed_ibfk_4` FOREIGN KEY (`category`) REFERENCES `category` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;');
  51. function writeLine ($f, $line) {
  52. fwrite ($f, $line . "\n");
  53. }
  54. function writeArray ($f, $array) {
  55. foreach ($array as $key => $val) {
  56. if (is_array ($val)) {
  57. writeLine ($f, '\'' . $key . '\' => array (');
  58. writeArray ($f, $val);
  59. writeLine ($f, '),');
  60. } else {
  61. writeLine ($f, '\'' . $key . '\' => \'' . $val . '\',');
  62. }
  63. }
  64. }
  65. // gestion internationalisation
  66. $translates = array ();
  67. $actual = 'en';
  68. function initTranslate () {
  69. global $translates;
  70. global $actual;
  71. $l = getBetterLanguage ('en');
  72. if (isset ($_SESSION['language'])) {
  73. $l = $_SESSION['language'];
  74. }
  75. $actual = $l;
  76. $file = APP_PATH . '/i18n/' . $actual . '.php';
  77. if (file_exists ($file)) {
  78. $translates = include ($file);
  79. }
  80. }
  81. function getBetterLanguage ($fallback) {
  82. $available = availableLanguages ();
  83. $accept = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  84. $language = strtolower (substr ($accept, 0, 2));
  85. if (isset ($available[$language])) {
  86. return $language;
  87. } else {
  88. return $fallback;
  89. }
  90. }
  91. function availableLanguages () {
  92. return array (
  93. 'en' => 'English',
  94. 'fr' => 'Français'
  95. );
  96. }
  97. function _t ($key) {
  98. global $translates;
  99. $translate = $key;
  100. if (isset ($translates[$key])) {
  101. $translate = $translates[$key];
  102. }
  103. $args = func_get_args ();
  104. unset($args[0]);
  105. return vsprintf ($translate, $args);
  106. }
  107. /*** SAUVEGARDES ***/
  108. function saveLanguage () {
  109. if (!empty ($_POST)) {
  110. if (!isset ($_POST['language'])) {
  111. return false;
  112. }
  113. $_SESSION['language'] = $_POST['language'];
  114. header ('Location: index.php?step=1');
  115. }
  116. }
  117. function saveStep2 () {
  118. if (!empty ($_POST)) {
  119. if (empty ($_POST['sel']) ||
  120. empty ($_POST['title']) ||
  121. empty ($_POST['old_entries'])) {
  122. return false;
  123. }
  124. $_SESSION['sel'] = $_POST['sel'];
  125. $_SESSION['base_url'] = $_POST['base_url'];
  126. $_SESSION['title'] = $_POST['title'];
  127. $_SESSION['old_entries'] = $_POST['old_entries'];
  128. if (!is_int (intval ($_SESSION['old_entries'])) ||
  129. $_SESSION['old_entries'] < 1) {
  130. $_SESSION['old_entries'] = 3;
  131. }
  132. $_SESSION['mail_login'] = $_POST['mail_login'];
  133. $file_data = PUBLIC_PATH . '/data/Configuration.array.php';
  134. $f = fopen ($file_data, 'w');
  135. writeLine ($f, '<?php');
  136. writeLine ($f, 'return array (');
  137. writeArray ($f, array (
  138. 'language' => $_SESSION['language'],
  139. 'old_entries' => $_SESSION['old_entries'],
  140. 'mail_login' => $_SESSION['mail_login']
  141. ));
  142. writeLine ($f, ');');
  143. fclose ($f);
  144. header ('Location: index.php?step=3');
  145. }
  146. }
  147. function saveStep3 () {
  148. if (!empty ($_POST)) {
  149. if (empty ($_POST['host']) ||
  150. empty ($_POST['user']) ||
  151. empty ($_POST['pass']) ||
  152. empty ($_POST['base'])) {
  153. return false;
  154. }
  155. $_SESSION['bd_host'] = $_POST['host'];
  156. $_SESSION['bd_user'] = $_POST['user'];
  157. $_SESSION['bd_pass'] = $_POST['pass'];
  158. $_SESSION['bd_name'] = $_POST['base'];
  159. $file_conf = APP_PATH . '/configuration/application.ini';
  160. $f = fopen ($file_conf, 'w');
  161. writeLine ($f, '[general]');
  162. writeLine ($f, 'environment = "production"');
  163. writeLine ($f, 'use_url_rewriting = false');
  164. writeLine ($f, 'sel_application = "' . $_SESSION['sel'] . '"');
  165. writeLine ($f, 'base_url = "' . $_SESSION['base_url'] . '"');
  166. writeLine ($f, 'title = "' . $_SESSION['title'] . '"');
  167. writeLine ($f, '[db]');
  168. writeLine ($f, 'host = "' . $_SESSION['bd_host'] . '"');
  169. writeLine ($f, 'user = "' . $_SESSION['bd_user'] . '"');
  170. writeLine ($f, 'password = "' . $_SESSION['bd_pass'] . '"');
  171. writeLine ($f, 'base = "' . $_SESSION['bd_name'] . '"');
  172. fclose ($f);
  173. $res = checkBD ();
  174. if ($res) {
  175. header ('Location: index.php?step=4');
  176. }
  177. }
  178. }
  179. function deleteInstall () {
  180. $res = unlink (PUBLIC_PATH . '/install.php');
  181. if ($res) {
  182. header ('Location: index.php');
  183. }
  184. }
  185. /*** VÉRIFICATIONS ***/
  186. function checkStep () {
  187. $s0 = checkStep0 ();
  188. $s1 = checkStep1 ();
  189. $s2 = checkStep2 ();
  190. $s3 = checkStep3 ();
  191. if (STEP > 0 && $s0['all'] != 'ok') {
  192. header ('Location: index.php?step=0');
  193. } elseif (STEP > 1 && $s1['all'] != 'ok') {
  194. header ('Location: index.php?step=1');
  195. } elseif (STEP > 2 && $s2['all'] != 'ok') {
  196. header ('Location: index.php?step=2');
  197. } elseif (STEP > 3 && $s3['all'] != 'ok') {
  198. header ('Location: index.php?step=3');
  199. }
  200. }
  201. function checkStep0 () {
  202. $languages = availableLanguages ();
  203. $language = isset ($_SESSION['language']) &&
  204. isset ($languages[$_SESSION['language']]);
  205. return array (
  206. 'language' => $language ? 'ok' : 'ko',
  207. 'all' => $language ? 'ok' : 'ko'
  208. );
  209. }
  210. function checkStep1 () {
  211. $php = version_compare (PHP_VERSION, '5.1.0') >= 0;
  212. $minz = file_exists (LIB_PATH . '/minz');
  213. $curl = extension_loaded ('curl');
  214. $pdo = extension_loaded ('pdo_mysql');
  215. $cache = CACHE_PATH && is_writable (CACHE_PATH);
  216. $log = LOG_PATH && is_writable (LOG_PATH);
  217. $conf = APP_PATH && is_writable (APP_PATH . '/configuration');
  218. $data = is_writable (PUBLIC_PATH . '/data');
  219. return array (
  220. 'php' => $php ? 'ok' : 'ko',
  221. 'minz' => $minz ? 'ok' : 'ko',
  222. 'curl' => $curl ? 'ok' : 'ko',
  223. 'pdo-mysql' => $pdo ? 'ok' : 'ko',
  224. 'cache' => $cache ? 'ok' : 'ko',
  225. 'log' => $log ? 'ok' : 'ko',
  226. 'configuration' => $conf ? 'ok' : 'ko',
  227. 'data' => $data ? 'ok' : 'ko',
  228. 'all' => $php && $minz && $curl && $pdo && $cache && $log && $conf && $data ? 'ok' : 'ko'
  229. );
  230. }
  231. function checkStep2 () {
  232. $conf = isset ($_SESSION['sel']) &&
  233. isset ($_SESSION['base_url']) &&
  234. isset ($_SESSION['title']) &&
  235. isset ($_SESSION['old_entries']) &&
  236. isset ($_SESSION['mail_login']);
  237. $data = file_exists (PUBLIC_PATH . '/data/Configuration.array.php');
  238. return array (
  239. 'conf' => $conf ? 'ok' : 'ko',
  240. 'data' => $data ? 'ok' : 'ko',
  241. 'all' => $conf && $data ? 'ok' : 'ko'
  242. );
  243. }
  244. function checkStep3 () {
  245. $conf = file_exists (APP_PATH . '/configuration/application.ini');
  246. $bd = isset ($_SESSION['bd_host']) &&
  247. isset ($_SESSION['bd_user']) &&
  248. isset ($_SESSION['bd_pass']) &&
  249. isset ($_SESSION['bd_name']);
  250. return array (
  251. 'bd' => $bd ? 'ok' : 'ko',
  252. 'conf' => $conf ? 'ok' : 'ko',
  253. 'all' => $bd && $conf ? 'ok' : 'ko'
  254. );
  255. }
  256. function checkBD () {
  257. $error = false;
  258. try {
  259. $c = new PDO ('mysql:host=' . $_SESSION['bd_host'] . ';dbname=' . $_SESSION['bd_name'],
  260. $_SESSION['bd_user'],
  261. $_SESSION['bd_pass']);
  262. $res = $c->query (SQL_REQ);
  263. if (!$res) {
  264. $error = true;
  265. }
  266. } catch (PDOException $e) {
  267. $error = true;
  268. }
  269. if ($error && file_exists (APP_PATH . '/configuration/application.ini')) {
  270. unlink (APP_PATH . '/configuration/application.ini');
  271. }
  272. return !$error;
  273. }
  274. /*** AFFICHAGE ***/
  275. function printStep0 () {
  276. global $actual;
  277. ?>
  278. <?php $s0 = checkStep0 (); if ($s0['all'] == 'ok') { ?>
  279. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('language_defined'); ?></p>
  280. <?php } ?>
  281. <form action="index.php?step=0" method="post">
  282. <legend><?php echo _t ('choose_language'); ?></legend>
  283. <div class="form-group">
  284. <label class="group-name" for="language"><?php echo _t ('language'); ?></label>
  285. <div class="group-controls">
  286. <select name="language" id="language">
  287. <?php $languages = availableLanguages (); ?>
  288. <?php foreach ($languages as $short => $lib) { ?>
  289. <option value="<?php echo $short; ?>"<?php echo $actual == $short ? ' selected="selected"' : ''; ?>><?php echo $lib; ?></option>
  290. <?php } ?>
  291. </select>
  292. </div>
  293. </div>
  294. <div class="form-group form-actions">
  295. <div class="group-controls">
  296. <button type="submit" class="btn btn-important"><?php echo _t ('save'); ?></button>
  297. <button type="reset" class="btn"><?php echo _t ('cancel'); ?></button>
  298. <?php if ($s0['all'] == 'ok') { ?>
  299. <a class="btn btn-important next-step" href="?step=1"><?php echo _t ('next_step'); ?></a>
  300. <?php } ?>
  301. </div>
  302. </div>
  303. </form>
  304. <?php
  305. }
  306. function printStep1 () {
  307. $res = checkStep1 ();
  308. ?>
  309. <noscript><p class="alert alert-warn"><span class="alert-head"><?php echo _t ('attention'); ?></span> <?php echo _t ('javascript_is_better'); ?></p></noscript>
  310. <?php if ($res['php'] == 'ok') { ?>
  311. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('php_is_ok', PHP_VERSION); ?></p>
  312. <?php } else { ?>
  313. <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>
  314. <?php } ?>
  315. <?php if ($res['minz'] == 'ok') { ?>
  316. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('minz_is_ok'); ?></p>
  317. <?php } else { ?>
  318. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('minz_is_nok', LIB_PATH . '/minz'); ?></p>
  319. <?php } ?>
  320. <?php $version = curl_version(); ?>
  321. <?php if ($res['curl'] == 'ok') { ?>
  322. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('curl_is_ok', $version['version']); ?></p>
  323. <?php } else { ?>
  324. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('curl_is_nok'); ?></p>
  325. <?php } ?>
  326. <?php if ($res['pdo-mysql'] == 'ok') { ?>
  327. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('pdomysql_is_ok'); ?></p>
  328. <?php } else { ?>
  329. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('pdomysql_is_nok'); ?></p>
  330. <?php } ?>
  331. <?php if ($res['cache'] == 'ok') { ?>
  332. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('cache_is_ok'); ?></p>
  333. <?php } else { ?>
  334. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', PUBLIC_PATH . '/../cache'); ?></p>
  335. <?php } ?>
  336. <?php if ($res['log'] == 'ok') { ?>
  337. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('log_is_ok'); ?></p>
  338. <?php } else { ?>
  339. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', PUBLIC_PATH . '/../log'); ?></p>
  340. <?php } ?>
  341. <?php if ($res['configuration'] == 'ok') { ?>
  342. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('conf_is_ok'); ?></p>
  343. <?php } else { ?>
  344. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', APP_PATH . '/configuration'); ?></p>
  345. <?php } ?>
  346. <?php if ($res['data'] == 'ok') { ?>
  347. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('data_is_ok'); ?></p>
  348. <?php } else { ?>
  349. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', PUBLIC_PATH . '/data'); ?></p>
  350. <?php } ?>
  351. <?php if ($res['all'] == 'ok') { ?>
  352. <a class="btn btn-important next-step" href="?step=2"><?php echo _t ('next_step'); ?></a>
  353. <?php } else { ?>
  354. <p class="alert alert-error"><?php echo _t ('fix_errors_before'); ?></p>
  355. <?php } ?>
  356. <?php
  357. }
  358. function printStep2 () {
  359. ?>
  360. <?php $s2 = checkStep2 (); if ($s2['all'] == 'ok') { ?>
  361. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('general_conf_is_ok'); ?></p>
  362. <?php } ?>
  363. <form action="index.php?step=2" method="post">
  364. <legend><?php echo _t ('general_configuration'); ?></legend>
  365. <div class="form-group">
  366. <label class="group-name" for="sel"><?php echo _t ('random_string'); ?></label>
  367. <div class="group-controls">
  368. <input type="text" id="sel" name="sel" value="<?php echo isset ($_SESSION['sel']) ? $_SESSION['sel'] : '123~abcdefghijklmnopqrstuvwxyz~321'; ?>" /> <i class="icon i_help"></i> <?php echo _t ('change_value'); ?>
  369. </div>
  370. </div>
  371. <?php
  372. $url = substr ($_SERVER['PHP_SELF'], 0, -10);
  373. ?>
  374. <div class="form-group">
  375. <label class="group-name" for="base_url"><?php echo _t ('base_url'); ?></label>
  376. <div class="group-controls">
  377. <input type="text" id="base_url" name="base_url" value="<?php echo isset ($_SESSION['base_url']) ? $_SESSION['base_url'] : $url; ?>" /> <i class="icon i_help"></i> <?php echo _t ('do_not_change_if_doubt'); ?>
  378. </div>
  379. </div>
  380. <div class="form-group">
  381. <label class="group-name" for="title"><?php echo _t ('title'); ?></label>
  382. <div class="group-controls">
  383. <input type="text" id="title" name="title" value="<?php echo isset ($_SESSION['title']) ? $_SESSION['title'] : _t ('freshrss'); ?>" />
  384. </div>
  385. </div>
  386. <div class="form-group">
  387. <label class="group-name" for="old_entries"><?php echo _t ('delete_articles_every'); ?></label>
  388. <div class="group-controls">
  389. <input type="number" id="old_entries" name="old_entries" value="<?php echo isset ($_SESSION['old_entries']) ? $_SESSION['old_entries'] : '3'; ?>" /> <?php echo _t ('month'); ?>
  390. </div>
  391. </div>
  392. <div class="form-group">
  393. <label class="group-name" for="mail_login"><?php echo _t ('persona_connection_email'); ?></label>
  394. <div class="group-controls">
  395. <input type="email" id="mail_login" name="mail_login" value="<?php echo isset ($_SESSION['mail_login']) ? $_SESSION['mail_login'] : ''; ?>" placeholder="<?php echo _t ('blank_to_disable'); ?>" />
  396. <noscript><b><?php echo _t ('javascript_should_be_activated'); ?></b></noscript>
  397. </div>
  398. </div>
  399. <div class="form-group form-actions">
  400. <div class="group-controls">
  401. <button type="submit" class="btn btn-important"><?php echo _t ('save'); ?></button>
  402. <button type="reset" class="btn"><?php echo _t ('cancel'); ?></button>
  403. <?php if ($s2['all'] == 'ok') { ?>
  404. <a class="btn btn-important next-step" href="?step=3"><?php echo _t ('next_step'); ?></a>
  405. <?php } ?>
  406. </div>
  407. </div>
  408. </form>
  409. <?php
  410. }
  411. function printStep3 () {
  412. ?>
  413. <?php $s3 = checkStep3 (); if ($s3['all'] == 'ok') { ?>
  414. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('bdd_conf_is_ok'); ?></p>
  415. <?php } ?>
  416. <form action="index.php?step=3" method="post">
  417. <legend><?php echo _t ('bdd_configuration'); ?></legend>
  418. <div class="form-group">
  419. <label class="group-name" for="host"><?php echo _t ('host'); ?></label>
  420. <div class="group-controls">
  421. <input type="text" id="host" name="host" value="<?php echo isset ($_SESSION['bd_host']) ? $_SESSION['bd_host'] : 'localhost'; ?>" />
  422. </div>
  423. </div>
  424. <div class="form-group">
  425. <label class="group-name" for="user"><?php echo _t ('username'); ?></label>
  426. <div class="group-controls">
  427. <input type="text" id="user" name="user" value="<?php echo isset ($_SESSION['bd_user']) ? $_SESSION['bd_user'] : ''; ?>" />
  428. </div>
  429. </div>
  430. <div class="form-group">
  431. <label class="group-name" for="pass"><?php echo _t ('password'); ?></label>
  432. <div class="group-controls">
  433. <input type="password" id="pass" name="pass" value="<?php echo isset ($_SESSION['bd_pass']) ? $_SESSION['bd_pass'] : ''; ?>" />
  434. </div>
  435. </div>
  436. <div class="form-group">
  437. <label class="group-name" for="base"><?php echo _t ('bdd'); ?></label>
  438. <div class="group-controls">
  439. <input type="text" id="base" name="base" value="<?php echo isset ($_SESSION['bd_name']) ? $_SESSION['bd_name'] : ''; ?>" />
  440. </div>
  441. </div>
  442. <div class="form-group form-actions">
  443. <div class="group-controls">
  444. <button type="submit" class="btn btn-important"><?php echo _t ('save'); ?></button>
  445. <button type="reset" class="btn"><?php echo _t ('cancel'); ?></button>
  446. <?php if ($s3['all'] == 'ok') { ?>
  447. <a class="btn btn-important next-step" href="?step=4"><?php echo _t ('next_step'); ?></a>
  448. <?php } ?>
  449. </div>
  450. </div>
  451. </form>
  452. <?php
  453. }
  454. function printStep4 () {
  455. ?>
  456. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('congratulations'); ?></span> <?php echo _t ('installation_is_ok'); ?></p>
  457. <a class="btn btn-important next-step" href="?step=5"><?php echo _t ('finish_installation'); ?></a>
  458. <?php
  459. }
  460. function printStep5 () {
  461. ?>
  462. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('oops'); ?></span> <?php echo _t ('install_not_deleted', PUBLIC_PATH . '/install.php'); ?></p>
  463. <?php
  464. }
  465. initTranslate ();
  466. checkStep ();
  467. switch (STEP) {
  468. case 0:
  469. default:
  470. saveLanguage ();
  471. break;
  472. case 1:
  473. break;
  474. case 2:
  475. saveStep2 ();
  476. break;
  477. case 3:
  478. saveStep3 ();
  479. break;
  480. case 4:
  481. break;
  482. case 5:
  483. deleteInstall ();
  484. break;
  485. }
  486. ?>
  487. <!DOCTYPE html>
  488. <html lang="fr">
  489. <head>
  490. <meta charset="utf-8">
  491. <meta name="viewport" content="initial-scale=1.0">
  492. <title><?php echo _t ('freshrss_installation'); ?></title>
  493. <link rel="stylesheet" type="text/css" media="all" href="theme/fallback.css" />
  494. <link rel="stylesheet" type="text/css" media="all" href="theme/global.css" />
  495. <link rel="stylesheet" type="text/css" media="all" href="theme/freshrss.css" />
  496. </head>
  497. <body>
  498. <div class="header">
  499. <div class="item title">
  500. <h1><a href="index.php"><?php echo _t ('freshrss'); ?></a></h1>
  501. <h2><?php echo _t ('installation_step', STEP); ?></h2>
  502. </div>
  503. </div>
  504. <div id="global">
  505. <ul class="nav nav-list aside">
  506. <li class="nav-header"><?php echo _t ('steps'); ?></li>
  507. <li class="item<?php echo STEP == 0 ? ' active' : ''; ?>"><a href="?step=0"><?php echo _t ('language'); ?></a></li>
  508. <li class="item<?php echo STEP == 1 ? ' active' : ''; ?>"><a href="?step=1"><?php echo _t ('checks'); ?></a></li>
  509. <li class="item<?php echo STEP == 2 ? ' active' : ''; ?>"><a href="?step=2"><?php echo _t ('general_configuration'); ?></a></li>
  510. <li class="item<?php echo STEP == 3 ? ' active' : ''; ?>"><a href="?step=3"><?php echo _t ('bdd_configuration'); ?></a></li>
  511. <li class="item<?php echo STEP == 4 ? ' active' : ''; ?>"><a href="?step=4"><?php echo _t ('this_is_the_end'); ?></a></li>
  512. </ul>
  513. <div class="post">
  514. <?php
  515. switch (STEP) {
  516. case 0:
  517. default:
  518. printStep0 ();
  519. break;
  520. case 1:
  521. printStep1 ();
  522. break;
  523. case 2:
  524. printStep2 ();
  525. break;
  526. case 3:
  527. printStep3 ();
  528. break;
  529. case 4:
  530. printStep4 ();
  531. break;
  532. case 5:
  533. printStep5 ();
  534. break;
  535. }
  536. ?>
  537. </div>
  538. </div>
  539. </body>
  540. </html>