Refactoring quotas 'oneuser' display with get_size_xx function
This commit is contained in:
parent
70009c1118
commit
4a8c177fcb
|
@ -8,10 +8,10 @@ if (!defined("QUOTASONE")) return;
|
||||||
<p><h3><center><?php __("Account"); ?> <span style="font-weight: bold;"><?php echo $c["login"]; ?></span></center></h3></p>
|
<p><h3><center><?php __("Account"); ?> <span style="font-weight: bold;"><?php echo $c["login"]; ?></span></center></h3></p>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
list($totalweb)=@mysql_fetch_array(mysql_query("SELECT SUM(size) FROM size_web WHERE uid = '" . $c["uid"] . "'"));
|
$totalweb = $quota->get_size_web_sum_user($c["uid"]);
|
||||||
|
|
||||||
echo "<p>"._("Web Space:")." ";
|
echo "<p>"._("Web Space:")." ";
|
||||||
echo sprintf("%.1f", $totalweb / 1024)." "._("MB");
|
echo sprintf("%.1f", $totalweb / 1024)." "._("MB");
|
||||||
echo "</p>";
|
echo "</p>";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -31,14 +31,18 @@ if (!defined("QUOTASONE")) return;
|
||||||
$s=mysql_query("SELECT * FROM domaines WHERE compte='".$c["uid"]."';");
|
$s=mysql_query("SELECT * FROM domaines WHERE compte='".$c["uid"]."';");
|
||||||
$totalmail=0;
|
$totalmail=0;
|
||||||
while ($d=mysql_fetch_array($s)) {
|
while ($d=mysql_fetch_array($s)) {
|
||||||
list($mstmp)=@mysql_fetch_array(mysql_query("SELECT SUM(size) FROM size_mail WHERE alias LIKE '%\_".$d["domaine"]."';"));
|
$mstmp = $quota->get_size_mail_sum_domain($d["domaine"]);
|
||||||
$totalmail+=$mstmp;
|
$totalmail+=$mstmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "<p>"._("Mail boxes:")." ";
|
||||||
|
echo sprintf("%.1f", $totalmail / 1024)." "._("MB");
|
||||||
|
echo "</p>";
|
||||||
|
|
||||||
$s=mysql_query("SELECT * FROM domaines WHERE compte='".$c["uid"]."';");
|
$s=mysql_query("SELECT * FROM domaines WHERE compte='".$c["uid"]."';");
|
||||||
while ($d=mysql_fetch_array($s)) {
|
while ($d=mysql_fetch_array($s)) {
|
||||||
$t=mysql_query("SELECT alias,size FROM size_mail WHERE alias LIKE '%\_".$d["domaine"]."' ORDER BY alias;");
|
$alias_sizes = $quota->get_size_mail_details_domain($d["domaine"]);
|
||||||
while ($e=mysql_fetch_array($t)) {
|
foreach ($alias_sizes as $e) {
|
||||||
echo "<tr><td>".$d["domaine"]."</td>";
|
echo "<tr><td>".$d["domaine"]."</td>";
|
||||||
echo "<td>".str_replace("_","@",$e["alias"])."</td>";
|
echo "<td>".str_replace("_","@",$e["alias"])."</td>";
|
||||||
echo "<td";
|
echo "<td";
|
||||||
|
@ -64,6 +68,15 @@ if (!defined("QUOTASONE")) return;
|
||||||
</table>
|
</table>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Espace DB :
|
||||||
|
$totaldb = $quota->get_size_db_sum_user($c["login"]);
|
||||||
|
|
||||||
|
echo "<p>"._("Databases:")." ";
|
||||||
|
echo sprintf("%.1f", $totaldb/(1024*1024))." "._("MB");
|
||||||
|
echo "</p>";
|
||||||
|
?>
|
||||||
|
|
||||||
<table class="tedit">
|
<table class="tedit">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -74,10 +87,8 @@ if (!defined("QUOTASONE")) return;
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Espace DB :
|
$db_sizes = $quota->get_size_db_details_user($c["login"]);
|
||||||
list($totaldb)=@mysql_fetch_array(mysql_query("SELECT SUM(size) FROM size_db WHERE db='".$c["login"]."' OR db LIKE '".$c["login"]."\_%';"));
|
foreach ($db_sizes as $d) {
|
||||||
$s=mysql_query("SELECT db,size FROM size_db WHERE db='".$c["login"]."' OR db LIKE '".$c["login"]."\_%';");
|
|
||||||
while ($d=mysql_fetch_array($s)) {
|
|
||||||
echo "<tr><td>".$d["db"]."</td><td";
|
echo "<tr><td>".$d["db"]."</td><td";
|
||||||
if ($mode!=2) echo " style=\"text-align: right\"";
|
if ($mode!=2) echo " style=\"text-align: right\"";
|
||||||
echo ">";
|
echo ">";
|
||||||
|
@ -100,10 +111,16 @@ if (!defined("QUOTASONE")) return;
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
list($totallist)=@mysql_fetch_array(mysql_query("SELECT SUM(size) FROM size_mailman WHERE uid='".$c["uid"]."'"));
|
$totallist = $quota->get_size_mailman_sum_user($c["uid"]);
|
||||||
if ($totallist) {
|
if ($totallist) {
|
||||||
?>
|
?>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
echo "<p>"._("Mailman lists:")." ";
|
||||||
|
echo sprintf("%.1f", $totallist/1024)." "._("MB");
|
||||||
|
echo "</p>";
|
||||||
|
?>
|
||||||
|
|
||||||
<table class="tedit">
|
<table class="tedit">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -115,9 +132,9 @@ if (!defined("QUOTASONE")) return;
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Espace Liste :
|
// Espace Liste :
|
||||||
$s=mysql_query("SELECT list,size FROM size_mailman WHERE uid='".$c["uid"]."' ORDER BY list ASC");
|
$mailman_size = $quota->get_size_mailman_details_user($c["uid"]);
|
||||||
while ($d=mysql_fetch_array($s)) {
|
foreach ($mailman_size as $d) {
|
||||||
echo "<tr><td>".$d["list"]."</td><td";
|
echo "<tr><td>".$d["list"]."</td><td";
|
||||||
if ($mode!=2) echo " style=\"text-align: right\"";
|
if ($mode!=2) echo " style=\"text-align: right\"";
|
||||||
echo ">";
|
echo ">";
|
||||||
|
|
|
@ -387,6 +387,20 @@ class m_quota {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _get_size_and_record_sql($sql) {
|
||||||
|
global $db,$err,$cuid;
|
||||||
|
$db->query($sql);
|
||||||
|
if ($db->num_rows() == 0) {
|
||||||
|
return array();
|
||||||
|
} else {
|
||||||
|
$ret = array();
|
||||||
|
while ($db->next_record()) {
|
||||||
|
$ret[] = $db->Record;
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* sum of websites sizes from all users */
|
/* sum of websites sizes from all users */
|
||||||
function get_size_web_sum_all() {
|
function get_size_web_sum_all() {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web;");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web;");
|
||||||
|
@ -397,6 +411,7 @@ class m_quota {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web WHERE uid='$u';");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web WHERE uid='$u';");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* sum of mailbox sizes from all domains */
|
/* sum of mailbox sizes from all domains */
|
||||||
function get_size_mail_sum_all() {
|
function get_size_mail_sum_all() {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mail;");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mail;");
|
||||||
|
@ -417,6 +432,12 @@ class m_quota {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mail FROM size_mail WHERE alias LIKE '%\_{$dom}'");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mail FROM size_mail WHERE alias LIKE '%\_{$dom}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get list of mailbox alias and size for one domain */
|
||||||
|
function get_size_mail_details_domain($dom) {
|
||||||
|
return $this->_get_size_and_record_sql("SELECT alias,size FROM size_mail WHERE alias LIKE '%\_{$dom}' ORDER BY alias;");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* sum of mailman lists sizes from all domains */
|
/* sum of mailman lists sizes from all domains */
|
||||||
function get_size_mailman_sum_all() {
|
function get_size_mailman_sum_all() {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman;");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman;");
|
||||||
|
@ -427,6 +448,11 @@ class m_quota {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman WHERE list LIKE '%@{$dom}'");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman WHERE list LIKE '%@{$dom}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* sum of mailman lists for one user */
|
||||||
|
function get_size_mailman_sum_user($u) {
|
||||||
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman WHERE uid = '{$u}'");
|
||||||
|
}
|
||||||
|
|
||||||
/* count of mailman lists sizes from all domains */
|
/* count of mailman lists sizes from all domains */
|
||||||
function get_size_mailman_count_all() {
|
function get_size_mailman_count_all() {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman;");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman;");
|
||||||
|
@ -437,6 +463,12 @@ class m_quota {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman WHERE uid = '{$u}'");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman WHERE uid = '{$u}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get list of mailman list and size for one user */
|
||||||
|
function get_size_mailman_details_user($u) {
|
||||||
|
return $this->_get_size_and_record_sql("SELECT list,size FROM size_mailman WHERE uid='{$u}' ORDER BY list ASC");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* sum of databases sizes from all users */
|
/* sum of databases sizes from all users */
|
||||||
function get_size_db_sum_all() {
|
function get_size_db_sum_all() {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_db;");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_db;");
|
||||||
|
@ -452,11 +484,17 @@ class m_quota {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db;");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count of mailman lists for one user */
|
/* count of databases for one user */
|
||||||
function get_size_db_count_user($u) {
|
function get_size_db_count_user($u) {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db WHERE db = '{$u}' OR db LIKE '{$u}\_%'");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db WHERE db = '{$u}' OR db LIKE '{$u}\_%'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get list of databases name and size for one user */
|
||||||
|
function get_size_db_details_user($u) {
|
||||||
|
return $this->_get_size_and_record_sql("SELECT db,size FROM size_db WHERE db='{$u}' OR db LIKE '{$u}\_%';");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#list($dc)=@mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM domaines;"));
|
#list($dc)=@mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM domaines;"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue