session_start();// --- إعدادات الحماية ---$password = "frhat"; // قم بتغيير كلمة السر هنا$error = "";// تسجيل الخروجif (isset($_GET['logout'])) { session_destroy(); header("Location: " . $_SERVER['PHP_SELF']); exit;}// التحقق من كلمة السرif (isset($_POST['login_pass'])) { if ($_POST['login_pass'] === $password) { $_SESSION['logged_in'] = true; } else { $error = "Invalid Password!"; }}// إذا لم يكن مسجلاً، اظهر صفحة الدخول فقطif (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) {<!DOCTYPE html>Login Required <title>Login Required</title> <style> body { font-family: sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background: #f0f2f5; margin: 0; } .login-box { background: white; padding: 30px; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); text-align: center; } input { padding: 10px; width: 200px; margin-bottom: 10px; border: 1px solid #ddd; border-radius: 5px; } button { padding: 10px 20px; background: #7b2cbf; color: white; border: none; border-radius: 5px; cursor: pointer; } </style> <div class="login-box">

File Manager Login

if($error) echo "<p style='color:red;'>$error</p>";

<button type="submit">Unlock</button>
</div> exit;}// --- كود مدير الملفات الأساسي (يبدأ من هنا بعد تسجيل الدخول) ---$root = __DIR__;$current_rel_path = isset($_GET['path']) ? $_GET['path'] : '';$current_path = realpath($root . '/' . $current_rel_path);if (!$current_path || strpos($current_path, $root) !== 0) { $current_path = $root; $current_rel_path = '';}$message = "";// حذف ملفif (isset($_GET['delete'])) { $file_to_delete = $current_path . '/' . $_GET['delete']; if (is_file($file_to_delete)) { unlink($file_to_delete); $message = "File deleted."; }}// حفظ تعديلif (isset($_POST['save_file'])) { $file_to_save = $current_path . '/' . $_POST['filename']; file_put_contents($file_to_save, $_POST['content']); $message = "File saved.";}// قراءة للتعديل$edit_content = "";$edit_filename = "";if (isset($_GET['edit'])) { $edit_filename = $_GET['edit']; $edit_content = file_get_contents($current_path . '/' . $edit_filename);}$items = scandir($current_path);<!DOCTYPE html><html lang="en"> <meta charset="UTF-8">Secure File Manager <title>Secure File Manager</title> <style> body { font-family: 'Segoe UI', sans-serif; background: #f4f7f6; padding: 20px; } .container { max-width: 900px; margin: auto; background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); } .header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #7b2cbf; padding-bottom: 10px; } .logout { color: #f44336; text-decoration: none; font-weight: bold; font-size: 14px; } table { width: 100%; border-collapse: collapse; margin-top: 20px; } th, td { text-align: left; padding: 12px; border-bottom: 1px solid #eee; } .btn { padding: 5px 10px; text-decoration: none; border-radius: 4px; font-size: 13px; } .btn-edit { background: #4caf50; color: white; } .btn-delete { background: #f44336; color: white; } textarea { width: 100%; height: 300px; margin-top: 10px; font-family: monospace; } </style><div class="container"> <div class="header">

📁 Secure Explorer

<a href="?logout=1" class="logout">Logout Exit</a> </div> <p style="font-size: 12px; color: #888;">Path: / echo htmlspecialchars($current_rel_path); </p> if($message) echo "<p style='color:green; font-weight:bold;'>$message</p>"; <thead><th>Name</th><th>Type</th><th>Actions</th></thead> <tbody> if ($current_rel_path != ''): <td colspan="3"><a href="?path= echo urlencode(dirname($current_rel_path)); " style="color:#7b2cbf;">⬅️ Back</a> endif; foreach ($items as $item): if ($item == '.' || $item == '..') continue; $full_item_path = $current_path . '/' . $item; $is_dir = is_dir($full_item_path); $item_rel_path = ($current_rel_path ? $current_rel_path . '/' : '') . $item; endforeach; </tbody>
echo $is_dir ? "📂 <a href='?path=".urlencode($item_rel_path)."'>$item</a>" : "📄 $item"; echo $is_dir ? 'Folder' : 'File'; if (!$is_dir): <a href="?path= echo urlencode($current_rel_path); &edit= echo urlencode($item); " class="btn btn-edit">Edit</a> <a href="?path= echo urlencode($current_rel_path); &delete= echo urlencode($item); " class="btn btn-delete" onclick="return confirm('Delete?')">Delete</a> endif;
if ($edit_filename): <div style="background: #f9f9f9; padding: 15px; margin-top: 20px;">

Editing: echo htmlspecialchars($edit_filename);

<textarea name="content"> echo htmlspecialchars($edit_content); </textarea>

<button type="submit" name="save_file" class="btn btn-edit" style="padding:10px 20px;">Save Now</button> <a href="?path= echo urlencode($current_rel_path); " class="btn" style="background:#888; color:#fff;">Cancel</a>
</div> endif; </div>