install.php 22 KB

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