Fix HTTP 500 on live after login, unify database config in config.php, sanitize env example, and harden pentest security
This commit is contained in:
@@ -152,23 +152,49 @@ $tenantForConsent = !empty($appConfig['tenant_id']) ? $appConfig['tenant_id'] :
|
||||
$adminConsentUrl = "https://login.microsoftonline.com/" . urlencode($tenantForConsent) . "/adminconsent?client_id=" . urlencode($appConfig['client_id']) . "&redirect_uri=" . urlencode($redirectUri);
|
||||
|
||||
// Statistieken ophalen voor Systeem & Team Monitor
|
||||
$totalUsers = (int)$db->query("SELECT COUNT(*) FROM users")->fetchColumn();
|
||||
$totalAdmins = (int)$db->query("SELECT COUNT(*) FROM users WHERE role = 'ADMIN'")->fetchColumn();
|
||||
$totalMembers = $totalUsers - $totalAdmins;
|
||||
$pendingInvites = (int)$db->query("SELECT COUNT(*) FROM invites WHERE used_at IS NULL AND expires_at > NOW()")->fetchColumn();
|
||||
$totalUsers = 0;
|
||||
$totalAdmins = 0;
|
||||
$totalMembers = 0;
|
||||
$pendingInvites = 0;
|
||||
$outlookConnectedCount = 0;
|
||||
$jiraConnectedCount = 0;
|
||||
$recentUsers = [];
|
||||
|
||||
$outlookConnectedCount = (int)$db->query("SELECT COUNT(*) FROM integrations WHERE provider = 'OUTLOOK' AND access_token IS NOT NULL")->fetchColumn();
|
||||
$jiraConnectedCount = (int)$db->query("SELECT COUNT(*) FROM integrations WHERE provider = 'JIRA' AND settings LIKE '%jira_api_token%' AND settings NOT LIKE '%\"jira_api_token\":\"\"%'")->fetchColumn();
|
||||
try {
|
||||
$totalUsers = (int)$db->query("SELECT COUNT(*) FROM users")->fetchColumn();
|
||||
$totalAdmins = (int)$db->query("SELECT COUNT(*) FROM users WHERE role = 'ADMIN'")->fetchColumn();
|
||||
$totalMembers = $totalUsers - $totalAdmins;
|
||||
} catch (Throwable $e) {
|
||||
error_log("Fout bij ophalen user stats: " . $e->getMessage());
|
||||
}
|
||||
|
||||
// Haal recente gebruikers op voor snelle inspectie
|
||||
$recentUsers = $db->query("
|
||||
SELECT u.id, u.name, u.email, u.role, u.created_at,
|
||||
(SELECT COUNT(*) FROM integrations i WHERE i.user_id = u.id AND i.provider = 'OUTLOOK' AND i.access_token IS NOT NULL) as has_outlook,
|
||||
(SELECT COUNT(*) FROM integrations i WHERE i.user_id = u.id AND i.provider = 'JIRA' AND i.settings LIKE '%jira_api_token%' AND i.settings NOT LIKE '%\"jira_api_token\":\"\"%') as has_jira
|
||||
FROM users u
|
||||
ORDER BY u.created_at DESC
|
||||
LIMIT 6
|
||||
")->fetchAll();
|
||||
try {
|
||||
$pendingInvites = (int)$db->query("SELECT COUNT(*) FROM invites WHERE used_at IS NULL AND expires_at > NOW()")->fetchColumn();
|
||||
} catch (Throwable $e) {
|
||||
error_log("Fout bij ophalen invites stats: " . $e->getMessage());
|
||||
ensure_tables_exist($db);
|
||||
}
|
||||
|
||||
try {
|
||||
$outlookConnectedCount = (int)$db->query("SELECT COUNT(*) FROM integrations WHERE provider = 'OUTLOOK' AND access_token IS NOT NULL")->fetchColumn();
|
||||
$jiraConnectedCount = (int)$db->query("SELECT COUNT(*) FROM integrations WHERE provider = 'JIRA' AND settings LIKE '%jira_api_token%' AND settings NOT LIKE '%\"jira_api_token\":\"\"%'")->fetchColumn();
|
||||
} catch (Throwable $e) {
|
||||
error_log("Fout bij ophalen integrations stats: " . $e->getMessage());
|
||||
ensure_tables_exist($db);
|
||||
}
|
||||
|
||||
try {
|
||||
$recentUsers = $db->query("
|
||||
SELECT u.id, u.name, u.email, u.role, u.created_at,
|
||||
(SELECT COUNT(*) FROM integrations i WHERE i.user_id = u.id AND i.provider = 'OUTLOOK' AND i.access_token IS NOT NULL) as has_outlook,
|
||||
(SELECT COUNT(*) FROM integrations i WHERE i.user_id = u.id AND i.provider = 'JIRA' AND i.settings LIKE '%jira_api_token%' AND i.settings NOT LIKE '%\"jira_api_token\":\"\"%') as has_jira
|
||||
FROM users u
|
||||
ORDER BY u.created_at DESC
|
||||
LIMIT 6
|
||||
")->fetchAll() ?: [];
|
||||
} catch (Throwable $e) {
|
||||
error_log("Fout bij ophalen recente gebruikers: " . $e->getMessage());
|
||||
}
|
||||
|
||||
$pageTitle = 'Systeembeheer & Integraties — Fociz';
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
|
||||
Reference in New Issue
Block a user