<?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('inc/debug.php');
require_once('inc/base.php');
require_once('inc/security.php');
require_once('class/domain.php');
require_once('common.php');
function mailaccounts($uid)
{
$uid = (int) $uid;
$result = db_query("SELECT m.id,concat_ws('@',`m`.`local`,if(isnull(`m`.`domain`),:masterdomain,`d`.`domainname`)) AS `account`, `m`.`password` AS `cryptpass`,`m`.`maildir` AS `maildir`,aktiv from (`mail`.`mailaccounts` `m` left join `mail`.`v_domains` `d` on((`d`.`id` = `m`.`domain`))) WHERE m.uid=:uid ORDER BY if(isnull(`m`.`domain`),:masterdomain,`d`.`domainname`), local", [":masterdomain" => config("masterdomain"), ":uid" => $uid]);
DEBUG("Found ".@$result->rowCount()." rows!");
$accounts = [];
if (@$result->rowCount() > 0) {
while ($acc = @$result->fetch(PDO::FETCH_OBJ)) {
array_push($accounts, ['id'=> $acc->id, 'account' => $acc->account, 'mailbox' => $acc->maildir, 'cryptpass' => $acc->cryptpass, 'enabled' => ($acc->aktiv == 1)]);
}
}
return $accounts;
}
function get_mailaccount($id)
{
$id = (int) $id;
$uid = (int) $_SESSION['userinfo']['uid'];
$result = db_query("SELECT concat_ws('@',`m`.`local`,if(isnull(`m`.`domain`),:masterdomain,`d`.`domainname`)) AS `account`, `m`.`password` AS `cryptpass`,`m`.`maildir` AS `maildir`,aktiv from (`mail`.`mailaccounts` `m` left join `mail`.`v_domains` `d` on((`d`.`id` = `m`.`domain`))) WHERE m.id=:mid AND m.uid=:uid", [":masterdomain" => config("masterdomain"), ":uid" => $uid, ":mid" => $id]);
DEBUG("Found ".$result->rowCount()." rows!");
if ($result->rowCount() != 1) {
system_failure('Dieser Mailaccount existiert nicht oder gehört Ihnen nicht');
}
$acc = $result->fetch(PDO::FETCH_OBJ);
$ret = ['account' => $acc->account, 'mailbox' => $acc->maildir, 'enabled' => ($acc->aktiv == 1)];
DEBUG(print_r($ret, true));
return $ret;
}
function change_mailaccount($id, $arr)