From 090935b5d150a74d9c5660c188e2f07182684a48 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Tue, 22 Feb 2011 10:00:52 -0500
Subject: [PATCH] Fixed: FS#1520 - Customer can set webspace unlimit with a limit.

---
 interface/web/sites/form/ftp_user.tform.php    |    3 +++
 interface/web/sites/lib/lang/en_web_domain.lng |    2 ++
 interface/web/sites/web_domain_edit.php        |    4 ++--
 interface/web/sites/form/web_domain.tform.php  |    6 ++++++
 interface/web/sites/lib/lang/en_ftp_user.lng   |    1 +
 5 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/interface/web/sites/form/ftp_user.tform.php b/interface/web/sites/form/ftp_user.tform.php
index 91dc080..3450764 100644
--- a/interface/web/sites/form/ftp_user.tform.php
+++ b/interface/web/sites/form/ftp_user.tform.php
@@ -108,6 +108,9 @@
 			'formtype'	=> 'TEXT',
 			'validators'	=> array ( 	0 => array (	'type'	=> 'NOTEMPTY',
 														'errmsg'=> 'quota_size_error_empty'),
+										1 => array (	'type'	=> 'REGEX',
+														'regex' => '/^(\-1|[0-9]{1,10})$/',
+														'errmsg'=> 'quota_size_error_regex'),
 									),
 			'default'	=> '-1',
 			'value'		=> '',
diff --git a/interface/web/sites/form/web_domain.tform.php b/interface/web/sites/form/web_domain.tform.php
index 277a3a4..2985205 100644
--- a/interface/web/sites/form/web_domain.tform.php
+++ b/interface/web/sites/form/web_domain.tform.php
@@ -133,6 +133,9 @@
 			'formtype'	=> 'TEXT',
 			'validators'	=> array ( 	0 => array (	'type'	=> 'NOTEMPTY',
 														'errmsg'=> 'hd_quota_error_empty'),
+										1 => array (	'type'	=> 'REGEX',
+														'regex' => '/^(\-1|[0-9]{1,10})$/',
+														'errmsg'=> 'hd_quota_error_regex'),
 									),
 			'default'	=> '-1',
 			'value'		=> '',
@@ -144,6 +147,9 @@
 			'formtype'	=> 'TEXT',
 			'validators'	=> array ( 	0 => array (	'type'	=> 'NOTEMPTY',
 														'errmsg'=> 'traffic_quota_error_empty'),
+										1 => array (	'type'	=> 'REGEX',
+														'regex' => '/^(\-1|[0-9]{1,10})$/',
+														'errmsg'=> 'traffic_quota_error_regex'),
 									),
 			'default'	=> '-1',
 			'value'		=> '',
diff --git a/interface/web/sites/lib/lang/en_ftp_user.lng b/interface/web/sites/lib/lang/en_ftp_user.lng
index f5b1116..88c644e 100644
--- a/interface/web/sites/lib/lang/en_ftp_user.lng
+++ b/interface/web/sites/lib/lang/en_ftp_user.lng
@@ -25,4 +25,5 @@
 $wb["directory_error_empty"] = 'Directory empty.';
 $wb['directory_error_notinweb'] = 'Directory not inside of web root directory.';
 $wb["parent_domain_id_error_empty"] = 'No website selected.';
+$wb["quota_size_error_regex"] = 'Quota: enter a -1 for unlimited or a number > 0';
 ?>
diff --git a/interface/web/sites/lib/lang/en_web_domain.lng b/interface/web/sites/lib/lang/en_web_domain.lng
index 47d4215..ae02252 100644
--- a/interface/web/sites/lib/lang/en_web_domain.lng
+++ b/interface/web/sites/lib/lang/en_web_domain.lng
@@ -65,4 +65,6 @@
 $wb["stats_user_txt"] = 'Webstatistics username';
 $wb["stats_type_txt"] = 'Webstatistics program';
 $wb["custom_php_ini_txt"] = 'Custom php.ini settings';
+$wb["hd_quota_error_regex"] = 'Harddisk quota: enter a -1 for unlimited or a number > 0';
+$wb["traffic_quota_error_regex"] = 'Traffic quota: enter a -1 for unlimited or a number > 0';
 ?>
\ No newline at end of file
diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php
index 0b47a3f..2f25ddb 100644
--- a/interface/web/sites/web_domain_edit.php
+++ b/interface/web/sites/web_domain_edit.php
@@ -283,7 +283,7 @@
 				$tmp = $app->db->queryOneRecord("SELECT sum(hd_quota) as webquota FROM web_domain WHERE domain_id != ".intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
 				$webquota = $tmp["webquota"];
 				$new_web_quota = intval($this->dataRecord["hd_quota"]);
-				if(($webquota + $new_web_quota > $client["limit_web_quota"]) || ($new_web_quota == -1 && $client["limit_web_quota"] != -1)) {
+				if(($webquota + $new_web_quota > $client["limit_web_quota"]) || ($new_web_quota < 0 && $client["limit_web_quota"] >= 0)) {
 					$max_free_quota = floor($client["limit_web_quota"] - $webquota);
 					if($max_free_quota < 0) $max_free_quota = 0;
 					$app->tform->errorMessage .= $app->tform->lng("limit_web_quota_free_txt").": ".$max_free_quota." MB<br>";
@@ -299,7 +299,7 @@
 				$tmp = $app->db->queryOneRecord("SELECT sum(traffic_quota) as trafficquota FROM web_domain WHERE domain_id != ".intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
 				$trafficquota = $tmp["trafficquota"];
 				$new_traffic_quota = intval($this->dataRecord["traffic_quota"]);
-				if(($trafficquota + $new_traffic_quota > $client["limit_traffic_quota"]) || ($new_traffic_quota == -1 && $client["limit_traffic_quota"] != -1)) {
+				if(($trafficquota + $new_traffic_quota > $client["limit_traffic_quota"]) || ($new_traffic_quota < 0 && $client["limit_traffic_quota"] >= 0)) {
 					$max_free_quota = floor($client["limit_traffic_quota"] - $trafficquota);
 					if($max_free_quota < 0) $max_free_quota = 0;
 					$app->tform->errorMessage .= $app->tform->lng("limit_traffic_quota_free_txt").": ".$max_free_quota." MB<br>";

--
Gitblit v1.9.1