Sfoglia il codice sorgente

remove mailbox_limit from includes

Thor77 10 anni fa
parent
commit
c5db4bc153
2 ha cambiato i file con 23 aggiunte e 54 eliminazioni
  1. 21 52
      include/php/pages/admin/edituser.php
  2. 2 2
      include/php/pages/admin/listusers.php

+ 21 - 52
include/php/pages/admin/edituser.php

@@ -1,68 +1,42 @@
-<?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];
-		}
-	}
-	
-	
+<?php
 	if(isset($_POST['savemode'])){
 		$savemode = $_POST['savemode'];
 		
 		if($savemode === "edit"){
 			// Edit mode entered
-			$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 . ']');
-			}
-			else{
+			$id = $db->escape_string($_POST['id']);
 				// 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.");
+			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);
-					}
 				}
 				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");
 			}				
 		}
 		
 		else if($savemode === "create"){
 			// Create mode entered
 			$username = $db->escape_string($_POST['username']);
-			$domain = $db->escape_string($_POST['domain']);
-			$mailbox_limit = $db->escape_string($_POST['mailbox_limit']);			
+			$domain = $db->escape_string($_POST['domain']);			
 			$pass = $_POST['password'];
 			$pass_rep = $_POST['password_rep'];
 			
-			if($username !== "" && $domain !== "" && $quota !== "" && $mailbox_limit !== ""){
+			if($username !== "" && $domain !== "" && $quota !== ""){
 				// All fields filled with content
 				// Check passwords
 				$pass_ok = check_new_pass($pass, $pass_rep);
@@ -70,7 +44,7 @@
 					// Password is okay ... continue
 					$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')";
+					$sql = "INSERT INTO `".DBT_USERS."` (`".DBC_USERS_USERNAME."`, `".DBC_USERS_DOMAIN."`, `".DBC_USERS_PASSWORD."`) VALUES ('$username', '$domain', '$pass_hash')";
 					
 					if(!$result = $db->query($sql)){
 						die('There was an error running the query [' . $db->error . ']');
@@ -110,7 +84,6 @@
 		while($row = $result->fetch_assoc()){
 			$username = $row[DBC_USERS_USERNAME];
 			$domain = $row[DBC_USERS_DOMAIN];
-			$mailbox_limit = $row[DBC_USERS_MAILBOXLIMIT];
 		}
 	}
 ?>
@@ -137,7 +110,7 @@
 
 <form action="" method="post">	
 	<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> </tr>
 	
 	<tr>
 		<td>
@@ -168,10 +141,6 @@
 			<input name="password" class="textinput" type="password" placeholder="New password"/></br>
 			<input name="password_rep"  class="textinput" type="password" placeholder="New password (repeat)"/>
 		</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"/> 
-		</td>
 	</tr>
 	
 	</table>

+ 2 - 2
include/php/pages/admin/listusers.php

@@ -38,11 +38,11 @@ if(!$result = $db->query($sql)){
 </p>
 
 <table class="list">
-<tr class="head"><th>Username</th> <th>Domain</th> <th>Mailbox Limit (MB)</th> <th></th> <th></th><tr>
+<tr class="head"><th>Username</th> <th>Domain</th> <th></th> <th></th><tr>
 
 <?php 
 	while($row = $result->fetch_assoc()){
-		echo "<tr><td>".$row[DBC_USERS_USERNAME]."</td><td>".$row[DBC_USERS_DOMAIN]."</td><td>".$row[DBC_USERS_MAILBOXLIMIT]."<td><a href=\"".FRONTEND_BASE_PATH."admin/edituser/?id=".$row[DBC_USERS_ID]."\">[Edit]</a></td> <td><a href=\"".FRONTEND_BASE_PATH."admin/deleteuser/?id=".$row[DBC_USERS_ID]."\">[Delete]</a></td> </tr>";
+		echo "<tr><td>".$row[DBC_USERS_USERNAME]."</td><td>".$row[DBC_USERS_DOMAIN]."</td><td><a href=\"".FRONTEND_BASE_PATH."admin/edituser/?id=".$row[DBC_USERS_ID]."\">[Edit]</a></td> <td><a href=\"".FRONTEND_BASE_PATH."admin/deleteuser/?id=".$row[DBC_USERS_ID]."\">[Delete]</a></td> </tr>";
 	}
 ?>
 </table>