Files
html/office-365/api/office-checker.php
Opus-Yacine 95520854f8
Some checks failed
WEVAL NonReg / nonreg (push) Has been cancelled
fix: office_accounts 1000→6403 (localhost→S95 10.1.0.3) + screens cleanup 1167→5 — doctrine 34
2026-04-17 01:12:20 +02:00

42 lines
2.1 KiB
PHP

<?php
header('Content-Type: application/json');
// S95 LIVE DB (10.1.0.3 via WireGuard) — NOT local 127.0.0.1 copy
$db = @pg_connect("host=10.1.0.3 port=5432 user=admin password=admin123 dbname=adx_system");
if (!$db) { echo json_encode(['status'=>'error','error'=>'s95_db_connect_failed']); exit; }
$action = $_GET['action'] ?? $_POST['action'] ?? (json_decode(file_get_contents('php://input'),true)['action'] ?? 'stats');
@pg_query($db, "SET search_path TO admin");
switch ($action) {
case 'stats':
// Case-insensitive status (table has both 'Active' and 'active')
$r = @pg_query($db, "SELECT
COUNT(*) as total,
COUNT(*) FILTER(WHERE LOWER(status)='active') as active,
COUNT(*) FILTER(WHERE LOWER(status)='pending') as pending,
COUNT(*) FILTER(WHERE LOWER(status)='warming') as warming,
COUNT(*) FILTER(WHERE LOWER(status)='blocked') as blocked,
COUNT(*) FILTER(WHERE LOWER(status)='suspended') as suspended,
COUNT(*) FILTER(WHERE mfa_enabled=true) as mfa
FROM admin.office_accounts");
if (!$r) { echo json_encode(['status'=>'error','pg_error'=>pg_last_error($db)]); exit; }
$s = pg_fetch_assoc($r);
echo json_encode(['status'=>'success','source'=>'S95 10.1.0.3','data'=>[
'total'=>(int)$s['total'], 'active'=>(int)$s['active'],
'pending'=>(int)$s['pending'], 'warming'=>(int)$s['warming'],
'blocked'=>(int)$s['blocked'], 'suspended'=>(int)$s['suspended'],
'mfa'=>(int)$s['mfa']
]]);
break;
case 'accounts':
$limit = (int)($_GET['limit'] ?? 50);
$r = @pg_query_params($db, "SELECT email,status,mfa_enabled,daily_limit,sent_today,last_check FROM admin.office_accounts ORDER BY status,email LIMIT $1", [$limit]);
if (!$r) { echo json_encode(['status'=>'error']); exit; }
$rows=[]; while($row=pg_fetch_assoc($r)) $rows[]=$row;
echo json_encode(['status'=>'success','count'=>count($rows),'data'=>$rows]);
break;
default:
echo json_encode(['status'=>'ok','actions'=>['stats','accounts']]);
}