[cvs] [Wiki] changed: QuotaHack

Wiki Guest wiki at wiki.horde.org
Mon Nov 14 10:20:25 PST 2005


guest [203.145.159.37]  Mon, 14 Nov 2005 10:20:25 -0800

Modified page: http://wiki.horde.org/QuotaHack
New Revision:  1.1
Change log:  page added

@@ -1 +1,77 @@
+To assign quota to a user
+
+create a folder quota on your server '/' partition
+
+mkdir /quota
+
+to assign quota to any user
+
+echo "10000" > /quota/username
+
+This would give 10MB quota to a user. Give whatever you wish to assign.
+
+Create the following file
+
+/var/www/html/horde/quota.php
+
+<?php
+{
+
+    $user=Auth::getAuth();
+    $usage = `sudo du -s /home/$user/mail | cut -d "/" -f 1` + `sudo du -s /var/spool/mail/$user | cut -d "/" -f 1` - $archive;
+    $archiveused = round($archive/1000);
+    $usedmb = round($usage / 1000);
+    $quota = `cat /quota/$user`+ 1;
+    $quotamb = round($quota / 1000);
+    $percent = round($usage * 100 / $quota);
+        if ($quota > 1) {
+             echo '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td class=
+"item"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr>';
+             echo '<td align="left" class="header">Login: ' .  $user . '</td>';
+             echo '<td align="right" class="header">';
+             echo "Quota Used $usedmb MB of $quotamb MB ($percent %)";
+             echo '</td></tr></table></td></tr></table>';
+        }
+
+if ($percent >= 100 && $quota > 2) {
+             echo '<script language="JavaScript" type="text/javascript"><!--
+alert("QUOTA EXCEEDED, DELETE EMAILS TO CONTINUE THE USE OF EMAIL FACILITY")
+// -->
+</script>';}
+if ($percent >= 80 && $quota > 2) {
+             echo '<script language="JavaScript" type="text/javascript"><!--
+alert("You are nearing your mailbox quota limit, please delete & purge
+emails to avoid any inconvinience.")
+// -->
+</script>';}
+}
+
+Change the above reflecting your mailserver's folder locations. Above is for dovecot on RHEL 3, with mails in /home/username/mail and /var/spool/mail/username.
+
+
+Add this in horde/imp/templates/common-headers.inc (line 27, 28,29)
+
+$page_title = $GLOBALS['registry']->get('name');
+if (!empty($title)) $page_title .= ' :: ' . $title;
+if (!empty($refresh_time) && !empty($refresh_url)) {
+    echo "<meta http-equiv="refresh" content="$refresh_time;url=$refresh_url" />n";
+}
+Horde::includeScriptFiles();
+?>
+<title><?php echo htmlspecialchars($page_title) ?></title>
+
+--->Add the following here <----
+
+<?php
+include_once HORDE_BASE . '/quota.php';
+?>
+
+---end---
+
+<link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
+<?php if (isset($mailbox_url)): ?>
+
+This should give you quota information on any mail server regardless of the support of quota by the server or OS quota assignments. Do let me know if this was useful or any improvement suggestions.
+
+jigish dot gohil at gmail dot com
 


More information about the cvs mailing list