<?php
require '../vendor/autoload.php';
use OTPHP\TOTP;

date_default_timezone_set('UTC');

$secretKey = 'JBSWY3DPEHPK3PXP'; // Replace with your actual stored secret
$totp = TOTP::createFromSecret($secretKey);

$currentTime = time();
$timeCounter = floor($currentTime / 30);
$otp = $totp->now();

$logMessage = "[" . date("Y-m-d H:i:s") . "] Current Unix Time: $currentTime\n";
$logMessage .= "[" . date("Y-m-d H:i:s") . "] Time Step Counter: $timeCounter\n";
$logMessage .= "[" . date("Y-m-d H:i:s") . "] Generated OTP: $otp\n";
$logMessage .= "[" . date("Y-m-d H:i:s") . "] Server Timezone: " . date_default_timezone_get() . "\n";
$logMessage .= "[" . date("Y-m-d H:i:s") . "] Secret Key Used: $secretKey\n";
file_put_contents("test_debug_log.txt", $logMessage, FILE_APPEND);

echo "Generated OTP: " . $otp;
?>
