diff --git a/storage/fileserver/index.php b/storage/fileserver/index.php new file mode 100644 index 00000000..d09645b7 --- /dev/null +++ b/storage/fileserver/index.php @@ -0,0 +1,205 @@ + $currentTime) { + $remaining = $_SESSION['lock_until'] - $currentTime; + $minutes = ceil($remaining / 60); + $error = "Too many failed attempts. Please try again in $minutes minute(s)."; + $isLocked = true; +} else { + $isLocked = false; + // Reset attempts if the lock time has passed + if ($_SESSION['lock_until'] > 0 && $_SESSION['lock_until'] <= $currentTime) { + $_SESSION['login_attempts'] = 0; + $_SESSION['lock_until'] = 0; + } +} + +// Logout logic +if (isset($_GET['logout'])) { + session_destroy(); + header("Location: " . $_SERVER['PHP_SELF']); + exit; +} + +// Login validation +if (isset($_POST['password']) && !$isLocked) { + if ($_POST['password'] === PASSWORD) { + $_SESSION['loggedin'] = true; + $_SESSION['login_attempts'] = 0; // Reset on success + $_SESSION['lock_until'] = 0; + } else { + $_SESSION['login_attempts']++; + if ($_SESSION['login_attempts'] >= MAX_ATTEMPTS) { + $_SESSION['lock_until'] = $currentTime + LOCK_TIME; + $error = "Too many failed attempts. You are locked out for 10 minutes."; + } else { + $remaining_attempts = MAX_ATTEMPTS - $_SESSION['login_attempts']; + $error = "Incorrect password! Remaining attempts: $remaining_attempts"; + } + } +} + +// Show login form if not logged in +if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) { + ?> + +
File uploaded successfully!
"; + } else { + $uploadMessage = "Upload failed. Please check Linux directory permissions.
"; + } + } +} + +// 3. DELETE LOGIC +if (isset($_GET['delete'])) { + $filename = basename($_GET['delete']); + $filepath = $dir . '/' . $filename; + + if ($filename === 'index.php') { + $message = "Deleting index.php is not allowed!
"; + } elseif (file_exists($filepath) && is_file($filepath)) { + if (unlink($filepath)) { + $message = "File '$filename' deleted successfully!
"; + } else { + $message = "Could not delete file. Check Linux permissions.
"; + } + } else { + $message = "File not found.
"; + } +} + +// Fetch files for the list +$files = array_diff(scandir($dir), array('.', '..', 'index.php')); +?> + + + + +No files available.
+ + + + + + diff --git a/storage/fileserver/manual.md b/storage/fileserver/manual.md new file mode 100644 index 00000000..30fb58f3 --- /dev/null +++ b/storage/fileserver/manual.md @@ -0,0 +1,5 @@ +chown -R apache:apache /var/www/html/file +sudo chmod -R 755 /var/www/html/file + +only pass +vLDS!DWmMwJE^vFbnhS!IZ!Rpr42W5#8q4SVg7W7 \ No newline at end of file