Error_Page.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. require_once($path["page"] . "Page.php");
  3. require_once($path["helper"] . "text.php");
  4. /**
  5. * Error page model.
  6. */
  7. class Error_Page extends Page{
  8. public $code = "";
  9. public $error_description = "";
  10. public $advice = "";
  11. public $solution = [];
  12. /**
  13. * Constructor.
  14. *
  15. * Retrieves the data and initializes the page.
  16. *
  17. * @param MySQL_connection $db Connection to the database.
  18. * @param string $lang Lowercase, two-letter language code.
  19. */
  20. public function __construct($db, $lang){
  21. global $path;
  22. global $base_url;
  23. parent::__construct($db, $lang);
  24. $this->view = $path["view"] . "error.php";
  25. $this->code = http_response_code();
  26. if (in_array($this->code, array(400, 401, 403, 404, 500))){
  27. $err = $this->code;
  28. }
  29. else{
  30. $err = "XXX";
  31. }
  32. $this->error_description = text($this, "ERROR_" . $err . "_DESCRIPTION");
  33. $this->advice = text($this, "ERROR_" . $err . "_SOLUTION");
  34. array_push($this->solution, text($this, "ERROR_" . $err . "_SOLUTION_0"));
  35. array_push($this->solution, text($this, "ERROR_" . $err . "_SOLUTION_1"));
  36. array_push($this->solution, text($this, "ERROR_" . $err . "_SOLUTION_2"));
  37. $this->title = text($this, "ERROR_TITLE") . " " . $this->code . " - " . text($this, "USER_NAME");
  38. $this->description = text($this, "ERROR_TITLE") . " " . $this->code . " - " . text($this, "USER_NAME");
  39. }
  40. }
  41. ?>