install.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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['base'])) {
  152. $_SESSION['bd_error'] = true;
  153. }
  154. $_SESSION['bd_host'] = $_POST['host'];
  155. $_SESSION['bd_user'] = $_POST['user'];
  156. $_SESSION['bd_pass'] = $_POST['pass'];
  157. $_SESSION['bd_name'] = $_POST['base'];
  158. $file_conf = APP_PATH . '/configuration/application.ini';
  159. $f = fopen ($file_conf, 'w');
  160. writeLine ($f, '[general]');
  161. writeLine ($f, 'environment = "production"');
  162. writeLine ($f, 'use_url_rewriting = false');
  163. writeLine ($f, 'sel_application = "' . $_SESSION['sel'] . '"');
  164. writeLine ($f, 'base_url = "' . $_SESSION['base_url'] . '"');
  165. writeLine ($f, 'title = "' . $_SESSION['title'] . '"');
  166. writeLine ($f, '[db]');
  167. writeLine ($f, 'host = "' . $_SESSION['bd_host'] . '"');
  168. writeLine ($f, 'user = "' . $_SESSION['bd_user'] . '"');
  169. writeLine ($f, 'password = "' . $_SESSION['bd_pass'] . '"');
  170. writeLine ($f, 'base = "' . $_SESSION['bd_name'] . '"');
  171. fclose ($f);
  172. $res = checkBD ();
  173. if ($res) {
  174. $_SESSION['bd_error'] = false;
  175. header ('Location: index.php?step=4');
  176. } else {
  177. $_SESSION['bd_error'] = true;
  178. }
  179. }
  180. }
  181. function deleteInstall () {
  182. $res = unlink (PUBLIC_PATH . '/install.php');
  183. if ($res) {
  184. header ('Location: index.php');
  185. }
  186. }
  187. /*** VÉRIFICATIONS ***/
  188. function checkStep () {
  189. $s0 = checkStep0 ();
  190. $s1 = checkStep1 ();
  191. $s2 = checkStep2 ();
  192. $s3 = checkStep3 ();
  193. if (STEP > 0 && $s0['all'] != 'ok') {
  194. header ('Location: index.php?step=0');
  195. } elseif (STEP > 1 && $s1['all'] != 'ok') {
  196. header ('Location: index.php?step=1');
  197. } elseif (STEP > 2 && $s2['all'] != 'ok') {
  198. header ('Location: index.php?step=2');
  199. } elseif (STEP > 3 && $s3['all'] != 'ok') {
  200. header ('Location: index.php?step=3');
  201. }
  202. }
  203. function checkStep0 () {
  204. $languages = availableLanguages ();
  205. $language = isset ($_SESSION['language']) &&
  206. isset ($languages[$_SESSION['language']]);
  207. return array (
  208. 'language' => $language ? 'ok' : 'ko',
  209. 'all' => $language ? 'ok' : 'ko'
  210. );
  211. }
  212. function checkStep1 () {
  213. $php = version_compare (PHP_VERSION, '5.1.0') >= 0;
  214. $minz = file_exists (LIB_PATH . '/minz');
  215. $curl = extension_loaded ('curl');
  216. $pdo = extension_loaded ('pdo_mysql');
  217. $cache = CACHE_PATH && is_writable (CACHE_PATH);
  218. $log = LOG_PATH && is_writable (LOG_PATH);
  219. $conf = APP_PATH && is_writable (APP_PATH . '/configuration');
  220. $data = is_writable (PUBLIC_PATH . '/data');
  221. return array (
  222. 'php' => $php ? 'ok' : 'ko',
  223. 'minz' => $minz ? 'ok' : 'ko',
  224. 'curl' => $curl ? 'ok' : 'ko',
  225. 'pdo-mysql' => $pdo ? 'ok' : 'ko',
  226. 'cache' => $cache ? 'ok' : 'ko',
  227. 'log' => $log ? 'ok' : 'ko',
  228. 'configuration' => $conf ? 'ok' : 'ko',
  229. 'data' => $data ? 'ok' : 'ko',
  230. 'all' => $php && $minz && $curl && $pdo && $cache && $log && $conf && $data ? 'ok' : 'ko'
  231. );
  232. }
  233. function checkStep2 () {
  234. $conf = isset ($_SESSION['sel']) &&
  235. isset ($_SESSION['base_url']) &&
  236. isset ($_SESSION['title']) &&
  237. isset ($_SESSION['old_entries']) &&
  238. isset ($_SESSION['mail_login']);
  239. $data = file_exists (PUBLIC_PATH . '/data/Configuration.array.php');
  240. return array (
  241. 'conf' => $conf ? 'ok' : 'ko',
  242. 'data' => $data ? 'ok' : 'ko',
  243. 'all' => $conf && $data ? 'ok' : 'ko'
  244. );
  245. }
  246. function checkStep3 () {
  247. $conf = file_exists (APP_PATH . '/configuration/application.ini');
  248. $bd = isset ($_SESSION['bd_host']) &&
  249. isset ($_SESSION['bd_user']) &&
  250. isset ($_SESSION['bd_pass']) &&
  251. isset ($_SESSION['bd_name']);
  252. $conn = !isset ($_SESSION['bd_error']) || !$_SESSION['bd_error'];
  253. return array (
  254. 'bd' => $bd ? 'ok' : 'ko',
  255. 'conn' => $conn ? 'ok' : 'ko',
  256. 'conf' => $conf ? 'ok' : 'ko',
  257. 'all' => $bd && $conn && $conf ? 'ok' : 'ko'
  258. );
  259. }
  260. function checkBD () {
  261. $error = false;
  262. try {
  263. $c = new PDO ('mysql:host=' . $_SESSION['bd_host'] . ';dbname=' . $_SESSION['bd_name'],
  264. $_SESSION['bd_user'],
  265. $_SESSION['bd_pass']);
  266. $res = $c->query (SQL_REQ);
  267. if (!$res) {
  268. $error = true;
  269. }
  270. } catch (PDOException $e) {
  271. $error = true;
  272. }
  273. if ($error && file_exists (APP_PATH . '/configuration/application.ini')) {
  274. unlink (APP_PATH . '/configuration/application.ini');
  275. }
  276. return !$error;
  277. }
  278. /*** AFFICHAGE ***/
  279. function printStep0 () {
  280. global $actual;
  281. ?>
  282. <?php $s0 = checkStep0 (); if ($s0['all'] == 'ok') { ?>
  283. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('language_defined'); ?></p>
  284. <?php } ?>
  285. <form action="index.php?step=0" method="post">
  286. <legend><?php echo _t ('choose_language'); ?></legend>
  287. <div class="form-group">
  288. <label class="group-name" for="language"><?php echo _t ('language'); ?></label>
  289. <div class="group-controls">
  290. <select name="language" id="language">
  291. <?php $languages = availableLanguages (); ?>
  292. <?php foreach ($languages as $short => $lib) { ?>
  293. <option value="<?php echo $short; ?>"<?php echo $actual == $short ? ' selected="selected"' : ''; ?>><?php echo $lib; ?></option>
  294. <?php } ?>
  295. </select>
  296. </div>
  297. </div>
  298. <div class="form-group form-actions">
  299. <div class="group-controls">
  300. <button type="submit" class="btn btn-important"><?php echo _t ('save'); ?></button>
  301. <button type="reset" class="btn"><?php echo _t ('cancel'); ?></button>
  302. <?php if ($s0['all'] == 'ok') { ?>
  303. <a class="btn btn-important next-step" href="?step=1"><?php echo _t ('next_step'); ?></a>
  304. <?php } ?>
  305. </div>
  306. </div>
  307. </form>
  308. <?php
  309. }
  310. function printStep1 () {
  311. $res = checkStep1 ();
  312. ?>
  313. <noscript><p class="alert alert-warn"><span class="alert-head"><?php echo _t ('attention'); ?></span> <?php echo _t ('javascript_is_better'); ?></p></noscript>
  314. <?php if ($res['php'] == 'ok') { ?>
  315. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('php_is_ok', PHP_VERSION); ?></p>
  316. <?php } else { ?>
  317. <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>
  318. <?php } ?>
  319. <?php if ($res['minz'] == 'ok') { ?>
  320. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('minz_is_ok'); ?></p>
  321. <?php } else { ?>
  322. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('minz_is_nok', LIB_PATH . '/minz'); ?></p>
  323. <?php } ?>
  324. <?php if ($res['curl'] == 'ok') { ?>
  325. <?php $version = curl_version(); ?>
  326. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('curl_is_ok', $version['version']); ?></p>
  327. <?php } else { ?>
  328. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('curl_is_nok'); ?></p>
  329. <?php } ?>
  330. <?php if ($res['pdo-mysql'] == 'ok') { ?>
  331. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('pdomysql_is_ok'); ?></p>
  332. <?php } else { ?>
  333. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('pdomysql_is_nok'); ?></p>
  334. <?php } ?>
  335. <?php if ($res['cache'] == 'ok') { ?>
  336. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('cache_is_ok'); ?></p>
  337. <?php } else { ?>
  338. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', PUBLIC_PATH . '/../cache'); ?></p>
  339. <?php } ?>
  340. <?php if ($res['log'] == 'ok') { ?>
  341. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('log_is_ok'); ?></p>
  342. <?php } else { ?>
  343. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', PUBLIC_PATH . '/../log'); ?></p>
  344. <?php } ?>
  345. <?php if ($res['configuration'] == 'ok') { ?>
  346. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('conf_is_ok'); ?></p>
  347. <?php } else { ?>
  348. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', APP_PATH . '/configuration'); ?></p>
  349. <?php } ?>
  350. <?php if ($res['data'] == 'ok') { ?>
  351. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('data_is_ok'); ?></p>
  352. <?php } else { ?>
  353. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', PUBLIC_PATH . '/data'); ?></p>
  354. <?php } ?>
  355. <?php if ($res['all'] == 'ok') { ?>
  356. <a class="btn btn-important next-step" href="?step=2"><?php echo _t ('next_step'); ?></a>
  357. <?php } else { ?>
  358. <p class="alert alert-error"><?php echo _t ('fix_errors_before'); ?></p>
  359. <?php } ?>
  360. <?php
  361. }
  362. function printStep2 () {
  363. ?>
  364. <?php $s2 = checkStep2 (); if ($s2['all'] == 'ok') { ?>
  365. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('general_conf_is_ok'); ?></p>
  366. <?php } ?>
  367. <form action="index.php?step=2" method="post">
  368. <legend><?php echo _t ('general_configuration'); ?></legend>
  369. <div class="form-group">
  370. <label class="group-name" for="sel"><?php echo _t ('random_string'); ?></label>
  371. <div class="group-controls">
  372. <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'); ?>
  373. </div>
  374. </div>
  375. <?php
  376. $url = substr ($_SERVER['PHP_SELF'], 0, -10);
  377. ?>
  378. <div class="form-group">
  379. <label class="group-name" for="base_url"><?php echo _t ('base_url'); ?></label>
  380. <div class="group-controls">
  381. <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'); ?>
  382. </div>
  383. </div>
  384. <div class="form-group">
  385. <label class="group-name" for="title"><?php echo _t ('title'); ?></label>
  386. <div class="group-controls">
  387. <input type="text" id="title" name="title" value="<?php echo isset ($_SESSION['title']) ? $_SESSION['title'] : _t ('freshrss'); ?>" />
  388. </div>
  389. </div>
  390. <div class="form-group">
  391. <label class="group-name" for="old_entries"><?php echo _t ('delete_articles_every'); ?></label>
  392. <div class="group-controls">
  393. <input type="number" id="old_entries" name="old_entries" value="<?php echo isset ($_SESSION['old_entries']) ? $_SESSION['old_entries'] : '3'; ?>" /> <?php echo _t ('month'); ?>
  394. </div>
  395. </div>
  396. <div class="form-group">
  397. <label class="group-name" for="mail_login"><?php echo _t ('persona_connection_email'); ?></label>
  398. <div class="group-controls">
  399. <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'); ?>" />
  400. <noscript><b><?php echo _t ('javascript_should_be_activated'); ?></b></noscript>
  401. </div>
  402. </div>
  403. <div class="form-group form-actions">
  404. <div class="group-controls">
  405. <button type="submit" class="btn btn-important"><?php echo _t ('save'); ?></button>
  406. <button type="reset" class="btn"><?php echo _t ('cancel'); ?></button>
  407. <?php if ($s2['all'] == 'ok') { ?>
  408. <a class="btn btn-important next-step" href="?step=3"><?php echo _t ('next_step'); ?></a>
  409. <?php } ?>
  410. </div>
  411. </div>
  412. </form>
  413. <?php
  414. }
  415. function printStep3 () {
  416. ?>
  417. <?php $s3 = checkStep3 (); if ($s3['all'] == 'ok') { ?>
  418. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('bdd_conf_is_ok'); ?></p>
  419. <?php } elseif ($s3['conn'] == 'ko') { ?>
  420. <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('bdd_conf_is_ko'); ?></p>
  421. <?php } ?>
  422. <form action="index.php?step=3" method="post">
  423. <legend><?php echo _t ('bdd_configuration'); ?></legend>
  424. <div class="form-group">
  425. <label class="group-name" for="host"><?php echo _t ('host'); ?></label>
  426. <div class="group-controls">
  427. <input type="text" id="host" name="host" value="<?php echo isset ($_SESSION['bd_host']) ? $_SESSION['bd_host'] : 'localhost'; ?>" />
  428. </div>
  429. </div>
  430. <div class="form-group">
  431. <label class="group-name" for="user"><?php echo _t ('username'); ?></label>
  432. <div class="group-controls">
  433. <input type="text" id="user" name="user" value="<?php echo isset ($_SESSION['bd_user']) ? $_SESSION['bd_user'] : ''; ?>" />
  434. </div>
  435. </div>
  436. <div class="form-group">
  437. <label class="group-name" for="pass"><?php echo _t ('password'); ?></label>
  438. <div class="group-controls">
  439. <input type="password" id="pass" name="pass" value="<?php echo isset ($_SESSION['bd_pass']) ? $_SESSION['bd_pass'] : ''; ?>" />
  440. </div>
  441. </div>
  442. <div class="form-group">
  443. <label class="group-name" for="base"><?php echo _t ('bdd'); ?></label>
  444. <div class="group-controls">
  445. <input type="text" id="base" name="base" value="<?php echo isset ($_SESSION['bd_name']) ? $_SESSION['bd_name'] : ''; ?>" />
  446. </div>
  447. </div>
  448. <div class="form-group form-actions">
  449. <div class="group-controls">
  450. <button type="submit" class="btn btn-important"><?php echo _t ('save'); ?></button>
  451. <button type="reset" class="btn"><?php echo _t ('cancel'); ?></button>
  452. <?php if ($s3['all'] == 'ok') { ?>
  453. <a class="btn btn-important next-step" href="?step=4"><?php echo _t ('next_step'); ?></a>
  454. <?php } ?>
  455. </div>
  456. </div>
  457. </form>
  458. <?php
  459. }
  460. function printStep4 () {
  461. ?>
  462. <p class="alert alert-success"><span class="alert-head"><?php echo _t ('congratulations'); ?></span> <?php echo _t ('installation_is_ok'); ?></p>
  463. <a class="btn btn-important next-step" href="?step=5"><?php echo _t ('finish_installation'); ?></a>
  464. <?php
  465. }
  466. function printStep5 () {
  467. ?>
  468. <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>
  469. <?php
  470. }
  471. initTranslate ();
  472. checkStep ();
  473. switch (STEP) {
  474. case 0:
  475. default:
  476. saveLanguage ();
  477. break;
  478. case 1:
  479. break;
  480. case 2:
  481. saveStep2 ();
  482. break;
  483. case 3:
  484. saveStep3 ();
  485. break;
  486. case 4:
  487. break;
  488. case 5:
  489. deleteInstall ();
  490. break;
  491. }
  492. ?>
  493. <!DOCTYPE html>
  494. <html lang="fr">
  495. <head>
  496. <meta charset="utf-8">
  497. <meta name="viewport" content="initial-scale=1.0">
  498. <title><?php echo _t ('freshrss_installation'); ?></title>
  499. <link rel="stylesheet" type="text/css" media="all" href="theme/fallback.css" />
  500. <link rel="stylesheet" type="text/css" media="all" href="theme/global.css" />
  501. <link rel="stylesheet" type="text/css" media="all" href="theme/freshrss.css" />
  502. </head>
  503. <body>
  504. <div class="header">
  505. <div class="item title">
  506. <h1><a href="index.php"><?php echo _t ('freshrss'); ?></a></h1>
  507. <h2><?php echo _t ('installation_step', STEP); ?></h2>
  508. </div>
  509. </div>
  510. <div id="global">
  511. <ul class="nav nav-list aside">
  512. <li class="nav-header"><?php echo _t ('steps'); ?></li>
  513. <li class="item<?php echo STEP == 0 ? ' active' : ''; ?>"><a href="?step=0"><?php echo _t ('language'); ?></a></li>
  514. <li class="item<?php echo STEP == 1 ? ' active' : ''; ?>"><a href="?step=1"><?php echo _t ('checks'); ?></a></li>
  515. <li class="item<?php echo STEP == 2 ? ' active' : ''; ?>"><a href="?step=2"><?php echo _t ('general_configuration'); ?></a></li>
  516. <li class="item<?php echo STEP == 3 ? ' active' : ''; ?>"><a href="?step=3"><?php echo _t ('bdd_configuration'); ?></a></li>
  517. <li class="item<?php echo STEP == 4 ? ' active' : ''; ?>"><a href="?step=4"><?php echo _t ('this_is_the_end'); ?></a></li>
  518. </ul>
  519. <div class="post">
  520. <?php
  521. switch (STEP) {
  522. case 0:
  523. default:
  524. printStep0 ();
  525. break;
  526. case 1:
  527. printStep1 ();
  528. break;
  529. case 2:
  530. printStep2 ();
  531. break;
  532. case 3:
  533. printStep3 ();
  534. break;
  535. case 4:
  536. printStep4 ();
  537. break;
  538. case 5:
  539. printStep5 ();
  540. break;
  541. }
  542. ?>
  543. </div>
  544. </div>
  545. </body>
  546. </html>