index.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. FreshRSS_Context::initSystem();
  60. $front_controller = new FreshRSS();
  61. $front_controller->init();
  62. Minz_Session::_param('keepAlive', 1); //To prevent the PHP session from expiring
  63. $front_controller->run();
  64. } else {
  65. $error = $result;
  66. }
  67. } catch (Exception $e) {
  68. $error = $e->getMessage();
  69. }
  70. if ($error) {
  71. Minz_Log::error($error);
  72. errorMessage('Fatal error');
  73. syslog(LOG_INFO, 'FreshRSS Fatal error! ' . $error);
  74. }
  75. }