Some changes in functions
This commit is contained in:
@@ -49,80 +49,32 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT
|
||||
`domain`,
|
||||
`aliases`,
|
||||
`mailboxes`,
|
||||
`maxquota` * 1048576 AS `maxquota`,
|
||||
`quota` * 1048576 AS `quota`,
|
||||
CASE `backupmx` WHEN 1 THEN '".$lang['mailbox']['yes']."' ELSE '".$lang['mailbox']['no']."' END AS `backupmx`,
|
||||
CASE `active` WHEN 1 THEN '".$lang['mailbox']['yes']."' ELSE '".$lang['mailbox']['no']."' END AS `active`
|
||||
FROM `domain` WHERE
|
||||
`domain` IN (
|
||||
SELECT `domain` FROM `domain_admins` WHERE `username`= :username AND `active`='1'
|
||||
)
|
||||
OR 'admin'= :admin");
|
||||
$stmt->execute(array(
|
||||
':username' => $_SESSION['mailcow_cc_username'],
|
||||
':admin' => $_SESSION['mailcow_cc_role'],
|
||||
));
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => 'MySQL: '.$e
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if(!empty($rows)):
|
||||
while($row = array_shift($rows)):
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT COUNT(*) AS `count` FROM `alias`
|
||||
WHERE `domain`= :domain
|
||||
AND `address` NOT IN (
|
||||
SELECT `username` FROM `mailbox`)");
|
||||
$stmt->execute(array(':domain' => $row['domain']));
|
||||
$AliasData = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$stmt = $pdo->prepare("SELECT
|
||||
COUNT(*) AS `count`,
|
||||
COALESCE(SUM(`quota`), '0') AS `quota`
|
||||
FROM `mailbox`
|
||||
WHERE `domain` = :domain");
|
||||
$stmt->execute(array(':domain' => $row['domain']));
|
||||
$MailboxData = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => 'MySQL: '.$e
|
||||
);
|
||||
return false;
|
||||
}
|
||||
$domains = mailbox_get_domains();
|
||||
if (!empty($domains)):
|
||||
foreach ($domains as $domain):
|
||||
$domaindata = mailbox_get_domain_details($domain);
|
||||
?>
|
||||
<tr id="data">
|
||||
<td><?=htmlspecialchars($row['domain']);?></td>
|
||||
<td><?=intval($AliasData['count']);?> / <?=intval($row['aliases']);?></td>
|
||||
<td><?=$MailboxData['count'];?> / <?=$row['mailboxes'];?></td>
|
||||
<td><?=formatBytes(intval($row['maxquota']), 2);?></td>
|
||||
<td><?=formatBytes(intval($MailboxData['quota']), 2);?> / <?=formatBytes(intval($row['quota']));?></td>
|
||||
<td><?=htmlspecialchars($domaindata['domain_name']);?></td>
|
||||
<td><?=$domaindata['aliases_in_domain'];?> / <?=$domaindata['max_num_aliases_for_domain'];?></td>
|
||||
<td><?=$domaindata['mboxes_in_domain'];?> / <?=$domaindata['max_num_mboxes_for_domain'];?></td>
|
||||
<td><?=$domaindata['max_quota_for_mbox'];?></td>
|
||||
<td><?=$domaindata['quota_used_in_domain'];?> / <?=$domaindata['max_quota_for_domain'];?></td>
|
||||
<?php
|
||||
if ($_SESSION['mailcow_cc_role'] == "admin"):
|
||||
?>
|
||||
<td><?=$row['backupmx'];?></td>
|
||||
<td><?=$domaindata['backupmx'];?></td>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<td><?=$row['active'];?></td>
|
||||
<td><?=$domaindata['active'];?></td>
|
||||
<?php
|
||||
if ($_SESSION['mailcow_cc_role'] == "admin"):
|
||||
?>
|
||||
<td style="text-align: right;">
|
||||
<div class="btn-group">
|
||||
<a href="/edit.php?domain=<?=urlencode($row['domain']);?>" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> <?=$lang['mailbox']['edit'];?></a>
|
||||
<a href="/delete.php?domain=<?=urlencode($row['domain']);?>" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> <?=$lang['mailbox']['remove'];?></a>
|
||||
<a href="/edit.php?domain=<?=urlencode($domaindata['domain_name']);?>" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> <?=$lang['mailbox']['edit'];?></a>
|
||||
<a href="/delete.php?domain=<?=urlencode($domaindata['domain_name']);?>" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> <?=$lang['mailbox']['remove'];?></a>
|
||||
</div>
|
||||
</td>
|
||||
<?php
|
||||
@@ -130,19 +82,19 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||
?>
|
||||
<td style="text-align: right;">
|
||||
<div class="btn-group">
|
||||
<a href="/edit.php?domain=<?=urlencode($row['domain']);?>" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> <?=$lang['mailbox']['edit'];?></a>
|
||||
<a href="/edit.php?domain=<?=urlencode($domaindata['domain_name']);?>" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> <?=$lang['mailbox']['edit'];?></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endif;
|
||||
endwhile;
|
||||
else:
|
||||
?>
|
||||
<tr id="no-data"><td colspan="8" style="text-align: center; font-style: italic;"><?=$lang['mailbox']['no_record'];?></td></tr>
|
||||
<?php
|
||||
endif;
|
||||
<?php
|
||||
endif;
|
||||
endforeach;
|
||||
else:
|
||||
?>
|
||||
<tr id="no-data"><td colspan="8" style="text-align: center; font-style: italic;"><?=$lang['mailbox']['no_record'];?></td></tr>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</tbody>
|
||||
<?php
|
||||
if ($_SESSION['mailcow_cc_role'] == "admin"):
|
||||
@@ -189,51 +141,33 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT
|
||||
`alias_domain`,
|
||||
`target_domain`,
|
||||
CASE `active` WHEN 1 THEN '".$lang['mailbox']['yes']."' ELSE '".$lang['mailbox']['no']."' END AS `active`
|
||||
FROM `alias_domain`
|
||||
WHERE `target_domain` IN (
|
||||
SELECT `domain` FROM `domain_admins`
|
||||
WHERE `username`= :username
|
||||
AND `active`='1'
|
||||
)
|
||||
OR 'admin' = :admin");
|
||||
$stmt->execute(array(
|
||||
':username' => $_SESSION['mailcow_cc_username'],
|
||||
':admin' => $_SESSION['mailcow_cc_role'],
|
||||
));
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch(PDOException $e) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => 'MySQL: '.$e
|
||||
);
|
||||
}
|
||||
if(!empty($rows)):
|
||||
while($row = array_shift($rows)):
|
||||
?>
|
||||
<tr id="data">
|
||||
<td><?=htmlspecialchars($row['alias_domain']);?></td>
|
||||
<td><?=htmlspecialchars($row['target_domain']);?></td>
|
||||
<td><?=$row['active'];?></td>
|
||||
<td style="text-align: right;">
|
||||
<div class="btn-group">
|
||||
<a href="/edit.php?aliasdomain=<?=urlencode($row['alias_domain']);?>" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> <?=$lang['mailbox']['edit'];?></a>
|
||||
<a href="/delete.php?aliasdomain=<?=urlencode($row['alias_domain']);?>" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> <?=$lang['mailbox']['remove'];?></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endwhile;
|
||||
else:
|
||||
foreach (mailbox_get_domains() as $domain) {
|
||||
$alias_domains = mailbox_get_alias_domains($domain);
|
||||
if (!empty($alias_domains)) {
|
||||
foreach ($alias_domains as $alias_domain) {
|
||||
$aliasdomaindata = mailbox_get_alias_domain_details($alias_domain);
|
||||
?>
|
||||
<tr id="data">
|
||||
<td><?=htmlspecialchars($aliasdomaindata['alias_domain']);?></td>
|
||||
<td><?=htmlspecialchars($aliasdomaindata['target_domain']);?></td>
|
||||
<td><?=$aliasdomaindata['active'];?></td>
|
||||
<td style="text-align: right;">
|
||||
<div class="btn-group">
|
||||
<a href="/edit.php?aliasdomain=<?=urlencode($aliasdomaindata['alias_domain']);?>" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> <?=$lang['mailbox']['edit'];?></a>
|
||||
<a href="/delete.php?aliasdomain=<?=urlencode($aliasdomaindata['alias_domain']);?>" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> <?=$lang['mailbox']['remove'];?></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<tr id="no-data"><td colspan="4" style="text-align: center; font-style: italic;"><?=$lang['mailbox']['no_record'];?></td></tr>
|
||||
<tr id="no-data"><td colspan="8" style="text-align: center; font-style: italic;"><?=sprintf($lang['mailbox']['no_record'], $domain);?></td></tr>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr id="no-data">
|
||||
@@ -278,91 +212,45 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT
|
||||
`domain`.`backupmx`,
|
||||
`mailbox`.`username`,
|
||||
`mailbox`.`name`,
|
||||
CASE `mailbox`.`active` WHEN 1 THEN '".$lang['mailbox']['yes']."' ELSE '".$lang['mailbox']['no']."' END AS `active`,
|
||||
`mailbox`.`domain`,
|
||||
`mailbox`.`quota`,
|
||||
`quota2`.`bytes`,
|
||||
`quota2`.`messages`
|
||||
FROM `mailbox`, `quota2`, `domain`
|
||||
WHERE (`mailbox`.`username` = `quota2`.`username`)
|
||||
AND (`domain`.`domain` = `mailbox`.`domain`)
|
||||
AND (`mailbox`.`domain` IN (
|
||||
SELECT `domain` FROM `domain_admins`
|
||||
WHERE `username`= :username
|
||||
AND `active`='1'
|
||||
)
|
||||
OR 'admin' = :admin)");
|
||||
$stmt->execute(array(
|
||||
':username' => $_SESSION['mailcow_cc_username'],
|
||||
':admin' => $_SESSION['mailcow_cc_role'],
|
||||
));
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => 'MySQL: '.$e
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if(!empty($rows)):
|
||||
while($row = array_shift($rows)):
|
||||
foreach (mailbox_get_domains() as $domain) {
|
||||
$mailboxes = mailbox_get_mailboxes($domain);
|
||||
if (!empty($mailboxes)) {
|
||||
foreach ($mailboxes as $mailbox) {
|
||||
$mailboxdata = mailbox_get_mailbox_details($mailbox);
|
||||
?>
|
||||
<tr id="data">
|
||||
<?php
|
||||
if ($row['backupmx'] == "0"):
|
||||
?>
|
||||
<td><?=htmlspecialchars($row['username']);?></td>
|
||||
<?php
|
||||
else:
|
||||
?>
|
||||
<td><span data-toggle="tooltip" title="Relayed"><i class="glyphicon glyphicon-forward"></i> <?=htmlspecialchars($row['username']);?></span></td>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<td><?=htmlspecialchars($row['name'], ENT_QUOTES, 'UTF-8');?></td>
|
||||
<td><?=htmlspecialchars($row['domain']);?></td>
|
||||
<td><?=formatBytes(intval($row['bytes']), 2);?> / <?=formatBytes(intval($row['quota']), 2);?></td>
|
||||
<td><?=($mailboxdata['is_relayed'] == "0") ? htmlspecialchars($mailboxdata['username']) : '<span data-toggle="tooltip" title="Relayed"><i class="glyphicon glyphicon-forward"></i>' . htmlspecialchars($mailboxdata['username']) . '</span>';?></td>
|
||||
<td><?=htmlspecialchars($mailboxdata['name'], ENT_QUOTES, 'UTF-8');?></td>
|
||||
<td><?=htmlspecialchars($mailboxdata['domain']);?></td>
|
||||
<td><?=$mailboxdata['quota_used'];?> / <?=$mailboxdata['quota'];?></td>
|
||||
<td style="min-width:120px;">
|
||||
<?php
|
||||
$percentInUse = round((intval($row['bytes']) / intval($row['quota'])) * 100);
|
||||
if ($percentInUse >= 90) {
|
||||
$pbar = "progress-bar-danger";
|
||||
}
|
||||
elseif ($percentInUse >= 75) {
|
||||
$pbar = "progress-bar-warning";
|
||||
}
|
||||
else {
|
||||
$pbar = "progress-bar-success";
|
||||
}
|
||||
?>
|
||||
<div class="progress">
|
||||
<div class="progress-bar <?=$pbar;?>" role="progressbar" aria-valuenow="<?=$percentInUse;?>" aria-valuemin="0" aria-valuemax="100" style="min-width:2em;width: <?=$percentInUse;?>%;">
|
||||
<?=$percentInUse;?>%
|
||||
<div class="progress-bar progress-bar-<?=$mailboxdata['percent_class'];?>" role="progressbar" aria-valuenow="<?=$mailboxdata['percent_in_use'];?>" aria-valuemin="0" aria-valuemax="100" style="min-width:2em;width: <?=$mailboxdata['percent_in_use'];?>%;">
|
||||
<?=$mailboxdata['percent_in_use'];?>%
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td><?=$row['messages'];?></td>
|
||||
<td><?=$row['active'];?></td>
|
||||
<td><?=$mailboxdata['messages'];?></td>
|
||||
<td><?=$mailboxdata['active'];?></td>
|
||||
<td style="text-align: right;">
|
||||
<div class="btn-group">
|
||||
<a href="/edit.php?mailbox=<?=urlencode($row['username']);?>" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> <?=$lang['mailbox']['edit'];?></a>
|
||||
<a href="/delete.php?mailbox=<?=urlencode($row['username']);?>" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> <?=$lang['mailbox']['remove'];?></a>
|
||||
<a href="/edit.php?mailbox=<?=urlencode($mailboxdata['username']);?>" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> <?=$lang['mailbox']['edit'];?></a>
|
||||
<a href="/delete.php?mailbox=<?=urlencode($mailboxdata['username']);?>" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> <?=$lang['mailbox']['remove'];?></a>
|
||||
<?php if ($_SESSION['mailcow_cc_role'] == "admin"): ?>
|
||||
<a href="/index.php?duallogin=<?=urlencode($mailboxdata['username']);?>" class="btn btn-xs btn-success"><span class="glyphicon glyphicon-user"></span> Login</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endwhile;
|
||||
else:
|
||||
?>
|
||||
<tr id="no-data"><td colspan="8" style="text-align: center; font-style: italic;"><?=$lang['mailbox']['no_record'];?></td></tr>
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<tr id="no-data"><td colspan="8" style="text-align: center; font-style: italic;"><?=sprintf($lang['mailbox']['no_record'], $domain);?></td></tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
@@ -405,76 +293,42 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT
|
||||
`address`,
|
||||
`goto`,
|
||||
`domain`,
|
||||
CASE `active` WHEN 1 THEN '".$lang['mailbox']['yes']."' ELSE '".$lang['mailbox']['no']."' END AS `active`
|
||||
FROM alias
|
||||
WHERE (
|
||||
`address` NOT IN (
|
||||
SELECT `username` FROM `mailbox`
|
||||
)
|
||||
AND `address` != `goto`
|
||||
) AND (`domain` IN (
|
||||
SELECT `domain` FROM `domain_admins`
|
||||
WHERE `username` = :username
|
||||
AND active='1'
|
||||
)
|
||||
OR 'admin' = :admin)");
|
||||
$stmt->execute(array(
|
||||
':username' => $_SESSION['mailcow_cc_username'],
|
||||
':admin' => $_SESSION['mailcow_cc_role'],
|
||||
));
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => 'MySQL: '.$e
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if(!empty($rows)):
|
||||
while($row = array_shift($rows)):
|
||||
foreach (mailbox_get_domains() as $domain) {
|
||||
$aliases = mailbox_get_aliases($domain);
|
||||
if (!empty($aliases)) {
|
||||
foreach ($aliases as $alias) {
|
||||
$aliasdata = mailbox_get_alias_details($alias);
|
||||
?>
|
||||
<tr id="data">
|
||||
<td>
|
||||
<?php
|
||||
if(!filter_var($row['address'], FILTER_VALIDATE_EMAIL)):
|
||||
?>
|
||||
<span class="glyphicon glyphicon-pushpin" aria-hidden="true"></span> Catch-all @<?=htmlspecialchars($row['domain']);?>
|
||||
<?php
|
||||
else:
|
||||
echo htmlspecialchars($row['address']);
|
||||
endif;
|
||||
?>
|
||||
<?= ($aliasdata['is_catch_all'] == "1") ? '<span class="glyphicon glyphicon-pushpin" aria-hidden="true"></span> Catch-all ' . htmlspecialchars($aliasdata['address']) : htmlspecialchars($aliasdata['address']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
foreach(explode(",", $row['goto']) as $goto) {
|
||||
foreach(explode(",", $aliasdata['goto']) as $goto) {
|
||||
echo nl2br(htmlspecialchars($goto.PHP_EOL));
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><?=htmlspecialchars($row['domain']);?></td>
|
||||
<td><?=$row['active'];?></td>
|
||||
<td><?=htmlspecialchars($aliasdata['domain']);?></td>
|
||||
<td><?=$aliasdata['active'];?></td>
|
||||
<td style="text-align: right;">
|
||||
<div class="btn-group">
|
||||
<a href="/edit.php?alias=<?=urlencode($row['address']);?>" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> <?=$lang['mailbox']['edit'];?></a>
|
||||
<a href="/delete.php?alias=<?=urlencode($row['address']);?>" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> <?=$lang['mailbox']['remove'];?></a>
|
||||
<a href="/edit.php?alias=<?=urlencode($aliasdata['address']);?>" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> <?=$lang['mailbox']['edit'];?></a>
|
||||
<a href="/delete.php?alias=<?=urlencode($aliasdata['address']);?>" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> <?=$lang['mailbox']['remove'];?></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endwhile;
|
||||
else:
|
||||
?>
|
||||
<tr id="no-data"><td colspan="5" style="text-align: center; font-style: italic;"><?=$lang['mailbox']['no_record'];?></td></tr>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<tr id="no-data"><td colspan="8" style="text-align: center; font-style: italic;"><?=sprintf($lang['mailbox']['no_record'], $domain);?></td></tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr id="no-data">
|
||||
|
Reference in New Issue
Block a user