This commit has been accessed 821 times via Git panel.
commit 523c23fa3b933e792d3eb0511978a19c9ee82df7
tree e0131d557c0ffd3a0d0b9da75b166eb1ad9abbea
parent 2dc399d976c773474023943cf29c110df720fb31
author Engels Antonio <engels@majcms.org> 1328363435 +0800
committer Engels Antonio <engels@majcms.org> 1328363435 +0800
Enable per-domain account limit
diff --git a/index.php b/index.php
index da83266..4eca8a8 100644
--- a/index.php
+++ b/index.php
@@ -295,68 +295,81 @@ if (isset($_SESSION['logged_uid'])) {
if ($dom_query[0] == "0") {
nak("{$_SESSION['logged_uid']} disabled by admin - new settings will take effect once it is re-enabled");
}
-
+
+$max_get = mysql_query("select max from domains where id='{$_SESSION['logged_uid']}'");
+
+$pm_max = mysql_fetch_row($max_get);
+
+$pm_get = mysql_query("select * from users where domain='{$_SESSION['logged_uid']}' order by id");
+
+$pm_now = mysql_num_rows($pm_get);
+
if (isset($_POST['pm_id']) and isset($_POST['pm_name']) and isset($_POST['pm_pw']) and !empty($_POST['pm_id']) and !empty($_POST['pm_name']) and !empty($_POST['pm_pw'])) {
-
- $pm_id = trim($_POST['pm_id']);
- $pm_id = strtolower($pm_id);
-
- if (preg_match("/@/",$pm_id)) {
- $pm_id = substr($pm_id,0,strpos($pm_id,"@"));
- }
-
- $pm_addr = $pm_id . "@" . $_SESSION['logged_uid'];
-
- $alias_query = mysql_query("select id from aliases where id='$pm_addr'");
-
- if (mysql_fetch_row($alias_query) > 0) {
- nak("$pm_addr alias exists");
+
+ if ($pm_now >= $pm_max[0]) {
+ nak("{$_SESSION['logged_uid']} limit exceeded");
}
else {
- $pm_name = trim($_POST['pm_name']);
- $pm_name = ucwords($pm_name);
-
- $pm_pw = trim($_POST['pm_pw']);
- $pm_pw = crypt($pm_pw);
-
- $pm_init = substr($pm_id,0,1);
-
- $pm_maildir = "{$_SESSION['logged_uid']}/$pm_init/$pm_id";
-
- $pm_host = trim($_POST['pm_host']);
- $pm_host = strtolower($pm_host);
-
- $pm_query = mysql_query("insert into users values('$pm_addr','$pm_pw','$pm_maildir/','$pm_name','{$_SESSION['logged_uid']}','1','$pm_host')");
-
- if (!$pm_query) {
- nak(strtolower(mysql_error()));
+ $pm_id = trim($_POST['pm_id']);
+ $pm_id = strtolower($pm_id);
+
+ if (preg_match("/@/",$pm_id)) {
+ $pm_id = substr($pm_id,0,strpos($pm_id,"@"));
+ }
+
+ $pm_addr = $pm_id . "@" . $_SESSION['logged_uid'];
+
+ $alias_query = mysql_query("select id from aliases where id='$pm_addr'");
+
+ if (mysql_fetch_row($alias_query) > 0) {
+ nak("$pm_addr alias exists");
}
else {
- if (!file_exists("$mail_root/{$_SESSION['logged_uid']}")) {
- mkdir("$mail_root/{$_SESSION['logged_uid']}");
- }
-
- if (!file_exists("$mail_root/{$_SESSION['logged_uid']}/$pm_init")) {
- mkdir("$mail_root/{$_SESSION['logged_uid']}/$pm_init");
- }
-
- if (!file_exists("$mail_root/$pm_maildir")) {
- mkdir("$mail_root/$pm_maildir");
- }
+ $pm_name = trim($_POST['pm_name']);
+ $pm_name = ucwords($pm_name);
+
+ $pm_pw = trim($_POST['pm_pw']);
+ $pm_pw = crypt($pm_pw);
+
+ $pm_init = substr($pm_id,0,1);
+
+ $pm_maildir = "{$_SESSION['logged_uid']}/$pm_init/$pm_id";
- if (!file_exists("$mail_root/$pm_maildir/cur")) {
- mkdir("$mail_root/$pm_maildir/cur");
- }
+ $pm_host = trim($_POST['pm_host']);
+ $pm_host = strtolower($pm_host);
+
+ $pm_query = mysql_query("insert into users values('$pm_addr','$pm_pw','$pm_maildir/','$pm_name','{$_SESSION['logged_uid']}','1','$pm_host')");
- if (!file_exists("$mail_root/$pm_maildir/new")) {
- mkdir("$mail_root/$pm_maildir/new");
+ if (!$pm_query) {
+ nak(strtolower(mysql_error()));
}
-
- if (!file_exists("$mail_root/$pm_maildir/tmp")) {
- mkdir("$mail_root/$pm_maildir/tmp");
+ else {
+ if (!file_exists("$mail_root/{$_SESSION['logged_uid']}")) {
+ mkdir("$mail_root/{$_SESSION['logged_uid']}");
+ }
+
+ if (!file_exists("$mail_root/{$_SESSION['logged_uid']}/$pm_init")) {
+ mkdir("$mail_root/{$_SESSION['logged_uid']}/$pm_init");
+ }
+
+ if (!file_exists("$mail_root/$pm_maildir")) {
+ mkdir("$mail_root/$pm_maildir");
+ }
+
+ if (!file_exists("$mail_root/$pm_maildir/cur")) {
+ mkdir("$mail_root/$pm_maildir/cur");
+ }
+
+ if (!file_exists("$mail_root/$pm_maildir/new")) {
+ mkdir("$mail_root/$pm_maildir/new");
+ }
+
+ if (!file_exists("$mail_root/$pm_maildir/tmp")) {
+ mkdir("$mail_root/$pm_maildir/tmp");
+ }
+
+ ack("$pm_addr added");
}
-
- ack("$pm_addr added");
}
}
}
@@ -941,7 +954,7 @@ if (isset($_SESSION['logged_uid'])) {
}
if ($_SESSION['logged_lvl'] == "postmaster") {
-
+
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
echo "<tr bgcolor=\"#eeeeee\"><td colspan=\"4\" align=\"center\">status</td><td align=\"center\">username</td><td align=\"center\">complete name</td><td align=\"center\">password</td><td align=\"center\">host</td><td align=\"center\" colspan=\"2\">action</td></tr>";
echo "<form method=\"post\">";
tree e0131d557c0ffd3a0d0b9da75b166eb1ad9abbea
parent 2dc399d976c773474023943cf29c110df720fb31
author Engels Antonio <engels@majcms.org> 1328363435 +0800
committer Engels Antonio <engels@majcms.org> 1328363435 +0800
Enable per-domain account limit
diff --git a/index.php b/index.php
index da83266..4eca8a8 100644
--- a/index.php
+++ b/index.php
@@ -295,68 +295,81 @@ if (isset($_SESSION['logged_uid'])) {
if ($dom_query[0] == "0") {
nak("{$_SESSION['logged_uid']} disabled by admin - new settings will take effect once it is re-enabled");
}
-
+
+$max_get = mysql_query("select max from domains where id='{$_SESSION['logged_uid']}'");
+
+$pm_max = mysql_fetch_row($max_get);
+
+$pm_get = mysql_query("select * from users where domain='{$_SESSION['logged_uid']}' order by id");
+
+$pm_now = mysql_num_rows($pm_get);
+
if (isset($_POST['pm_id']) and isset($_POST['pm_name']) and isset($_POST['pm_pw']) and !empty($_POST['pm_id']) and !empty($_POST['pm_name']) and !empty($_POST['pm_pw'])) {
-
- $pm_id = trim($_POST['pm_id']);
- $pm_id = strtolower($pm_id);
-
- if (preg_match("/@/",$pm_id)) {
- $pm_id = substr($pm_id,0,strpos($pm_id,"@"));
- }
-
- $pm_addr = $pm_id . "@" . $_SESSION['logged_uid'];
-
- $alias_query = mysql_query("select id from aliases where id='$pm_addr'");
-
- if (mysql_fetch_row($alias_query) > 0) {
- nak("$pm_addr alias exists");
+
+ if ($pm_now >= $pm_max[0]) {
+ nak("{$_SESSION['logged_uid']} limit exceeded");
}
else {
- $pm_name = trim($_POST['pm_name']);
- $pm_name = ucwords($pm_name);
-
- $pm_pw = trim($_POST['pm_pw']);
- $pm_pw = crypt($pm_pw);
-
- $pm_init = substr($pm_id,0,1);
-
- $pm_maildir = "{$_SESSION['logged_uid']}/$pm_init/$pm_id";
-
- $pm_host = trim($_POST['pm_host']);
- $pm_host = strtolower($pm_host);
-
- $pm_query = mysql_query("insert into users values('$pm_addr','$pm_pw','$pm_maildir/','$pm_name','{$_SESSION['logged_uid']}','1','$pm_host')");
-
- if (!$pm_query) {
- nak(strtolower(mysql_error()));
+ $pm_id = trim($_POST['pm_id']);
+ $pm_id = strtolower($pm_id);
+
+ if (preg_match("/@/",$pm_id)) {
+ $pm_id = substr($pm_id,0,strpos($pm_id,"@"));
+ }
+
+ $pm_addr = $pm_id . "@" . $_SESSION['logged_uid'];
+
+ $alias_query = mysql_query("select id from aliases where id='$pm_addr'");
+
+ if (mysql_fetch_row($alias_query) > 0) {
+ nak("$pm_addr alias exists");
}
else {
- if (!file_exists("$mail_root/{$_SESSION['logged_uid']}")) {
- mkdir("$mail_root/{$_SESSION['logged_uid']}");
- }
-
- if (!file_exists("$mail_root/{$_SESSION['logged_uid']}/$pm_init")) {
- mkdir("$mail_root/{$_SESSION['logged_uid']}/$pm_init");
- }
-
- if (!file_exists("$mail_root/$pm_maildir")) {
- mkdir("$mail_root/$pm_maildir");
- }
+ $pm_name = trim($_POST['pm_name']);
+ $pm_name = ucwords($pm_name);
+
+ $pm_pw = trim($_POST['pm_pw']);
+ $pm_pw = crypt($pm_pw);
+
+ $pm_init = substr($pm_id,0,1);
+
+ $pm_maildir = "{$_SESSION['logged_uid']}/$pm_init/$pm_id";
- if (!file_exists("$mail_root/$pm_maildir/cur")) {
- mkdir("$mail_root/$pm_maildir/cur");
- }
+ $pm_host = trim($_POST['pm_host']);
+ $pm_host = strtolower($pm_host);
+
+ $pm_query = mysql_query("insert into users values('$pm_addr','$pm_pw','$pm_maildir/','$pm_name','{$_SESSION['logged_uid']}','1','$pm_host')");
- if (!file_exists("$mail_root/$pm_maildir/new")) {
- mkdir("$mail_root/$pm_maildir/new");
+ if (!$pm_query) {
+ nak(strtolower(mysql_error()));
}
-
- if (!file_exists("$mail_root/$pm_maildir/tmp")) {
- mkdir("$mail_root/$pm_maildir/tmp");
+ else {
+ if (!file_exists("$mail_root/{$_SESSION['logged_uid']}")) {
+ mkdir("$mail_root/{$_SESSION['logged_uid']}");
+ }
+
+ if (!file_exists("$mail_root/{$_SESSION['logged_uid']}/$pm_init")) {
+ mkdir("$mail_root/{$_SESSION['logged_uid']}/$pm_init");
+ }
+
+ if (!file_exists("$mail_root/$pm_maildir")) {
+ mkdir("$mail_root/$pm_maildir");
+ }
+
+ if (!file_exists("$mail_root/$pm_maildir/cur")) {
+ mkdir("$mail_root/$pm_maildir/cur");
+ }
+
+ if (!file_exists("$mail_root/$pm_maildir/new")) {
+ mkdir("$mail_root/$pm_maildir/new");
+ }
+
+ if (!file_exists("$mail_root/$pm_maildir/tmp")) {
+ mkdir("$mail_root/$pm_maildir/tmp");
+ }
+
+ ack("$pm_addr added");
}
-
- ack("$pm_addr added");
}
}
}
@@ -941,7 +954,7 @@ if (isset($_SESSION['logged_uid'])) {
}
if ($_SESSION['logged_lvl'] == "postmaster") {
-
+
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
echo "<tr bgcolor=\"#eeeeee\"><td colspan=\"4\" align=\"center\">status</td><td align=\"center\">username</td><td align=\"center\">complete name</td><td align=\"center\">password</td><td align=\"center\">host</td><td align=\"center\" colspan=\"2\">action</td></tr>";
echo "<form method=\"post\">";