<?php require __DIR__.'/../lib/bootstrap.php';$from=preg_replace('/[^A-Z]/','',strtoupper(isset($_GET['from'])?$_GET['from']:''));$to=preg_replace('/[^A-Z]/','',strtoupper(isset($_GET['to'])?$_GET['to']:''));if(strlen($from)!==3||strlen($to)!==3)json_out(array('error'=>'Invalid currency pair'),422);$rows=db_all("SELECT s.name,s.source_type,r.rate,r.fee_amount,r.recipient_amount,r.delivery_label,r.captured_at FROM rate_quotes r JOIN rate_sources s ON s.id=r.source_id WHERE r.from_currency=? AND r.to_currency=? AND r.status='approved' AND r.expires_at>NOW() ORDER BY r.recipient_amount DESC",array($from,$to));json_out(array('pair'=>$from.'/'.$to,'results'=>$rows,'disclaimer'=>'Indicative quotes; verify before transacting.'));