diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php index 28e233de027eeea4ecb6fdee940e7f9699bfd094..4ed306d7b5e2de4c176dfea4194a457d00e152a2 100644 --- a/interface/web/sites/web_domain_edit.php +++ b/interface/web/sites/web_domain_edit.php @@ -278,7 +278,7 @@ class page_action extends tform_actions { $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_traffic_quota, limit_web_domain, default_webserver, parent_client_id, limit_web_quota FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - //* Check the website quota + //* Check the website quota of the client if(isset($_POST["hd_quota"]) && $client["limit_web_quota"] >= 0) { $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"]; @@ -294,7 +294,7 @@ class page_action extends tform_actions { unset($tmp_quota); } - //* Check the traffic quota + //* Check the traffic quota of the client if(isset($_POST["traffic_quota"]) && $client["limit_traffic_quota"] > 0) { $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"]; @@ -309,6 +309,43 @@ class page_action extends tform_actions { unset($tmp); unset($tmp_quota); } + + if($client['parent_client_id'] > 0) { + // Get the limits of the reseller + $reseller = $app->db->queryOneRecord("SELECT limit_traffic_quota, limit_web_domain, default_webserver, limit_web_quota FROM client WHERE client_id = ".$client['parent_client_id']); + + //* Check the website quota of the client + if(isset($_POST["hd_quota"]) && $reseller["limit_web_quota"] >= 0) { + $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 > $reseller["limit_web_quota"]) || ($new_web_quota < 0 && $reseller["limit_web_quota"] >= 0)) { + $max_free_quota = floor($reseller["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
"; + // Set the quota field to the max free space + $this->dataRecord["hd_quota"] = $max_free_quota; + } + unset($tmp); + unset($tmp_quota); + } + + //* Check the traffic quota of the client + if(isset($_POST["traffic_quota"]) && $reseller["limit_traffic_quota"] > 0) { + $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 > $reseller["limit_traffic_quota"]) || ($new_traffic_quota < 0 && $reseller["limit_traffic_quota"] >= 0)) { + $max_free_quota = floor($reseller["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
"; + // Set the quota field to the max free space + $this->dataRecord["traffic_quota"] = $max_free_quota; + } + unset($tmp); + unset($tmp_quota); + } + } // When the record is updated if($this->id > 0) {