From 18898953ae3768aef356a3a8b614ce559e30455e Mon Sep 17 00:00:00 2001 From: Alan Garcia Date: Sun, 26 Aug 2012 16:54:21 +0000 Subject: [PATCH] =?UTF-8?q?Adieu=20table=20size=5Fmail,=20deprecated=20gra?= =?UTF-8?q?ce=20=C3=A0=20dovecot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bureau/class/m_quota.php | 10 +++++----- install/mysql.sql | 9 --------- install/upgrades/1.1.sql | 4 +++- src/spoolsize.php | 9 --------- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/bureau/class/m_quota.php b/bureau/class/m_quota.php index 0d8f95e1..06864ee2 100644 --- a/bureau/class/m_quota.php +++ b/bureau/class/m_quota.php @@ -365,27 +365,27 @@ class m_quota { /* sum of mailbox sizes from all domains */ 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(bytes) AS sum FROM mailbox;"); } /* sum of mailbox sizes for one domain */ function get_size_mail_sum_domain($dom) { - return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mail WHERE alias LIKE '%\_{$dom}'"); + return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM dovecot_view WHERE user LIKE '%@{$dom}'"); } /* count of mailbox sizes from all domains */ function get_size_mail_count_all() { - return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mail;"); + return $this->_get_count_sql("SELECT COUNT(*) AS count FROM mailbox;"); } /* count of mailbox for one domain */ function get_size_mail_count_domain($dom) { - 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 dovecot_view WHERE user 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;"); + return $this->_get_size_and_record_sql("SELECT user as alias,quota_dovecot as size FROM dovecot_view WHERE alias LIKE '%@{$dom}' ORDER BY alias;"); } diff --git a/install/mysql.sql b/install/mysql.sql index 3b693c7e..b0c23924 100644 --- a/install/mysql.sql +++ b/install/mysql.sql @@ -430,15 +430,6 @@ PRIMARY KEY ( `login` ) ) COMMENT = 'Allowed account for secondary mx managment'; --- -------------------------------------------------------- -CREATE TABLE IF NOT EXISTS `size_mail` ( - `alias` varchar(255) NOT NULL default '', - `size` int(10) unsigned NOT NULL default '0', - `ts` timestamp(14) NOT NULL, - PRIMARY KEY (`alias`), - KEY `ts` (`ts`) -) TYPE=MyISAM COMMENT='Mail space used by pop accounts.'; - -- -------------------------------------------------------- CREATE TABLE IF NOT EXISTS `size_web` ( `uid` int(10) unsigned NOT NULL default '0', diff --git a/install/upgrades/1.1.sql b/install/upgrades/1.1.sql index d97b54c9..c2b25e49 100644 --- a/install/upgrades/1.1.sql +++ b/install/upgrades/1.1.sql @@ -221,5 +221,7 @@ DELETE FROM quotas WHERE name = 'mysql_users'; -- Raw web statistics are deprecated since vlogger DELETE FROM quotas WHERE name = 'sta2'; DELETE FROM defquotas WHERE quota = 'sta2'; - DROP TABLE stats2; + +-- With Dovecot, no more use of size_mail +DROP TABLE size_mail; diff --git a/src/spoolsize.php b/src/spoolsize.php index 8915fdec..880b4d3c 100644 --- a/src/spoolsize.php +++ b/src/spoolsize.php @@ -5,15 +5,6 @@ require_once("/var/alternc/bureau/class/config_nochk.php"); // On déverrouile le bureau AlternC :) @alternc_shutdown(); -echo "---------------------------\n Generating size-cache for mail accounts\n\n"; -$r=mysql_query("SELECT * FROM dovecot_view ;"); -while ($c=mysql_fetch_array($r)) { - 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(); -} - echo "---------------------------\n Generating size-cache for web accounts\n\n"; $r=mysql_query("SELECT uid,login FROM membres;"); while ($c=mysql_fetch_array($r)) {