install.php 23 KB

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