From a3277ae6b48b161e1edac83383c11e3918a57e59 Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Mon, 25 Mar 2013 08:18:16 -0400
Subject: [PATCH] - Fixed FS#2827 - Subdomain vhost quota interferes with the site quota.
---
interface/web/sites/form/web_vhost_subdomain.tform.php | 8 ---
interface/web/sites/web_vhost_subdomain_edit.php | 36 ++----------------
server/plugins-available/apache2_plugin.inc.php | 4 +-
interface/web/sites/templates/web_vhost_subdomain_edit.htm | 4 --
interface/web/sites/web_domain_edit.php | 4 +-
server/plugins-available/nginx_plugin.inc.php | 4 +-
install/tpl/apache_ispconfig.conf.master | 2 +
7 files changed, 13 insertions(+), 49 deletions(-)
diff --git a/install/tpl/apache_ispconfig.conf.master b/install/tpl/apache_ispconfig.conf.master
index aaa9e0d..f5b2a91 100644
--- a/install/tpl/apache_ispconfig.conf.master
+++ b/install/tpl/apache_ispconfig.conf.master
@@ -50,3 +50,5 @@
Alias /awstats-icon "/usr/share/awstats/icon"
+NameVirtualHost *:80
+NameVirtualHost *:443
\ No newline at end of file
diff --git a/interface/web/sites/form/web_vhost_subdomain.tform.php b/interface/web/sites/form/web_vhost_subdomain.tform.php
index bb12974..190a55b 100644
--- a/interface/web/sites/form/web_vhost_subdomain.tform.php
+++ b/interface/web/sites/form/web_vhost_subdomain.tform.php
@@ -167,13 +167,7 @@
'hd_quota' => array (
'datatype' => 'INTEGER',
'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',
+ 'default' => '0',
'value' => '',
'width' => '7',
'maxlength' => '7'
diff --git a/interface/web/sites/templates/web_vhost_subdomain_edit.htm b/interface/web/sites/templates/web_vhost_subdomain_edit.htm
index 30745dd..8070e00 100644
--- a/interface/web/sites/templates/web_vhost_subdomain_edit.htm
+++ b/interface/web/sites/templates/web_vhost_subdomain_edit.htm
@@ -34,10 +34,6 @@
<input name="web_folder" id="web_folder" value="{tmpl_var name='web_folder'}" size="30" maxlength="100" type="text" class="textInput formLengthHalf"<tmpl_if name='fixed_folder' op='==' value='y'> readonly="readonly"</tmpl_if> />
</div>
<div class="ctrlHolder">
- <label for="hd_quota">{tmpl_var name='hd_quota_txt'}</label>
- <input name="hd_quota" id="hd_quota" value="{tmpl_var name='hd_quota'}" size="7" maxlength="7" type="text" class="textInput formLengthLimit" /> MB
- </div>
- <div class="ctrlHolder">
<label for="traffic_quota">{tmpl_var name='traffic_quota_txt'}</label>
<input name="traffic_quota" id="traffic_quota" value="{tmpl_var name='traffic_quota'}" size="7" maxlength="7" type="text" class="textInput formLengthLimit" /> MB <tmpl_var name='traffic_quota_exceeded_txt'>
</div>
diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php
index 7de4846..e9284d1 100644
--- a/interface/web/sites/web_domain_edit.php
+++ b/interface/web/sites/web_domain_edit.php
@@ -505,7 +505,7 @@
//* 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 != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
+ $tmp = $app->db->queryOneRecord("SELECT sum(hd_quota) as webquota FROM web_domain WHERE domain_id != ".$app->functions->intval($this->id)." AND type = 'vhost' AND ".$app->tform->getAuthSQL('u'));
$webquota = $tmp["webquota"];
$new_web_quota = $app->functions->intval($this->dataRecord["hd_quota"]);
if(($webquota + $new_web_quota > $client["limit_web_quota"]) || ($new_web_quota < 0 && $client["limit_web_quota"] >= 0)) {
@@ -541,7 +541,7 @@
//* 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 != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
+ $tmp = $app->db->queryOneRecord("SELECT sum(hd_quota) as webquota FROM web_domain WHERE domain_id != ".$app->functions->intval($this->id)." AND type = 'vhost' AND ".$app->tform->getAuthSQL('u'));
$webquota = $tmp["webquota"];
$new_web_quota = $app->functions->intval($this->dataRecord["hd_quota"]);
if(($webquota + $new_web_quota > $reseller["limit_web_quota"]) || ($new_web_quota < 0 && $reseller["limit_web_quota"] >= 0)) {
diff --git a/interface/web/sites/web_vhost_subdomain_edit.php b/interface/web/sites/web_vhost_subdomain_edit.php
index 80258bb..1574698 100644
--- a/interface/web/sites/web_vhost_subdomain_edit.php
+++ b/interface/web/sites/web_vhost_subdomain_edit.php
@@ -363,6 +363,10 @@
if(in_array($check_folder, $forbidden_folders)) {
$app->tform->errorMessage .= $app->tform->lng("web_folder_invalid_txt")."<br>";
}
+
+ // vhostsubdomains do not have a quota of their own
+ $this->dataRecord["hd_quota"] = 0;
+
// check for duplicate folder usage
/*
$check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `type` = 'vhostsubdomain' AND `parent_domain_id` = '" . $app->functions->intval($this->dataRecord['parent_domain_id']) . "' AND `web_folder` = '" . $app->db->quote($this->dataRecord['web_folder']) . "' AND `domain_id` != '" . $app->functions->intval($this->id) . "'");
@@ -388,22 +392,6 @@
if($client['limit_hterror'] != 'y') $this->dataRecord['errordocs'] = '-';
if($client['limit_wildcard'] != 'y' && $this->dataRecord['subdomain'] == '*') $this->dataRecord['subdomain'] = '-';
if($client['limit_ssl'] != 'y') $this->dataRecord['ssl'] = '-';
-
- //* 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 != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
- $webquota = $tmp["webquota"];
- $new_web_quota = $app->functions->intval($this->dataRecord["hd_quota"]);
- 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>";
- // 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"]) && $client["limit_traffic_quota"] > 0) {
@@ -424,22 +412,6 @@
if($client['parent_client_id'] > 0) {
// Get the limits of the reseller
$reseller = $app->db->queryOneRecord("SELECT limit_traffic_quota, limit_web_subdomain, 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 != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
- $webquota = $tmp["webquota"];
- $new_web_quota = $app->functions->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<br>";
- // 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) {
diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 9eb6962..8437ba4 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -651,8 +651,8 @@
exec('chown -R '.$data['new']['system_user'].':'.$data['new']['system_group'].' '.$error_page_path);
} // end copy error docs
- // Set the quota for the user
- if($username != '' && $app->system->is_user($username)) {
+ // Set the quota for the user, but only for vhosts, not vhostsubdomains
+ if($username != '' && $app->system->is_user($username) && $data['new']['type'] == 'vhost') {
if($data['new']['hd_quota'] > 0) {
$blocks_soft = $data['new']['hd_quota'] * 1024;
$blocks_hard = $blocks_soft + 1024;
diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php
index d6ec88e..7a1e562 100644
--- a/server/plugins-available/nginx_plugin.inc.php
+++ b/server/plugins-available/nginx_plugin.inc.php
@@ -655,8 +655,8 @@
exec('chown -R '.$data['new']['system_user'].':'.$data['new']['system_group'].' '.$error_page_path);
} // end copy error docs
- // Set the quota for the user
- if($username != '' && $app->system->is_user($username)) {
+ // Set the quota for the user, but only for vhosts, not vhostsubdomains
+ if($username != '' && $app->system->is_user($username) && $data['new']['type'] == 'vhost') {
if($data['new']['hd_quota'] > 0) {
$blocks_soft = $data['new']['hd_quota'] * 1024;
$blocks_hard = $blocks_soft + 1024;
--
Gitblit v1.9.1