bernd
Auch mailaccounts können sich einloggen
bernd commited ce0caaf at 2007-08-13 13:15:55
mailaccounts.php
<?php
require_once('inc/debug.php');
require_once('inc/db_connect.php');
require_once('inc/base.php');
require_once('inc/security.php');
require_once('class/domain.php');
function mailaccounts($uid)
{
$uid = (int) $uid;
$result = db_query("SELECT m.id,concat_ws('@',`m`.`local`,if(isnull(`m`.`domain`),_utf8'schokokeks.org',`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");
DEBUG("Found ".@mysql_num_rows($result)." rows!");
$accounts = array();
if (@mysql_num_rows($result) > 0)
while ($acc = @mysql_fetch_object($result))
array_push($accounts, array('id'=> $acc->id, 'account' => $acc->account, 'mailbox' => $acc->maildir, 'cryptpass' => $acc->cryptpass, 'enabled' => ($acc->aktiv == 1)));
return $accounts;
}
function get_mailaccount($id)
{
$uid = (int) $uid;
$result = db_query("SELECT concat_ws('@',`m`.`local`,if(isnull(`m`.`domain`),_utf8'schokokeks.org',`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=$id");
DEBUG("Found ".mysql_num_rows($result)." rows!");
$acc = mysql_fetch_object($result);
$ret = array('account' => $acc->account, 'mailbox' => $acc->maildir, 'enabled' => ($acc->aktiv == 1));
DEBUG(print_r($ret, true));
return $ret;
}
function encrypt_mail_password($pw)
{
DEBUG("unencrypted PW: ".$pw);
require_once('inc/base.php');
$salt = random_string(8);
$encpw = crypt($pw, "\$1\${$salt}\$");
DEBUG("encrypted PW: ".$encpw);
return chop($encpw);
}
function change_mailaccount($id, $arr)
{
$id = (int) $id;
$conditions = array();
if (isset($arr['account']))
{
list($local, $domain) = explode('@', $arr['account'], 2);
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX