برمجه خفيفه مفيده لتعرف على احجام ما هو موجود بموقعك
['بايت', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
والدخول برقم سري

الكود
<?php
session_start();
if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true) {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$password = '12345';
if (isset($_POST['password']) && $_POST['password'] == $password) {
$_SESSION['authenticated'] = true;
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
} else {
$error_message = "كلمة المرور غير صحيحة!"; // رسالة الخطأ إذا كانت كلمة المرور خاطئة
}
}
echo '
<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>تسجيل الدخول</title>
<style>
body { font-family: Arial, sans-serif; background-color: #f4f4f4; display: flex; justify-content: center; align-items: center; height: 100vh; }
.container { background-color: white; padding: 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); width: 300px; text-align: center; }
input[type="password"] { padding: 8px; width: 80%; margin: 10px 0; border: 1px solid #ddd; border-radius: 4px; }
input[type="submit"] { background-color: #4CAF50; color: white; padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; }
input[type="submit"]:hover { background-color: #45a049; }
.error { color: red; }
</style>
</head>
<body>
<div class="container">
<h2>أدخل كلمة المرور</h2>';
if (isset($error_message)) {
echo '<p class="error">' . $error_message . '</p>';
}
echo '
<form method="POST" action="">
<input type="password" name="password" required placeholder="كلمة المرور">
<input type="submit" value="دخول">
</form>
</div>
</body>
</html>';
exit;
}
echo '<p>تم التحقق من كلمة المرور بنجاح! الآن يمكنك الوصول إلى الملفات.</p>';
$directory = __DIR__;
if (isset($_GET['dir'])) {
$directory = $_GET['dir'];
}
if (is_dir($directory)) {
$files = array_diff(scandir($directory), array('..', '.'));
if ($directory !== __DIR__) {
$parentDir = dirname($directory);
echo '<a href="' . $parentDir . '" class="back-btn">العودة إلى المجلد السابق</a><br><br>';
}
if (!empty($files)) {
$counter = 1;
foreach ($files as $file) {
// تجاهل ملفات index.html و index.htm
if (strtolower($file) === 'index.html' || strtolower($file) === 'index.htm') {
continue;
}
$filePath = $directory . '/' . $file;
if (is_dir($filePath)) {
$relativePath = str_replace($_SERVER['DOCUMENT_ROOT'], '', $filePath);
echo '<div class="file-item">';
echo '<span class="file-name">' . $counter . '. <a href="' . $relativePath . '">' . $file . '</a></span>';
echo '</div>';
} else {
$fileSize = filesize($filePath);
$fileSizeFormatted = formatBytes($fileSize);
$relativeFilePath = str_replace($_SERVER['DOCUMENT_ROOT'], '', $filePath);
echo '<div class="file-item">';
echo '<span class="file-name">' . $counter . '. ' . $file . '</span>';
echo '<span>' . $fileSizeFormatted . '</span>';
echo '<a href="' . $relativeFilePath . '" class="download-btn" download>تنزيل</a>';
echo '<a href="' . $relativeFilePath . '" class="view-btn" target="_blank">مشاهدة</a>';
echo '</div>';
}
$counter++;
}
} else {
echo "<p>لا توجد ملفات أو مجلدات في هذا المجلد.</p>";
}
} else {
echo "<p>المجلد غير موجود أو غير قابل للوصول.</p>";
}
function formatBytes($bytes, $precision = 2) {
$units = ['بايت', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
$bytes = max($bytes, 0);
$power = floor(($bytes ? log($bytes) : 0) / log(1024));
return number_format($bytes / pow(1024, $power), $precision) . ' ' . $units[$power];
}
?>
يوجد برمجه مطوره
0 تعليقات