error.php 5.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. // Include functions if not already included
  3. require_once('functions.php');
  4. // Upgrade environment
  5. upgradeCheck();
  6. // Lazyload settings
  7. $databaseConfig = configLazy('config/config.php');
  8. // Load USER
  9. require_once("user.php");
  10. $USER = new User("registration_callback");
  11. if(isset($_GET['error']) && $_GET['error'] !== '404'){
  12. $status = (isset($_GET['error'])?$_GET['error']:404);
  13. setcookie('lec', $status, time() + (5), "/", DOMAIN);
  14. http_response_code($status);
  15. header('Location: '.$_SERVER['PHP_SELF']);
  16. exit();
  17. }
  18. if(!isset($_COOKIE['lec'])) {
  19. $status = '404';
  20. } else {
  21. $status = $_COOKIE['lec'];
  22. }
  23. // Create Database Connection
  24. $file_db = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
  25. $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  26. // Some PHP config stuff
  27. ini_set("display_errors", 1);
  28. ini_set("error_reporting", E_ALL | E_STRICT);
  29. //Color stuff
  30. foreach(loadAppearance() as $key => $value) {
  31. $$key = $value;
  32. }
  33. //error stuff
  34. $requested = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
  35. $codes = array(
  36. 400 => array('Bad Request', 'The server cannot or will not process the request due to an apparent client error.', 'sowwy'),
  37. 401 => array('Unauthorized', 'You do not have access to this page.', 'sowwy'),
  38. 403 => array('Forbidden', 'The server has refused to fulfill your request.', 'sowwy'),
  39. 404 => array('Not Found', $requested . ' was not found on this server.', 'confused'),
  40. 405 => array('Method Not Allowed', 'The method specified in the Request-Line is not allowed for the specified resource.', 'confused'),
  41. 408 => array('Request Timeout', 'Your browser failed to send a request in the time allowed by the server.', 'sowwy'),
  42. 500 => array('Internal Server Error', 'The request was unsuccessful due to an unexpected condition encountered by the server.', 'confused'),
  43. 502 => array('Bad Gateway', 'The server received an invalid response from the upstream server while trying to fulfill the request.', 'confused'),
  44. 503 => array('Service Unavailable', 'The server is currently unavailable (because it is overloaded or down for maintenance).', 'confused'),
  45. 504 => array('Gateway Timeout', 'The upstream server failed to send a request in the time allowed by the server.', 'confused'),
  46. 999 => array('Not Logged In', 'You need to be logged in to access this page.', 'confused'),
  47. );
  48. $errorTitle = ($codes[$status][0]) ? $codes[$status][0] : "Error";
  49. $message = ($codes[$status][1]) ? $codes[$status][1] : "An Error Occured";
  50. $errorImage = ($codes[$status][2]) ? $codes[$status][2] : "confused";
  51. ?>
  52. <!DOCTYPE html>
  53. <html lang="en" class="no-js">
  54. <head>
  55. <meta charset="UTF-8">
  56. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  57. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  58. <meta name="msapplication-tap-highlight" content="no" />
  59. <title><?=$errorTitle;?></title>
  60. <link rel="stylesheet" href="<?php echo checkRootPath(dirname($_SERVER['SCRIPT_NAME'])); ?>bower_components/font-awesome/css/font-awesome.min.css?v=<?php echo INSTALLEDVERSION; ?>">
  61. <link rel="stylesheet" href="<?php echo checkRootPath(dirname($_SERVER['SCRIPT_NAME'])); ?>bower_components/bootstrap/dist/css/bootstrap.min.css?v=<?php echo INSTALLEDVERSION; ?>">
  62. <link rel="stylesheet" href="<?php echo checkRootPath(dirname($_SERVER['SCRIPT_NAME'])); ?>bower_components/Waves/dist/waves.min.css">
  63. <link rel="stylesheet" href="<?php echo checkRootPath(dirname($_SERVER['SCRIPT_NAME'])); ?>css/style.css?v=<?php echo INSTALLEDVERSION; ?>">
  64. <style><?php customCSS(); ?></style>
  65. </head>
  66. <body id="body-error" class="gray-bg" style="padding: 0;">
  67. <div class="main-wrapper" style="position: initial;">
  68. <div style="margin:0 20px; overflow:hidden">
  69. <div class="table-wrapper" style="background:<?=$sidebar;?>;">
  70. <div class="table-row">
  71. <div class="table-cell text-center">
  72. <div class="pagenotfound i-block">
  73. <div class="content-box">
  74. <div class="top" style="background:<?=$topbar;?>;">
  75. <h1 class="zero-m" style="color:<?=$topbartext;?>;"><?=$status;?></h1>
  76. <a href="#" onclick="parent.location='../'" class="fa-stack fa-2x icon-back">
  77. <i class="fa fa-circle fa-stack-2x" style="color:<?=$topbartext;?>;"></i>
  78. <i class="fa fa-long-arrow-left fa-stack-1x fa-inverse" style="color:<?=$topbar;?>;"></i>
  79. </a>
  80. </div>
  81. <div class="big-box">
  82. <h4 style="color: <?=$topbar;?>;"><?=$errorTitle;?></h4>
  83. <p style="color: <?=$topbar;?>;"><?php echo $message;?></p>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </body>
  93. </html>