trim((string)($query['mem_no'] ?? '')), 'phone' => trim((string)($query['phone'] ?? '')), ]; // mem_no: 숫자만 if ($filters['mem_no'] !== '' && !ctype_digit($filters['mem_no'])) { $filters['mem_no'] = ''; } // phone: 숫자만 (10~11자리 아니어도 부분검색 가능하게 숫자만 유지) $filters['phone_digits'] = preg_replace('/\D+/', '', $filters['phone']) ?: ''; $page = $this->repo->paginate($filters, 30); $rows = []; foreach ($page->items() as $it) { $r = is_array($it) ? $it : (array)$it; $phone = (string)($r['mobile_number'] ?? ''); $r['phone_digits'] = preg_replace('/\D+/', '', $phone) ?: ''; $r['phone_display'] = $this->formatPhone($r['phone_digits']) ?: $phone; // JSON(모달용) - 개인정보 최소화 (mem_no/전화 + 결과/거래정보만) $infoArr = $this->decodeJson((string)($r['info'] ?? '')); $r['info_sanitized'] = $this->sanitizeInfo($infoArr, $r); $rows[] = $r; } return [ 'page' => $page, 'rows' => $rows, 'filters' => $filters, ]; } private function decodeJson(string $json): array { $json = trim($json); if ($json === '') return []; $arr = json_decode($json, true); return is_array($arr) ? $arr : []; } private function sanitizeInfo(array $info, array $row): array { // 허용 필드만 남김 (요구사항: mem_no + 전화만 노출) // + 로그 판단에 필요한 최소 정보(RETURNCODE/RETURNMSG/TID/telecom 등)만 $out = []; $out['gubun'] = (string)($row['gubun'] ?? ''); $out['res_code'] = (string)($row['res_code'] ?? ''); $out['TID'] = (string)($row['TID'] ?? ''); $out['mem_no'] = (string)($row['mem_no'] ?? ''); // info에서 가져오되, 화면엔 전화번호만 $out['mobile_number'] = (string)($info['mobile_number'] ?? ($row['mobile_number'] ?? '')); // 결과코드/메시지(있으면) $out['RETURNCODE'] = (string)($info['RETURNCODE'] ?? ($info['res_code'] ?? '')); $out['RETURNMSG'] = (string)($info['RETURNMSG'] ?? ''); // telecom은 개인식별 정보는 아니지만, 원하면 모달에서도 빼도 됨. // 지금은 로그 파악에 도움돼서 유지. if (isset($info['telecom'])) $out['telecom'] = (string)$info['telecom']; // CI/DI/name/birthday/sex/email 등은 완전히 제거 return array_filter($out, fn($v) => $v !== ''); } private function formatPhone(string $digits): string { if (!preg_match('/^\d{10,11}$/', $digits)) return ''; if (strlen($digits) === 11) return substr($digits, 0, 3).'-'.substr($digits, 3, 4).'-'.substr($digits, 7, 4); return substr($digits, 0, 3).'-'.substr($digits, 3, 3).'-'.substr($digits, 6, 4); } }