$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

File Management

Log Out

Upload File

Available Files (Click to download)

No files available.