Sindbad~EG File Manager
<?php
require_once 'config/config.php';
checkLogin();
// Only superusers can run this
if (!isSuperuser()) {
die('Access denied. Only superusers can install modules.');
}
$pageTitle = 'Install Chat & Messaging System - ' . APP_NAME;
$db = Database::getInstance()->getConnection();
$errors = [];
$success = [];
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['install'])) {
try {
// Read and execute SQL schema
$sql = file_get_contents('sql/chat_messaging.sql');
// Split by semicolons and execute each statement
$statements = array_filter(array_map('trim', explode(';', $sql)));
foreach ($statements as $statement) {
if (!empty($statement)) {
$db->exec($statement);
}
}
$success[] = 'Database tables created successfully.';
// Register module in module_management
$checkModule = $db->prepare("SELECT id FROM module_management WHERE module_name = 'Messaging'");
$checkModule->execute();
if (!$checkModule->fetch()) {
$stmt = $db->prepare("INSERT INTO module_management (module_name, module_url, module_icon, display_order, required_role, is_active)
VALUES ('Messaging', 'modules/messaging/index.php', 'comments', 45, 'assembly', 1)");
$stmt->execute();
$success[] = 'Messaging module registered.';
} else {
$success[] = 'Messaging module already registered.';
}
} catch (Exception $e) {
$errors[] = 'Installation failed: ' . $e->getMessage();
}
}
include 'includes/header.php';
?>
<style>
.gradient-bg {
background: linear-gradient(135deg, #1E40AF 0%, #9333EA 50%, #F97316 100%);
}
</style>
<div class="min-h-screen bg-gray-50 py-12 px-4">
<div class="max-w-3xl mx-auto">
<div class="bg-white rounded-2xl shadow-2xl overflow-hidden">
<div class="gradient-bg px-6 py-8 text-white">
<h1 class="text-3xl font-bold mb-2">
<i class="fas fa-comments mr-3"></i>Chat & Messaging System Installation
</h1>
<p class="text-white/90">Install the comprehensive chat and messaging system for your church</p>
</div>
<div class="p-8">
<?php if (!empty($success)): ?>
<div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-4 rounded-lg mb-6">
<div class="flex items-start">
<i class="fas fa-check-circle text-xl mr-3 mt-0.5"></i>
<div>
<p class="font-semibold mb-2">Installation Successful!</p>
<ul class="list-disc list-inside space-y-1">
<?php foreach ($success as $msg): ?>
<li><?php echo htmlspecialchars($msg); ?></li>
<?php endforeach; ?>
</ul>
<div class="mt-4 pt-4 border-t border-green-200">
<a href="modules/messaging/index.php" class="inline-flex items-center px-6 py-3 rounded-lg font-semibold text-white shadow-lg hover:shadow-xl transition" style="background: linear-gradient(135deg, #1E40AF 0%, #F97316 100%);">
<i class="fas fa-comments mr-2"></i>Open Messaging Panel
</a>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php if (!empty($errors)): ?>
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 rounded-lg mb-6">
<div class="flex items-start">
<i class="fas fa-exclamation-circle text-xl mr-3 mt-0.5"></i>
<div>
<p class="font-semibold mb-2">Installation Errors:</p>
<ul class="list-disc list-inside space-y-1">
<?php foreach ($errors as $error): ?>
<li><?php echo htmlspecialchars($error); ?></li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<?php endif; ?>
<?php if (empty($success)): ?>
<div class="space-y-6">
<div class="bg-blue-50 border-l-4 border-blue-500 p-4 rounded-lg">
<h3 class="font-semibold text-blue-900 mb-2">
<i class="fas fa-info-circle mr-2"></i>What will be installed:
</h3>
<ul class="list-disc list-inside text-blue-800 space-y-2 ml-4">
<li><strong>chat_conversations</strong> - Stores all chat sessions (public, member-admin, group)</li>
<li><strong>chat_messages</strong> - Stores all messages with sender info and timestamps</li>
<li><strong>message_groups</strong> - Manages message groups (global, area, district, assembly)</li>
<li><strong>message_group_members</strong> - Tracks group memberships</li>
<li><strong>Messaging Module</strong> - Admin panel for chat management and broadcasts</li>
</ul>
</div>
<div class="bg-purple-50 border-l-4 border-purple-500 p-4 rounded-lg">
<h3 class="font-semibold text-purple-900 mb-2">
<i class="fas fa-star mr-2"></i>Features:
</h3>
<ul class="list-disc list-inside text-purple-800 space-y-2 ml-4">
<li>Public chat widget on landing page for guests and members</li>
<li>Admin messaging panel to manage conversations</li>
<li>Broadcast messages by area, district, assembly, or groups</li>
<li>Member portal messaging for member-admin communication</li>
<li>Message history and archiving</li>
<li>Real-time message polling</li>
</ul>
</div>
<form method="POST" class="pt-6">
<button type="submit" name="install" class="w-full px-8 py-4 rounded-lg text-white text-lg font-bold shadow-xl hover:shadow-2xl transition" style="background: linear-gradient(135deg, #1E40AF 0%, #F97316 100%);">
<i class="fas fa-download mr-2"></i>Install Chat & Messaging System
</button>
</form>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php include 'includes/footer.php'; ?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists