From 04f8f5db1aceea13ce5091cf4a911d862f38a03f Mon Sep 17 00:00:00 2001 From: Yehuda Eisenberg <32451776+YehudaEi@users.noreply.github.com> Date: Tue, 10 Nov 2020 19:11:50 +0200 Subject: [PATCH] =?UTF-8?q?Add=20secret=20mode=20=F0=9F=A5=B3=F0=9F=8E=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SysManager.php | 284 ++++++++++++++++++++++++++----------------------- 1 file changed, 149 insertions(+), 135 deletions(-) diff --git a/SysManager.php b/SysManager.php index db5c50a..784ea36 100644 --- a/SysManager.php +++ b/SysManager.php @@ -3,6 +3,7 @@ define('DONT_SHOW', array('.', '..', ".htaccess", "readme.md")); define('DS', DIRECTORY_SEPARATOR); define('BASE_PATH', __DIR__ . DS . "data" . DS); +define('BASE_PATH_SF', __DIR__ . DS . "Secret-Folder" . DS); define('BASE_URL', ($_SERVER['REQUEST_SCHEME'] ?? ($_SERVER['HTTPS'] == "on" ? "https" : "http")) . "://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . "/"); session_name('FileServerMng'); @@ -10,8 +11,10 @@ if(file_exists(substr(BASE_PATH, 0, -1)) && !is_dir(substr(BASE_PATH, 0, -1))) die("
Hello " . htmlspecialchars($_SESSION['FileServerMngUser']['logged']) . ". + [home] + [logout] + [upload] + [public files] " : "?act=secret'>secret files] ") . " + [create folder] + Secret Mode: " . ($secretMode ? "ON" : "OFF") . " +
+ "; +} +function printFilesTable($path, $isLogged, $secretMode = false){ +?> + + + +Name | +Last modified | +Size | + + +ReName | +Delete | + + +
---|---|---|---|---|
Go Back | +- | +- | + + +- | +- | + + +
Login | +- | +- | +||
+ | + | + + + | ReName this file / folder | +Delete this file / folder | + + +
Hello " . htmlspecialchars($_SERVER['PHP_AUTH_USER']) . ". [logout] [home]
"; - if(is_dir($file)){ $name = $file; } else{ header('location: ' . BASE_URL); } + printHeader(getFakePath($file, $secretMode), $secretMode); echo ''; } } - elseif($act == "password"){ - die("In Building..."); + elseif($act == "secret"){ + $_SESSION['secretMode'] = true; + header('location: ' . BASE_URL); + } + elseif($act == "public"){ + $_SESSION['secretMode'] = false; + header('location: ' . BASE_URL); } elseif($act == "rename"){ - $oldName = BASE_PATH . $file; + $oldName = ($secretMode ? BASE_PATH_SF : BASE_PATH) . $file; if(isset($_POST['newName']) && $_POST['newName']){ if(file_exists($oldName) || is_dir($oldName)){ - if((!in_array(basename($oldName), DONT_SHOW) || basename($oldName) == 'readme.md') && $oldName != BASE_PATH){ + if((!in_array(basename($oldName), DONT_SHOW) || basename($oldName) == 'readme.md') && $oldName != ($secretMode ? BASE_PATH_SF : BASE_PATH)){ $newName = dirname($oldName) . DS . basename($_POST['newName']); if(file_exists($newName) || is_dir($newName)){ @@ -247,27 +362,26 @@ function getFakePath($path){ } } else{ - echo "Hello " . htmlspecialchars($_SERVER['PHP_AUTH_USER']) . ". [logout] [home]
"; - if(file_exists($oldName) || is_dir($oldName)){ $name = $oldName; } else{ header('location: ' . BASE_URL); } + printHeader((is_dir($file) ? getFakePath($file, $secretMode) : getFakePath(dirname($file))), $secretMode); echo ''; } } elseif($act == "delete"){ - $file = BASE_PATH . $file; + $file = ($secretMode ? BASE_PATH_SF : BASE_PATH) . $file; if(isset($_POST['delete']) && $_POST['delete']){ if(file_exists($file) || is_dir($file)){ - if((!in_array(basename($file), DONT_SHOW) || basename($file) == 'readme.md') && $file != BASE_PATH){ + if((!in_array(basename($file), DONT_SHOW) || basename($file) == 'readme.md') && $file != ($secretMode ? BASE_PATH_SF : BASE_PATH)){ del($file); if(!file_exists($file)) echo 'Hello " . htmlspecialchars($_SERVER['PHP_AUTH_USER']) . ". [logout] [home]
"; - if(file_exists($file) || is_dir($file)){ $name = $file; } else{ header('location: ' . BASE_URL); } + printHeader((is_dir($file) ? getFakePath($file, $secretMode) : getFakePath(dirname($file), $secretMode)), $secretMode); echo ''; } @@ -310,110 +423,11 @@ function getFakePath($path){ die(); } -if(is_dir(BASE_PATH . $file)){ -?> - - -Name | -Last modified | -Size | - - -ReName | -Delete | - - -
---|---|---|---|---|
Go Back | -- | -- | - - -- | -- | - - -
Login | -- | -- | -||
- | - | - - - | ReName this file / folder | -Delete this file / folder | - - -