From 51e2659a1e9270fa3bc7e3929a2a89d062d80966 Mon Sep 17 00:00:00 2001
From: salam
Date: Mon, 26 Oct 2026 07:58:58 +0100
Subject: [PATCH] add fileserver
---
storage/fileserver/index.php | 205 +++++++++++++++++++++++++++++++++++
storage/fileserver/manual.md | 5 +
2 files changed, 210 insertions(+)
create mode 100644 storage/fileserver/index.php
create mode 100644 storage/fileserver/manual.md
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) {
+ ?>
+
+ Login
+
+
+
+

+
File Server Login
+ $error"; ?>
+
+
+ Overwriting index.php is not allowed!
";
+ } else {
+ if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $targetFile)) {
+ $uploadMessage = "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'));
+?>
+
+
+
+
+ Download & Upload Server
+
+
+
+
+
+
+
+
+
+
Upload File
+
+
+
+
+
+ Available Files (Click to download)
+
+ 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