install.php 22 KB

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