mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-01-18 10:17:57 -05:00
* Minz allow parallel sessions #fix https://github.com/FreshRSS/FreshRSS/issues/3093 * Array optimisation * Array optimisation missing * Reduce direct access to $_SESSION except in install process * Fix session start headers warning * Use cookie only the first time the session is started: `PHP Warning: session_start(): Cannot start session when headers already sent in /var/www/FreshRSS/lib/Minz/Session.php on line 39` * New concept of volatile session for API calls Optimisation: do not use cookies or local storage at all for API calls without a Web session Fix warning: ``` PHP Warning: session_destroy(): Trying to destroy uninitialized session in Unknown on line 0 ``` * Only call Minz_Session::init once in our index It was called twice (once indirectly via FreshRSS->init()) * Whitespace * Mutex for notifications Implement mutex for notifications https://github.com/FreshRSS/FreshRSS/pull/3208#discussion_r499509809 * Typo * Install script is not ready for using Minz_Session
86 lines
3.3 KiB
PHP
Executable File
86 lines
3.3 KiB
PHP
Executable File
<?php
|
|
// > Error: FreshRSS requires PHP, which does not seem to be installed or configured correctly! <!--
|
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
|
# MINZ - A free PHP framework
|
|
# Copyright (C) 2011 Marien Fressinaud
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# ***** END LICENSE BLOCK *****
|
|
|
|
require(__DIR__ . '/../../constants.php');
|
|
require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
|
|
|
|
if (file_exists(DATA_PATH . '/do-install.txt')) {
|
|
require(APP_PATH . '/install.php');
|
|
} else {
|
|
session_cache_limiter('');
|
|
|
|
if (!file_exists(DATA_PATH . '/no-cache.txt')) {
|
|
require(LIB_PATH . '/http-conditional.php');
|
|
$currentUser = Minz_Session::param('currentUser', '');
|
|
$dateLastModification = $currentUser === '' ? time() : max(
|
|
@filemtime(join_path(USERS_PATH, $currentUser, 'log.txt')),
|
|
@filemtime(join_path(DATA_PATH, 'config.php'))
|
|
);
|
|
if (httpConditional($dateLastModification, 0, 0, false, PHP_COMPRESSION, true)) {
|
|
Minz_Session::init('FreshRSS');
|
|
Minz_Session::_param('keepAlive', 1); //To prevent the PHP session from expiring
|
|
exit(); //No need to send anything
|
|
}
|
|
}
|
|
|
|
$migrations_path = APP_PATH . '/migrations';
|
|
$applied_migrations_path = DATA_PATH . '/applied_migrations.txt';
|
|
|
|
// The next line is temporary: the migrate method expects the applied_migrations.txt
|
|
// file to exist. This is because the install script creates this file, so
|
|
// if it is missing, it means the application is not installed. But we
|
|
// should also take care of applications installed before the new
|
|
// migrations system (<=1.16). Indeed, they are installed but the migrations
|
|
// version file doesn't exist. So for now (1.17), we continue to check if the
|
|
// application is installed with the do-install.txt file: if yes, we create
|
|
// the version file. Starting from version 1.18, all the installed systems
|
|
// will have the file and so we will be able to remove this temporary line
|
|
// and stop using the do-install.txt file to check if FRSS is already
|
|
// installed.
|
|
touch($applied_migrations_path);
|
|
|
|
$error = false;
|
|
try {
|
|
// Apply the migrations if any
|
|
$result = Minz_Migrator::execute($migrations_path, $applied_migrations_path);
|
|
if ($result === true) {
|
|
$front_controller = new FreshRSS();
|
|
$front_controller->init();
|
|
Minz_Session::_param('keepAlive', 1); //To prevent the PHP session from expiring
|
|
$front_controller->run();
|
|
} else {
|
|
$error = $result;
|
|
}
|
|
} catch (Exception $e) {
|
|
$error = $e->getMessage();
|
|
}
|
|
|
|
if ($error) {
|
|
// TODO this should be definitely improved to display a nicer error
|
|
// page to the users (especially non administrators).
|
|
echo '### Fatal error! ###<br />', "\n";
|
|
Minz_Log::error($error);
|
|
echo 'See logs files.';
|
|
syslog(LOG_INFO, 'FreshRSS Fatal error! ' . $error);
|
|
}
|
|
}
|