mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-01-25 21:58:03 -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
85 lines
2.0 KiB
PHP
85 lines
2.0 KiB
PHP
<?php
|
|
/**
|
|
* MINZ - Copyright 2011 Marien Fressinaud
|
|
* Sous licence AGPL3 <http://www.gnu.org/licenses/>
|
|
*/
|
|
|
|
/**
|
|
* La classe Error permet de lancer des erreurs HTTP
|
|
*/
|
|
class Minz_Error {
|
|
public function __construct () { }
|
|
|
|
/**
|
|
* Permet de lancer une erreur
|
|
* @param $code le type de l'erreur, par défaut 404 (page not found)
|
|
* @param $logs logs d'erreurs découpés de la forme
|
|
* > $logs['error']
|
|
* > $logs['warning']
|
|
* > $logs['notice']
|
|
* @param $redirect indique s'il faut forcer la redirection (les logs ne seront pas transmis)
|
|
*/
|
|
public static function error ($code = 404, $logs = array (), $redirect = true) {
|
|
$logs = self::processLogs ($logs);
|
|
$error_filename = APP_PATH . '/Controllers/errorController.php';
|
|
|
|
if (file_exists ($error_filename)) {
|
|
Minz_Session::_params([
|
|
'error_code' => $code,
|
|
'error_logs' => $logs,
|
|
]);
|
|
|
|
Minz_Request::forward (array (
|
|
'c' => 'error'
|
|
), $redirect);
|
|
} else {
|
|
echo '<h1>An error occured</h1>' . "\n";
|
|
|
|
if (!empty ($logs)) {
|
|
echo '<ul>' . "\n";
|
|
foreach ($logs as $log) {
|
|
echo '<li>' . $log . '</li>' . "\n";
|
|
}
|
|
echo '</ul>' . "\n";
|
|
}
|
|
|
|
exit ();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Permet de retourner les logs de façon à n'avoir que
|
|
* ceux que l'on veut réellement
|
|
* @param $logs les logs rangés par catégories (error, warning, notice)
|
|
* @return la liste des logs, sans catégorie,
|
|
* > en fonction de l'environment
|
|
*/
|
|
private static function processLogs ($logs) {
|
|
$conf = Minz_Configuration::get('system');
|
|
$env = $conf->environment;
|
|
$logs_ok = array ();
|
|
$error = array ();
|
|
$warning = array ();
|
|
$notice = array ();
|
|
|
|
if (isset ($logs['error'])) {
|
|
$error = $logs['error'];
|
|
}
|
|
if (isset ($logs['warning'])) {
|
|
$warning = $logs['warning'];
|
|
}
|
|
if (isset ($logs['notice'])) {
|
|
$notice = $logs['notice'];
|
|
}
|
|
|
|
if ($env == 'production') {
|
|
$logs_ok = $error;
|
|
}
|
|
if ($env == 'development') {
|
|
$logs_ok = array_merge ($error, $warning, $notice);
|
|
}
|
|
|
|
return $logs_ok;
|
|
}
|
|
}
|