Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * [loadPage determines what page should be loaded]
- * @return [string]
- */
- function loadPage()
- {
- global $_GET;
- //Verify that the data about the site actually exists.
- if (!isset($_GET['side']))
- {
- return 'page_default';
- }
- //I hate using get-variables, store in variable
- $userSuppliedPage = $_GET['side'];
- //Verify that the page is allowed, do this by comparing it to an array with allowed pages.
- $allowedPages = array('side1', 'side2', 'side3', 'side4');
- if (!in_array($userSuppliedPage, $allowedPages))
- {
- //User tried to navigate to a webpage that ain't allowed, give 404-error.
- return 'errors/404';
- }
- //Verify that the page actually exists.
- if (!file_exists('pagefiles/' . $userSuppliedPage . '.php'))
- {
- //File doens't exist. Give a 404-error.
- return 'errors/404';
- }
- //File exists and is valid. Security check is OK.
- return $userSuppliedPage;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment