xaviermontenegro

Untitled

Jul 16th, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $galleries_base_dir = "/path/to/galleries";
  4. $default_gallery = "default_gallery";
  5. $pages_base_dir = "/path/to/pages";
  6. $default_page = "home";
  7.  
  8. if(isset($_GET['page'])) {
  9.     $page = $_GET['page'];
  10. } else {
  11.     $page = $default_page;
  12. }
  13.  
  14. include("header.php");
  15.  
  16. switch($page) {
  17.     case "gallery":
  18.         if(isset($_GET['gallery'])) {
  19.             $gallery = $_GET['gallery'];
  20.         } else {
  21.             $gallery = $default_gallery;
  22.         }
  23.         $gallery_path = "{$galleries_base_dir}/{$gallery}.php";
  24.         include(get_page_to_load($gallery_path, "{$galleries_base_dir}/{$default_gallery}.php");
  25.     break;
  26.     default:
  27.         $page_path = "{$pages_base_dir}/{$page}.php";
  28.         include(get_page_to_load($page_path, "{$pages_base_dir}/{$default_page}.php"));
  29.     break;
  30. }
  31.  
  32.  
  33. include("footer.php");
  34.  
  35. function get_page_to_load($attempted_page, $default_page) {
  36.     if($attempted_page != $default_page && file_exists($attempted_page)) {
  37.         return $attempted_page;
  38.     } else {
  39.         return $default_page;
  40.     }
  41. }
  42.  
  43. ?>
Add Comment
Please, Sign In to add comment