. /** * Client error action. * * @category Action * @package GNUsocial * @author Evan Prodromou * @author Zach Copley * @copyright 2008-2010 StatusNet, Inc. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ defined('GNUSOCIAL') || die(); /** * Class for displaying HTTP client errors * * @category Action * @package GNUsocial * @author Zach Copley * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ class ClientErrorAction extends ErrorAction { public static $status = [ 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed' ]; public function __construct($message = 'Error', $code = 400) { parent::__construct($message, $code); $this->default = 400; if (!$this->code || $this->code < 400 || $this->code > 499) { $this->code = $this->default; } if (!$this->message) { $this->message = "Client Error $this->code"; } } /** * To specify additional HTTP headers for the action * * @return void */ public function extraHeaders() { http_response_code($this->code); } /** * Page title. * * @return page title */ public function title() { return @self::$status[$this->code]; } }