<?php declare(strict_types=1); if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } if (php_sapi_name() !== 'cli') { exit('CLI only.'); } if ($argc < 2) { echo "Usage: php pin_generator.php <6-digit-pin>\n"; exit(1); } $pin = $argv[1]; if (!preg_match('/^\d{6}$/', $pin)) { echo "Error: PIN must be exactly 6 digits.\n"; exit(1); } $hash = password_hash($pin, PASSWORD_BCRYPT, ['cost' => 12]); $output = "<?php\nreturn " . var_export($hash, true) . ";\n"; $path = '/var/www/private/admin_pin.secret.php'; file_put_contents($path, $output); chmod($path, 0600); echo "PIN hash written to {$path}\n"; 