AlternC/bureau/admin/quotas_users.php

398 lines
10 KiB
PHP
Raw Normal View History

2009-09-08 05:29:38 +00:00
<?php
require_once("../class/config.php");
$fields = array (
"mode" => array ("get", "integer" ,0),
"sd" => array ("get", "integer" ,0),
"usr" => array ("get", "integer" ,0),
);
getFields($fields);
2009-09-08 05:29:38 +00:00
if (!$admin->enabled) {
__("This page is restricted to authorized staff");
exit();
}
include_once ("head.php");
?>
2012-08-24 12:43:05 +00:00
<h3><?php __("Quotas status"); ?></h3>
<hr id="topbar"/>
<br />
2009-09-08 05:29:38 +00:00
<?php
if (isset($error) && $error) {
2009-09-08 05:29:38 +00:00
echo "<p class=\"error\">$error</p>";
}
?>
<p>
<?php __("This page shows the space and service count of your AlternC server and each AlternC accounts."); ?>
</p>
<p>
<?php printf(_("Sizes are shown as %s"),($mode==0 || $mode==4)?_("MB."):_("% of the total.")); ?>
2009-09-08 05:29:38 +00:00
</p>
<p>
<?php __("Server-side view:"); ?> <span class="ina <?php if ($mode==4) { echo 'ina-active'; } ?>"><a href="quotas_users.php?mode=4"><?php __("Global"); ?></a></span><br /><br />
<?php __("Detailed view:"); ?>
<span class="ina <?php if ($mode==0) { echo 'ina-active'; } ?>"><a href="quotas_users.php?mode=0&amp;sd=<?php echo $sd; ?>&amp;usr=<?php echo $usr; ?>"><?php __("In MB"); ?></a></span>
<span class="ina <?php if ($mode==1) { echo 'ina-active'; } ?>"><a href="quotas_users.php?mode=1&amp;sd=<?php echo $sd; ?>&amp;usr=<?php echo $usr; ?>"><?php __("Percentage"); ?></a></span>
<span class="ina <?php if ($mode==2) { echo 'ina-active'; } ?>"><a href="quotas_users.php?mode=2&amp;sd=<?php echo $sd; ?>&amp;usr=<?php echo $usr; ?>"><?php __("Graphical"); ?></a></span>
2009-09-08 05:29:38 +00:00
<?php if ($mode != 4) { ?>
<?php if ($usr==0) { if ($sd==0) { ?>
<span class="ina"><a href="quotas_users.php?mode=<?php echo $mode; ?>&amp;sd=1&amp;usr=<?php echo $usr; ?>"><?php __("Show the domain names"); ?></a></span>
2009-09-08 05:29:38 +00:00
<?php } else { ?>
<span class="ina"><a href="quotas_users.php?mode=<?php echo $mode; ?>&amp;sd=0&amp;usr=<?php echo $usr; ?>"><?php __("Hide the domain names"); ?></a></span>
2009-09-08 05:29:38 +00:00
<?php } } ?>
<?php if ($usr) { ?>
2012-08-20 08:49:22 +00:00
<span class="ina"><a href="quotas_users.php?mode=<?php echo $mode; ?>&amp;sd=<?php echo $sd; ?>"><?php __("All accounts"); ?></a></span>
2009-09-08 05:29:38 +00:00
<?php } ?>
<?php } ?>
</p>
<?php if ($mode == 4) {
// Mode : affichage des donn<6E>es globales
if ($cuid != 2000)
{
$mList = array();
2012-08-25 13:25:51 +00:00
$membres_list = $admin->get_list(0, $cuid);
foreach ($membres_list as $n) {
$domList = $dom->enum_domains($n["uid"]);
2009-09-08 05:29:38 +00:00
$mList[$n["uid"]] = array (
"login" => $n["login"],
"domaines" => $domList,
);
}
$totalweb = 0; $totalmail = 0; $totallist = 0; $totaldb = 0;
$dc = 0; $mc = 0; $mlc = 0; $dbc = 0;
foreach ($mList as $mUID => $mData)
{
$tmpweb = $quota->get_size_web_sum_user($mUID);
2009-09-08 05:29:38 +00:00
$totalweb += $tmpweb;
if (!empty($mData["domaines"]))
{
foreach ($mData["domaines"] as $domaine)
{
$dc++;
$tmpmail = $quota->get_size_mail_sum_domain($domaine);
2009-09-08 05:29:38 +00:00
$totalmail += $tmpmail;
$mc = $quota->get_size_mail_count_domain($domaine);
2009-09-08 05:29:38 +00:00
$tmplist = $quota->get_size_mailman_sum_domain($domaine);
2009-09-08 05:29:38 +00:00
$totallist += $tmplist;
}
}
$mlc = $quota->get_size_mailman_count_user($mUID);
$tmpdb = $quota->get_size_db_sum_user($mData["login"]);
2009-09-08 05:29:38 +00:00
$totaldb += $tmpdb;
$dbc = $quota->get_size_db_count_user($mData["login"]);
2009-09-08 05:29:38 +00:00
}
$totaltotal=$totalweb+$totallist+$totalmail+($totaldb/1024); // en Ko
}
else
{
$totalweb = $quota->get_size_web_sum_all();
$totalmail = $quota->get_size_mail_sum_all();
$totallist = $quota->get_size_mailman_sum_all();
$totaldb = $quota->get_size_db_sum_all();
2009-09-08 05:29:38 +00:00
$totaltotal=$totalweb+$totallist+$totalmail+($totaldb/1024); // en Ko
2012-08-25 13:25:51 +00:00
$dc = $dom->count_domains_all();
$mc = $quota->get_size_mail_count_all();
$mlc = $quota->get_size_mailman_count_all();
$dbc = $quota->get_size_db_count_all();
2009-09-08 05:29:38 +00:00
}
?>
<center>
<div style="width: 650px">
<table class="tedit">
2009-09-08 05:29:38 +00:00
<thead>
<tr><th>&nbsp;</th><th><?php __("Count"); ?></th><th><?php __("Space"); ?></th></tr>
2009-09-08 05:29:38 +00:00
</thead>
<tbody>
<tr>
<th><?php __("Domains"); ?></th>
<td><?php echo $dc; ?></td>
<td><?php echo sprintf("%.1f", $totalweb / 1024); ?>&nbsp;Mo</td>
2009-09-08 05:29:38 +00:00
</tr>
<tr>
<th><?php __("Email addresses"); ?></th>
<td><?php echo $mc; ?></td>
<td><?php echo sprintf("%.1f", $totalmail / 1024); ?>&nbsp;Mo</td>
2009-09-08 05:29:38 +00:00
</tr>
<?php if ($mlc) { ?>
2009-09-08 05:29:38 +00:00
<tr>
<th><?php __("Mailman lists"); ?></th>
<td><?php echo $mlc; ?></td>
<td><?php echo sprintf("%.1f", $totallist / 1024); ?>&nbsp;Mo</td>
2009-09-08 05:29:38 +00:00
</tr>
<?php } ?>
2009-09-08 05:29:38 +00:00
<tr>
<th><?php __("MySQL Databases"); ?></th>
<td><?php echo $dbc; ?></td>
<td><?php echo sprintf("%.1f", $totaldb / 1024 / 1024); ?>&nbsp;Mo</td>
2009-09-08 05:29:38 +00:00
</tr>
<tr>
<th colspan="2"><?php __("Total"); ?></th>
<td><?php echo sprintf("%.1f", $totaltotal / 1024); ?>&nbsp;Mo</td>
2009-09-08 05:29:38 +00:00
</tr>
</tbody>
</table>
</div>
</center>
<?php } elseif ($usr==0) {
// Mode : affichage de tous les comptes
?>
<center>
<div style="width: 650px">
<table class="tedit">
2009-09-08 05:29:38 +00:00
<thead>
<tr><th rowspan="2"><?php __("Account"); ?></th><th colspan="3"><?php __("Count"); ?></th><th colspan="5"><?php __("Space"); ?></th></tr>
2009-09-08 05:29:38 +00:00
<tr>
<th><?php __("Dom"); ?></th>
<th><?php __("Mails"); ?></th>
<th><?php __("Lists"); ?></th>
<th><?php __("Web"); ?></th>
<th><?php __("Mails"); ?></th>
<th><?php __("Lists"); ?></th>
<th><?php __("DB"); ?></th>
<th><?php __("Total"); ?></th>
2009-09-08 05:29:38 +00:00
</tr>
</thead>
<tbody>
<?php
if ($cuid != 2000)
{
$mList = array();
2012-08-25 13:25:51 +00:00
$membres_list = $admin->get_list(0, $cuid);
foreach ($membres_list as $minfo) {
$domList = $dom->enum_domains($minfo['uid']);
$mList[$muid] = array (
"login" => $minfo['login'],
2009-09-08 05:29:38 +00:00
"domaines" => $domList,
);
}
$totalweb = 0; $totalmail = 0; $totallist = 0; $totaldb = 0;
$dc = 0; $mc = 0; $mlc = 0; $dbc = 0;
foreach ($mList as $mUID => $mData)
{
$tmpweb = $quota->get_size_web_sum_user($mUID);
2009-09-08 05:29:38 +00:00
$totalweb += $tmpweb;
if (!empty($mData["domaines"]))
{
foreach ($mData["domaines"] as $domaine)
{
$dc++;
$tmpmail = $quota->get_size_mail_sum_domain($domaine);
2009-09-08 05:29:38 +00:00
$totalmail += $tmpmail;
$mc = $quota->get_size_mail_count_domain($domaine);
2009-09-08 05:29:38 +00:00
$tmplist = $quota->get_size_mailman_sum_domain($domaine);
2009-09-08 05:29:38 +00:00
$totallist += $tmplist;
}
}
2012-08-25 13:25:51 +00:00
$mlc = $quota->get_size_mailman_count_user($mUID);
$tmpdb = $quota->get_size_db_sum_user($mData["login"]);
2009-09-08 05:29:38 +00:00
$totaldb += $tmpdb;
$dbc = $quota->get_size_db_count_user($mData["login"]);
2009-09-08 05:29:38 +00:00
}
}
else
{
$totalweb = $quota->get_size_web_sum_all();
$totalmail = $quota->get_size_mail_sum_all();
$totallist = $quota->get_size_mailman_sum_all();
$totaldb = $quota->get_size_db_sum_all();
2009-09-08 05:29:38 +00:00
}
$totaltotal=$totalweb+$totallist+$totalmail+($totaldb/1024); // en Ko
2012-08-21 12:53:29 +00:00
if ($totaltotal==0) $totaltotal=1;
2009-09-08 05:29:38 +00:00
2012-08-25 13:25:51 +00:00
if ($cuid != 2000) {
$membres_list = $admin->get_list(0, $cuid);
} else {
$membres_list = $admin->get_list(1);
2009-09-08 05:29:38 +00:00
}
2012-08-25 13:25:51 +00:00
foreach ($membres_list as $c) {
2009-09-08 05:29:38 +00:00
echo "<tr><td>";
// On affiche le compte et ses domaines :
echo "<b><a href=\"quotas_users.php?mode=".$mode."&sd=".$sd."&usr=".$c["uid"]."\">".$c["login"]."</a></b><br />\n";
2012-08-25 13:25:51 +00:00
$domaines_list = $dom->enum_domains($c["uid"]);
2009-09-08 05:29:38 +00:00
$dc=0; // Domain Count
$ms=0; // Mail Space
2012-08-25 13:25:51 +00:00
$mls=0;
foreach ($domaines_list as $d) {
if ($sd) echo "&nbsp;&nbsp;&nbsp;-&nbsp;{$d}<br />\n";
2009-09-08 05:29:38 +00:00
$dc++;
2012-08-25 13:25:51 +00:00
$mstmp = $quota->get_size_mail_sum_domain($d);
2009-09-08 05:29:38 +00:00
$ms+=$mstmp;
2012-08-25 13:25:51 +00:00
$mlstmp = $quota->get_size_mailman_sum_domain($d);
2009-09-08 05:29:38 +00:00
$mls+=$mlstmp;
}
// Mail Count
2012-08-25 13:25:51 +00:00
$maildomains_list = $mail->enum_domains($c["uid"]);
$mc = 0;
foreach ($maildomains_list as $md) {
$mc += $md['nb_mail'];
}
if (isset($mailman)) {
2009-09-08 05:29:38 +00:00
// Mailman List Count
2012-08-25 13:25:51 +00:00
$mlc = $mailman->count_ml_user($c["uid"]);
2009-09-08 05:29:38 +00:00
echo "</td><td>$dc</td><td>$mc</td><td>$mlc</td><td";
if ($mode!=2) echo " style=\"text-align: right\"";
echo ">";
} // isset mailman
2009-09-08 05:29:38 +00:00
// Espace WEB
$ws = $quota->get_size_web_sum_user($c["uid"]);
2009-09-08 05:29:38 +00:00
if (isset($totalweb) && $totalweb){
2009-09-08 05:29:38 +00:00
$pc=intval(100*$ws/$totalweb);
}
else{
2009-09-08 05:29:38 +00:00
$pc=0;
}
2009-09-08 05:29:38 +00:00
if ($mode==0) {
echo sprintf("%.1f", $ws / 1024)."&nbsp;"._("MB");
2009-09-08 05:29:38 +00:00
} elseif ($mode==1) {
echo sprintf("%.1f",$pc)."&nbsp;%";
} else {
echo "<img src=\"hippo_bleue.gif\" style=\"width: ".(1*$pc)."px; height: 16px\" alt=\"".$pc."%\" title=\"".$pc."\"/>";
}
echo "</td><td";
if ($mode!=2) echo " style=\"text-align: right\"";
echo ">";
// Espace Mail :
if ($totalmail)
$pc=intval(100*$ms/$totalmail);
else
$pc=0;
if ($mode==0) {
echo sprintf("%.1f", $ms / 1024)."&nbsp;Mo";
} elseif ($mode==1) {
echo sprintf("%.1f",$pc)."&nbsp;%";
} else {
echo "<img src=\"hippo_bleue.gif\" style=\"width: ".(1*$pc)."px; height: 16px\" alt=\"".$pc."%\" title=\"".$pc."%\"/>";
}
echo "</td><td";
if ($mode!=2) echo " style=\"text-align: right\"";
echo ">";
// Espace Mailman :
if ($totallist)
$pc=intval(100*$mls/$totallist);
else
$pc=0;
if ($mode==0) {
echo sprintf("%.1f", $mls / 1024)."&nbsp;"._("MB");
2009-09-08 05:29:38 +00:00
} elseif ($mode==1) {
echo sprintf("%.1f",$pc)."&nbsp;%";
} else {
echo "<img src=\"hippo_bleue.gif\" style=\"width: ".(1*$pc)."px; height: 16px\" alt=\"".$pc."%\" title=\"".$pc."%\"/>";
}
echo "</td><td";
if ($mode!=2) echo " style=\"text-align: right\"";
echo ">";
// Espace DB :
$ds = $quota->get_size_db_sum_user($c["login"]);
2009-09-08 05:29:38 +00:00
if ($totaldb)
$pc=intval(100*$ds/$totaldb);
else
$pc=0;
if ($mode==0) {
echo sprintf("%.1f", $ds / 1024/1024)."&nbsp;"._("MB");
2009-09-08 05:29:38 +00:00
} elseif ($mode==1) {
echo sprintf("%.1f",$pc)."&nbsp;%";
} else {
echo "<img src=\"hippo_bleue.gif\" style=\"width: ".(1*$pc)."px; height: 16px\" alt=\"".$pc."%\" title=\"".$pc."%\"/>";
}
echo "</td><td";
if ($mode!=2) echo " style=\"text-align: right\"";
echo ">";
$ts=$ds/1024+$ws+$ms+$mls;
if ($mode==0) {
echo sprintf("%.1f", $ts/1024)."&nbsp;"._("MB");
2009-09-08 05:29:38 +00:00
} elseif ($mode==1) {
echo sprintf("%.1f",(100*$ts/$totaltotal))."&nbsp;%";
} else {
if ($totaltotal) {
2009-09-08 05:29:38 +00:00
$pc=intval(100*$ts/$totaltotal);
} else {
$pc=0;
}
2009-09-08 05:29:38 +00:00
echo "<img src=\"hippo_bleue.gif\" style=\"width: ".(1*$pc)."px; height: 16px\" alt=\"".$pc."%\" title=\"".$pc."%\"/>";
}
echo "</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</center>
<?php
} else { // Mode affichage d'UN seul compte
2012-08-25 13:25:51 +00:00
$oneuser_ok = false;
if ($cuid != 2000) {
$c = $admin->get($usr);
$mcreator = $admin->get_creator($c['uid']);
if ($mcreator['uid'] == $cuid) {
$oneuser_ok = true;
}
} else {
$c = $admin->get($usr);
if ($c != false) {
$oneuser_ok = true;
}
2009-09-08 05:29:38 +00:00
}
2012-08-25 13:25:51 +00:00
if ($oneuser_ok) { # quotas_oneuser.php will used prefilled $c
define("QUOTASONE","1");
require_once("quotas_oneuser.php");
2009-09-08 05:29:38 +00:00
}
2012-08-25 13:25:51 +00:00
} // endif un seul compte
2009-09-08 05:29:38 +00:00
?>
<?php include_once("foot.php"); ?>