// === ??????? ===
$password = 'myStrongPassword'; // ? ?????? ??? ????
$auth_key = 'auth_okay';
session_start();
if (!isset($_SESSION[$auth_key])) {
if (isset($_POST['password']) && $_POST['password'] === $password) {
$_SESSION[$auth_key] = true;
header("Location: ?");
exit;
} else {
echo '

?? Protected File Manager




';
exit;
}
}

// === ????? ===
function sanitize($str) {
return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
}
function list_dir($path) {
return array_diff(scandir($path), ['.', '..']);
}
function is_zip_supported() {
return class_exists('ZipArchive');
}
function create_zip($files, $destination) {
$zip = new ZipArchive;
if ($zip->open($destination, ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
foreach ($files as $file) {
if (file_exists($file)) {
$zip->addFile($file, basename($file));
}
}
$zip->close();
return true;
}
return false;
}

// === ?????? ???????? ===
if (isset($_FILES['file'])) {
move_uploaded_file($_FILES['file']['tmp_name'], basename($_FILES['file']['name']));
header("Location: ?");
exit;
}
if (isset($_POST['zip']) && !empty($_POST['files']) && is_zip_supported()) {
$zip_name = "archive_" . date("Ymd_His") . ".zip";
create_zip($_POST['files'], $zip_name);
header("Location: ?done=zip");
exit;
}
if (isset($_GET['delete'])) {
$file = basename($_GET['delete']);
if (file_exists($file)) unlink($file);
header("Location: ?");
exit;
}
if (isset($_POST['save']) && isset($_POST['filename'])) {
file_put_contents($_POST['filename'], $_POST['content']);
header("Location: ?");
exit;
}
if (isset($_GET['edit'])) {
$edit_file = basename($_GET['edit']);
if (!file_exists($edit_file)) die("File not found!");
$content = file_get_contents($edit_file);

<!DOCTYPE html>

Edit File - <?= sanitize($edit_file) ?> <title>Edit File - = sanitize($edit_file) </title>
<style>
body { background: #111; color: #eee; font-family: sans-serif; padding: 20px; }
textarea { width: 100%; height: 80vh; background: #222; color: #0f0; font-family: monospace; padding: 10px; }
input[type="submit"] { padding: 10px; background: #0f0; color: #000; border: none; margin-top: 10px; }
</style>


?? Editing: = sanitize($edit_file)




<textarea name="content">= sanitize($content) </textarea>





exit; }
$files = list_dir('.');


<!DOCTYPE html>


<meta charset="UTF-8">
Secure File Manager <title>Secure File Manager</title>
<style>
body { font-family: Arial, sans-serif; background: #111; color: #eee; text-align: center; padding: 20px; }
table { width: 90%; margin: auto; border-collapse: collapse; margin-top: 20px; }
th, td { border: 1px solid #333; padding: 10px; }
th { background: #222; }
td { background: #1a1a1a; }
a { color: #0ff; text-decoration: none; }
a:hover { text-decoration: underline; }
input[type="file"], input[type="submit"] { margin: 10px; }
.actions a { margin: 0 5px; }
</style>



??? Secure File Manager



if (isset($_GET['done']) && $_GET['done'] == 'zip'):
<p style="color: lime;">? ZIP file created successfully!</p>
endif;

<!-- ??? ??????? -->





<!-- ??? ??????? -->


<th></th><th>?? Name</th><th>?? Size</th><th>?? Actions</th>
foreach ($files as $f):




<td class="actions">
<a href="= sanitize($f) " download>??</a>
<a href="?edit== urlencode($f) ">??</a>
<a href="?delete== urlencode($f) " onclick="return confirm('Delete this file?');">???</a>


endforeach;
= sanitize($f) = filesize($f) bytes

if (is_zip_supported()):

endif;