= 1048576) return round($bytes/1048576,2)." MB"; if ($bytes >= 1024) return round($bytes/1024,2)." KB"; return $bytes." B"; } function backLink($path){ echo "⬅️ Yukarı"; } function redirect($path){ header("Location: ?path=".urlencode($path)); exit; } /* ------------------ POST İŞLEMLERİ ------------------ */ if ($_SERVER['REQUEST_METHOD'] === 'POST') { try { // DOSYA YÜKLE if (!empty($_FILES['file']['name'])) { $ext = strtolower(pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION)); if (!in_array($ext, ALLOWED_EXTENSIONS)) throw new Exception("Uzantıya izin yok!"); move_uploaded_file($_FILES['file']['tmp_name'], $currentPath."/".basename($_FILES['file']['name'])); } // KLASÖR OLUŞTUR if (!empty($_POST['folder'])) { mkdir($currentPath."/".basename($_POST['folder']),0755,true); } // DOSYA OLUŞTUR if (!empty($_POST['file']) && isset($_POST['content'])) { file_put_contents( $currentPath."/".basename($_POST['file']), $_POST['content'] ); } // YENİDEN ADLANDIR if (!empty($_POST['rename']) && $itemPath) { rename($itemPath, $currentPath."/".basename($_POST['rename'])); } redirect($currentPath); } catch(Exception $e) { echo "

{$e->getMessage()}

"; } } /* ------------------ ACTION İŞLEMLERİ ------------------ */ if ($action && $itemPath) { if ($action === 'delete') { is_dir($itemPath) ? rmdir($itemPath) : unlink($itemPath); redirect($currentPath); } if ($action === 'edit') { if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit'])) { file_put_contents($itemPath, $_POST['edit']); redirect($currentPath); } $content = htmlspecialchars(file_get_contents($itemPath)); echo "

Düzenle: ".basename($itemPath)."



"; backLink($currentPath); exit; } if ($action === 'rename') { echo "

Yeniden Adlandır

"; backLink($currentPath); exit; } } /* ------------------ ANA EKRAN ------------------ */ echo "

Mevcut Konum: ".htmlspecialchars($currentPath)."

"; backLink($currentPath); echo "
"; $files = array_diff(scandir($currentPath),['.','..']); echo ""; echo "
"; ?>

Dosya Yükle

Klasör Oluştur

Dosya Oluştur