Example #1
0
				<div class="alert alert-info" role="alert"><?php 
            echo $lang['info']['no_action'];
            ?>
</div>
			<?php 
        }
    } elseif (isset($_GET['mailbox']) && filter_var($_GET["mailbox"], FILTER_VALIDATE_EMAIL) && !empty($_GET["mailbox"])) {
        $mailbox = $_GET["mailbox"];
        try {
            $stmt = $pdo->prepare("SELECT `username`, `domain`, `name`, `quota`, `active` FROM `mailbox` WHERE `username` = :username1");
            $stmt->execute(array(':username1' => $mailbox));
            $result = $stmt->fetch(PDO::FETCH_ASSOC);
        } catch (PDOException $e) {
            $_SESSION['return'] = array('type' => 'danger', 'msg' => 'MySQL: ' . $e);
        }
        if ($result !== false && hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $result['domain'])) {
            $left_m = remaining_specs($result['domain'], $_GET['mailbox'])['left_m'];
            ?>
				<h4><?php 
            echo $lang['edit']['mailbox'];
            ?>
</h4>
				<form class="form-horizontal" role="form" method="post" action="<?php 
            echo $FORM_ACTION == "previous" ? $_SESSION['return_to'] : null;
            ?>
">
				<input type="hidden" name="username" value="<?php 
            echo $result['username'];
            ?>
">
					<div class="form-group">
Example #2
0
        ?>
">
					<div class="form-group">
						<div class="col-sm-offset-1 col-sm-10">
							<button type="submit" name="trigger_delete_domain_admin" class="btn btn-default btn-sm"><?php 
        echo $lang['delete']['remove_button'];
        ?>
</button>
						</div>
					</div>
				</form>
				<?php 
    } elseif (isset($_GET["mailbox"]) && filter_var($_GET["mailbox"], FILTER_VALIDATE_EMAIL) && !empty($_GET["mailbox"])) {
        $mailbox = $_GET["mailbox"];
        $domain = substr(strrchr($mailbox, "@"), 1);
        if (hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) {
            ?>
					<div class="alert alert-warning" role="alert"><?php 
            echo sprintf($lang['delete']['remove_mailbox_warning'], htmlspecialchars($_GET["mailbox"]));
            ?>
</div>
					<p><?php 
            echo $lang['delete']['remove_mailbox_details'];
            ?>
</p>
					<form class="form-horizontal" role="form" method="post" action="/mailbox.php">
					<input type="hidden" name="username" value="<?php 
            echo $mailbox;
            ?>
">
						<div class="form-group">
Example #3
0
function remaining_specs($domain, $object = null, $js = null)
{
    // left_m	without object given	= MiB left in domain
    // left_m	with object given		= Max. MiB we can assign to given object
    // limit_m							= Domain limit in MiB
    // left_c							= Mailboxes we can create depending on domain quota
    global $pdo;
    if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) {
        return false;
    }
    try {
        $stmt = $pdo->prepare("SELECT `mailboxes`, `maxquota`, `quota` FROM `domain` WHERE `domain` = :domain");
        $stmt->execute(array(':domain' => $domain));
        $DomainData = $stmt->fetch(PDO::FETCH_ASSOC);
        $stmt = $pdo->prepare("SELECT COUNT(*) AS `count`, COALESCE(ROUND(SUM(`quota`)/1048576), 0) as `in_use_m` FROM `mailbox` WHERE `domain` = :domain AND `username` != :object");
        $stmt->execute(array(':domain' => $domain, ':object' => $object));
        $MailboxDataDomain = $stmt->fetch(PDO::FETCH_ASSOC);
        $quota_left_m = $DomainData['quota'] - $MailboxDataDomain['in_use_m'];
        $mboxs_left = $DomainData['mailboxes'] - $MailboxDataDomain['count'];
        if ($quota_left_m > $DomainData['maxquota']) {
            $quota_left_m = $DomainData['maxquota'];
        }
    } catch (PDOException $e) {
        return false;
    }
    if (is_numeric($quota_left_m)) {
        $spec['left_m'] = $quota_left_m;
        $spec['limit_m'] = $DomainData['maxquota'];
    }
    if (is_numeric($mboxs_left)) {
        $spec['left_c'] = $mboxs_left;
    }
    if (!empty($js)) {
        echo $quota_left_m;
        exit;
    }
    return $spec;
}