Feature #536: Use complete domain name as default path for DocumentRoot

This commit is contained in:
Sorin Pohontu (frontline)
2013-03-20 21:37:37 +02:00
parent 236ba6abfb
commit faada48e38
8 changed files with 83 additions and 8 deletions

View File

@@ -32,6 +32,14 @@ return array(
'save_method' => 'storeSettingField',
'plausibility_check_method' => 'checkPathConflicts'
),
'system_documentroot_use_default_value' => array(
'label' => $lng['serversettings']['documentroot_use_default_value'],
'settinggroup' => 'system',
'varname' => 'documentroot_use_default_value',
'type' => 'bool',
'default' => true,
'save_method' => 'storeSettingField',
),
'system_ipaddress' => array(
'label' => $lng['serversettings']['ipaddress'],
'settinggroup' => 'system',

View File

@@ -305,8 +305,10 @@ if($page == 'domains'
$specialsettings = validate(str_replace("\r\n", "\n", $_POST['specialsettings']), 'specialsettings', '/^[^\0]*$/');
validate($_POST['documentroot'], 'documentroot');
// If path is empty and 'Use domain name as default value for DocumentRoot path' is enabled in settings,
// set default path to subdomain or domain name
if(isset($_POST['documentroot'])
&& $_POST['documentroot'] != '')
&& ($_POST['documentroot'] != ''))
{
if(substr($_POST['documentroot'], 0, 1) != '/'
&& !preg_match('/^https?\:\/\//', $_POST['documentroot']))
@@ -318,6 +320,12 @@ if($page == 'domains'
$documentroot = $_POST['documentroot'];
}
}
elseif (isset($_POST['documentroot'])
&& ($_POST['documentroot'] == '')
&& ($settings['system']['documentroot_use_default_value'] == 1))
{
$documentroot = makeCorrectDir($customer['documentroot'] . '/' . $domain);
}
}
else
{
@@ -827,9 +835,18 @@ if($page == 'domains'
$documentroot = validate($_POST['documentroot'], 'documentroot');
if($documentroot == '')
{
// If path is empty and 'Use domain name as default value for DocumentRoot path' is enabled in settings,
// set default path to subdomain or domain name
if ($settings['system']['documentroot_use_default_value'] == 1)
{
$documentroot = makeCorrectDir($customer['documentroot'] . '/' . $result['domain']);
}
else
{
$documentroot = $customer['documentroot'];
}
}
if(!preg_match('/^https?\:\/\//', $documentroot)
&& strstr($documentroot, ":") !== FALSE

View File

@@ -254,8 +254,17 @@ elseif($page == 'domains')
if(!preg_match('/^https?\:\/\//', $path)
|| !validateUrl($idna_convert->encode($path)))
{
$path = $userinfo['documentroot'] . '/' . $path;
$path = makeCorrectDir($path);
// If path is empty or '/' and 'Use domain name as default value for DocumentRoot path' is enabled in settings,
// set default path to subdomain or domain name
if((($path == '') || ($path == '/'))
&& $settings['system']['documentroot_use_default_value'] == 1)
{
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $completedomain);
}
else
{
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
}
if (strstr($path, ":") !== FALSE)
{
standard_error('pathmaynotcontaincolon');
@@ -430,8 +439,17 @@ elseif($page == 'domains')
if(!preg_match('/^https?\:\/\//', $path)
|| !validateUrl($idna_convert->encode($path)))
{
$path = $userinfo['documentroot'] . '/' . $path;
$path = makeCorrectDir($path);
// If path is empty or '/' and 'Use domain name as default value for DocumentRoot path' is enabled in settings,
// set default path to subdomain or domain name
if((($path == '') || ($path == '/'))
&& $settings['system']['documentroot_use_default_value'] == 1)
{
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $result['domain']);
}
else
{
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
}
if (strstr($path, ":") !== FALSE)
{
standard_error('pathmaynotcontaincolon');

View File

@@ -509,6 +509,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('system', 'perl_server', 'unix:/var/run/nginx/cgiwrap-dispatch.sock'),
('system', 'phpreload_command', ''),
('system', 'apache24', '0'),
('system', 'documentroot_use_default_value', '0'),
('panel', 'decimal_places', '4'),
('panel', 'adminmail', 'admin@SERVERNAME'),
('panel', 'phpmyadmin_url', ''),

View File

@@ -2024,3 +2024,15 @@ if (isFroxlorVersion('0.9.28-svn6')) {
lastStepStatus(0);
updateToVersion('0.9.28-rc1');
}
if (isFroxlorVersion('0.9.28-rc1')) {
$update_system_documentroot_use_default_value = isset($_POST['update_system_documentroot_use_default_value']) ? (int)$_POST['update_system_documentroot_use_default_value'] : '0';
showUpdateStep("Adding new settings for using domain name as default value for DocumentRoot path", true);
$db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'documentroot_use_default_value', '".$update_system_documentroot_use_default_value."');");
lastStepStatus(0);
showUpdateStep("Updating from 0.9.28-rc1 to 0.9.28-rc2", true);
lastStepStatus(0);
updateToVersion('0.9.28-rc2');
}

View File

@@ -471,4 +471,17 @@ LoadModule authz_host_module modules/mod_authz_host.so</pre><br />';
}
}
if(versionInUpdate($current_version, '0.9.28-rc2'))
{
$has_preconfig = true;
$description = 'This version will add an option to set default path for all domains and subdomains, to be the full subdomain or domain name.<br />';
$description .= 'You can enable or disable this feature anytime from Server -> Settings -> System settings.<br />';
$question .= '<strong>Do you want to Use domain name as default value for DocumentRoot path?:</strong>&nbsp;';
$question.= makeyesno('update_system_documentroot_use_default_value', '1', '0', '1');
eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";");
}
}

View File

@@ -73,6 +73,6 @@ define('PACKAGE_ENABLED', 2);
// VERSION INFO
$version = '0.9.28-rc1';
$version = '0.9.28-rc2';
$dbversion = '2';
$branding = '';

View File

@@ -1933,3 +1933,9 @@ $lng['serversettings']['enablewebfonts']['title'] = 'Enable usage of a google we
$lng['serversettings']['enablewebfonts']['description'] = 'If enabled, the defined webfont is being used for the font-display';
$lng['serversettings']['definewebfont']['title'] = 'Define a <a href="http://www.google.com/webfonts" rel="external">google-webfont</a> for the panel';
$lng['serversettings']['definewebfont']['description'] = 'If enabled, this wefont will be used for the font-display.<br />Note: replace spaces with the "+" sign, e.g. "Open+Sans"';
/*
* Added in Froxlor 0.9.28-rc2
*/
$lng['serversettings']['documentroot_use_default_value']['title'] = 'Use domain name as default value for DocumentRoot path';
$lng['serversettings']['documentroot_use_default_value']['description'] = 'If enabled and DocumentRoot path is empty, default value will be the (sub)domain name.<br /><br />Examples: <br />/var/customers/customer_name/example.com/<br />/var/customers/customer_name/subdomain.example.com/';