|
@@ -1,14 +1,17 @@
|
|
<?php
|
|
<?php
|
|
- // Get mailbox_limit default value from DB
|
|
|
|
- $sql = "SELECT DEFAULT(".DBC_USERS_MAILBOXLIMIT.") AS `".DBC_USERS_MAILBOXLIMIT."` FROM `".DBT_USERS."` LIMIT 1;";
|
|
|
|
-
|
|
|
|
- if(!$result = $db->query($sql)){
|
|
|
|
- die('There was an error running the query [' . $db->error . ']');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- else{
|
|
|
|
- while($row = $result->fetch_assoc()){
|
|
|
|
- $mailbox_limit_default = $row[DBC_USERS_MAILBOXLIMIT];
|
|
|
|
|
|
+ // If mailbox_limit is supported in the MySQL database
|
|
|
|
+ if(defined('DBC_USERS_MAILBOXLIMIT')){
|
|
|
|
+ // Get mailbox_limit default value from DB
|
|
|
|
+ $sql = "SELECT DEFAULT(".DBC_USERS_MAILBOXLIMIT.") AS `".DBC_USERS_MAILBOXLIMIT."` FROM `".DBT_USERS."` LIMIT 1;";
|
|
|
|
+
|
|
|
|
+ if(!$result = $db->query($sql)){
|
|
|
|
+ die('There was an error running the query [' . $db->error . ']');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ else{
|
|
|
|
+ while($row = $result->fetch_assoc()){
|
|
|
|
+ $mailbox_limit_default = $row[DBC_USERS_MAILBOXLIMIT];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -19,38 +22,39 @@
|
|
if($savemode === "edit"){
|
|
if($savemode === "edit"){
|
|
// Edit mode entered
|
|
// Edit mode entered
|
|
$id = $db->escape_string($_POST['id']);
|
|
$id = $db->escape_string($_POST['id']);
|
|
- if($mailbox_limit == ""){
|
|
|
|
- $mailbox_limit = $mailbox_limit_default;
|
|
|
|
- }
|
|
|
|
- $mailbox_limit = $db->escape_string($_POST['mailbox_limit']);
|
|
|
|
|
|
|
|
- $sql = "UPDATE `".DBT_USERS."` SET `".DBC_USERS_MAILBOXLIMIT."` = '$mailbox_limit' WHERE `".DBC_USERS_ID."` = '$id';";
|
|
|
|
- if(!$result = $db->query($sql)){
|
|
|
|
- die('There was an error running the query [' . $db->error . ']');
|
|
|
|
|
|
+ if(defined('DBC_USERS_MAILBOXLIMIT')){
|
|
|
|
+ if($mailbox_limit == ""){
|
|
|
|
+ $mailbox_limit = $mailbox_limit_default;
|
|
|
|
+ }
|
|
|
|
+ $mailbox_limit = $db->escape_string($_POST['mailbox_limit']);
|
|
|
|
+
|
|
|
|
+ $sql = "UPDATE `".DBT_USERS."` SET `".DBC_USERS_MAILBOXLIMIT."` = '$mailbox_limit' WHERE `".DBC_USERS_ID."` = '$id';";
|
|
|
|
+ if(!$result = $db->query($sql)){
|
|
|
|
+ die('There was an error running the query [' . $db->error . ']');
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- else{
|
|
|
|
- // SQL was successful
|
|
|
|
- // Is there a changed password?
|
|
|
|
- if($_POST['password'] !== ""){
|
|
|
|
- $pass_ok = check_new_pass($_POST['password'], $_POST['password_rep']);
|
|
|
|
- if($pass_ok === true){
|
|
|
|
- // Password is okay and can be set
|
|
|
|
- $pass_hash = gen_pass_hash($_POST['password']);
|
|
|
|
- write_pass_hash_to_db($pass_hash, $id);
|
|
|
|
- // $editsuccessful = true;
|
|
|
|
- add_message("success", "User edited successfully.");
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- else{
|
|
|
|
- // Password is not okay
|
|
|
|
- // $editsuccessful = 2;
|
|
|
|
- add_message("fail", $PASS_ERR_MSG);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ // Is there a changed password?
|
|
|
|
+ if($_POST['password'] !== ""){
|
|
|
|
+ $pass_ok = check_new_pass($_POST['password'], $_POST['password_rep']);
|
|
|
|
+ if($pass_ok === true){
|
|
|
|
+ // Password is okay and can be set
|
|
|
|
+ $pass_hash = gen_pass_hash($_POST['password']);
|
|
|
|
+ write_pass_hash_to_db($pass_hash, $id);
|
|
|
|
+ // $editsuccessful = true;
|
|
|
|
+ add_message("success", "User edited successfully.");
|
|
|
|
+
|
|
}
|
|
}
|
|
else{
|
|
else{
|
|
- // Redirect user to user list
|
|
|
|
- header("Location: ".FRONTEND_BASE_PATH."admin/listusers/?edited=1");
|
|
|
|
|
|
+ // Password is not okay
|
|
|
|
+ // $editsuccessful = 2;
|
|
|
|
+ add_message("fail", $PASS_ERR_MSG);
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ // Redirect user to user list
|
|
|
|
+ header("Location: ".FRONTEND_BASE_PATH."admin/listusers/?edited=1");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -58,7 +62,13 @@
|
|
// Create mode entered
|
|
// Create mode entered
|
|
$username = $db->escape_string($_POST['username']);
|
|
$username = $db->escape_string($_POST['username']);
|
|
$domain = $db->escape_string($_POST['domain']);
|
|
$domain = $db->escape_string($_POST['domain']);
|
|
- $mailbox_limit = $db->escape_string($_POST['mailbox_limit']);
|
|
|
|
|
|
+ if(defined('DBC_USERS_MAILBOXLIMIT')){
|
|
|
|
+ $mailbox_limit = $db->escape_string($_POST['mailbox_limit']);
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ // make mailbox_limit dummy for "if"
|
|
|
|
+ $mailbox_limit = 0;
|
|
|
|
+ }
|
|
$pass = $_POST['password'];
|
|
$pass = $_POST['password'];
|
|
$pass_rep = $_POST['password_rep'];
|
|
$pass_rep = $_POST['password_rep'];
|
|
|
|
|
|
@@ -70,7 +80,13 @@
|
|
// Password is okay ... continue
|
|
// Password is okay ... continue
|
|
$pass_hash = gen_pass_hash($pass);
|
|
$pass_hash = gen_pass_hash($pass);
|
|
|
|
|
|
- $sql = "INSERT INTO `".DBT_USERS."` (`".DBC_USERS_USERNAME."`, `".DBC_USERS_DOMAIN."`, `".DBC_USERS_PASSWORD."`, `".DBC_USERS_MAILBOXLIMIT."`) VALUES ('$username', '$domain', '$pass_hash', '$mailbox_limit')";
|
|
|
|
|
|
+ // Differ between version with mailbox_limit and version without
|
|
|
|
+ if(defined('DBC_USERS_MAILBOXLIMIT')){
|
|
|
|
+ $sql = "INSERT INTO `".DBT_USERS."` (`".DBC_USERS_USERNAME."`, `".DBC_USERS_DOMAIN."`, `".DBC_USERS_PASSWORD."`, `".DBC_USERS_MAILBOXLIMIT."`) VALUES ('$username', '$domain', '$pass_hash', '$mailbox_limit')";
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ $sql = "INSERT INTO `".DBT_USERS."` (`".DBC_USERS_USERNAME."`, `".DBC_USERS_DOMAIN."`, `".DBC_USERS_PASSWORD."`) VALUES ('$username', '$domain', '$pass_hash')";
|
|
|
|
+ }
|
|
|
|
|
|
if(!$result = $db->query($sql)){
|
|
if(!$result = $db->query($sql)){
|
|
die('There was an error running the query [' . $db->error . ']');
|
|
die('There was an error running the query [' . $db->error . ']');
|
|
@@ -110,7 +126,9 @@
|
|
while($row = $result->fetch_assoc()){
|
|
while($row = $result->fetch_assoc()){
|
|
$username = $row[DBC_USERS_USERNAME];
|
|
$username = $row[DBC_USERS_USERNAME];
|
|
$domain = $row[DBC_USERS_DOMAIN];
|
|
$domain = $row[DBC_USERS_DOMAIN];
|
|
- $mailbox_limit = $row[DBC_USERS_MAILBOXLIMIT];
|
|
|
|
|
|
+ if(defined('DBC_USERS_MAILBOXLIMIT')){
|
|
|
|
+ $mailbox_limit = $row[DBC_USERS_MAILBOXLIMIT];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
?>
|
|
@@ -137,7 +155,7 @@
|
|
|
|
|
|
<form action="" method="post">
|
|
<form action="" method="post">
|
|
<table>
|
|
<table>
|
|
- <tr> <th>Username</th> <th>Domain</th> <th>Password</th> <th>Mailbox limit (in MB)</th> </tr>
|
|
|
|
|
|
+ <tr> <th>Username</th> <th>Domain</th> <th>Password</th> <?php if(defined('DBC_USERS_MAILBOXLIMIT')){ ?><th>Mailbox limit (in MB)</th> <?php } ?> </tr>
|
|
|
|
|
|
<tr>
|
|
<tr>
|
|
<td>
|
|
<td>
|
|
@@ -169,9 +187,11 @@
|
|
<input name="password_rep" class="textinput" type="password" placeholder="New password (repeat)"/>
|
|
<input name="password_rep" class="textinput" type="password" placeholder="New password (repeat)"/>
|
|
</td>
|
|
</td>
|
|
|
|
|
|
|
|
+ <?php if(defined('DBC_USERS_MAILBOXLIMIT')){ ?>
|
|
<td>
|
|
<td>
|
|
<input name="mailbox_limit" class="textinput" type="number" value="<?php if(isset($mailbox_limit)){echo $mailbox_limit;} else{echo $mailbox_limit_default;} ?>" placeholder="Mailbox size (MB)" required="required"/>
|
|
<input name="mailbox_limit" class="textinput" type="number" value="<?php if(isset($mailbox_limit)){echo $mailbox_limit;} else{echo $mailbox_limit_default;} ?>" placeholder="Mailbox size (MB)" required="required"/>
|
|
</td>
|
|
</td>
|
|
|
|
+ <?php } ?>
|
|
</tr>
|
|
</tr>
|
|
|
|
|
|
</table>
|
|
</table>
|