Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. <?php
  2. /*
  3. * Made by Samerton
  4. * http://worldscapemc.co.uk
  5. *
  6. * License: MIT
  7. * Copyright (c) 2016 Samerton
  8. */
  9.  
  10. // Start page load timer
  11. $start = microtime(true);
  12.  
  13. // Temp
  14. date_default_timezone_set('Europe/London');
  15.  
  16. // Definitions
  17. define('PATH', '/');
  18. define('ROOT_PATH', dirname(__FILE__));
  19. $page = 'Home';
  20.  
  21. if(!ini_get('upload_tmp_dir')){
  22. $tmp_dir = sys_get_temp_dir();
  23. } else {
  24. $tmp_dir = ini_get('upload_tmp_dir');
  25. }
  26.  
  27. ini_set('open_basedir', ROOT_PATH . PATH_SEPARATOR . $tmp_dir);
  28.  
  29. // Get the directory the user is trying to access
  30. $directory = $_SERVER['REQUEST_URI'];
  31.  
  32. $directories = explode("/", $directory);
  33. $lim = count($directories);
  34.  
  35. // Installer?
  36. if(is_file('pages/install.php')){
  37. if(isset($_GET['from']) && $_GET['from'] == 'install'){
  38. if(!unlink('pages/install.php')) die('Please delete <strong>pages/install.php</strong> before continuing.');
  39. } else {
  40. $page = 'install';
  41.  
  42. require('core/init.php');
  43. require('pages/install.php');
  44. die();
  45. }
  46. }
  47.  
  48. // Start initialising the page
  49. require('core/init.php');
  50.  
  51. // Load the main page content
  52. // Check if the page actually exists..
  53. // First, check the contents of the URL
  54. if(empty($directories[0]) && empty($directories[1])){
  55. // Must be the index page
  56. $page_path = 'pages/index.php';
  57. } else {
  58. $n = 0;
  59. foreach($directories as $directory){
  60. if(strpos($directory, '?') !== false){
  61. $params = $directory; // Get URL parameters
  62. unset($directories[$n]);
  63. }
  64. $n++;
  65. }
  66. $page_path = 'pages' . implode('/', $directories);
  67. if(substr($page_path, -1) == "/"){
  68. $page_path = rtrim($page_path, '/');
  69. }
  70. }
  71.  
  72. // Include the page
  73. if(is_file($page_path)){
  74. require($page_path);
  75. } else {
  76. if(is_file($page_path . '.php')){
  77. require($page_path . '.php');
  78. } else {
  79. if(is_dir($page_path)){
  80. if(file_exists($page_path . '/index.php')){
  81. require($page_path . '/index.php');
  82. }
  83. } else {
  84. // Profile page?
  85. if($directories[1] == 'profile'){
  86. if(isset($directories[2])) $profile = htmlspecialchars($directories[2]);
  87. require('pages/profile.php');
  88. // Kill the script
  89. die();
  90. }
  91.  
  92. // API?
  93. if($directories[1] == 'api'){
  94. if(is_file('pages' . DIRECTORY_SEPARATOR . 'api' . DIRECTORY_SEPARATOR . $directories[2] . DIRECTORY_SEPARATOR . 'index.php')){
  95. require('pages' . DIRECTORY_SEPARATOR . 'api' . DIRECTORY_SEPARATOR . $directories[2] . DIRECTORY_SEPARATOR . 'index.php');
  96. die();
  97. }
  98. }
  99.  
  100. // Custom page?
  101. $page_path = explode('/', $page_path);
  102.  
  103. $custom_pages = $queries->getWhere('custom_pages', array('url', '=', '/' . $page_path[1]));
  104.  
  105. if(count($custom_pages)){
  106. $page_title = $custom_pages[0]->title;
  107. $page_content = $custom_pages[0]->content;
  108. $page_id = $custom_pages[0]->id;
  109.  
  110. if($custom_pages[0]->redirect == 1) $redirect_page = htmlspecialchars($custom_pages[0]->link);
  111.  
  112. // For navbar
  113. $page = $custom_pages[0]->title;
  114.  
  115. // Include the page
  116. require 'pages/extra.php';
  117.  
  118. // Kill the page
  119. die();
  120. }
  121.  
  122. // Doesn't exist without trailing '/', try again with trailing '/'
  123. $custom_pages = $queries->getWhere('custom_pages', array('url', '=', '/' . $page_path[1] . '/'));
  124.  
  125. if(count($custom_pages)){
  126. $page_title = $custom_pages[0]->title;
  127. $page_content = $custom_pages[0]->content;
  128. $page_id = $custom_pages[0]->id;
  129.  
  130. if($custom_pages[0]->redirect == 1) $redirect_page = htmlspecialchars($custom_pages[0]->link);
  131.  
  132. // For navbar
  133. $page = $custom_pages[0]->title;
  134.  
  135. // Include the page
  136. require 'pages/extra.php';
  137.  
  138. // Kill the page
  139. die();
  140. }
  141.  
  142. // 404
  143. require('404.php');
  144. }
  145. }
  146. }
  147. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement