// Get current path $current_path = str_replace($home_uri, "", $_SERVER['REQUEST_URI']); $current_path = preg_replace("#(^/|/\$)#", "", $current_path); $current_path = str_replace("%20", " ", $current_path); // Current folder $current_folder = "{$home_folder}/{$current_path}"; // Thumbnail folder $thumb_home_uri = "{$home_uri}/{$index_folder}/thumbs"; $thumb_home_folder = "{$home_folder}/{$index_folder}/thumbs"; $thumb_current_folder = "{$thumb_home_folder}/{$current_path}"; $thumb_current_uri = "{$thumb_home_uri}/{$current_path}"; // Nested folder depth $nest_depth = substr_count(preg_replace("#^{$home_uri}/#", "", $_SERVER["REQUEST_URI"]), "/"); // Local passwords $local_key = false; $local_restriction = find_password($current_folder, $nest_depth); if (isset($local_restriction["key"])) { $local_key = "junkbox-" . $local_restriction["key"]; $private = true; } ?> <!doctype html> <html> <head> <title><?php echo $page_title; ?> </title> <meta charset="utf-8">
<?php if (!empty($_POST)) { include "../_config.php"; include "../library/functions.php"; // Admin login if (isset($admins)) { foreach ($admins as $account) { if (strtolower($_POST['name']) === strtolower($account->name) and md5($_POST['password']) === $account->password) { setcookie($admin_key, true, time() + 7200, '/'); header('Location: ' . $_SERVER['REQUEST_URI']); exit; } } } // Local folder login if (isset($_POST['local_password'])) { // Get password values $current_folder = "{$home_folder}/" . $_POST['local_password']; $local_restriction = find_password($current_folder, $_POST['nest_depth']); // Compare credentials if (strtolower($_POST['name']) === strtolower($local_restriction['name']) and $_POST['password'] === $local_restriction['password']) { setcookie("junkbox-" . $local_restriction['key'], true, time() + 7200, '/'); header('Location: ' . $_SERVER['REQUEST_URI']); exit; } } } header('Location: ' . $_SERVER['HTTP_REFERER']);