<?php
require_once __DIR__.'/../includes/functions.php';
$admin = require_admin();
$adminTitle = 'Trust & Safety Dashboard';
$adminSubtitle = 'Review reports, suspicious activity, verification queue, fraud risk and blocked users.';
$reports = table_exists('mj_reports') ? safe_count_public('SELECT COUNT(*) c FROM mj_reports WHERE status IN ("new","open","pending")') : 0;
$reportedListings = table_exists('mj_listing_reports') ? safe_count_public('SELECT COUNT(*) c FROM mj_listing_reports WHERE status IN ("new","open","pending")') : 0;
$reviews = table_exists('mj_reviews') ? safe_count_public('SELECT COUNT(*) c FROM mj_reviews WHERE status IN ("pending","reported")') : 0;
$verification = table_exists('mj_verification_requests') ? safe_count_public('SELECT COUNT(*) c FROM mj_verification_requests WHERE status IN ("pending","submitted")') : 0;
$blocked = table_exists('mj_blocked_users') ? safe_count_public('SELECT COUNT(*) c FROM mj_blocked_users') : 0;
$rows = table_exists('mj_reports') ? mj_v290_simple_rows('SELECT * FROM mj_reports ORDER BY id DESC LIMIT 20') : [];
include __DIR__.'/_header.php';
?>
<div class="mj-admin-pro-ribbon"><a href="reports.php"><i class="fas fa-flag"></i><span><b><?=e($reports+$reportedListings)?></b><small>Open reports / scam reviews</small></span></a><a href="reviews.php"><i class="fas fa-star"></i><span><b><?=e($reviews)?></b><small>Reviews pending / reported</small></span></a><a href="approval-center.php"><i class="fas fa-user-check"></i><span><b><?=e($verification)?></b><small>Verification pending</small></span></a><a href="fraud-dashboard.php"><i class="fas fa-user-secret"></i><span><b>Fraud</b><small>Open fraud dashboard</small></span></a><a href="audit-logs.php"><i class="fas fa-history"></i><span><b>Audit</b><small>Admin action trail</small></span></a></div>
<div class="card card-danger card-outline"><div class="card-header"><h3 class="card-title">Latest Safety Reports</h3></div><div class="card-body table-responsive"><table class="table table-hover"><thead><tr><th>ID</th><th>Type</th><th>Reason</th><th>Status</th><th>Date</th></tr></thead><tbody><?php foreach($rows as $r): ?><tr><td>#<?=e($r['id']??'')?></td><td><?=e($r['report_type']??$r['type']??'Report')?></td><td><?=e(mb_strimwidth($r['reason']??$r['message']??'',0,80,'...'))?></td><td><?=mj_v289_render_status_badge($r['status']??'new')?></td><td><?=e($r['created_at']??'')?></td></tr><?php endforeach; ?><?php if(!$rows): ?><tr><td colspan="5" class="text-center text-muted p-4">No safety reports found.</td></tr><?php endif; ?></tbody></table></div></div>
<?php include __DIR__.'/_footer.php'; ?>
