Sindbad~EG File Manager
<?php
require_once 'config/config.php';
checkLogin();
if (!isSuperuser()) {
die('Access denied');
}
$db = Database::getInstance()->getConnection();
// Get first 3 modules with their access config
$query = "
SELECT
m.id,
m.module_name,
GROUP_CONCAT(
CONCAT(mal.access_level, ':', mal.is_enabled)
ORDER BY FIELD(mal.access_level, 'assembly', 'district', 'area', 'superuser')
SEPARATOR '|'
) as access_config
FROM module_management m
LEFT JOIN module_access_levels mal ON m.id = mal.module_id
GROUP BY m.id
LIMIT 3
";
$modules = $db->query($query)->fetchAll();
?>
<!DOCTYPE html>
<html>
<head>
<title>Debug Toggles</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 p-8">
<div class="max-w-4xl mx-auto bg-white rounded-lg shadow p-6">
<h1 class="text-2xl font-bold mb-4">Debug Toggle Values</h1>
<?php foreach ($modules as $module): ?>
<div class="mb-6 p-4 border rounded">
<h3 class="font-bold text-lg mb-2"><?php echo $module['module_name']; ?></h3>
<div class="bg-gray-50 p-3 rounded mb-3">
<strong>Raw access_config:</strong>
<pre class="text-xs"><?php echo htmlspecialchars($module['access_config']); ?></pre>
</div>
<?php
// Parse it
$access_levels = [];
if (!empty($module['access_config'])) {
$configs = explode('|', $module['access_config']);
foreach ($configs as $config) {
if (strpos($config, ':') !== false) {
list($level, $enabled) = explode(':', $config);
$access_levels[$level] = ($enabled === '1' || $enabled === 1 || $enabled === true);
}
}
}
// Show defaults
foreach (['assembly', 'district', 'area', 'superuser'] as $level) {
if (!isset($access_levels[$level])) {
$access_levels[$level] = true;
}
}
?>
<div class="mb-3">
<strong>Parsed values:</strong>
<pre class="text-xs bg-blue-50 p-2 rounded"><?php print_r($access_levels); ?></pre>
</div>
<div class="flex gap-4">
<?php foreach (['assembly', 'district', 'area', 'superuser'] as $level): ?>
<div class="flex flex-col items-center">
<span class="text-xs font-semibold mb-2"><?php echo ucfirst($level); ?></span>
<!-- Toggle -->
<label class="relative inline-flex items-center cursor-pointer">
<input
type="checkbox"
class="sr-only peer"
<?php echo !empty($access_levels[$level]) ? 'checked' : ''; ?>
>
<div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
</label>
<span class="text-xs mt-2">
Value: <?php echo $access_levels[$level] ? 'TRUE' : 'FALSE'; ?>
</span>
<span class="text-xs">
Should be: <?php echo !empty($access_levels[$level]) ? 'CHECKED' : 'UNCHECKED'; ?>
</span>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
<div class="mt-6 p-4 bg-yellow-50 rounded border border-yellow-200">
<h3 class="font-bold mb-2">What to Look For:</h3>
<ul class="text-sm space-y-1">
<li>✅ <strong>Green toggles</strong> = Working correctly</li>
<li>❌ <strong>Gray toggles</strong> = Data issue or CSS problem</li>
<li>🔍 Check "Value" matches the toggle color</li>
<li>🔍 Check "Raw access_config" has correct format</li>
</ul>
</div>
<div class="mt-4">
<a href="modules/module-management/index.php" class="text-blue-600 hover:underline">← Back to Module Management</a>
</div>
</div>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists