<?php
/*
This file belongs to the Webinterface of schokokeks.org Hosting
Written by schokokeks.org Hosting, namely
Bernd Wurst <bernd@schokokeks.org>
Hanno Böck <hanno@schokokeks.org>
This code is published under a 0BSD license.
Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
*/
require_once('vendor/autoload.php');
function list_systemuser_totp($uid = null)
{
if (!$uid) {
$uid = (int)$_SESSION['userinfo']['uid'];
}
$result = db_query("SELECT id, description, setuptime FROM system.systemuser_totp WHERE uid=?", [$uid]);
$ret = [];
while ($line = $result->fetch()) {
$ret[] = $line;
}
return $ret;
}
function check_systemuser_password($password)
{
$result = db_query("SELECT passwort AS password FROM system.passwoerter WHERE uid=:uid", [":uid" => $_SESSION['userinfo']['uid']]);
if (@$result->rowCount() > 0) {
$entry = $result->fetch(PDO::FETCH_OBJ);
$db_password = $entry->password;
$hash = crypt($password, $db_password);
if ($hash == $db_password) {
return true;
}
}
return false;
}
function generate_systemuser_secret()
{
$ga = new PHPGangsta_GoogleAuthenticator();
$secret = $ga->createSecret();
DEBUG('GA-Secret: ' . $secret);
return $secret;
}