index.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. declare(strict_types=1);
  3. // > Error: FreshRSS requires PHP, which does not seem to be installed or configured correctly! <!--
  4. # ***** BEGIN LICENSE BLOCK *****
  5. # MINZ - A free PHP framework
  6. # Copyright (C) 2011 Marien Fressinaud
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU Affero General Public License as
  10. # published by the Free Software Foundation, either version 3 of the
  11. # License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU Affero General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Affero General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. require dirname(__DIR__, 2) . '/constants.php';
  23. require LIB_PATH . '/lib_rss.php'; //Includes class autoloader
  24. $migrations_path = APP_PATH . '/migrations';
  25. $applied_migrations_path = DATA_PATH . '/applied_migrations.txt';
  26. if (!file_exists($applied_migrations_path)) {
  27. require APP_PATH . '/install.php';
  28. } else {
  29. session_cache_limiter('');
  30. Minz_Session::init('FreshRSS');
  31. Minz_Session::_param('keepAlive', 1); //To prevent the PHP session from expiring
  32. require LIB_PATH . '/http-conditional.php';
  33. $currentUser = Minz_User::name();
  34. $dateLastModification = $currentUser === null ? time() : max(
  35. FreshRSS_UserDAO::ctime($currentUser),
  36. FreshRSS_UserDAO::mtime($currentUser),
  37. @filemtime(DATA_PATH . '/config.php') ?: 0
  38. );
  39. if (!file_exists(DATA_PATH . '/no-cache.txt')
  40. && httpConditional($dateLastModification ?: time(), 0, 0, false, PHP_COMPRESSION, true)) {
  41. exit(); //No need to send anything
  42. }
  43. $error = false;
  44. try {
  45. // Apply the migrations if any
  46. $result = Minz_Migrator::execute($migrations_path, $applied_migrations_path);
  47. if ($result === true) {
  48. FreshRSS_Context::initSystem();
  49. $front_controller = new FreshRSS();
  50. $front_controller->init();
  51. $front_controller->run();
  52. } else {
  53. $error = $result;
  54. }
  55. } catch (Exception $e) {
  56. $error = $e->getMessage();
  57. }
  58. if ($error !== false) {
  59. syslog(LOG_INFO, 'FreshRSS Fatal error! ' . $error);
  60. FreshRSS::killApp($error);
  61. }
  62. }