install.php 22 KB

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