<?php
/*
This file belongs to the Webinterface of schokokeks.org Hosting
Written 2008-2018 by schokokeks.org Hosting, namely
Bernd Wurst <bernd@schokokeks.org>
Hanno Böck <hanno@schokokeks.org>
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
http://creativecommons.org/publicdomain/zero/1.0/
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.
*/
function account_has_totp($username)
{
$result = db_query("SELECT id FROM mail.webmail_totp WHERE email=?", array($username));
if ($result->rowCount() > 0) {
$tmp = $result->fetch();
$id = $tmp['id'];
return $id;
} else {
return false;
}
}
function validate_password($username, $password)
{
$args[":username"] = $username;
$result = db_query("SELECT account, cryptpass FROM mail.courier_mailaccounts WHERE account=:username UNION SELECT account, cryptpass FROM mail.courier_virtual_accounts WHERE account=:username", $args);
if ($result->rowCount() != 1) {
// Kein Account mit dem Namen oder Name nicht eindeutig
return false;
}
$account = $result->fetch();
return (crypt($password, $account['cryptpass']) == $account['cryptpass']);
}
function store_webmail_password($username, $oldpw, $newpw)
{
$secret = $newpw;
if (strlen($oldpw) > strlen($newpw)) {
$secret = str_pad($newpw, strlen($oldpw), $newpw);
}
if (strlen($oldpw) < strlen($newpw)) {
$newpw = substr($newpw, 0, strlen($oldpw));