Sindbad~EG File Manager
<?php
require_once 'config/config.php';
checkLogin();
// Only superusers can install
if (!isSuperuser()) {
redirect('dashboard.php');
}
$success = false;
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try {
$db = Database::getInstance()->getConnection();
// Read and execute SQL file
$sql = file_get_contents(__DIR__ . '/sql/public_directory_access.sql');
if ($sql === false) {
throw new Exception('Could not read SQL file');
}
// Split SQL into individual statements
$statements = array_filter(array_map('trim', explode(';', $sql)));
foreach ($statements as $statement) {
if (!empty($statement) && stripos($statement, '--') !== 0) {
$db->exec($statement);
}
}
$success = true;
} catch (Exception $e) {
$error = $e->getMessage();
}
}
$pageTitle = "Install Public Directory Access - " . APP_NAME;
include 'includes/header.php';
?>
<div class="container mx-auto px-4 py-8">
<div class="max-w-2xl mx-auto">
<div class="bg-white rounded-lg shadow-lg p-8">
<div class="text-center mb-8">
<div class="w-20 h-20 rounded-full mx-auto mb-4 flex items-center justify-center" style="background: linear-gradient(135deg, #1E40AF 0%, #9333EA 50%, #F97316 100%);">
<i class="fas fa-shield-alt text-white text-3xl"></i>
</div>
<h1 class="text-3xl font-bold text-gray-800 mb-2">Install Public Directory Access</h1>
<p class="text-gray-600">Set up the email verification system for public directory access</p>
</div>
<?php if ($success): ?>
<div class="bg-green-50 border border-green-200 text-green-800 px-6 py-4 rounded-lg mb-6">
<div class="flex items-center">
<i class="fas fa-check-circle text-2xl mr-3"></i>
<div>
<h3 class="font-bold text-lg">Installation Successful!</h3>
<p class="text-sm mt-1">The public directory access system has been installed successfully.</p>
</div>
</div>
</div>
<div class="space-y-4">
<div class="bg-blue-50 border border-blue-200 rounded-lg p-4">
<h4 class="font-semibold text-blue-900 mb-2">
<i class="fas fa-info-circle mr-2"></i>What's Next?
</h4>
<ul class="text-sm text-blue-800 space-y-2">
<li><i class="fas fa-check mr-2"></i>Members can access: <strong>public-directory.php</strong></li>
<li><i class="fas fa-check mr-2"></i>Email verification with 6-digit codes</li>
<li><i class="fas fa-check mr-2"></i>Location-based access (assembly/district/area)</li>
<li><i class="fas fa-check mr-2"></i>Verification codes expire after 15 minutes</li>
<li><i class="fas fa-check mr-2"></i>Sessions valid for 2 hours</li>
</ul>
</div>
<div class="flex gap-3">
<a href="public-directory.php" class="flex-1 text-center px-6 py-3 rounded-lg font-semibold text-white transition-all duration-300 hover:shadow-lg" style="background: linear-gradient(135deg, #1E40AF 0%, #9333EA 100%);">
<i class="fas fa-external-link-alt mr-2"></i>
Test Public Directory
</a>
<a href="dashboard.php" class="flex-1 text-center px-6 py-3 bg-gray-200 text-gray-700 rounded-lg font-semibold hover:bg-gray-300 transition-all duration-300">
<i class="fas fa-home mr-2"></i>
Back to Dashboard
</a>
</div>
</div>
<?php elseif ($error): ?>
<div class="bg-red-50 border border-red-200 text-red-800 px-6 py-4 rounded-lg mb-6">
<div class="flex items-center">
<i class="fas fa-exclamation-circle text-2xl mr-3"></i>
<div>
<h3 class="font-bold text-lg">Installation Failed</h3>
<p class="text-sm mt-1">Errors:</p>
<p class="text-sm font-mono mt-2 bg-red-100 p-2 rounded"><?= htmlspecialchars($error) ?></p>
</div>
</div>
</div>
<button onclick="location.reload()" class="w-full px-6 py-3 bg-gray-200 text-gray-700 rounded-lg font-semibold hover:bg-gray-300 transition">
Try Again
</button>
<?php else: ?>
<div class="mb-6">
<h3 class="font-bold text-gray-800 mb-3">
<i class="fas fa-database mr-2 text-blue-500"></i>
Installation Details
</h3>
<div class="bg-gray-50 rounded-lg p-4 space-y-2 text-sm">
<p class="flex items-start">
<i class="fas fa-check text-green-500 mr-2 mt-1"></i>
<span><strong>Creates table:</strong> public_directory_access</span>
</p>
<p class="flex items-start">
<i class="fas fa-check text-green-500 mr-2 mt-1"></i>
<span><strong>Features:</strong> Email verification codes, session tokens, expiration tracking</span>
</p>
<p class="flex items-start">
<i class="fas fa-check text-green-500 mr-2 mt-1"></i>
<span><strong>Security:</strong> Codes expire in 15 minutes, sessions valid for 2 hours</span>
</p>
<p class="flex items-start">
<i class="fas fa-check text-green-500 mr-2 mt-1"></i>
<span><strong>Access Control:</strong> Location-based filtering (assembly/district/area)</span>
</p>
</div>
</div>
<div class="bg-yellow-50 border border-yellow-200 rounded-lg p-4 mb-6">
<h4 class="font-semibold text-yellow-900 mb-2">
<i class="fas fa-exclamation-triangle mr-2"></i>Important Notes
</h4>
<ul class="text-sm text-yellow-800 space-y-1">
<li>• Requires EmailService class to be configured</li>
<li>• Members must have valid email addresses</li>
<li>• Expired codes are automatically cleaned up</li>
<li>• Users are restricted to their location members only</li>
</ul>
</div>
<form method="POST" onsubmit="return confirm('Are you sure you want to install the public directory access system?');">
<button type="submit" class="w-full px-6 py-4 rounded-lg font-bold text-white text-lg transition-all duration-300 hover:shadow-lg" style="background: linear-gradient(135deg, #1E40AF 0%, #9333EA 50%, #F97316 100%);">
<i class="fas fa-download mr-2"></i>
Install Public Directory Access
</button>
</form>
<?php endif; ?>
</div>
</div>
</div>
<?php include 'includes/footer.php'; ?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists