Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69793f47 authored by Akhil's avatar Akhil 🙂
Browse files

Fix postDeleteLDAP.php

parent 4b54c214
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -103,17 +103,17 @@ function deleteMailFolders()
    // Dir where /mnt/repo-base/volumes/mail/ is bind mounted on postfixadmin container
    $baseDir = "/var/mail/vhosts/";

    global $userOnly, $domain;
    global $emailUsername, $domain;

    if (!empty($domain) && !empty($userOnly)) {
    if (!empty($domain) && !empty($emailUsername)) {
        $ssh = new SSH2($PF_HOSTNAME);
        if (!$ssh->login($PF_USER, $PF_PWD)) {
            exit('Login Failed');
        }

        $ssh->exec('sudo /usr/local/bin/mailbox-postdeletion.sh ' . escapeshellarg($userOnly) . ' ' . escapeshellarg($domain));
        $ssh->exec('sudo /usr/local/bin/mailbox-postdeletion.sh ' . escapeshellarg($emailUsername) . ' ' . escapeshellarg($domain));
        // build path to check deletion
        $fullPath = $baseDir . $domain . "/" . $userOnly;
        $fullPath = $baseDir . $domain . "/" . $emailUsername;
        $delDirConfirm = $ssh->exec('[ ! -d ' . escapeshellarg($fullPath) . ' ] && echo "DELETED"');

        return $delDirConfirm === "DELETED";
@@ -122,17 +122,20 @@ function deleteMailFolders()
    } // $domain OR $userOnly empty, do nothing!!
}


if (sha1($_POST['sec']) !== getenv("WELCOME_SECRET_SHA")) {
    http_response_code(403);
    exit();
} else {
    $user2delete = $_POST['uid'];
    $exploded = explode("@", $user2delete);
    $userOnly = $exploded[0];
    $domain = $exploded[1];
    $explodedUsername = explode("@", $user2delete);
    $userOnly = $explodedUsername[0];
    
    $email = $_POST['email'];
    $explodedEmail = explode("@", $email);
    $emailUsername = $explodedEmail[0];
    $domain = $explodedEmail[1];

    // STEP 1 : remove $user2delete from postfix database AND remove its mail folder
    // STEP 1 : remove $email mail folder(s)
    $mailDeletionReturn = deleteMailFolders();
    if ($mailDeletionReturn == true) {
        /**