Sindbad~EG File Manager
<?php
require_once 'config/config.php';
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html>
<head>
<title>Directory Setup Checker</title>
<style>
body { font-family: Arial, sans-serif; max-width: 800px; margin: 50px auto; padding: 20px; }
.check { padding: 15px; margin: 10px 0; border-radius: 5px; }
.success { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; }
.error { background: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; }
.warning { background: #fff3cd; border: 1px solid #ffeaa7; color: #856404; }
h1 { color: #333; }
.icon { font-weight: bold; margin-right: 10px; }
</style>
</head>
<body>
<h1>๐ Public Directory Setup Checker</h1>
<?php
$db = Database::getInstance()->getConnection();
$allGood = true;
// Check 1: Table exists
echo "<h2>1. Database Table Check</h2>";
try {
$stmt = $db->query("SHOW TABLES LIKE 'public_directory_access'");
$tableExists = $stmt->rowCount() > 0;
if ($tableExists) {
echo "<div class='check success'><span class='icon'>โ</span>Table 'public_directory_access' exists</div>";
} else {
echo "<div class='check error'><span class='icon'>โ</span>Table 'public_directory_access' NOT found. Please run install_public_directory.php</div>";
$allGood = false;
}
} catch (Exception $e) {
echo "<div class='check error'><span class='icon'>โ</span>Database error: " . htmlspecialchars($e->getMessage()) . "</div>";
$allGood = false;
}
// Check 2: EmailService class
echo "<h2>2. EmailService Class Check</h2>";
if (class_exists('EmailService')) {
echo "<div class='check success'><span class='icon'>โ</span>EmailService class found</div>";
try {
$emailService = new EmailService();
echo "<div class='check success'><span class='icon'>โ</span>EmailService can be instantiated</div>";
} catch (Exception $e) {
echo "<div class='check error'><span class='icon'>โ</span>EmailService error: " . htmlspecialchars($e->getMessage()) . "</div>";
$allGood = false;
}
} else {
echo "<div class='check error'><span class='icon'>โ</span>EmailService class not found</div>";
$allGood = false;
}
// Check 3: Test member with email
echo "<h2>3. Test Member Data</h2>";
try {
$stmt = $db->query("
SELECT COUNT(*) as total,
SUM(CASE WHEN email IS NOT NULL AND email != '' THEN 1 ELSE 0 END) as with_email
FROM members
WHERE is_active = 1
");
$memberStats = $stmt->fetch(PDO::FETCH_ASSOC);
echo "<div class='check success'><span class='icon'>โ</span>Total active members: " . $memberStats['total'] . "</div>";
echo "<div class='check " . ($memberStats['with_email'] > 0 ? 'success' : 'warning') . "'><span class='icon'>" . ($memberStats['with_email'] > 0 ? 'โ' : 'โ ') . "</span>Members with email: " . $memberStats['with_email'] . "</div>";
if ($memberStats['with_email'] == 0) {
echo "<div class='check warning'><span class='icon'>โ </span>Warning: No members have email addresses. They won't be able to receive verification codes.</div>";
}
} catch (Exception $e) {
echo "<div class='check error'><span class='icon'>โ</span>Error checking members: " . htmlspecialchars($e->getMessage()) . "</div>";
}
// Check 4: Config constants
echo "<h2>4. Configuration Check</h2>";
echo "<div class='check success'><span class='icon'>โ</span>APP_NAME: " . htmlspecialchars(APP_NAME) . "</div>";
if (defined('APP_ENV')) {
echo "<div class='check success'><span class='icon'>โ</span>APP_ENV: " . htmlspecialchars(APP_ENV) . "</div>";
} else {
echo "<div class='check warning'><span class='icon'>โ </span>APP_ENV not defined. Add to config.php for better error messages during development.</div>";
}
// Summary
echo "<h2>๐ Summary</h2>";
if ($allGood) {
echo "<div class='check success'><span class='icon'>โ</span><strong>All checks passed! Public directory should work.</strong></div>";
echo "<p>Try testing with a valid membership ID that has an email address.</p>";
} else {
echo "<div class='check error'><span class='icon'>โ</span><strong>Some issues found. Please fix them before using the public directory.</strong></div>";
}
// Show a test member if available
echo "<h2>๐งช Test Data</h2>";
try {
$stmt = $db->query("
SELECT membershipcard_id, first_name, last_name, email
FROM members
WHERE is_active = 1
AND email IS NOT NULL
AND email != ''
LIMIT 1
");
$testMember = $stmt->fetch(PDO::FETCH_ASSOC);
if ($testMember) {
echo "<div class='check success'>";
echo "<p><strong>Test with this membership ID:</strong></p>";
echo "<p>Membership ID: <strong>" . htmlspecialchars($testMember['membershipcard_id']) . "</strong></p>";
echo "<p>Name: " . htmlspecialchars($testMember['first_name'] . ' ' . $testMember['last_name']) . "</p>";
echo "<p>Email: " . htmlspecialchars($testMember['email']) . "</p>";
echo "</div>";
}
} catch (Exception $e) {
echo "<div class='check error'>Error: " . htmlspecialchars($e->getMessage()) . "</div>";
}
?>
<hr style="margin: 30px 0;">
<p><a href="public-directory.php">โ Go to Public Directory</a></p>
<p><a href="install_public_directory.php">โ Run Installation</a></p>
<p><a href="dashboard.php">โ Back to Dashboard</a></p>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists