SHARE
TWEET

domainquota.patch

a guest Mar 30th, 2011 357 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff -ru postfixamin-2.3.2/create-mailbox.php ./create-mailbox.php
  2. --- ./create-mailbox.php        2010-05-18 00:56:23.000000000 +0200
  3. +++ ./create-mailbox.php        2010-10-12 16:58:07.103049751 +0200
  4. @@ -133,7 +133,7 @@
  5.  
  6. if ($CONF['quota'] == "YES")
  7. {
  8. - if (!check_quota ($fQuota, $fDomain))
  9. + if (!check_quota ($fQuota, $fUsername, $fDomain))
  10. {
  11. $error = 1;
  12. $tUsername = escape_string ($_POST['fUsername']);
  13. diff -ru postfixadmin-2.3.2/functions.inc.php ./functions.inc.php
  14. --- ./functions.inc.php 2010-08-22 23:41:31.000000000 +0200
  15. +++ ./functions.inc.php 2010-10-12 17:02:05.758725599 +0200
  16. @@ -665,13 +665,33 @@
  17. }
  18.  
  19. +//
  20. +// get_mailbox_quota
  21. +// Action: Get mailbox quota
  22. +// Call: get_mailbox_quota (string mailbox)
  23. +//
  24. +function get_mailbox_quota ($mailbox)
  25. +{
  26. +       global $CONF;
  27. +       $list = array ();
  28. +       $result = db_query ("SELECT quota FROM mailbox WHERE username='$mailbox'");
  29. +       $row = db_row ($result['result']);
  30. +       if ( $row[0] == "" ) {
  31. +        $mailbox_quota = "0";
  32. +       } else {
  33. +        $mailbox_quota = $row[0] / $CONF['quota_multiplier'];
  34. +       }
  35. +       return $mailbox_quota;
  36. +}
  37. +
  38. +
  39.  
  40. //
  41. // check_quota
  42. // Action: Checks if the user is creating a mailbox with the correct quota
  43. // Call: check_quota (string domain)
  44. //
  45. -function check_quota ($quota, $domain)
  46. +function check_quota ($quota, $mailbox, $domain)
  47. {
  48. $limit = get_domain_properties ($domain);
  49. if ($limit['maxquota'] == 0)
  50. @@ -686,7 +706,8 @@
  51. {
  52. return false;
  53. }
  54. - if ($quota > $limit['maxquota'])
  55. + #if ($quota > $limit['maxquota'])
  56. + if ($quota > ($limit['maxquota']-$limit['used_quota']+get_mailbox_quota($mailbox)))
  57. {
  58. return false;
  59. }
  60. --- edit-mailbox.php    2010-10-12 17:31:19.000000000 +0200
  61. +++ /tmp/admin/edit-mailbox.php 2008-12-12 20:40:39.000000000 +0100
  62. @@ -98,7 +98,6 @@
  63. if (isset ($_POST['fQuota'])) $fQuota = intval ($_POST['fQuota']);
  64. if (isset ($_POST['fActive'])) $fActive = escape_string ($_POST['fActive']);
  65.  
  66. + if( strlen($fPassword2) != 0) {
  67. if($fPassword != $user_details['password'] || $fPassword2 != $user_details['password']){
  68. $min_length = $CONF['min_password_length'];
  69.  
  70. @@ -116,10 +115,9 @@
  71. $error = 1;
  72. }
  73. }
  74. + }
  75. if ($CONF['quota'] == "YES")
  76. {
  77. + if (!check_quota ($fQuota, $fUsername, $fDomain))
  78. - if (!check_quota ($fQuota, $fDomain))
  79. {
  80. $error = 1;
  81. $tName = $fName;
RAW Paste Data
Top