install.php 22 KB

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