From 383f1a291d3caff9296fd5a4e3f8c8e342d5a2af Mon Sep 17 00:00:00 2001 From: Steven Mondji-Lerider Date: Tue, 12 Jun 2012 17:14:16 +0000 Subject: [PATCH] Bugfixes pour la gestion des quotas diques --- bureau/admin/quotas_users.php | 6 ++++-- bureau/class/m_quota.php | 4 +--- install/mysql.sql | 1 + src/quota_init | 4 ++-- src/spoolsize.php | 8 ++++---- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/bureau/admin/quotas_users.php b/bureau/admin/quotas_users.php index faddbdf8..8c2458ef 100644 --- a/bureau/admin/quotas_users.php +++ b/bureau/admin/quotas_users.php @@ -280,10 +280,12 @@ if ($sd) echo "   - ".$d["domaine"]."
\n"; // Espace WEB list($ws)=@mysql_fetch_array(mysql_query("SELECT size FROM size_web WHERE uid='".$c["uid"]."';")); - if ($totalweb) + if (isset($totalweb) && $totalweb){ $pc=intval(100*$ws/$totalweb); - else + } + else{ $pc=0; + } if ($mode==0) { echo sprintf("%.1f", $ws / 1024)." "._("MB"); diff --git a/bureau/class/m_quota.php b/bureau/class/m_quota.php index 357eaec1..5195178d 100644 --- a/bureau/class/m_quota.php +++ b/bureau/class/m_quota.php @@ -181,10 +181,8 @@ class m_quota { if (isset($this->disk[$ressource])) { // It's a disk resource, update it with shell command exec("/usr/lib/alternc/quota_edit $cuid $size"); - echo "quota set :::::ciud: $cuid :::: size: $size :::: \n "; // Now we check that the value has been written properly : - exec("/usr/lib/alternc/quota_get ".$cuid,$a); - print_r($a); + exec("usr/lib/alternc/quota_get $cuid",$a); if ($size!=$a[1]) { $err->raise("quota",1); return false; diff --git a/install/mysql.sql b/install/mysql.sql index bdb187dd..97fe0432 100644 --- a/install/mysql.sql +++ b/install/mysql.sql @@ -327,6 +327,7 @@ CREATE TABLE IF NOT EXISTS defquotas ( # Ces quotas par defaut sont redefinissables dans l`interface web INSERT IGNORE INTO defquotas (quota,value) VALUES ('dom',1); +INSERT IGNORE INTO defquotas (quota,value) VALUES ('web',51200); INSERT IGNORE INTO defquotas (quota,value) VALUES ('mail',10); INSERT IGNORE INTO defquotas (quota,value) VALUES ('ftp',2); INSERT IGNORE INTO defquotas (quota,value) VALUES ('stats',1); diff --git a/src/quota_init b/src/quota_init index a6f11fe1..c20fa4b1 100644 --- a/src/quota_init +++ b/src/quota_init @@ -52,8 +52,8 @@ if (mysql_errno()) { } while ($c=mysql_fetch_array($r)) { $s=mysql_query("SELECT name FROM quotas WHERE uid='$c[uid]' AND name='$name';"); - if (!mysql_num_rows($s)) { - mysql_query("INSERT INTO quotas (uid,name,total) VALUES ('$c[uid]','$name','$quota');"); + if (mysql_num_rows($s)) { + mysql_query("INSERT INTO quotas (uid,name,total) VALUES ('$c[uid]','$name','$quota') on DUPLICATE KEY UPDATE total=$quota;"); } } diff --git a/src/spoolsize.php b/src/spoolsize.php index 3dc6eec6..8915fdec 100644 --- a/src/spoolsize.php +++ b/src/spoolsize.php @@ -6,11 +6,11 @@ require_once("/var/alternc/bureau/class/config_nochk.php"); @alternc_shutdown(); echo "---------------------------\n Generating size-cache for mail accounts\n\n"; -$r=mysql_query("SELECT * FROM mail_users WHERE alias NOT LIKE '%@%' AND alias LIKE '%\_%';"); +$r=mysql_query("SELECT * FROM dovecot_view ;"); while ($c=mysql_fetch_array($r)) { - echo $c["alias"]; flush(); - $size=exec("/usr/lib/alternc/du.pl ".$c["path"]); - mysql_query("REPLACE INTO size_mail SET alias='".addslashes($c["alias"])."',size='$size';"); + echo $c["user"]; flush(); + $size=exec("/usr/lib/alternc/du.pl ".$c["userdb_home"]); + mysql_query("REPLACE INTO size_mail SET alias='".addslashes($c["user"])."',size='$size';"); echo " done ($size KB)\n"; flush(); }