index.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. // > Error: FreshRSS requires PHP, which does not seem to be installed or configured correctly! <!--
  3. # ***** BEGIN LICENSE BLOCK *****
  4. # MINZ - A free PHP framework
  5. # Copyright (C) 2011 Marien Fressinaud
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. # ***** END LICENSE BLOCK *****
  21. require(__DIR__ . '/../../constants.php');
  22. require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
  23. if (file_exists(DATA_PATH . '/do-install.txt')) {
  24. require(APP_PATH . '/install.php');
  25. } else {
  26. session_cache_limiter('');
  27. if (!file_exists(DATA_PATH . '/no-cache.txt')) {
  28. require(LIB_PATH . '/http-conditional.php');
  29. $currentUser = Minz_Session::param('currentUser', '');
  30. $dateLastModification = $currentUser === '' ? time() : max(
  31. @filemtime(join_path(USERS_PATH, $currentUser, 'log.txt')),
  32. @filemtime(join_path(DATA_PATH, 'config.php'))
  33. );
  34. if (httpConditional($dateLastModification, 0, 0, false, PHP_COMPRESSION, true)) {
  35. Minz_Session::init('FreshRSS');
  36. Minz_Session::_param('keepAlive', 1); //To prevent the PHP session from expiring
  37. exit(); //No need to send anything
  38. }
  39. }
  40. $migrations_path = APP_PATH . '/migrations';
  41. $applied_migrations_path = DATA_PATH . '/applied_migrations.txt';
  42. // The next line is temporary: the migrate method expects the applied_migrations.txt
  43. // file to exist. This is because the install script creates this file, so
  44. // if it is missing, it means the application is not installed. But we
  45. // should also take care of applications installed before the new
  46. // migrations system (<=1.16). Indeed, they are installed but the migrations
  47. // version file doesn't exist. So for now (1.17), we continue to check if the
  48. // application is installed with the do-install.txt file: if yes, we create
  49. // the version file. Starting from version 1.18, all the installed systems
  50. // will have the file and so we will be able to remove this temporary line
  51. // and stop using the do-install.txt file to check if FRSS is already
  52. // installed.
  53. touch($applied_migrations_path);
  54. $error = false;
  55. try {
  56. // Apply the migrations if any
  57. $result = Minz_Migrator::execute($migrations_path, $applied_migrations_path);
  58. if ($result === true) {
  59. $front_controller = new FreshRSS();
  60. $front_controller->init();
  61. Minz_Session::_param('keepAlive', 1); //To prevent the PHP session from expiring
  62. $front_controller->run();
  63. } else {
  64. $error = $result;
  65. }
  66. } catch (Exception $e) {
  67. $error = $e->getMessage();
  68. }
  69. if ($error) {
  70. // TODO this should be definitely improved to display a nicer error
  71. // page to the users (especially non administrators).
  72. echo '### Fatal error! ###<br />', "\n";
  73. Minz_Log::error($error);
  74. echo 'See logs files.';
  75. syslog(LOG_INFO, 'FreshRSS Fatal error! ' . $error);
  76. }
  77. }