error.php 5.4 KB

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