Advertisement
Sparkster

Untitled

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