From 0e2978ef48e7877ee46aa4a9e52e86b8f76c9733 Mon Sep 17 00:00:00 2001
From: Dominik Müller <info@profi-webdesign.net>
Date: Sat, 18 Jan 2014 23:34:06 -0500
Subject: [PATCH] Mailbox quota can now be included into website quota (FS#3297) -------------------------------------------------------------- Feature can be activated over admin mailserver settings. when activated websites uid is used instead of standard vmail-uid. this only takes effect if web and mailserver are on the same server, otherwise it will be old behaviour. switching this setting when mailboxes exist doesn't matter. Mailboxfolder will be created with website uid for this. access of postfix and dovecot now works over mysql-table mail_user. virtual_uid_maps is changed from static to mysql-table. for dovecot<->postfix communication protocoll is changed vrom lda to lmtp. disablelmtp-column is added to mail_user-table. uid and gid can be overwritten by remoting. ONE OPEN ISSUE: since remoting has completly changed and mail_user_add function is missing at the moment, this function now was inclulded again. it is important to add the both new lines to the future function and then remove this new one.

---
 interface/lib/classes/validate_ftpuser.inc.php |  111 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 57 insertions(+), 54 deletions(-)

diff --git a/interface/lib/classes/validate_ftpuser.inc.php b/interface/lib/classes/validate_ftpuser.inc.php
index 0682650..64ca12f 100644
--- a/interface/lib/classes/validate_ftpuser.inc.php
+++ b/interface/lib/classes/validate_ftpuser.inc.php
@@ -29,63 +29,66 @@
 */
 
 class validate_ftpuser {
-	
+
 	/*
 		Validator function to check if a given dir is ok.
 	*/
 	function ftp_dir($field_name, $field_value, $validator) {
 		global $app;
-		
-        if($app->tform->primary_id == 0) {
-            $errmsg = $validator['errmsg'];
-            if(isset($app->tform->wordbook[$errmsg])) {
-                return $app->tform->wordbook[$errmsg]."<br>\r\n";
-            } else {
-                return $errmsg."<br>\r\n";
-            }
-        }
-        
-        
-        $ftp_data = $app->db->queryOneRecord("SELECT parent_domain_id FROM ftp_user WHERE ftp_user_id = '".$app->db->quote($app->tform->primary_id)."'");
-        if(!$ftp_data["parent_domain_id"]) {
-            $errmsg = $validator['errmsg'];
-            if(isset($app->tform->wordbook[$errmsg])) {
-                return $app->tform->wordbook[$errmsg]."<br>\r\n";
-            } else {
-                return $errmsg."<br>\r\n";
-            }
-        }
-        
-        $domain_data = $app->db->queryOneRecord("SELECT domain_id, document_root FROM web_domain WHERE domain_id = '".$app->db->quote($ftp_data["parent_domain_id"])."'");
-        if(!$domain_data["domain_id"]) {
-            $errmsg = $validator['errmsg'];
-            if(isset($app->tform->wordbook[$errmsg])) {
-                return $app->tform->wordbook[$errmsg]."<br>\r\n";
-            } else {
-                return $errmsg."<br>\r\n";
-            }
-        }
-        
-        $doc_root = $domain_data["document_root"];
-        $is_ok = false;
-        if($doc_root == $field_value) $is_ok = true;
-        
-        $doc_root .= "/";
-        if(substr($field_value, 0, strlen($doc_root)) == $doc_root) $is_ok = true;
-		
-		if(stristr($field_value,'..') or stristr($field_value,'./') or stristr($field_value,'/.')) $is_ok = false;
-        
-        if($is_ok == false) {
-            $errmsg = $validator['errmsg'];
-            if(isset($app->tform->wordbook[$errmsg])) {
-                return $app->tform->wordbook[$errmsg]."<br>\r\n";
-            } else {
-                return $errmsg."<br>\r\n";
-            }
-        }
+
+		if($app->tform->primary_id == 0) {
+			$errmsg = $validator['errmsg'];
+			if(isset($app->tform->wordbook[$errmsg])) {
+				return $app->tform->wordbook[$errmsg]."<br>\r\n";
+			} else {
+				return $errmsg."<br>\r\n";
+			}
+		}
+
+
+		$ftp_data = $app->db->queryOneRecord("SELECT parent_domain_id FROM ftp_user WHERE ftp_user_id = '".$app->db->quote($app->tform->primary_id)."'");
+		if(!is_array($ftp_data) || $ftp_data["parent_domain_id"] < 1) {
+			$errmsg = $validator['errmsg'];
+			if(isset($app->tform->wordbook[$errmsg])) {
+				return $app->tform->wordbook[$errmsg]."<br>\r\n";
+			} else {
+				return $errmsg."<br>\r\n";
+			}
+		}
+
+		$domain_data = $app->db->queryOneRecord("SELECT domain_id, document_root FROM web_domain WHERE domain_id = '".$app->db->quote($ftp_data["parent_domain_id"])."'");
+		if(!is_array($domain_data) || $domain_data["domain_id"] < 1) {
+			$errmsg = $validator['errmsg'];
+			if(isset($app->tform->wordbook[$errmsg])) {
+				return $app->tform->wordbook[$errmsg]."<br>\r\n";
+			} else {
+				return $errmsg."<br>\r\n";
+			}
+		}
+
+		$doc_root = $domain_data["document_root"];
+		$is_ok = false;
+		if($doc_root == $field_value) $is_ok = true;
+
+		$doc_root .= "/";
+		if(substr($field_value, 0, strlen($doc_root)) == $doc_root) $is_ok = true;
+
+		if(stristr($field_value, '..') or stristr($field_value, './') or stristr($field_value, '/.')) $is_ok = false;
+
+		//* Final check if docroot path of website is >= 5 chars
+		if(strlen($doc_root) < 5) $is_ok = false;
+
+		if($is_ok == false) {
+			$errmsg = $validator['errmsg'];
+			if(isset($app->tform->wordbook[$errmsg])) {
+				return $app->tform->wordbook[$errmsg]."<br>\r\n";
+			} else {
+				return $errmsg."<br>\r\n";
+			}
+		}
 	}
-	
-	
-	
-	
-}
\ No newline at end of file
+
+
+
+
+}

--
Gitblit v1.9.1