| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | include_once(dirname(__FILE__)."/plog-load-config.php"); |
|---|
| 4 | |
|---|
| 5 | global $config; |
|---|
| 6 | |
|---|
| 7 | if (!empty($_POST['comment_post_ID'])) { |
|---|
| 8 | include_once(PLOGGER_DIR.'plog-includes/plog-comment.php'); |
|---|
| 9 | } |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | if (!empty($_REQUEST['path'])) { |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | $path = join("/",array_diff(explode("/",$_SERVER['REQUEST_URI']),explode("/",$_SERVER['PHP_SELF']))); |
|---|
| 16 | $resolved_path = resolve_path($path); |
|---|
| 17 | if (is_array($resolved_path)) { |
|---|
| 18 | if (isset($resolved_path['level'])) { |
|---|
| 19 | $_GET['level'] = $resolved_path['level']; |
|---|
| 20 | } |
|---|
| 21 | if (isset($resolved_path['id'])) { |
|---|
| 22 | $_GET['id'] = $resolved_path['id']; |
|---|
| 23 | } |
|---|
| 24 | if (isset($resolved_path['plog_page'])) { |
|---|
| 25 | $_GET['plog_page'] = $resolved_path['plog_page']; |
|---|
| 26 | } |
|---|
| 27 | if (isset($resolved_path['mode'])) { |
|---|
| 28 | $_GET['mode'] = $resolved_path['mode']; |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | $parts = parse_url($_SERVER['REQUEST_URI']); |
|---|
| 33 | $path = $parts['path']; |
|---|
| 34 | } |
|---|
| 35 | } else { |
|---|
| 36 | |
|---|
| 37 | $query_args = array(); |
|---|
| 38 | $query_parts = array(); |
|---|
| 39 | $parts = parse_url($_SERVER['REQUEST_URI']); |
|---|
| 40 | if (isset($parts['query'])) { |
|---|
| 41 | parse_str($parts['query'],$query_parts); |
|---|
| 42 | } |
|---|
| 43 | $plogger_args = array("level", "id", "mode", "plog_page", "searchterms", "sortby", "sortdir"); |
|---|
| 44 | $url_args = array_keys($query_parts); |
|---|
| 45 | $diff_args = array_diff($url_args, $plogger_args); |
|---|
| 46 | foreach ($diff_args as $diff){ |
|---|
| 47 | $query_args[] = $diff."=".$query_parts[$diff]; |
|---|
| 48 | } |
|---|
| 49 | if (!empty($query_args)){ |
|---|
| 50 | $config['query_args'] = implode("&",$query_args); |
|---|
| 51 | } |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | if (isset($_GET['sortby'])) { |
|---|
| 56 | $_SESSION['plogger_sortby'] = $_GET['sortby']; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | if (isset($_GET['sortdir'])) { |
|---|
| 60 | $_SESSION['plogger_sortdir'] = $_GET['sortdir']; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | $GLOBALS['plogger_level'] = isset($_GET['level']) ? $_GET['level'] : ''; |
|---|
| 71 | $GLOBALS['plogger_id'] = isset($_GET['id']) ? intval($_GET['id']) : 0; |
|---|
| 72 | $GLOBALS['plogger_mode'] = isset($_GET['mode']) ? $_GET['mode'] : ''; |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | $active = get_active_collections_albums(); |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | if (count($active['albums']) == 1) { |
|---|
| 79 | $config['truncate_breadcrumb'] = 'album'; |
|---|
| 80 | if ($GLOBALS['plogger_level']!="picture" && $GLOBALS['plogger_level']!="404") { |
|---|
| 81 | if ($GLOBALS['plogger_level']!="search") { |
|---|
| 82 | $GLOBALS['plogger_level'] = "album"; |
|---|
| 83 | } |
|---|
| 84 | $GLOBALS['plogger_id'] = $active['albums'][0]; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | } else if (count($active['collections']) == 1) { |
|---|
| 88 | $config['truncate_breadcrumb'] = 'collection'; |
|---|
| 89 | if ($GLOBALS['plogger_level']!="album" && $GLOBALS['plogger_level']!='picture' && $GLOBALS['plogger_level']!="404") { |
|---|
| 90 | if ($GLOBALS['plogger_level']!="search") { |
|---|
| 91 | $GLOBALS['plogger_level'] = "collection"; |
|---|
| 92 | } |
|---|
| 93 | $GLOBALS['plogger_id'] = $active['collections'][0]; |
|---|
| 94 | } |
|---|
| 95 | } else { |
|---|
| 96 | $config['truncate_breadcrumb'] = false; |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | $allowed_levels = array('collections','collection','album','picture','search','404'); |
|---|
| 100 | if (!in_array($GLOBALS['plogger_level'],$allowed_levels)) { |
|---|
| 101 | $GLOBALS['plogger_level'] = 'collections'; |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | define('THEME_DIR', PLOGGER_DIR.'plog-content/themes/'.$config['theme_dir']); |
|---|
| 107 | define('THEME_URL', $config['theme_url']); |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | plogger_init(); |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | if ($GLOBALS['plogger_level'] == "404" && !headers_sent()) { |
|---|
| 114 | header( "Status: 404 Not Found" ); |
|---|
| 115 | header($_SERVER['SERVER_PROTOCOL']." 404 Not Found"); |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | function the_plogger_head() { |
|---|
| 119 | plogger_head(); |
|---|
| 120 | |
|---|
| 121 | $use_file = 'head.php'; |
|---|
| 122 | if (file_exists(THEME_DIR."/".$use_file)) { |
|---|
| 123 | include(THEME_DIR."/".$use_file); |
|---|
| 124 | } else { |
|---|
| 125 | include(PLOGGER_DIR.'plog-content/themes/default/'.$use_file); |
|---|
| 126 | } |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | function the_plogger_gallery() { |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | $use_file = "collections.php"; |
|---|
| 133 | if ($GLOBALS['plogger_level'] == "picture"){ |
|---|
| 134 | $use_file = 'picture.php'; |
|---|
| 135 | } elseif ($GLOBALS['plogger_level'] == "search"){ |
|---|
| 136 | if ($GLOBALS['plogger_mode'] == "slideshow") { |
|---|
| 137 | $use_file = 'slideshow.php'; |
|---|
| 138 | } else { |
|---|
| 139 | $use_file = 'search.php'; |
|---|
| 140 | } |
|---|
| 141 | } elseif ($GLOBALS['plogger_level'] == "album") { |
|---|
| 142 | |
|---|
| 143 | if ($GLOBALS['plogger_mode'] == "slideshow") { |
|---|
| 144 | $use_file = 'slideshow.php'; |
|---|
| 145 | } else { |
|---|
| 146 | $use_file = 'album.php'; |
|---|
| 147 | } |
|---|
| 148 | } else if ($GLOBALS['plogger_level'] == "collection") { |
|---|
| 149 | $use_file = 'collection.php'; |
|---|
| 150 | } else if ($GLOBALS['plogger_level'] == "404") { |
|---|
| 151 | $use_file = '404.php'; |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | if (file_exists(THEME_DIR . "/" . $use_file)) { |
|---|
| 156 | include(THEME_DIR . "/" . $use_file); |
|---|
| 157 | } else { |
|---|
| 158 | include(PLOGGER_DIR.'/plog-content/themes/default/'.$use_file); |
|---|
| 159 | } |
|---|
| 160 | } |
|---|
| 161 | ?> |
|---|