mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2025-12-31 17:37:48 -05:00
* Fix most PHPDocs errors Contributes to https://github.com/FreshRSS/FreshRSS/issues/4103 https://phpstan.org/writing-php-code/phpdoc-types * Avoid func_get_args Use variadic syntax instead https://php.net/manual/functions.arguments#functions.variable-arg-list And avoid dynamic functions names when possible to more easily identify calls and unused functions. Contributes to https://github.com/FreshRSS/FreshRSS/issues/4103 * PHPStan level 3 * PHPStand level 4 * Update default to PHPStan level 4 * Towards level 5 * Fix level 4 regression * Towards level 5 * Pass PHPStan level 5 * Towards level 6 * Remove erronenous regression from changelog https://github.com/FreshRSS/FreshRSS/pull/4116
69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Controller to handle error page.
|
|
*/
|
|
class FreshRSS_error_Controller extends FreshRSS_ActionController {
|
|
/**
|
|
* This action is the default one for the controller.
|
|
*
|
|
* It is called by Minz_Error::error() method.
|
|
*
|
|
* Parameters are passed by Minz_Session to have a proper url:
|
|
* - error_code (default: 404)
|
|
* - error_logs (default: array())
|
|
*/
|
|
public function indexAction() {
|
|
$code_int = Minz_Session::param('error_code', 404);
|
|
$error_logs = Minz_Session::param('error_logs', array());
|
|
Minz_Session::_params([
|
|
'error_code' => false,
|
|
'error_logs' => false,
|
|
]);
|
|
|
|
switch ($code_int) {
|
|
case 200 :
|
|
header('HTTP/1.1 200 OK');
|
|
break;
|
|
case 400:
|
|
header('HTTP/1.1 400 Bad Request');
|
|
$this->view->code = 'Error 400 - Bad Request';
|
|
$this->view->errorMessage = '';
|
|
break;
|
|
case 403:
|
|
header('HTTP/1.1 403 Forbidden');
|
|
$this->view->code = 'Error 403 - Forbidden';
|
|
$this->view->errorMessage = _t('feedback.access.denied');
|
|
break;
|
|
case 404:
|
|
header('HTTP/1.1 404 Not Found');
|
|
$this->view->code = 'Error 404 - Not found';
|
|
$this->view->errorMessage = _t('feedback.access.not_found');
|
|
break;
|
|
case 405:
|
|
header('HTTP/1.1 405 Method Not Allowed');
|
|
$this->view->code = 'Error 405 - Method Not Allowed';
|
|
$this->view->errorMessage = '';
|
|
break;
|
|
case 503:
|
|
header('HTTP/1.1 503 Service Unavailable');
|
|
$this->view->code = 'Error 503 - Service Unavailable';
|
|
$this->view->errorMessage = 'Error 503 - Service Unavailable';
|
|
break;
|
|
case 500:
|
|
default:
|
|
header('HTTP/1.1 500 Internal Server Error');
|
|
$this->view->code = 'Error 500 - Internal Server Error';
|
|
$this->view->errorMessage = 'Error 500 - Internal Server Error';
|
|
break;
|
|
}
|
|
|
|
$error_message = trim(implode($error_logs));
|
|
if ($error_message !== '') {
|
|
$this->view->errorMessage = $error_message;
|
|
}
|
|
|
|
FreshRSS_View::prependTitle($this->view->code . ' · ');
|
|
}
|
|
}
|