Exemplo n.º 1
0
function user_delete_backend($props, $authenticate)
{
    if (1 == 1) {
        // system checks
        $username = strtolower(trim($props['username']));
        $domain = explode('@', $username);
        $domain = strtolower($domain[1]);
        $p = user_get_backend(array('arg' => $username), $authenticate);
        if (!$p['abort']) {
            // the user exists
            try {
                // delete the user
                $p = user_get_backend(array('arg' => $username), $authenticate);
                if ($p['abort']) {
                    // the user does not exist
                    $props = array('abort' => false);
                } else {
                    $props = array('abort' => true);
                    // deletion failed
                }
            } catch (Exception $e) {
                $props = array('abort' => true);
                // an error occured when deleting the user
            }
        } else {
            $props = array('abort' => false);
            // the user does not exist
        }
    } else {
        $props = array('abort' => true);
        // system checks failed
    }
    return $props;
}
Exemplo n.º 2
0
function user_delete_backend($props, $authenticate)
{
    if (class_exists('COM')) {
        $username = strtolower(trim($props['username']));
        $domain = explode('@', $username);
        $domain = strtolower($domain[1]);
        $p = user_get_backend(array('arg' => $username), $authenticate);
        if (!$p['abort']) {
            try {
                $obApp = new COM('hMailServer.Application');
                $obApp->Authenticate($authenticate['admin'], $authenticate['password']);
                $obDomain = $obApp->Domains->ItemByName($domain);
                $obAccount = $obDomain->Accounts->ItemByAddress($username);
                $obDomain->Accounts->DeleteByDBID($obAccount->ID);
                $p = user_get_backend(array('arg' => $username), $authenticate);
                if ($p['abort']) {
                    $props = array('abort' => false);
                } else {
                    $props = array('abort' => true, 'message' => array('type' => 'error', 'label' => 'errorsaving'));
                }
            } catch (Exception $e) {
                $props = array('abort' => true, 'message' => array('type' => 'error', 'label' => 'errorsaving'));
            }
        } else {
            $props = array('abort' => true, 'message' => array('type' => 'error', 'label' => 'companyaddressbook.usernotfound'));
        }
    } else {
        $props = array('abort' => true, 'message' => array('type' => 'error', 'label' => 'companyaddressbook.COMerror'));
    }
    return $props;
}
Exemplo n.º 3
0
function user_edit_backend($props, $authenticate, $db = false)
{
    $username = strtolower(trim($props['post']['_user']));
    if (!$username) {
        $username = strtolower(trim($props['post']['_email'][0]));
    }
    if ($username) {
        $p = user_get_backend(array('arg' => $username), $authenticate, $db);
        $db = $p['db'];
        if ($db) {
            if (!$p['abort']) {
                try {
                    $mailboxsize = (int) trim($props['post']['_size']);
                    $pass = trim($props['post']['_pass']);
                    $active = (int) trim($props['post']['_active']);
                    if (strtolower($pass) == '<< encrypted >>') {
                        $sql = 'UPDATE hm_accounts SET accountactive=?, accountmaxsize=? WHERE accountaddress LIKE ? LIMIT 1';
                        $db->query($sql, $active, $mailboxsize, $username);
                    } else {
                        $sql = 'UPDATE hm_accounts SET accountpassword=?, accountpwencryption=?, accountactive=?, accountmaxsize=? WHERE accountaddress LIKE ? LIMIT 1';
                        $db->query($sql, md5($pass), '2', $active, $mailboxsize, $username);
                    }
                    $props = user_get_backend(array('arg' => $username), $authenticate, $db);
                } catch (Exception $e) {
                    $props = array('abort' => true, 'message' => array('type' => 'error', 'label' => 'errorsaving'));
                }
            } else {
                $props['post']['_email'][0] = $username;
                $props = user_create_backend($props, $authenticate, $db);
            }
        } else {
            $props = array('abort' => true, 'message' => array('type' => 'error', 'label' => 'companyaddressbook.DBerror'));
        }
    } else {
        $props = array('abort' => true, 'message' => array('type' => 'error', 'label' => 'errorsaving'));
    }
    return $props;
}