index.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. Minz_Session::init('FreshRSS');
  28. Minz_Session::_param('keepAlive', 1); //To prevent the PHP session from expiring
  29. if (!file_exists(DATA_PATH . '/no-cache.txt')) {
  30. require(LIB_PATH . '/http-conditional.php');
  31. $currentUser = Minz_Session::param('currentUser', '');
  32. $dateLastModification = $currentUser === '' ? time() : max(
  33. @filemtime(join_path(USERS_PATH, $currentUser, 'log.txt')),
  34. @filemtime(join_path(DATA_PATH, 'config.php'))
  35. );
  36. if (httpConditional($dateLastModification, 0, 0, false, PHP_COMPRESSION, true)) {
  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. $front_controller->run();
  62. } else {
  63. $error = $result;
  64. }
  65. } catch (Exception $e) {
  66. $error = $e->getMessage();
  67. }
  68. if ($error) {
  69. // TODO this should be definitely improved to display a nicer error
  70. // page to the users (especially non administrators).
  71. echo '### Fatal error! ###<br />', "\n";
  72. Minz_Log::error($error);
  73. echo 'See logs files.';
  74. syslog(LOG_INFO, 'FreshRSS Fatal error! ' . $error);
  75. }
  76. }