' . lang("2fa active", false) . ''
. ''
. lang("remove 2fa", false) . '';
} else if ($_GET['2fa'] == "generate") {
$codeuri = newTOTP($_SESSION['username']);
$userdata = $database->select('accounts', ['email', 'authsecret', 'realname'], ['username' => $_SESSION['username']])[0];
$label = SYSTEM_NAME . ":" . is_null($userdata['email']) ? $userdata['realname'] : $userdata['email'];
$issuer = SYSTEM_NAME;
$qrCode = new QrCode($codeuri);
$qrCode->setWriterByName('svg');
$qrCode->setSize(550);
$qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH);
$qrcode = $qrCode->writeDataUri();
$totp = Factory::loadFromProvisioningUri($codeuri);
$codesecret = $totp->getSecret();
$chunk_secret = trim(chunk_split($codesecret, 4, ' '));
$lang_manualsetup = lang("manual setup", false);
$lang_secretkey = lang("secret key", false);
$lang_label = lang("label", false);
$lang_issuer = lang("issuer", false);
$lang_entercode = lang("enter otp code", false);
$APPS["setup_2fa"]["content"] = ' ' . lang("scan 2fa qrcode", false) . '
' . <<
.margintop-15px {
margin-top: 15px;
}
.mono-chunk {
text-align: center;
font-size: 110%;
font-family: monospace;
}
$lang_manualsetup
$chunk_secret
$label
$issuer
END;
} else {
$APPS["setup_2fa"]["content"] = ' ' . lang("2fa explained", false) . '
'
. ''
. lang("enable 2fa", false) . '';
}