76 lines
2.9 KiB
PHP
76 lines
2.9 KiB
PHP
<?php
|
|
/**
|
|
* Quick Encryption Tool (Development Only — Protected)
|
|
*/
|
|
|
|
require_once __DIR__ . '/../app/bootstrap/init.php';
|
|
|
|
use App\Core\Encryption;
|
|
use App\Middleware\AuthMiddleware;
|
|
|
|
// SECURITY: Block access in production
|
|
if (env('APP_ENV', 'production') === 'production') {
|
|
http_response_code(404);
|
|
echo 'Not Found';
|
|
exit;
|
|
}
|
|
|
|
// SECURITY: Require super_admin authentication
|
|
try {
|
|
$decoded = AuthMiddleware::check();
|
|
if (($decoded['role'] ?? '') !== 'super_admin') {
|
|
http_response_code(403);
|
|
echo 'Forbidden';
|
|
exit;
|
|
}
|
|
} catch (\Throwable $e) {
|
|
http_response_code(401);
|
|
echo 'Unauthorized';
|
|
exit;
|
|
}
|
|
|
|
$input = $_GET['text'] ?? '';
|
|
$encrypted = $input ? Encryption::encrypt($input) : '';
|
|
$hash = $input ? hash('sha256', strtolower($input)) : '';
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="ar" dir="rtl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>أداة التشفير | مُصادَق</title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
</head>
|
|
<body class="bg-slate-900 text-white p-10">
|
|
<div class="max-w-2xl mx-auto bg-slate-800 p-8 rounded-lg shadow-xl">
|
|
<h1 class="text-2xl font-bold mb-6 text-emerald-500">أداة تشفير البيانات</h1>
|
|
|
|
<form method="GET" class="space-y-4">
|
|
<div>
|
|
<label class="block text-sm text-slate-400 mb-1">النص المطلوب تشفيره (اسم أو بريد إلكتروني):</label>
|
|
<input type="text" name="text" value="<?= htmlspecialchars($input) ?>" class="w-full bg-slate-900 border border-slate-700 p-3 rounded text-white outline-none focus:border-emerald-500">
|
|
</div>
|
|
<button type="submit" class="bg-emerald-600 hover:bg-emerald-500 px-6 py-2 rounded font-bold transition">تشفير الآن 🔒</button>
|
|
</form>
|
|
|
|
<?php if ($encrypted): ?>
|
|
<div class="mt-10 space-y-6">
|
|
<div>
|
|
<label class="block text-sm text-slate-400 mb-1">النص المشفّر (للحفظ في عمود name أو email):</label>
|
|
<textarea readonly class="w-full bg-slate-900 border border-slate-700 p-3 rounded text-emerald-400 font-mono text-xs h-24"><?= $encrypted ?></textarea>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm text-slate-400 mb-1">الـ Hash (للحفظ في عمود email_hash - للبريد فقط):</label>
|
|
<input readonly type="text" value="<?= $hash ?>" class="w-full bg-slate-900 border border-slate-700 p-3 rounded text-emerald-400 font-mono text-xs">
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="mt-8 pt-6 border-t border-slate-700 text-sm text-slate-500">
|
|
استخدم هذه القيم لتحديث مستخدمي النظام الحاليين يدوياً في قاعدة البيانات إذا أردت.
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|