install.php 21 KB

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