install.php 23 KB

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