« Back to History
recon_dashboard.php
|
20260921_175631.php
Initial Domain Snapshot
Copy Code
<?php // recon_dashboard.php (DEBUG VERSION) - temporary. Shows detailed error diagnostics. // Replace production file with this to see exact failure reason, then revert. error_reporting(E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); try { // 1) auth include (try multiple candidate paths to surface the exact missing path) $acl_candidates = [ __DIR__ . '/../../auth/page_acl.php', __DIR__ . '/../../../auth/page_acl.php', __DIR__ . '/../../modules/auth/page_acl.php', __DIR__ . '/../../auth/auth.php', __DIR__ . '/../../../../erp/modules/auth/page_acl.php' ]; $acl_included = false; foreach ($acl_candidates as $c) { if (file_exists($c)) { require_once $c; $acl_included = $c; break; } } if (!$acl_included) throw new Exception("Auth include not found. Tried: " . implode(", ", $acl_candidates)); // page_require_access should now exist if (!function_exists('page_require_access')) { // If page_acl.php used a different function, show loaded file list throw new Exception("Auth include loaded but function page_require_access() not found. Please check auth file."); } // call access $ctx = page_require_access('expense_recon'); if (!is_array($ctx)) throw new Exception("page_require_access returned unexpected value: " . gettype($ctx)); $pdo = $ctx['pdo'] ?? null; $company_id = (int)($ctx['company_id'] ?? 0); $user_id = (int)($ctx['user']['id'] ?? 0); // 2) header include (robust) $header_candidates = [ __DIR__ . '/../../partials/header.php', __DIR__ . '/../../../erp/partials/header.php', __DIR__ . '/../../erp/partials/header.php', __DIR__ . '/../../partials/header.php', __DIR__ . '/partials/header.php' ]; $header_included = false; foreach ($header_candidates as $hf) { if (file_exists($hf)) { require_once $hf; $header_included = $hf; break; } } if (!$header_included) { // not fatal — we continue but report it $header_warning = "Header include not found. Tried: " . implode(", ", $header_candidates); } else { $header_warning = "Header included: " . $header_included; } // 3) check recon_lib existence $recon_lib_path = __DIR__ . '/api/recon_lib.php'; $recon_lib_exists = file_exists($recon_lib_path); // 4) check expense_recon_results table exists $table_ok = false; $table_msg = ''; if ($pdo instanceof PDO) { try { $st = $pdo->prepare("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = :t"); $st->execute([':t'=>'expense_recon_results']); $table_ok = (bool)$st->fetchColumn(); $table_msg = $table_ok ? "Table expense_recon_results exists." : "Table expense_recon_results NOT found."; } catch (Throwable $e) { $table_msg = "Error checking table: " . $e->getMessage(); } } else { $table_msg = "PDO not available in ctx (ctx['pdo'] missing)."; } // 4) Render tiny dashboard (diagnostics) ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Recon Dashboard — DEBUG</title> <style> body{font-family:Arial,Helvetica,sans-serif;margin:18px;color:#111} .card{border:1px solid #e6e6e6;padding:12px;border-radius:8px;background:#fff} pre{background:#f7f7f9;padding:12px;border-radius:6px;overflow:auto} .bad{color:#a00} .ok{color:#0a0} </style> </head> <body> <h2>Expense Recon — Debug Info</h2> <div class="card"> <h3>Auth / Context</h3> <pre><?php echo "page_require_access included: " . (is_string($acl_included) ? $acl_included : 'unknown') . "\n"; ?></pre> <p><b>Company ID:</b> <?php echo htmlspecialchars($company_id); ?> — <b>User ID:</b> <?php echo htmlspecialchars($user_id); ?></p> <p><b>PDO available:</b> <?php echo ($pdo instanceof PDO) ? '<span class="ok">Yes</span>' : '<span class="bad">No</span>'; ?></p> <p><b>Header include:</b> <?php echo htmlspecialchars($header_warning); ?></p> </div> <div style="height:12px"></div> <div class="card"> <h3>File checks</h3> <ul> <li>recon_lib.php present: <?php echo $recon_lib_exists ? '<span class="ok">Yes</span>' : '<span class="bad">No</span>'; ?></li> <li>API folder files (list):</li> </ul> <pre><?php $api_dir = __DIR__ . '/api'; if (is_dir($api_dir)) { $files = scandir($api_dir); foreach ($files as $f) { if ($f === '.' || $f === '..') continue; echo $f . "\n"; } } else { echo "API folder not found at " . $api_dir . "\n"; } ?></pre> </div> <div style="height:12px"></div> <div class="card"> <h3>Database check</h3> <pre><?php echo htmlspecialchars($table_msg); ?></pre> <?php if ($pdo instanceof PDO): ?> <h4>Recent expense_recon_results sample (max 10)</h4> <pre><?php try { $st = $pdo->prepare("SELECT id, source_type, source_ref, status, created_at FROM expense_recon_results WHERE company_id = :cid ORDER BY created_at DESC LIMIT 10"); $st->execute([':cid'=>$company_id]); $rows = $st->fetchAll(PDO::FETCH_ASSOC); if (!$rows) echo "No rows found.\n"; else echo json_encode($rows, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE); } catch (Throwable $e) { echo "Query failed: " . $e->getMessage(); } ?></pre> <?php endif; ?> </div> <div style="height:12px"></div> <div class="card"> <h3>If error still occurs</h3> <ol> <li>Copy the full page output (this debug view) and send to me.</li> <li>Also paste the server PHP error log tail (if available). Example: <code>tail -n 200 /var/log/php_errors.log</code></li> <li>If auth include failed, show me the auth folder listing: <code>ls -la /home/.../erp/modules/auth</code></li> </ol> </div> </body> </html> <?php exit; } catch (Throwable $e) { // final fallback: show error and stack trace in plain text (so browser won't 500) http_response_code(500); echo "<h2>Fatal error (debug)</h2>"; echo "<pre>"; echo "Message: " . htmlspecialchars($e->getMessage()) . "\n\n"; echo "File: " . htmlspecialchars($e->getFile()) . " : " . $e->getLine() . "\n\n"; echo "Trace:\n" . htmlspecialchars($e->getTraceAsString()); echo "</pre>"; exit; }