"; echo ""; echo "
"; echo "Generated: " . date('Y-m-d H:i:s T') . "
"; // ── PHP Version ── echo "PHP Version: $phpVer "; if (version_compare($phpVer, '8.2', '>=')) { echo "(Warning: utf8_encode/utf8_decode removed in 8.2)"; } elseif (version_compare($phpVer, '8.0', '>=')) { echo "(Good — PHP 8.x supported)"; } elseif (version_compare($phpVer, '7.4', '>=')) { echo "(PHP 7.4 — end of life but should work)"; } else { echo "(Too old — PHP 7.4+ recommended)"; } echo "
"; // Check critical functions $criticalFunctions = [ 'password_hash' => 'Password hashing (PHP 5.5+)', 'password_verify' => 'Password verification (PHP 5.5+)', 'json_encode' => 'JSON encoding', 'json_decode' => 'JSON decoding', 'mysqli_connect' => 'MySQLi extension', 'openssl_encrypt' => 'OpenSSL extension', 'session_start' => 'Session support', ]; foreach ($criticalFunctions as $func => $desc) { $exists = function_exists($func); echo "" . ($exists ? "✓" : "✗") . " $desc ($func)
✓ $func — available (polyfill installed)
✗ $func — MISSING! This will cause 500 errors if used in the code.
✗ Config file not found: incs/mysql.inc.php
Run the installer first to create this file.
"; } else { echo "✓ Config file exists
"; include($configFile); // NOSONAR — $configFile is hardcoded to __DIR__.'/../incs/mysql.inc.php', no user input $host = isset($mysql_host) ? $mysql_host : '(not set)'; $user = isset($mysql_user) ? $mysql_user : '(not set)'; $db = isset($mysql_db) ? $mysql_db : '(not set)'; echo "Host: $host | User: $user | Database: $db
✗ Connection failed: " . htmlspecialchars($conn->connect_error) . "
"; } else { echo "✓ Connected to database: " . htmlspecialchars($conn->server_info) . "
"; // ── Table Check ── echo "Total tables found: " . count($existing) . "
"; $missing = []; foreach ($requiredTables as $t) { $fullName = $prefix . $t; if (in_array($fullName, $existing)) { echo "✓ $fullName
✗ $fullName — MISSING
Missing tables detected. Re-run the installer in Upgrade mode to create them.
"; } // Check user table for admin account echo "| ID | Username | Level | Hash Type |
|---|---|---|---|
| {$row['id']} | {$row['user']} | {$row['level']} | $hashType (len={$row['pass_len']}) |
✗ No admin accounts found in user table!
"; } } // Check version echo "Database version: " . htmlspecialchars($row['value']) . "
"; } else { echo "⚠ No _version key in settings table (legacy install)
"; } } // ── Quick PHP compatibility test ── echo "Testing functions.inc.php load... ";
ob_start();
try {
// Functions.inc.php has already been partially loaded via the config include chain
// but let's test a key function
if (function_exists('get_variable')) {
echo "✓ get_variable() available
" . htmlspecialchars($err) . ""; } $output = ob_get_clean(); if ($output) echo $output; // Test 2: Try an AJAX-style query echo "
Testing incident query... "; try { $ticketTable = $prefix . 'ticket'; if (in_array($ticketTable, $existing)) { $res = $conn->query("SELECT COUNT(*) AS cnt FROM `$ticketTable`"); $row = $res->fetch_assoc(); echo "✓ " . $row['cnt'] . " incidents in database
"; } else { echo "⚠ ticket table not found"; } } catch (Throwable $e) { echo "✗ " . htmlspecialchars($e->getMessage()) . ""; } $conn->close(); } } // ── File Permissions ── echo "" . ($readable ? "✓" : "✗") . " $label (perms: $perms)
"; } else { echo "✗ $label — NOT FOUND
"; } } // ── Server Info ── echo "Server software: " . htmlspecialchars($_SERVER['SERVER_SOFTWARE'] ?? 'unknown') . "
"; echo "Document root: " . htmlspecialchars($_SERVER['DOCUMENT_ROOT'] ?? 'unknown') . "
"; echo "Script path: " . htmlspecialchars(__FILE__) . "
"; echo "PHP SAPI: " . htmlspecialchars(php_sapi_name()) . "
"; echo "Memory limit: " . htmlspecialchars(ini_get('memory_limit')) . "
"; echo "Max execution time: " . htmlspecialchars(ini_get('max_execution_time')) . "s
"; echo "display_errors: " . htmlspecialchars(ini_get('display_errors')) . "
"; echo "error_reporting: " . error_reporting() . "
"; $errorLog = ini_get('error_log'); echo "error_log: " . ($errorLog ? htmlspecialchars($errorLog) : 'default (server log)') . "
"; echo "Security Notice: Delete this file (tools/diagnose.php) after diagnosing the issue!