Skip to content

Commit 8d1b1f1

Browse files
author
mcramer
committed
Added web_folder name check for reserved names and already taken names
FS#1993 - Creating Subdomains as VirtualHost
1 parent 6fb93dd commit 8d1b1f1

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

interface/web/sites/lib/lang/de_web_vhost_subdomain.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
$wb["parent_domain_id_txt"] = 'Website';
33
$wb["web_folder_txt"] = 'Basisordner';
4+
$wb["web_folder_invalid_txt"] = 'Dieser Ordner darf nicht als Basisordner verwendet werden.';
5+
$wb["web_folder_unique_txt"] = 'Dieser Ordner wird bereits verwendet, bitte geben Sie einen anderen Basisordner an.';
46
$wb['ssl_state_txt'] = 'Bundesland';
57
$wb['ssl_locality_txt'] = 'Ort';
68
$wb['ssl_organisation_txt'] = 'Firma';

interface/web/sites/lib/lang/en_web_vhost_subdomain.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
$wb["parent_domain_id_txt"] = 'Parent Website';
33
$wb["web_folder_txt"] = 'Web folder';
4+
$wb["web_folder_invalid_txt"] = 'The web folder is invalid, please choose a different one.';
5+
$wb["web_folder_unique_txt"] = 'The web folder is already used, please choose a different one.';
46
$wb["backup_interval_txt"] = 'Backup interval';
57
$wb["backup_copies_txt"] = 'Number of backup copies';
68
$wb["ssl_state_txt"] = 'State';

interface/web/sites/web_vhost_subdomain_edit.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,16 @@ function onSubmit() {
245245
$this->parent_domain_record = $parent_domain;
246246

247247
$read_limits = array('limit_cgi', 'limit_ssi', 'limit_perl', 'limit_ruby', 'limit_python', 'force_suexec', 'limit_hterror', 'limit_wildcard', 'limit_ssl');
248-
248+
$this->dataRecord['web_folder'] = strtolower($this->dataRecord['web_folder']);
249+
$forbidden_folders = array('', 'cgi-bin', 'web', 'log', 'private', 'ssl', 'tmp', 'webdav');
250+
if(in_array($this->dataRecord['web_folder'], $forbidden_folders) || preg_match('/^log_web\d+$/', $this->dataRecord['web_folder'])) {
251+
$app->tform->errorMessage .= $app->tform->lng("web_folder_invalid_txt")."<br>";
252+
}
253+
// check for duplicate folder usage
254+
$check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `type` = 'vhostsubdomain' AND `parent_domain_id` = '" . intval($this->dataRecord['parent_domain_id']) . "' AND `web_folder` = '" . $app->db->quote($this->dataRecord['web_folder']) . "'");
255+
if($check && $check['cnt'] > 0) {
256+
$app->tform->errorMessage .= $app->tform->lng("web_folder_unique_txt")."<br>";
257+
}
249258

250259
if($_SESSION["s"]["user"]["typ"] != 'admin') {
251260
// Get the limits of the client

0 commit comments

Comments
 (0)