SHOW:
|
|
- or go back to the newest paste.
| 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 | if(isset($_GET['gallery'])) {
| |
| 15 | $gallery = $_GET['gallery']; | |
| 16 | } else {
| |
| 17 | $gallery = $default_gallery; | |
| 18 | } | |
| 19 | ||
| 20 | include("header.php");
| |
| 21 | ||
| 22 | switch($page) {
| |
| 23 | case "gallery": | |
| 24 | $gallery_path = "{$galleries_base_dir}/{$gallery}.php";
| |
| 25 | - | if(file_exists($gallery_path)) {
|
| 25 | + | include(get_page_to_load($gallery_path, "{$galleries_base_dir}/{$default_gallery}.php");
|
| 26 | - | include($gallery_path); |
| 26 | + | |
| 27 | - | } else {
|
| 27 | + | |
| 28 | - | include("{$galleries_base_dir}/{$default_gallery}.php");
|
| 28 | + | |
| 29 | - | } |
| 29 | + | include(get_page_to_load($page_path, "{$pages_base_dir}/{$default_page}.php"));
|
| 30 | break; | |
| 31 | } | |
| 32 | ||
| 33 | - | if(file_exists($page_path)) {
|
| 33 | + | |
| 34 | - | include($page_path); |
| 34 | + | |
| 35 | - | } else {
|
| 35 | + | |
| 36 | - | include("{$pages_base_dir}/{$default_page}.php");
|
| 36 | + | function get_page_to_load($attempted_page, $default_page) {
|
| 37 | - | } |
| 37 | + | if(file_exists($attempted_page)) {
|
| 38 | return $attempted_page; | |
| 39 | } else {
| |
| 40 | return $default_page; | |
| 41 | } | |
| 42 | } | |
| 43 | ||
| 44 | ?> |