<?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 secondary_token.php <4-digit-code>\n"; exit(1); } $code = $argv[1]; if (!preg_match('/^\d{4}$/', $code)) { echo "Error: Secondary code must be exactly 4 digits.\n"; exit(1); } $hash = password_hash($code, PASSWORD_BCRYPT, ['cost' => 12]); $output = "<?php\nreturn " . var_export($hash, true) . ";\n"; $path = '/var/www/private/admin_secondary.secret.php'; file_put_contents($path, $output); chmod($path, 0600); echo "Secondary code hash written to {$path}\n"; 