mcramer
2012-08-20 6fb93dd3b9817a656570a8ace8d22d1617fda506
Implemented (as optional!) FS#1993 - Creating Subdomains as VirtualHost 

18 files modified
12 files added
3118 ■■■■ changed files
install/sql/incremental/upd_0038.sql 5 ●●●●● patch | view | raw | blame | history
install/sql/ispconfig3.sql 1 ●●●● patch | view | raw | blame | history
interface/web/admin/form/system_config.tform.php 8 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/de_system_config.lng 2 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_system_config.lng 2 ●●●●● patch | view | raw | blame | history
interface/web/admin/system_config_edit.php 11 ●●●●● patch | view | raw | blame | history
interface/web/admin/templates/system_config_sites_edit.htm 6 ●●●●● patch | view | raw | blame | history
interface/web/sites/form/web_folder.tform.php 2 ●●● patch | view | raw | blame | history
interface/web/sites/form/web_vhost_subdomain.tform.php 705 ●●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/de_web_domain.lng 1 ●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/de_web_vhost_subdomain.lng 110 ●●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/de_web_vhost_subdomain_list.lng 8 ●●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_web_domain.lng 1 ●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_web_vhost_subdomain.lng 110 ●●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_web_vhost_subdomain_list.lng 8 ●●●●● patch | view | raw | blame | history
interface/web/sites/lib/module.conf.php 5 ●●●● patch | view | raw | blame | history
interface/web/sites/list/web_folder.list.php 2 ●●● patch | view | raw | blame | history
interface/web/sites/list/web_vhost_subdomain.list.php 99 ●●●●● patch | view | raw | blame | history
interface/web/sites/templates/web_vhost_subdomain_edit.htm 207 ●●●●● patch | view | raw | blame | history
interface/web/sites/templates/web_vhost_subdomain_list.htm 60 ●●●●● patch | view | raw | blame | history
interface/web/sites/web_domain_edit.php 2 ●●● patch | view | raw | blame | history
interface/web/sites/web_domain_list.php 2 ●●● patch | view | raw | blame | history
interface/web/sites/web_subdomain_edit.php 4 ●●●● patch | view | raw | blame | history
interface/web/sites/web_vhost_subdomain_del.php 72 ●●●●● patch | view | raw | blame | history
interface/web/sites/web_vhost_subdomain_edit.php 456 ●●●●● patch | view | raw | blame | history
interface/web/sites/web_vhost_subdomain_list.php 55 ●●●●● patch | view | raw | blame | history
server/conf/vhost.conf.master 4 ●●● patch | view | raw | blame | history
server/plugins-available/apache2_plugin.inc.php 351 ●●●●● patch | view | raw | blame | history
server/plugins-available/nginx_plugin.inc.php 813 ●●●●● patch | view | raw | blame | history
server/plugins-available/nginx_reverseproxy_plugin.inc.php 6 ●●●● patch | view | raw | blame | history
install/sql/incremental/upd_0038.sql
New file
@@ -0,0 +1,5 @@
-- --------------------------------------------------------
ALTER TABLE `web_domain` ADD `web_folder` VARCHAR( 100 ) DEFAULT NULL AFTER `document_root` ;
install/sql/ispconfig3.sql
@@ -1648,6 +1648,7 @@
  `parent_domain_id` int(11) unsigned NOT NULL default '0',
  `vhost_type` varchar(32) default NULL,
  `document_root` varchar(255) default NULL,
  `web_folder` varchar(100) default NULL,
  `system_user` varchar(255) default NULL,
  `system_group` varchar(255) default NULL,
  `hd_quota` bigint(20) NOT NULL default '0',
interface/web/admin/form/system_config.tform.php
@@ -148,6 +148,12 @@
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'vhost_subdomains' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
@@ -252,7 +258,7 @@
        ),
        'smtp_pass' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'formtype'    => 'PASSWORD',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
interface/web/admin/lib/lang/de_system_config.lng
@@ -5,6 +5,8 @@
$wb['dbuser_prefix_txt'] = 'Datenbankbenutzer Prefix';
$wb['shelluser_prefix_txt'] = 'Shellbenutzer Prefix';
$wb['ftpuser_prefix_txt'] = 'FTP Benutzer Prefix';
$wb['vhost_subdomains_txt'] = 'Subdomains als Website anlegen';
$wb['vhost_subdomains_note_txt'] = 'Diese Einstellung kann nicht geändert werden, wenn Subdomains im System vorhanden sind!';
$wb['dbname_prefix_error_regex'] = 'Zeichen nicht erlaubt in Datenbanknamen Prefix.';
$wb['dbuser_prefix_error_regex'] = 'Zeichen nicht erlaubt in Datenbankbenutzer Prefix.';
$wb['ftpuser_prefix_error_regex'] = 'Zeichen nicht erlaubt in FTP Benutzer Prefix.';
interface/web/admin/lib/lang/en_system_config.lng
@@ -9,6 +9,8 @@
$wb["shelluser_prefix_txt"] = 'Shell user prefix';
$wb["webdavuser_prefix_txt"] = 'Webdav user prefix';
$wb["ftpuser_prefix_txt"] = 'FTP user prefix';
$wb['vhost_subdomains_txt'] = 'Create Subdomains as web site';
$wb['vhost_subdomains_note_txt'] = 'You cannot change this as long as subdomains exist in the system!';
$wb["dbname_prefix_error_regex"] = 'Char not allowed in database name prefix.';
$wb["dbuser_prefix_error_regex"] = 'Char not allowed in database user prefix.';
$wb["ftpuser_prefix_error_regex"] = 'Char not allowed in ftp user prefix.';
interface/web/admin/system_config_edit.php
@@ -85,8 +85,17 @@
        
        $section = $app->tform->getCurrentTab();
        
        $server_config_array = $app->getconf->get_global_config();
        $server_config_array[$section] = $app->tform->encode($this->dataRecord,$section);
        $new_config = $app->tform->encode($this->dataRecord,$section);
        if($section == 'sites' && $new_config['vhost_subdomains'] != $server_config_array['vhost_subdomains']) {
            // check for existing subdomains
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `type` = 'subdomain' OR `type` = 'vhostsubdomain'");
            if($check['cnt'] > 0) {
                $new_config['vhost_subdomains'] = $server_config_array['vhost_subdomains'];
            }
        }
        $server_config_array[$section] = $new_config;
        $server_config_str = $app->ini_parser->get_ini_string($server_config_array);
        
        $sql = "UPDATE sys_ini SET config = '".$app->db->quote($server_config_str)."' WHERE sysini_id = 1";
interface/web/admin/templates/system_config_sites_edit.htm
@@ -39,6 +39,12 @@
                <label for="webftp_url">{tmpl_var name='webftp_url_txt'}</label>
                <input name="webftp_url" id="webftp_url" value="{tmpl_var name='webftp_url'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='vhost_subdomains_txt'}</p>
                <div class="multiField">
                    {tmpl_var name='vhost_subdomains'}&nbsp;{tmpl_var name='vhost_subdomains_note_txt'}
                </div>
            </div>
        </fieldset>
            
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
interface/web/sites/form/web_folder.tform.php
@@ -74,7 +74,7 @@
            'formtype'    => 'SELECT',
            'default'    => '',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => "SELECT domain_id,domain FROM web_domain WHERE type = 'vhost' AND {AUTHSQL} ORDER BY domain",
                                        'querystring' => "SELECT domain_id,domain FROM web_domain WHERE (type = 'vhost' OR type = 'vhostsubdomain') AND {AUTHSQL} ORDER BY domain",
                                        'keyfield'=> 'domain_id',
                                        'valuefield'=> 'domain'
                                     ),
interface/web/sites/form/web_vhost_subdomain.tform.php
New file
@@ -0,0 +1,705 @@
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
    Search:
    - searchable = 1 or searchable = 2 include the field in the search
    - searchable = 1: this field will be the title of the search result
    - searchable = 2: this field will be included in the description of the search result
*/
$form["title"]             = "Subdomain";
$form["description"]     = "";
$form["name"]             = "web_vhost_subdomain";
$form["action"]            = "web_vhost_subdomain_edit.php";
$form["db_table"]        = "web_domain";
$form["db_table_idx"]    = "domain_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "domain";
$form["list_default"]    = "web_vhost_subdomain_list.php";
$form["auth"]            = 'yes'; // yes / no
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
$wildcard_available = false;
$ssl_available = true;
if(!$app->auth->is_admin()) {
    $client_group_id = $_SESSION["s"]["user"]["default_group"];
    $client = $app->db->queryOneRecord("SELECT limit_wildcard, limit_ssl FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
    if($client['limit_ssl'] != 'y') $ssl_available = false;
}
$form["tabs"]['domain'] = array (
    'title'     => "Domain",
    'width'     => 100,
    'template'     => "templates/web_vhost_subdomain_edit.htm",
    'readonly'    => false,
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'server_id' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND web_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'ip_address' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => '',
            /*'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => "SELECT ip_address,ip_address FROM server_ip WHERE ip_type = 'IPv4' AND {AUTHSQL} ORDER BY ip_address",
                                        'keyfield'=> 'ip_address',
                                        'valuefield'=> 'ip_address'
                                     ),*/
            'value'        => '',
            'searchable' => 2
        ),
        'ipv6_address' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => '',
            /*'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => "SELECT ip_address,ip_address FROM server_ip WHERE ip_type = 'IPv6' AND {AUTHSQL} ORDER BY ip_address",
                                        'keyfield'=> 'ip_address',
                                        'valuefield'=> 'ip_address'
                                     ),*/
            'value'        => '',
            'searchable' => 2
        ),
        'domain' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'domain_error_empty'),
                                        1 => array (    'type'    => 'UNIQUE',
                                                        'errmsg'=> 'domain_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,30}$/',
                                                        'errmsg'=> 'domain_error_regex'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255',
            'searchable' => 1
        ),
        'type' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'y',
            'value'        => array('vhost' => 'Site', 'alias' => 'Alias', 'subdomain' => 'Subdomain', 'vhostsubdomain' => 'Subdomain')
        ),
        'parent_domain_id' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => "SELECT domain_id,domain FROM web_domain WHERE type = 'vhost' AND {AUTHSQL} ORDER BY domain",
                                        'keyfield'=> 'domain_id',
                                        'valuefield'=> 'domain'
                                     ),
            'value'        => ''
        ),
        'web_folder' => array (
            'datatype'    => 'VARCHAR',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '@^([\w/_\.\-]{1,100})$@',
                                                        'errmsg'=> 'web_folder_error_regex'),
                                    ),
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'vhost_type' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'y',
            'value'        => array('name' => 'Namebased', 'ip' => 'IP-Based')
        ),
        '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',
            'value'        => '',
            'width'        => '7',
            'maxlength'    => '7'
        ),
        'traffic_quota' => array (
            'datatype'    => 'INTEGER',
            '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'        => '',
            'width'        => '7',
            'maxlength'    => '7'
        ),
        'cgi' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'ssi' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'suexec' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'y',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'errordocs' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'CHECKBOX',
            'default'    => '1',
            'value'        => array(0 => '0',1 => '1')
        ),
        'subdomain' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'www',
            'value'        => ($wildcard_available ? array('none' => 'none_txt', 'www' => 'www.', '*' => '*.') : array('none' => 'none_txt', 'www' => 'www.'))
        ),
        'ssl' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'php' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'fast-cgi',
            'valuelimit' => 'client:web_php_options',
            'value'        => array('no' => 'disabled_txt', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP', 'php-fpm' => 'PHP-FPM'),
            'searchable' => 2
        ),
        'fastcgi_php_version' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => '',
            /*'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => "SELECT ip_address,ip_address FROM server_ip WHERE ip_type = 'IPv4' AND {AUTHSQL} ORDER BY ip_address",
                                        'keyfield'=> 'ip_address',
                                        'valuefield'=> 'ip_address'
                                     ),*/
            'value'        => ''
        ),
        'perl' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'ruby' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'python' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'active' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'y',
            'value'        => array(0 => 'n',1 => 'y')
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
$form["tabs"]['redirect'] = array (
    'title'     => "Redirect",
    'width'     => 100,
    'template'     => "templates/web_domain_redirect.htm",
    'readonly'    => false,
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'redirect_type' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => '',
            'value'        => array('' => 'no_redirect_txt', 'no' => 'no_flag_txt', 'R' => 'R', 'L' => 'L', 'R,L' => 'R,L', 'R=301,L' => 'R=301,L', 'last' => 'last', 'break' => 'break', 'redirect' => 'redirect', 'permanent' => 'permanent')
        ),
        'redirect_path' => array (
            'datatype'    => 'VARCHAR',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '@^(([\.]{0})|(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.\,\-\+\?\~]*(\?\S+)?)?)?)|(\[scheme\]://([-\w\.]+)+(:\d+)?(/([\w/_\.\-\,\+\?\~]*(\?\S+)?)?)?)|(/[\w/_\.\-]{1,255}/))$@',
                                                        'errmsg'=> 'redirect_error_regex'),
                                    ),
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'seo_redirect' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => '',
            'value'        => array('' => 'no_redirect_txt', 'non_www_to_www' => 'non_www_to_www_txt', 'www_to_non_www' => 'www_to_non_www_txt')
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
if($ssl_available) {
$form["tabs"]['ssl'] = array (
    'title'     => "SSL",
    'width'     => 100,
    'template'     => "templates/web_domain_ssl.htm",
    'readonly'    => false,
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'ssl_state' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^(([\.]{0})|([a-zA-Z0-9\ \.\-\_\,]{1,255}))$/',
                                                        'errmsg'=> 'ssl_state_error_regex'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'ssl_locality' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^(([\.]{0})|([a-zA-Z0-9\ \.\-\_\,]{1,255}))$/',
                                                        'errmsg'=> 'ssl_locality_error_regex'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'ssl_organisation' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^(([\.]{0})|([a-zA-Z0-9\ \.\-\_\,]{1,255}))$/',
                                                        'errmsg'=> 'ssl_organisation_error_regex'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'ssl_organisation_unit' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^(([\.]{0})|([a-zA-Z0-9\ \.\-\_\,]{1,255}))$/',
                                                        'errmsg'=> 'ssl_organistaion_unit_error_regex'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        /*
        'ssl_country' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^(([\.]{0})|([A-Z]{2,2}))$/',
                                                        'errmsg'=> 'ssl_country_error_regex'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '2',
            'maxlength'    => '2'
        ),
        */
        'ssl_country' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => '',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name',
                                        'keyfield'=> 'iso',
                                        'valuefield'=> 'printable_name'
                                     ),
            'value'        => ''
        ),
        'ssl_domain' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'ssl_key' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'cols'        => '30',
            'rows'        => '10'
        ),
        'ssl_request' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'cols'        => '30',
            'rows'        => '10'
        ),
        'ssl_cert' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'cols'        => '30',
            'rows'        => '10'
        ),
        'ssl_bundle' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'cols'        => '30',
            'rows'        => '10'
        ),
        'ssl_action' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => '',
            'value'        => array('' => 'none_txt', 'save' => 'save_certificate_txt', 'create' => 'create_certificate_txt','del' => 'delete_certificate_txt')
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
}
//* Statistics
$form["tabs"]['stats'] = array (
    'title'     => "Stats",
    'width'     => 100,
    'template'     => "templates/web_domain_stats.htm",
    'readonly'    => false,
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'stats_password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption' => 'CRYPT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'stats_type' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'webalizer',
            'value'        => array('webalizer' => 'Webalizer', 'awstats' => 'AWStats')
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
// if($_SESSION["s"]["user"]["typ"] == 'admin') {
//* Backup
$form["tabs"]['backup'] = array (
    'title'     => "Backup",
    'width'     => 100,
    'template'     => "templates/web_domain_backup.htm",
    'readonly'    => false,
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'backup_interval' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => '',
            'value'        => array('none' => 'No backup', 'daily' => 'Daily', 'weekly' => 'Weekly', 'monthly' => 'Monthly')
        ),
        'backup_copies' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '',
            'value'        => array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10')
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    ),
    'plugins' => array (
         'backup_records' => array (
             'class'   => 'plugin_backuplist',
             'options' => array(
            )
        )
    )
);
// }
if($_SESSION["s"]["user"]["typ"] == 'admin') {
$form["tabs"]['advanced'] = array (
    'title'     => "Options",
    'width'     => 100,
    'template'     => "templates/web_domain_advanced.htm",
    'readonly'    => false,
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'document_root' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'documentroot_error_empty'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'system_user' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'sysuser_error_empty'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'system_group' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'sysgroup_error_empty'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'allow_override' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'allow_override_error_empty'),
                                    ),
            'default'    => 'All',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'php_fpm_use_socket' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'pm' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'dynamic',
            'value'        => array('static' => 'static', 'dynamic' => 'dynamic', 'ondemand' => 'ondemand (PHP Version >= 5.3.9)')
        ),
        'pm_max_children' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^([1-9][0-9]{0,10})$/',
                                                        'errmsg'=> 'pm_max_children_error_regex'),
                                    ),
            'default'    => '10',
            'value'        => '',
            'width'        => '3',
            'maxlength'    => '3'
        ),
        'pm_start_servers' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^([1-9][0-9]{0,10})$/',
                                                        'errmsg'=> 'pm_start_servers_error_regex'),
                                    ),
            'default'    => '2',
            'value'        => '',
            'width'        => '3',
            'maxlength'    => '3'
        ),
        'pm_min_spare_servers' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^([1-9][0-9]{0,10})$/',
                                                        'errmsg'=> 'pm_min_spare_servers_error_regex'),
                                    ),
            'default'    => '1',
            'value'        => '',
            'width'        => '3',
            'maxlength'    => '3'
        ),
        'pm_max_spare_servers' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^([1-9][0-9]{0,10})$/',
                                                        'errmsg'=> 'pm_max_spare_servers_error_regex'),
                                    ),
            'default'    => '5',
            'value'        => '',
            'width'        => '3',
            'maxlength'    => '3'
        ),
        'pm_process_idle_timeout' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^([1-9][0-9]{0,10})$/',
                                                        'errmsg'=> 'pm_process_idle_timeout_error_regex'),
                                    ),
            'default'    => '10',
            'value'        => '',
            'width'        => '3',
            'maxlength'    => '6'
        ),
        'pm_max_requests' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^([0-9]{1,11})$/',
                                                        'errmsg'=> 'pm_max_requests_error_regex'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'width'        => '3',
            'maxlength'    => '6'
        ),
        'php_open_basedir' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            /*'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'php_open_basedir_error_empty'),
                                    ),   */
            'default'    => 'All',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'custom_php_ini' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'apache_directives' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'nginx_directives' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        )
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
}
?>
interface/web/sites/lib/lang/de_web_domain.lng
@@ -13,6 +13,7 @@
$wb['domain_txt'] = 'Domain';
$wb['type_txt'] = 'Typ';
$wb['parent_domain_id_txt'] = 'Zugehörige Website';
$wb['web_folder_error_regex'] = 'Ungültige Ordnerangabe, bitte keinen / eingeben.';
$wb['redirect_type_txt'] = 'Redirect Typ';
$wb['redirect_path_txt'] = 'Redirect Pfad';
$wb['active_txt'] = 'Aktiv';
interface/web/sites/lib/lang/de_web_vhost_subdomain.lng
New file
@@ -0,0 +1,110 @@
<?php
$wb["parent_domain_id_txt"] = 'Website';
$wb["web_folder_txt"] = 'Basisordner';
$wb['ssl_state_txt'] = 'Bundesland';
$wb['ssl_locality_txt'] = 'Ort';
$wb['ssl_organisation_txt'] = 'Firma';
$wb['ssl_organisation_unit_txt'] = 'Abteilung';
$wb['ssl_country_txt'] = 'Land';
$wb["ssl_key_txt"] = 'SSL-Key';
$wb['ssl_request_txt'] = 'SSL-Request';
$wb['ssl_cert_txt'] = 'SSL-Zertifikat';
$wb['ssl_bundle_txt'] = 'SSL-Bundle';
$wb['ssl_action_txt'] = 'SSL-Aktion';
$wb['server_id_txt'] = 'Server';
$wb['domain_txt'] = 'Domain';
$wb['type_txt'] = 'Typ';
$wb['parent_domain_id_txt'] = 'Zugehörige Website';
$wb['web_folder_error_regex'] = 'Ungültige Ordnerangabe, bitte keinen / eingeben.';
$wb['redirect_type_txt'] = 'Redirect Typ';
$wb['redirect_path_txt'] = 'Redirect Pfad';
$wb['active_txt'] = 'Aktiv';
$wb['document_root_txt'] = 'Documentroot';
$wb['system_user_txt'] = 'Linux Benutzer';
$wb['system_group_txt'] = 'Linux Gruppe';
$wb['ip_address_txt'] = 'IP-Adresse';
$wb['vhost_type_txt'] = 'VHost Type';
$wb['hd_quota_txt'] = 'Festplatten Quota';
$wb['traffic_quota_txt'] = 'Traffic Quota';
$wb['cgi_txt'] = 'CGI';
$wb['ssi_txt'] = 'SSI';
$wb['ssl_txt'] = 'SSL';
$wb['suexec_txt'] = 'SuEXEC';
$wb['php_txt'] = 'PHP';
$wb['client_txt'] = 'Kunde';
$wb['limit_web_domain_txt'] = 'Die maximale Anzahl an Webdomains für ihr Konto wurde erreicht.';
$wb['limit_web_aliasdomain_txt'] = 'Die maximale Anzahl an Aliasdomains für ihr Konto wurde erreicht.';
$wb['limit_web_subdomain_txt'] = 'Die maximale Anzahl an Subdomains für ihr Konto wurde erreicht.';
$wb['apache_directives_txt'] = 'Apache Direktiven';
$wb['domain_error_empty'] = 'Domain ist leer.';
$wb['domain_error_unique'] = 'Domain muss eindeutig sein';
$wb['domain_error_regex'] = 'Domainname ungültig.';
$wb['hd_quota_error_empty'] = 'Harddisk Quota ist leer.';
$wb['traffic_quota_error_empty'] = 'Traffic Quota ist leer.';
$wb['errordocs_txt'] = 'Eigene Fehlerseiten';
$wb['error_ssl_state_empty'] = 'SSL-Status ist leer.';
$wb['error_ssl_locality_empty'] = 'Ort (SSL) ist leer.';
$wb['error_ssl_organisation_empty'] = 'Organisation (SSL) ist leer.';
$wb['error_ssl_organisation_unit_empty'] = 'Abteilung (SSL) ist leer.';
$wb['error_ssl_country_empty'] = 'Land (SSL) ist leer.';
$wb['subdomain_txt'] = 'Auto-Subdomain';
$wb['client_group_id_txt'] = 'Kunde';
$wb['stats_password_txt'] = 'Webstatistik Passwort';
$wb['ssl_domain_txt'] = 'SSL Domain';
$wb['allow_override_txt'] = 'Allow Override';
$wb['limit_web_quota_free_txt'] = 'Max. möglicher Festplatten Quota';
$wb['ssl_state_error_regex'] = 'Ungültige SSL State. Gültige Zeichen sind: a-z, 0-9 und .,-_';
$wb['ssl_locality_error_regex'] = 'Ungültige SSL Locality. Gülige Zeichen sind: a-z, 0-9 und .,-_';
$wb['ssl_organisation_error_regex'] = 'Ungültige SSL Organisation. Gültige Zeichen sind: a-z, 0-9 und .,-_';
$wb['ssl_organistaion_unit_error_regex'] = 'Ungültige SSL Organisation Unit. Gültige Zeichen sind: a-z, 0-9 und .,-_';
$wb['ssl_country_error_regex'] = 'Ungültiges SSL Land. Gültige Zeichen sind: A-Z';
$wb['limit_traffic_quota_free_txt'] = 'Max. möglicher Traffic Quota';
$wb['redirect_error_regex'] = 'Ungültiger redirect Pfad. Gültige Angaben sind beispielsweise: /test/ oder http://www.domain.tld/test/';
$wb['php_open_basedir_txt'] = 'PHP open_basedir';
$wb['backup_interval_txt'] = 'Backup-Intervall';
$wb['backup_copies_txt'] = 'Anzahl an Backups';
$wb['traffic_quota_exceeded_txt'] = 'Übertragungs-Volumen verbraucht.';
$wb['ruby_txt'] = 'Ruby';
$wb['stats_user_txt'] = 'Webstatistik-Benutzername';
$wb['stats_type_txt'] = 'Webstatistik-Programm';
$wb['custom_php_ini_txt'] = 'Individuelle php.ini-Einstellungen';
$wb['error_ssl_cert_empty'] = 'SSL-Zertifikat-Fels ist leer.';
$wb['none_txt'] = 'Keine';
$wb['disabled_txt'] = 'Deaktiviert';
$wb['no_redirect_txt'] = 'Kein Redirect';
$wb['no_flag_txt'] = 'Kein Flag';
$wb['save_certificate_txt'] = 'Zertifikat speichern';
$wb['create_certificate_txt'] = 'Zertifikat erstellen';
$wb['delete_certificate_txt'] = 'Zertifikat löschen';
$wb['nginx_directives_txt'] = 'nginx Direktiven';
$wb['seo_redirect_txt'] = 'SEO Redirect';
$wb['non_www_to_www_txt'] = 'Nicht-www -&gt; www';
$wb['www_to_non_www_txt'] = 'www -&gt; Nicht-www';
$wb['php_fpm_use_socket_txt'] = 'Benutze Socket für PHP-FPM';
$wb['ipv6_address_txt'] = 'IPv6-Adresse';
$wb['error_no_sni_txt'] = 'SNI für SSL ist auf diesem Server nicht aktiviert. Sie können daher nur ein SSL Zertifikat pro IP Adresse eintragen.';
$wb['python_txt'] = 'Python';
$wb['perl_txt'] = 'Perl';
$wb['pm_max_children_txt'] = 'PHP-FPM pm.max_children';
$wb['pm_start_servers_txt'] = 'PHP-FPM pm.start_servers';
$wb['pm_min_spare_servers_txt'] = 'PHP-FPM pm.min_spare_servers';
$wb['pm_max_spare_servers_txt'] = 'PHP-FPM pm.max_spare_servers';
$wb['error_php_fpm_pm_settings_txt'] = 'Die Werte der PHP-FPM pm Einstellungen müssen wie folgt sein: pm.max_children &gt;= pm.max_spare_servers &gt;= pm.start_servers &gt;= pm.min_spare_servers &gt; 0';
$wb['pm_max_children_error_regex'] = 'PHP-FPM pm.max_children mu&szlig; eine positive ganze Zahl sein.';
$wb['pm_start_servers_error_regex'] = 'PHP-FPM pm.start_servers mu&szlig; eine positive ganze Zahl sein.';
$wb['pm_min_spare_servers_error_regex'] = 'PHP-FPM pm.min_spare_servers mu&szlig; eine positive ganze Zahl sein.';
$wb['pm_max_spare_servers_error_regex'] = 'PHP-FPM pm.max_spare_servers mu&szlig; eine positive ganze Zahl sein.';
$wb['hd_quota_error_regex'] = 'Harddisk Quota ist ungültig.';
$wb['traffic_quota_error_regex'] = 'Traffic Quota ist ungültig.';
$wb["fastcgi_php_version_txt"] = 'PHP-Version';
$wb["pm_txt"] = 'PHP-FPM Prozess Manager';
$wb["pm_process_idle_timeout_txt"] = 'PHP-FPM pm.process_idle_timeout';
$wb["pm_max_requests_txt"] = 'PHP-FPM pm.max_requests';
$wb["pm_process_idle_timeout_error_regex"] = 'PHP-FPM pm.process_idle_timeout mu&szlig; eine positive ganze Zahl sein.';
$wb["pm_max_requests_error_regex"] = 'PHP-FPM pm.max_requests mu&szlig; eine ganze Zahl >= 0 sein.';
$wb["pm_ondemand_hint_txt"] = 'Bitte beachten Sie, daß Ihre PHP-Version >= 5.3.9 sein muß, wenn Sie den ondemand Process-Manager nutzen möchten. Wenn Sie ondemand für eine ältere PHP-Version auswählen, wird PHP nicht mehr starten!';
$wb['generate_password_txt'] = 'Passwort erzeugen';
$wb['repeat_password_txt'] = 'Passwort wiederholen';
$wb['password_mismatch_txt'] = 'Die Passwörter stimmen nicht überein.';
$wb['password_match_txt'] = 'Die Passwörter stimmen überein.';
?>
interface/web/sites/lib/lang/de_web_vhost_subdomain_list.lng
New file
@@ -0,0 +1,8 @@
<?php
$wb['list_head_txt'] = 'Subdomains';
$wb['active_txt'] = 'Aktiv';
$wb['server_id_txt'] = 'Server';
$wb['parent_domain_id_txt'] = 'Website';
$wb['domain_txt'] = 'Subdomain';
$wb['add_new_record_txt'] = 'Neue Subdomain hinzufügen';
?>
interface/web/sites/lib/lang/en_web_domain.lng
@@ -14,6 +14,7 @@
$wb["ssl_domain_txt"] = 'SSL Domain';
$wb["server_id_txt"] = 'Server';
$wb["domain_txt"] = 'Domain';
$wb['web_folder_error_regex'] = 'Invalid folder entered. Please do not enter a slash.';
$wb["type_txt"] = 'Type';
$wb["parent_domain_id_txt"] = 'Parent Website';
$wb["redirect_type_txt"] = 'Redirect Type';
interface/web/sites/lib/lang/en_web_vhost_subdomain.lng
New file
@@ -0,0 +1,110 @@
<?php
$wb["parent_domain_id_txt"] = 'Parent Website';
$wb["web_folder_txt"] = 'Web folder';
$wb["backup_interval_txt"] = 'Backup interval';
$wb["backup_copies_txt"] = 'Number of backup copies';
$wb["ssl_state_txt"] = 'State';
$wb["ssl_locality_txt"] = 'Locality';
$wb["ssl_organisation_txt"] = 'Organisation';
$wb["ssl_organisation_unit_txt"] = 'Organisation Unit';
$wb["ssl_country_txt"] = 'Country';
$wb["ssl_key_txt"] = 'SSL Key';
$wb["ssl_request_txt"] = 'SSL Request';
$wb["ssl_cert_txt"] = 'SSL Certificate';
$wb["ssl_bundle_txt"] = 'SSL Bundle';
$wb["ssl_action_txt"] = 'SSL Action';
$wb["ssl_domain_txt"] = 'SSL Domain';
$wb["server_id_txt"] = 'Server';
$wb["domain_txt"] = 'Domain';
$wb['web_folder_error_regex'] = 'Invalid folder entered. Please do not enter a slash.';
$wb["type_txt"] = 'Type';
$wb["parent_domain_id_txt"] = 'Parent Website';
$wb["redirect_type_txt"] = 'Redirect Type';
$wb["redirect_path_txt"] = 'Redirect Path';
$wb["active_txt"] = 'Active';
$wb["document_root_txt"] = 'Documentroot';
$wb["system_user_txt"] = 'Linux User';
$wb["system_group_txt"] = 'Linux Group';
$wb["ip_address_txt"] = 'IPv4-Address';
$wb["ipv6_address_txt"] = 'IPv6-Address';
$wb["vhost_type_txt"] = 'VHost Type';
$wb["hd_quota_txt"] = 'Harddisk Quota';
$wb["traffic_quota_txt"] = 'Traffic Quota';
$wb["cgi_txt"] = 'CGI';
$wb["ssi_txt"] = 'SSI';
$wb["errordocs_txt"] = 'Own Error-Documents';
$wb["subdomain_txt"] = 'Auto-Subdomain';
$wb["ssl_txt"] = 'SSL';
$wb["suexec_txt"] = 'SuEXEC';
$wb["php_txt"] = 'PHP';
$wb["client_txt"] = 'Client';
$wb["limit_web_domain_txt"] = 'The max. number of web domains for your account is reached.';
$wb["limit_web_aliasdomain_txt"] = 'The max. number of aliasdomains for your account is reached.';
$wb["limit_web_subdomain_txt"] = 'The max. number of web subdomains for your account is reached.';
$wb["apache_directives_txt"] = 'Apache Directives';
$wb["domain_error_empty"] = 'Domain is empty.';
$wb["domain_error_unique"] = 'There is already a website or sub / aliasdomain with this domain name.';
$wb["domain_error_regex"] = 'Domain name invalid.';
$wb["hd_quota_error_empty"] = 'Harddisk quota is 0 or empty.';
$wb["traffic_quota_error_empty"] = 'Traffic quota is empty.';
$wb["error_ssl_state_empty"] = 'SSL State is empty.';
$wb["error_ssl_locality_empty"] = 'SSL Locality is empty.';
$wb["error_ssl_organisation_empty"] = 'SSL Organisation is empty.';
$wb["error_ssl_organisation_unit_empty"] = 'SSL Organisation Unit is empty.';
$wb["error_ssl_country_empty"] = 'SSL Country is empty.';
$wb["error_ssl_cert_empty"] = 'SSL Certificate field is empty';
$wb["client_group_id_txt"] = 'Client';
$wb["stats_password_txt"] = 'Webstatistics password';
$wb["allow_override_txt"] = 'Apache AllowOverride';
$wb["limit_web_quota_free_txt"] = 'Max. available Harddisk Quota';
$wb["ssl_state_error_regex"] = 'Invalid SSL State. Valid characters are: a-z, 0-9 and .,-_';
$wb["ssl_locality_error_regex"] = 'Invalid SSL Locality. Valid characters are: a-z, 0-9 and .,-_';
$wb["ssl_organisation_error_regex"] = 'Invalid SSL Organisation. Valid characters are: a-z, 0-9 and .,-_';
$wb["ssl_organistaion_unit_error_regex"] = 'Invalid SSL Organisation Unit. Valid characters are: a-z, 0-9 and .,-_';
$wb["ssl_country_error_regex"] = 'Invalid SSL Country. Valid characters are: A-Z';
$wb["limit_traffic_quota_free_txt"] = 'Max. available Traffic Quota';
$wb["redirect_error_regex"] = 'Invalid redirect path. Valid redirects are for example: /test/ or http://www.domain.tld/test/';
$wb["php_open_basedir_txt"] = 'PHP open_basedir';
$wb["traffic_quota_exceeded_txt"] = 'Traffic quota exceeded';
$wb["ruby_txt"] = 'Ruby';
$wb["stats_user_txt"] = 'Webstatistics username';
$wb["stats_type_txt"] = 'Webstatistics program';
$wb["custom_php_ini_txt"] = 'Custom php.ini settings';
$wb['none_txt'] = 'None';
$wb['disabled_txt'] = 'Disabled';
$wb['no_redirect_txt'] = 'No redirect';
$wb['no_flag_txt'] = 'No flag';
$wb['save_certificate_txt'] = 'Save certificate';
$wb['create_certificate_txt'] = 'Create certificate';
$wb['delete_certificate_txt'] = 'Delete certificate';
$wb["nginx_directives_txt"] = 'nginx Directives';
$wb["seo_redirect_txt"] = 'SEO Redirect';
$wb["non_www_to_www_txt"] = 'Non-www -&gt; www';
$wb["www_to_non_www_txt"] = 'www -&gt; non-www';
$wb["php_fpm_use_socket_txt"] = 'Use Socket For PHP-FPM';
$wb["error_no_sni_txt"] = 'SNI for SSL is not activated on this server. You can enable only one SSL certificate on each IP address.';
$wb["python_txt"] = 'Python';
$wb["perl_txt"] = 'Perl';
$wb["pm_max_children_txt"] = 'PHP-FPM pm.max_children';
$wb["pm_start_servers_txt"] = 'PHP-FPM pm.start_servers';
$wb["pm_min_spare_servers_txt"] = 'PHP-FPM pm.min_spare_servers';
$wb["pm_max_spare_servers_txt"] = 'PHP-FPM pm.max_spare_servers';
$wb["error_php_fpm_pm_settings_txt"] = 'Values of PHP-FPM pm settings must be as follows: pm.max_children &gt;= pm.max_spare_servers &gt;= pm.start_servers &gt;= pm.min_spare_servers &gt; 0';
$wb["pm_max_children_error_regex"] = 'PHP-FPM pm.max_children must be a positive integer value.';
$wb["pm_start_servers_error_regex"] = 'PHP-FPM pm.start_servers must be a positive integer value.';
$wb["pm_min_spare_servers_error_regex"] = 'PHP-FPM pm.min_spare_servers must be a positive integer value.';
$wb["pm_max_spare_servers_error_regex"] = 'PHP-FPM pm.max_spare_servers must be a positive integer value.';
$wb["hd_quota_error_regex"] = 'Harddisk quota is invalid.';
$wb["traffic_quota_error_regex"] = 'Traffic quota is invalid.';
$wb["fastcgi_php_version_txt"] = 'PHP Version';
$wb["pm_txt"] = 'PHP-FPM Process Manager';
$wb["pm_process_idle_timeout_txt"] = 'PHP-FPM pm.process_idle_timeout';
$wb["pm_max_requests_txt"] = 'PHP-FPM pm.max_requests';
$wb["pm_process_idle_timeout_error_regex"] = 'PHP-FPM pm.process_idle_timeout must be a positive integer value.';
$wb["pm_max_requests_error_regex"] = 'PHP-FPM pm.max_requests must be an integer value >= 0.';
$wb["pm_ondemand_hint_txt"] = 'Please note that you must have PHP version >= 5.3.9 in order to use the ondemand process manager. If you select ondemand for an older PHP version, PHP will not start anymore!';
$wb['generate_password_txt'] = 'Generate Password';
$wb['repeat_password_txt'] = 'Repeat Password';
$wb['password_mismatch_txt'] = 'The passwords do not match.';
$wb['password_match_txt'] = 'The passwords do match.';
?>
interface/web/sites/lib/lang/en_web_vhost_subdomain_list.lng
New file
@@ -0,0 +1,8 @@
<?php
$wb["list_head_txt"] = 'Subdomains';
$wb["active_txt"] = 'Active';
$wb["server_id_txt"] = 'Server';
$wb["parent_domain_id_txt"] = 'Website';
$wb["domain_txt"] = 'Subdomain';
$wb["add_new_record_txt"] = 'Add new subdomain';
?>
interface/web/sites/lib/module.conf.php
@@ -21,9 +21,12 @@
if($app->auth->get_client_limit($userid,'web_subdomain') != 0)
{
    // read web config
    $app->uses('getconf');
    $sys_config = $app->getconf->get_global_config('sites');
$items[] = array(   'title'     => "Subdomain",
                    'target'     => 'content',
                    'link'      => 'sites/web_subdomain_list.php',
                    'link'      => 'sites/' . ($sys_config['vhost_subdomains'] == 'y' ? 'web_vhost_subdomain_list.php' : 'web_subdomain_list.php'),
                    'html_id'   => 'subdomain_list');
}
interface/web/sites/list/web_folder.list.php
@@ -79,7 +79,7 @@
                            'prefix'    => "",
                            'suffix'    => "",
                            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => "SELECT domain_id,domain FROM web_domain WHERE type = 'vhost' AND {AUTHSQL} ORDER BY domain",
                                        'querystring' => "SELECT domain_id,domain FROM web_domain WHERE (type = 'vhost' OR type = 'vhostsubdomain') AND {AUTHSQL} ORDER BY domain",
                                        'keyfield'=> 'domain_id',
                                        'valuefield'=> 'domain'
                                     ),
interface/web/sites/list/web_vhost_subdomain.list.php
New file
@@ -0,0 +1,99 @@
<?php
/*
    Datatypes:
    - INTEGER
    - DOUBLE
    - CURRENCY
    - VARCHAR
    - TEXT
    - DATE
*/
// Name of the list
$liste["name"]                 = "web_vhost_subdomain";
// Database table
$liste["table"]             = "web_domain";
// Index index field of the database table
$liste["table_idx"]            = "domain_id";
// Search Field Prefix
$liste["search_prefix"]     = "search_";
// Records per page
$liste["records_per_page"]     = "15";
// Script File of the list
$liste["file"]                = "web_vhost_subdomain_list.php";
// Script file of the edit form
$liste["edit_file"]            = "web_vhost_subdomain_edit.php";
// Script File of the delete script
$liste["delete_file"]        = "web_vhost_subdomain_del.php";
// Paging Template
$liste["paging_tpl"]        = "templates/paging.tpl.htm";
// Enable auth
$liste["auth"]                = "yes";
/*****************************************************
* Suchfelder
*****************************************************/
$liste["item"][] = array(    'field'        => "active",
                            'datatype'    => "VARCHAR",
                            'formtype'    => "SELECT",
                            'op'        => "=",
                            'prefix'    => "",
                            'suffix'    => "",
                            'width'        => "",
                            'value'        => array('y' => "<div id=\"ir-Yes\" class=\"swap\"><span>Yes</span></div>",'n' => "<div class=\"swap\" id=\"ir-No\"><span>No</span></div>"));
$liste["item"][] = array(    'field'        => "server_id",
                            'datatype'    => "VARCHAR",
                            'formtype'    => "SELECT",
                            'op'        => "like",
                            'prefix'    => "%",
                            'suffix'    => "%",
                            'datasource'    => array (     'type'    => 'SQL',
                                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
                                                        'keyfield'=> 'server_id',
                                                        'valuefield'=> 'server_name'
                                                       ),
                            'width'        => "",
                            'value'        => "");
$liste["item"][] = array(    'field'        => "parent_domain_id",
                            'datatype'    => "VARCHAR",
                            'formtype'    => "SELECT",
                            'op'        => "=",
                            'prefix'    => "",
                            'suffix'    => "",
                            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => "SELECT domain_id,domain FROM web_domain WHERE type = 'vhost' AND {AUTHSQL} ORDER BY domain",
                                        'keyfield'=> 'domain_id',
                                        'valuefield'=> 'domain'
                                     ),
                            'width'        => "",
                            'value'        => "");
$liste["item"][] = array(    'field'        => "domain",
                            'datatype'    => "VARCHAR",
                            'formtype'    => "TEXT",
                            'op'        => "like",
                            'prefix'    => "%",
                            'suffix'    => "%",
                            'width'        => "",
                            'value'        => "");
?>
interface/web/sites/templates/web_vhost_subdomain_edit.htm
New file
@@ -0,0 +1,207 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_web_domain">
    <div class="pnl_formsarea">
        <fieldset class="inlineLabels">
            <div class="ctrlHolder">
                <label for="domain">{tmpl_var name='host_txt'}</label>
                <input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput formLengthHalf" />
            </div>
            <div class="ctrlHolder">
                <label for="parent_domain_id">{tmpl_var name='domain_txt'}</label>
                <select id="parent_domain_id" name="parent_domain_id" class="selectInput formLengthHalf">{tmpl_var name='parent_domain_id'}</select>
            </div>
            <div class="ctrlHolder">
                <label for="web_folder">{tmpl_var name='web_folder_txt'}</label>
                <input name="web_folder" id="web_folder" value="{tmpl_var name='web_folder'}" size="30" maxlength="100" type="text" class="textInput formLengthHalf" />
            </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" />&nbsp;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" />&nbsp;MB <tmpl_var name='traffic_quota_exceeded_txt'>
            </div>
            <tmpl_if name="limit_cgi" op="==" value="y"><div class="ctrlHolder">
                <p class="label">{tmpl_var name='cgi_txt'}</p>
                <div class="multiField">
                    {tmpl_var name='cgi'}
                </div>
            </div></tmpl_if>
            <tmpl_if name="limit_ssi" op="==" value="y"><div class="ctrlHolder">
                <p class="label">{tmpl_var name='ssi_txt'}</p>
                <div class="multiField">
                    {tmpl_var name='ssi'}
                </div>
            </div></tmpl_if>
            <tmpl_if name="limit_perl" op="==" value="y"><div class="ctrlHolder apache">
                <p class="label">{tmpl_var name='perl_txt'}</p>
                <div class="multiField">
                    {tmpl_var name='perl'}
                </div>
            </div></tmpl_if>
            <tmpl_if name="limit_ruby" op="==" value="y"><div class="ctrlHolder apache">
                <p class="label">{tmpl_var name='ruby_txt'}</p>
                <div class="multiField">
                    {tmpl_var name='ruby'}
                </div>
            </div></tmpl_if>
            <tmpl_if name="limit_python" op="==" value="y"><div class="ctrlHolder apache">
                <p class="label">{tmpl_var name='python_txt'}</p>
                <div class="multiField">
                    {tmpl_var name='python'}
                </div>
            </div></tmpl_if>
            <tmpl_if name="force_suexec" op="==" value="n"><div class="ctrlHolder apache">
                <p class="label">{tmpl_var name='suexec_txt'}</p>
                <div class="multiField">
                    {tmpl_var name='suexec'}
                </div>
            </div></tmpl_if>
            <tmpl_if name="limit_hterror" op="==" value="y"><div class="ctrlHolder">
                <p class="label">{tmpl_var name='errordocs_txt'}</p>
                <div class="multiField">
                    {tmpl_var name='errordocs'}
                </div>
            </div></tmpl_if>
            <div class="ctrlHolder">
                <label for="subdomain">{tmpl_var name='subdomain_txt'}</label>
                <select name="subdomain" id="subdomain" class="selectInput formLengthHalf">
                    {tmpl_var name='subdomain'}
                </select>
            </div>
            <tmpl_if name="limit_ssl" op="==" value="y"><div class="ctrlHolder">
                <p class="label">{tmpl_var name='ssl_txt'}</p>
                <div class="multiField">
                    {tmpl_var name='ssl'}
                </div>
            </div></tmpl_if>
            <div class="ctrlHolder">
                <label for="php">{tmpl_var name='php_txt'}</label>
                <select name="php" id="php" class="selectInput formLengthHalf">
                    {tmpl_var name='php'}
                </select>
            </div>
            <div class="ctrlHolder fastcgi_php_version">
                <label for="fastcgi_php_version">{tmpl_var name='fastcgi_php_version_txt'}</label>
                <select name="fastcgi_php_version" id="fastcgi_php_version" class="selectInput formLengthHalf">
                    {tmpl_var name='fastcgi_php_version'}
                </select>
            </div>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='active_txt'}</p>
                <div class="multiField">
                    {tmpl_var name='active'}
                </div>
            </div>
        </fieldset>
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
        <div class="buttonHolder buttons">
            <button id="dom-edit-submit" class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}"><span>{tmpl_var name='btn_save_txt'}</span></button>
            <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('sites/web_vhost_subdomain_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
        </div>
    </div>
</div>
<script language="JavaScript" type="text/javascript">
    var serverId;
    var clientGroupId = jQuery('#client_group_id').val();
    var serverIdDisabled = jQuery('#server_id_disabled').val();
    if(serverIdDisabled > 0){
        serverId = serverIdDisabled;
    } else {
        serverId = jQuery('#server_id').val();
        jQuery('#server_id').change(function(){
            serverId = $(this).val();
            adjustForm();
            reloadWebIP();
            reloadFastcgiPHPVersions();
        });
    }
    adjustForm();
    reloadFastcgiPHPVersions();
    jQuery('#client_group_id').change(function(){
        clientGroupId = $(this).val();
        reloadWebIP();
    });
    if(jQuery('#php').val() == 'fast-cgi' || jQuery('#php').val() == 'php-fpm'){
        jQuery('.fastcgi_php_version:hidden').show();
    } else {
        jQuery('.fastcgi_php_version:visible').hide();
    }
    jQuery('#php').change(function(){
        reloadFastcgiPHPVersions();
        if(jQuery(this).val() == 'fast-cgi' || jQuery(this).val() == 'php-fpm'){
            jQuery('.fastcgi_php_version:hidden').show();
        } else {
            jQuery('.fastcgi_php_version:visible').hide();
        }
    });
    function adjustForm(){
        jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getservertype"}, function(data) {
            if(data.servertype == "nginx"){
                var selected = jQuery('#php').val();
                jQuery('.apache').hide();
                jQuery('.apache').hide();
                jQuery('#php option[value="fast-cgi"]').hide();
                jQuery('#php option[value="cgi"]').hide();
                jQuery('#php option[value="mod"]').hide();
                jQuery('#php option[value="suphp"]').hide();
                if(selected != "no" && selected != "php-fpm") jQuery('#php option[value="php-fpm"]').attr('selected', 'selected');
            } else {
                jQuery('.apache').show();
                jQuery('.apache').show();
                jQuery('#php option[value="fast-cgi"]').show();
                jQuery('#php option[value="cgi"]').show();
                jQuery('#php option[value="mod"]').show();
                jQuery('#php option[value="suphp"]').show();
            }
        });
    }
    function reloadWebIP() {
        loadOptionInto('ip_address','sites/ajax_get_ip.php?ip_type=IPv4&server_id='+serverId+'&client_group_id='+clientGroupId);
        loadOptionInto('ipv6_address','sites/ajax_get_ip.php?ip_type=IPv6&server_id='+serverId+'&client_group_id='+clientGroupId);
    }
    function reloadFastcgiPHPVersions() {
        jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, php_type : jQuery('#php').val(), type : "getphpfastcgi"}, function(data) {
            var options = '<option value="">Default</option>';
            var phpfastcgiselected = '';
            $.each(data, function(key, val) {
                if($('#fastcgi_php_version').val() == key){
                    phpfastcgiselected = ' selected="selected"';
                } else {
                    phpfastcgiselected = '';
                }
                options += '<option value="'+key+'"'+phpfastcgiselected+'>'+val+'</option>';
            });
            $('#fastcgi_php_version').html(options);
        });
    }
    <tmpl_if name="readonly_tab">
        jQuery('div.panel_web_domain').find('fieldset').find('input,select,button').attr('disabled', 'disabled');
        jQuery('div.tabbox_tabs').find('a').click(function() {
               jQuery('div.panel_web_domain').find('fieldset').find('input,select,button').removeAttr('disabled');
        });
        jQuery('#dom-edit-submit').click(function() {
               jQuery('div.panel_web_domain').find('fieldset').find('input,select,button').removeAttr('disabled');
               submitForm('pageForm','sites/web_vhost_subdomain_edit.php');
        });
    <tmpl_else>
        jQuery('#dom-edit-submit').click(function() {
            submitForm('pageForm','sites/web_vhost_subdomain_edit.php');
        });
    </tmpl_if>
</script>
interface/web/sites/templates/web_vhost_subdomain_list.htm
New file
@@ -0,0 +1,60 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_list_web_subdomain">
    <div class="pnl_toolsarea">
        <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
            <div class="buttons">
                <button class="iconstxt icoAdd" type="button" onClick="loadContent('sites/web_vhost_subdomain_edit.php');">
                    <span>{tmpl_var name="add_new_record_txt"}</span>
                </button>
            </div>
        </fieldset>
    </div>
    <div class="pnl_listarea">
        <fieldset><legend><tmpl_var name="list_head_txt"></legend>
            <table class="list">
                <thead>
                    <tr>
                        <th class="tbl_col_active" scope="col"><tmpl_var name="active_txt"></th>
                        <th class="tbl_col_server_id" scope="col"><tmpl_var name="server_id_txt"></th>
                        <th class="tbl_col_parent_domain_id" scope="col"><tmpl_var name="parent_domain_id_txt"></th>
                        <th class="tbl_col_domain" scope="col"><tmpl_var name="domain_txt"></th>
                        <th class="tbl_col_limit" scope="col">{tmpl_var name='search_limit'}</th>
                    </tr>
                    <tr>
                        <td class="tbl_col_active"><select name="search_active">{tmpl_var name='search_active'}</select></td>
                        <td class="tbl_col_server_id"><select name="search_server_id">{tmpl_var name='search_server_id'}</select></td>
                        <td class="tbl_col_parent_domain_id"><select name="search_parent_domain_id">{tmpl_var name='search_parent_domain_id'}</select></td>
                        <td class="tbl_col_domain"><input type="text" name="search_domain" value="{tmpl_var name='search_domain'}" /></td>
                        <td class="tbl_col_buttons"><div class="buttons"><button type="button" class="icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onClick="submitForm('pageForm','sites/web_vhost_subdomain_list.php');"><span>{tmpl_var name="filter_txt"}</span></button></div></td>
                    </tr>
                </thead>
                <tbody>
                    <tmpl_loop name="records">
                        <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
                            <td class="tbl_col_active"><a href="#" onClick="loadContent('sites/web_vhost_subdomain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="active"}</a></td>
                            <td class="tbl_col_server_id"><a href="#" onClick="loadContent('sites/web_vhost_subdomain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="server_id"}</a></td>
                            <td class="tbl_col_parent_domain_id"><a href="#" onClick="loadContent('sites/web_vhost_subdomain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="parent_domain_id"}</a></td>
                            <td class="tbl_col_domain"><a href="#" onClick="loadContent('sites/web_vhost_subdomain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="domain"}</a></td>
                            <td class="tbl_col_buttons">
                                <div class="buttons icons16">
                                    <a class="icons16 icoDelete" href="javascript: del_record('sites/web_vhost_subdomain_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span>{tmpl_var name='delete_txt'}</span></a>
                                </div>
                            </td>
                        </tr>
                    </tmpl_loop>
                </tbody>
                <tfoot>
                    <tr>
                    <td class="tbl_footer tbl_paging" colspan="5"><tmpl_var name="paging"></td>
                    </tr>
                </tfoot>
            </table>
        </fieldset>
    </div>
</div>
interface/web/sites/web_domain_edit.php
@@ -768,7 +768,7 @@
        //* If the domain name has been changed, we will have to change all subdomains
        if(!empty($this->dataRecord["domain"]) && !empty($this->oldDataRecord["domain"]) && $this->dataRecord["domain"] != $this->oldDataRecord["domain"]) {
            $records = $app->db->queryAllRecords("SELECT domain_id,domain FROM web_domain WHERE type = 'subdomain' AND domain LIKE '%.".$app->db->quote($this->oldDataRecord["domain"])."'");
            $records = $app->db->queryAllRecords("SELECT domain_id,domain FROM web_domain WHERE (type = 'subdomain' OR type = 'vhostsubdomain') AND domain LIKE '%.".$app->db->quote($this->oldDataRecord["domain"])."'");
            foreach($records as $rec) {
                $subdomain = $app->db->quote(str_replace($this->oldDataRecord["domain"],$this->dataRecord["domain"],$rec['domain']));
                $app->db->datalogUpdate('web_domain', "domain = '".$subdomain."'", 'domain_id', $rec['domain_id']);
interface/web/sites/web_domain_list.php
@@ -52,7 +52,7 @@
}
$list = new list_action;
$list->SQLExtWhere = "type = 'vhost'";
$list->SQLExtWhere = "type = 'vhost' AND parent_domain_id = '0'";
$list->SQLOrderBy = 'ORDER BY domain';
$list->onLoad();
interface/web/sites/web_subdomain_edit.php
@@ -57,10 +57,10 @@
        
        // we will check only users, not admins
        if($_SESSION["s"]["user"]["typ"] == 'user') {
            if(!$app->tform->checkClientLimit('limit_web_subdomain',"type = 'subdomain'")) {
            if(!$app->tform->checkClientLimit('limit_web_subdomain',"(type = 'subdomain' OR type = 'vhostsubdomain')")) {
                $app->error($app->tform->wordbook["limit_web_subdomain_txt"]);
            }
            if(!$app->tform->checkResellerLimit('limit_web_subdomain',"type = 'subdomain'")) {
            if(!$app->tform->checkResellerLimit('limit_web_subdomain',"(type = 'subdomain' OR type = 'vhostsubdomain')")) {
                $app->error('Reseller: '.$app->tform->wordbook["limit_web_subdomain_txt"]);
            }
        }
interface/web/sites/web_vhost_subdomain_del.php
New file
@@ -0,0 +1,72 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/web_vhost_subdomain.list.php";
$tform_def_file = "form/web_vhost_subdomain.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('sites');
$app->uses('tpl,tform,tform_actions');
$app->load("tform_actions");
class page_action extends tform_actions {
    function onBeforeDelete() {
        global $app; $conf;
        //* Delete all web folders
        $records = $app->db->queryAllRecords("SELECT web_folder_id FROM web_folder WHERE parent_domain_id = '".intval($this->id)."'");
        foreach($records as $rec) {
            //* Delete all web folder users
            $records2 = $app->db->queryAllRecords("SELECT web_folder_user_id FROM web_folder_user WHERE web_folder_id = '".$rec['web_folder_id']."'");
            foreach($records2 as $rec2) {
                $app->db->datalogDelete('web_folder_user','web_folder_user_id',$rec2['web_folder_user_id']);
        }
            $app->db->datalogDelete('web_folder','web_folder_id',$rec['web_folder_id']);
        }
    }
}
$page = new page_action;
$page->onDelete();
?>
interface/web/sites/web_vhost_subdomain_edit.php
New file
@@ -0,0 +1,456 @@
<?php
/*
Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************
* Begin Form configuration
******************************************/
$tform_def_file = "form/web_vhost_subdomain.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('sites');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
    //* Returna a "3/2/1" path hash from a numeric id '123'
    function id_hash($id,$levels) {
        $hash = "" . $id % 10 ;
        $id /= 10 ;
        $levels -- ;
        while ( $levels > 0 ) {
            $hash .= "/" . $id % 10 ;
            $id /= 10 ;
            $levels-- ;
        }
        return $hash;
    }
    function onShowNew() {
        global $app, $conf;
        // we will check only users, not admins
        if($_SESSION["s"]["user"]["typ"] == 'user') {
            if(!$app->tform->checkClientLimit('limit_web_subdomain',"(type = 'subdomain' OR type = 'vhostsubdomain')")) {
                $app->error($app->tform->wordbook["limit_web_subdomain_txt"]);
            }
            if(!$app->tform->checkResellerLimit('limit_web_subdomain',"(type = 'subdomain' OR type = 'vhostsubdomain')")) {
                $app->error('Reseller: '.$app->tform->wordbook["limit_web_subdomain_txt"]);
            }
        }
        parent::onShowNew();
    }
    function onShowEnd() {
        global $app, $conf;
        $app->uses('ini_parser,getconf');
        $read_limits = array('limit_cgi', 'limit_ssi', 'limit_perl', 'limit_ruby', 'limit_python', 'force_suexec', 'limit_hterror', 'limit_wildcard', 'limit_ssl');
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".intval(@$this->dataRecord["parent_domain_id"]));
        //* Client: If the logged in user is not admin and has no sub clients (no reseller)
        if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
            // Get the limits of the client
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT client.limit_web_domain, client.default_webserver, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
            //* Get global web config
            $web_config = $app->getconf->get_server_config($parent_domain['server_id'], 'web');
            //PHP Version Selection (FastCGI)
            $server_type = 'apache';
            if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
            if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
            if($this->dataRecord['php'] == 'php-fpm'){
                $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$parent_domain['server_id']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")");
            }
            if($this->dataRecord['php'] == 'fast-cgi'){
                $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$parent_domain['server_id']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")");
            }
            $php_select = "<option value=''>Default</option>";
            if(is_array($php_records) && !empty($php_records)) {
                foreach( $php_records as $php_record) {
                    if($this->dataRecord['php'] == 'php-fpm'){
                        $php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
                    } else {
                        $php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
                    }
                    $selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':'';
                    $php_select .= "<option value='$php_version' $selected>".$php_record['name']."</option>\r\n";
                }
            }
            $app->tpl->setVar("fastcgi_php_version",$php_select);
            unset($php_records);
            // add limits to template to be able to hide settings
            foreach($read_limits as $limit) $app->tpl->setVar($limit, $client[$limit]);
            //* Reseller: If the logged in user is not admin and has sub clients (is a reseller)
        } elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
            // Get the limits of the client
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_domain, client.default_webserver, client.contact_name, CONCAT(client.company_name,' :: ',client.contact_name) as contactname, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
            //* Get global web config
            $web_config = $app->getconf->get_server_config($parent_domain['server_id'], 'web');
            //PHP Version Selection (FastCGI)
            $server_type = 'apache';
            if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
            if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
            if($this->dataRecord['php'] == 'php-fpm'){
                $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$parent_domain['server_id']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")");
            }
            if($this->dataRecord['php'] == 'fast-cgi') {
                $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$parent_domain['server_id']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")");
            }
            $php_select = "<option value=''>Default</option>";
            if(is_array($php_records) && !empty($php_records)) {
                foreach( $php_records as $php_record) {
                    if($this->dataRecord['php'] == 'php-fpm'){
                        $php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
                    } else {
                        $php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
                    }
                    $selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':'';
                    $php_select .= "<option value='$php_version' $selected>".$php_record['name']."</option>\r\n";
                }
            }
            $app->tpl->setVar("fastcgi_php_version",$php_select);
            unset($php_records);
            // add limits to template to be able to hide settings
            foreach($read_limits as $limit) $app->tpl->setVar($limit, $client[$limit]);
            //* Admin: If the logged in user is admin
        } else {
            //* get global web config
            $web_config = $app->getconf->get_server_config($parent_domain['server_id'], 'web');
            //PHP Version Selection (FastCGI)
            $server_type = 'apache';
            if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
            if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
            if($this->dataRecord['php'] == 'php-fpm'){
                $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = " . $parent_domain['server_id']);
            }
            if($this->dataRecord['php'] == 'fast-cgi') {
                $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = " . $parent_domain['server_id']);
            }
            $php_select = "<option value=''>Default</option>";
            if(is_array($php_records) && !empty($php_records)) {
                foreach( $php_records as $php_record) {
                    if($this->dataRecord['php'] == 'php-fpm'){
                        $php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
                    } else {
                        $php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
                    }
                    $selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':'';
                    $php_select .= "<option value='$php_version' $selected>".$php_record['name']."</option>\r\n";
                }
            }
            $app->tpl->setVar("fastcgi_php_version",$php_select);
            unset($php_records);
            foreach($read_limits as $limit) $app->tpl->setVar($limit, 'y');
        }
        $ssl_domain_select = '';
        $tmp = $app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = ".$this->id);
        $ssl_domains = array($tmp["domain"],'www.'.$tmp["domain"]);
        if(is_array($ssl_domains)) {
            foreach( $ssl_domains as $ssl_domain) {
                $selected = ($ssl_domain == $this->dataRecord['ssl_domain'])?'SELECTED':'';
                $ssl_domain_select .= "<option value='$ssl_domain' $selected>$ssl_domain</option>\r\n";
            }
        }
        if($this->id > 0) $app->tpl->setVar('fixed_folder', 'y');
        else $app->tpl->setVar('fixed_folder', 'n');
        $app->tpl->setVar("ssl_domain",$ssl_domain_select);
        unset($ssl_domain_select);
        unset($ssl_domains);
        unset($ssl_domain);
        $tmp_txt = ($this->dataRecord['traffic_quota_lock'] == 'y')?'<b>('.$app->tform->lng('traffic_quota_exceeded_txt').')</b>':'';
        $app->tpl->setVar("traffic_quota_exceeded_txt", $tmp_txt);
        // remove the parent domain part of the domain name before we show it in the text field.
        $this->dataRecord["domain"] = str_replace('.'.$parent_domain["domain"],'',$this->dataRecord["domain"]);
        $app->tpl->setVar("domain",$this->dataRecord["domain"]);
        parent::onShowEnd();
    }
    function onSubmit() {
        global $app, $conf;
        // Get the record of the parent domain
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".intval(@$this->dataRecord["parent_domain_id"]));
        // Set a few fixed values
        $this->dataRecord["type"] = 'vhostsubdomain';
        $this->dataRecord["server_id"] = $parent_domain["server_id"];
        $this->dataRecord["ip_address"] = $parent_domain["ip_address"];
        $this->dataRecord["ipv6_address"] = $parent_domain["ipv6_address"];
        $this->dataRecord["client_group_id"] = $parent_domain["client_group_id"];
        $this->dataRecord["vhost_type"] = 'name';
        $this->dataRecord["domain"] = $this->dataRecord["domain"].'.'.$parent_domain["domain"];
        $this->parent_domain_record = $parent_domain;
        $read_limits = array('limit_cgi', 'limit_ssi', 'limit_perl', 'limit_ruby', 'limit_python', 'force_suexec', 'limit_hterror', 'limit_wildcard', 'limit_ssl');
        if($_SESSION["s"]["user"]["typ"] != 'admin') {
            // Get the limits of the client
            $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, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
            if($client['limit_cgi'] != 'y') $this->dataRecord['cgi'] = '-';
            if($client['limit_ssi'] != 'y') $this->dataRecord['ssi'] = '-';
            if($client['limit_perl'] != 'y') $this->dataRecord['perl'] = '-';
            if($client['limit_ruby'] != 'y') $this->dataRecord['ruby'] = '-';
            if($client['limit_python'] != 'y') $this->dataRecord['python'] = '-';
            if($client['force_suexec'] != 'n') $this->dataRecord['suexec'] = '-';
            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 != ".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 < 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) {
                $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 < 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>";
                    // Set the quota field to the max free space
                    $this->dataRecord["traffic_quota"] = $max_free_quota;
                }
                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<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) {
                    $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<br>";
                        // 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) {
                // restore the server ID if the user is not admin and record is edited
                $tmp = $app->db->queryOneRecord("SELECT server_id, `web_folder`, `cgi`, `ssi`, `perl`, `ruby`, `python`, `suexec`, `errordocs`, `subdomain`, `ssl` FROM web_domain WHERE domain_id = ".intval($this->id));
                $this->dataRecord['web_folder'] = $tmp['web_folder']; // cannot be changed!
                // set the settings to current if not provided (or cleared due to limits)
                if($this->dataRecord['cgi'] == '-') $this->dataRecord['cgi'] = $tmp['cgi'];
                if($this->dataRecord['ssi'] == '-') $this->dataRecord['ssi'] = $tmp['ssi'];
                if($this->dataRecord['perl'] == '-') $this->dataRecord['perl'] = $tmp['perl'];
                if($this->dataRecord['ruby'] == '-') $this->dataRecord['ruby'] = $tmp['ruby'];
                if($this->dataRecord['python'] == '-') $this->dataRecord['python'] = $tmp['python'];
                if($this->dataRecord['suexec'] == '-') $this->dataRecord['suexec'] = $tmp['suexec'];
                if($this->dataRecord['errordocs'] == '-') $this->dataRecord['errordocs'] = $tmp['errordocs'];
                if($this->dataRecord['subdomain'] == '-') $this->dataRecord['subdomain'] = $tmp['subdomain'];
                if($this->dataRecord['ssl'] == '-') $this->dataRecord['ssl'] = $tmp['ssl'];
                unset($tmp);
                // When the record is inserted
            } else {
                // Check if the user may add another web_domain
                if($client["limit_web_subdomain"] >= 0) {
                    $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and (type = 'subdomain' OR type = 'vhostsubdomain')");
                    if($tmp["number"] >= $client["limit_web_subdomain"]) {
                        $app->error($app->tform->wordbook["limit_web_subdomain_txt"]);
                    }
                }
            }
        }
        //* make sure that the domain is lowercase
        if(isset($this->dataRecord["domain"])) $this->dataRecord["domain"] = strtolower($this->dataRecord["domain"]);
        //* get the server config for this server
        $app->uses("getconf");
        $web_config = $app->getconf->get_server_config(intval(isset($this->dataRecord["server_id"]) ? $this->dataRecord["server_id"] : 0),'web');
        //* Check for duplicate ssl certs per IP if SNI is disabled
        if(isset($this->dataRecord['ssl']) && $this->dataRecord['ssl'] == 'y' && $web_config['enable_sni'] != 'y') {
            $sql = "SELECT count(domain_id) as number FROM web_domain WHERE `ssl` = 'y' AND ip_address = '".$app->db->quote($this->dataRecord['ip_address'])."' and domain_id != ".$this->id;
            $tmp = $app->db->queryOneRecord($sql);
            if($tmp['number'] > 0) $app->tform->errorMessage .= $app->tform->lng("error_no_sni_txt");
        }
        // Check if pm.max_children >= pm.max_spare_servers >= pm.start_servers >= pm.min_spare_servers > 0
        if(isset($this->dataRecord['pm_max_children']) && $this->dataRecord['pm'] == 'dynamic') {
            if(intval($this->dataRecord['pm_max_children']) >= intval($this->dataRecord['pm_max_spare_servers']) && intval($this->dataRecord['pm_max_spare_servers']) >= intval($this->dataRecord['pm_start_servers']) && intval($this->dataRecord['pm_start_servers']) >= intval($this->dataRecord['pm_min_spare_servers']) && intval($this->dataRecord['pm_min_spare_servers']) > 0){
            } else {
                $app->tform->errorMessage .= $app->tform->lng("error_php_fpm_pm_settings_txt").'<br>';
            }
        }
        parent::onSubmit();
    }
    function onAfterInsert() {
        global $app, $conf;
        // Get configuration for the web system
        $app->uses("getconf");
        $web_rec = $app->tform->getDataRecord($this->id);
        $web_config = $app->getconf->get_server_config(intval($web_rec["server_id"]),'web');
        var_dump($this->parent_domain_record, $web_rec);
        // Set the values for document_root, system_user and system_group
        $system_user = $app->db->quote($this->parent_domain_record['system_user']);
        $system_group = $app->db->quote($this->parent_domain_record['system_group']);
        $document_root = $app->db->quote($this->parent_domain_record['document_root']);
        $php_open_basedir = str_replace("[website_path]/web",$document_root.'/'.$web_rec['web_folder'],$web_config["php_open_basedir"]);
        $php_open_basedir = str_replace("[website_domain]/web",$web_rec['domain'].'/'.$web_rec['web_folder'],$php_open_basedir);
        $php_open_basedir = str_replace("[website_path]",$document_root,$php_open_basedir);
        $php_open_basedir = $app->db->quote(str_replace("[website_domain]",$web_rec['domain'],$php_open_basedir));
        $htaccess_allow_override = $app->db->quote($this->parent_domain_record['allow_override']);
        $sql = "UPDATE web_domain SET sys_groupid = ".intval($this->parent_domain_record['sys_groupid']).",system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir'  WHERE domain_id = ".$this->id;
        $app->db->query($sql);
    }
    function onBeforeUpdate () {
        global $app, $conf;
        //* Check that all fields for the SSL cert creation are filled
        if(isset($this->dataRecord['ssl_action']) && $this->dataRecord['ssl_action'] == 'create') {
            if($this->dataRecord['ssl_state'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_state_empty').'<br />';
            if($this->dataRecord['ssl_locality'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_locality_empty').'<br />';
            if($this->dataRecord['ssl_organisation'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_organisation_empty').'<br />';
            if($this->dataRecord['ssl_organisation_unit'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_organisation_unit_empty').'<br />';
            if($this->dataRecord['ssl_country'] == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_country_empty').'<br />';
        }
        if(isset($this->dataRecord['ssl_action']) && $this->dataRecord['ssl_action'] == 'save') {
            if(trim($this->dataRecord['ssl_cert']) == '') $app->tform->errorMessage .= $app->tform->lng('error_ssl_cert_empty').'<br />';
        }
    }
    function onAfterUpdate() {
        global $app, $conf;
        // Get configuration for the web system
        $app->uses("getconf");
        $web_rec = $app->tform->getDataRecord($this->id);
        $web_config = $app->getconf->get_server_config(intval($web_rec["server_id"]),'web');
        // Set the values for document_root, system_user and system_group
        $system_user = $app->db->quote($this->parent_domain_record['system_user']);
        $system_group = $app->db->quote($this->parent_domain_record['system_group']);
        $document_root = $app->db->quote($this->parent_domain_record['document_root']);
        $php_open_basedir = str_replace("[website_path]/web",$document_root.'/'.$web_rec['web_folder'],$web_config["php_open_basedir"]);
        $php_open_basedir = str_replace("[website_domain]/web",$web_rec['domain'].'/'.$web_rec['web_folder'],$php_open_basedir);
        $php_open_basedir = str_replace("[website_path]",$document_root,$php_open_basedir);
        $php_open_basedir = $app->db->quote(str_replace("[website_domain]",$web_rec['domain'],$php_open_basedir));
        $htaccess_allow_override = $app->db->quote($this->parent_domain_record['allow_override']);
        $sql = "UPDATE web_domain SET sys_groupid = ".intval($this->parent_domain_record['sys_groupid']).",system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir'  WHERE domain_id = ".$this->id;
        $app->db->query($sql);
    }
}
$page = new page_action;
$page->onLoad();
?>
interface/web/sites/web_vhost_subdomain_list.php
New file
@@ -0,0 +1,55 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/web_vhost_subdomain.list.php";
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app->auth->check_module_permissions('sites');
$app->uses('listform_actions');
// Limit the results to alias domains
$app->listform_actions->SQLExtWhere = "type = 'vhostsubdomain'";
$app->listform_actions->SQLOrderBy = 'ORDER BY domain';
$app->listform_actions->onLoad();
?>
server/conf/vhost.conf.master
@@ -114,11 +114,13 @@
            PerlModule ModPerl::Registry
            PerlModule Apache2::Reload
            <Directory {tmpl_var name='web_document_root_www'}>
                SetHandler perl-script
                PerlResponseHandler ModPerl::Registry
                PerlOptions +ParseHeaders
                Options +ExecCGI
            </Directory>
            <Files *.pl>
                SetHandler perl-script
            </Files>
        </IfModule>
</tmpl_if>
server/plugins-available/apache2_plugin.inc.php
@@ -103,7 +103,7 @@
            $app->log("CA path error, file does not exist:".$web_config['CA_path'].'/openssl.conf',LOGLEVEL_ERROR);    
        
        //* Only vhosts can have a ssl cert
        if($data["new"]["type"] != "vhost") return;
        if($data["new"]["type"] != "vhost" && $data["new"]["type"] != "vhostsubdomain") return;
        // if(!is_dir($data['new']['document_root'].'/ssl')) exec('mkdir -p '.$data['new']['document_root'].'/ssl');
        if(!is_dir($data['new']['document_root'].'/ssl')) $app->system->mkdirpath($data['new']['document_root'].'/ssl');
@@ -279,7 +279,7 @@
        if($this->action != 'insert') $this->action = 'update';
        if($data['new']['type'] != 'vhost' && $data['new']['parent_domain_id'] > 0) {
        if($data['new']['type'] != 'vhost' && $data['new']['type'] != 'vhostsubdomain' && $data['new']['parent_domain_id'] > 0) {
            $old_parent_domain_id = intval($data['old']['parent_domain_id']);
            $new_parent_domain_id = intval($data['new']['parent_domain_id']);
@@ -325,6 +325,13 @@
            return 0;
        }
        
        $web_folder = 'web';
        $log_folder = 'log';
        if($data['new']['type'] == 'vhostsubdomain') {
            $web_folder = $data['new']['web_folder'];
            $log_folder .= '_web' . $data['new']['domain_id'];
        }
        // Create group and user, if not exist
        $app->uses('system');
        
@@ -437,9 +444,9 @@
        // Check if the directories are there and create them if necessary.
        $app->system->web_folder_protection($data['new']['document_root'],false);
        
        if(!is_dir($data['new']['document_root'].'/web')) $app->system->mkdirpath($data['new']['document_root'].'/web');
        if(!is_dir($data['new']['document_root'].'/web/error') and $data['new']['errordocs']) $app->system->mkdirpath($data['new']['document_root'].'/web/error');
        //if(!is_dir($data['new']['document_root'].'/log')) exec('mkdir -p '.$data['new']['document_root'].'/log');
        if(!is_dir($data['new']['document_root'].'/' . $web_folder)) $app->system->mkdirpath($data['new']['document_root'].'/' . $web_folder);
        if(!is_dir($data['new']['document_root'].'/' . $web_folder . '/error') and $data['new']['errordocs']) $app->system->mkdirpath($data['new']['document_root'].'/' . $web_folder . '/error');
        //if(!is_dir($data['new']['document_root'].'/'.$log_folder)) exec('mkdir -p '.$data['new']['document_root'].'/'.$log_folder);
        if(!is_dir($data['new']['document_root'].'/ssl')) $app->system->mkdirpath($data['new']['document_root'].'/ssl');
        if(!is_dir($data['new']['document_root'].'/cgi-bin')) $app->system->mkdirpath($data['new']['document_root'].'/cgi-bin');
        if(!is_dir($data['new']['document_root'].'/tmp')) $app->system->mkdirpath($data['new']['document_root'].'/tmp');
@@ -457,19 +464,20 @@
        // Remove the symlink for the site, if site is renamed
        if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) {
            if(is_dir('/var/log/ispconfig/httpd/'.$data['old']['domain'])) exec('rm -rf /var/log/ispconfig/httpd/'.$data['old']['domain']);
            if(is_link($data['old']['document_root'].'/log')) $app->system->unlink($data['old']['document_root'].'/log');
            if(is_link($data['old']['document_root'].'/'.$log_folder)) $app->system->unlink($data['old']['document_root'].'/'.$log_folder);
        }
        
        //* Create the log dir if nescessary and mount it
        if(!is_dir($data['new']['document_root'].'/log') || is_link($data['new']['document_root'].'/log')) {
            if(is_link($data['new']['document_root'].'/log')) unlink($data['new']['document_root'].'/log');
            $app->system->mkdir($data['new']['document_root'].'/log');
            $app->system->chown($data['new']['document_root'].'/log','root');
            $app->system->chgrp($data['new']['document_root'].'/log','root');
            $app->system->chmod($data['new']['document_root'].'/log',0755);
            exec('mount --bind '.escapeshellarg('/var/log/ispconfig/httpd/'.$data['new']['domain']).' '.escapeshellarg($data['new']['document_root'].'/log'));
        if(!is_dir('/var/log/ispconfig/httpd/'.$data['new']['domain'])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data['new']['domain']);
        if(!is_dir($data['new']['document_root'].'/'.$log_folder) || is_link($data['new']['document_root'].'/'.$log_folder)) {
            if(is_link($data['new']['document_root'].'/'.$log_folder)) unlink($data['new']['document_root'].'/'.$log_folder);
            $app->system->mkdir($data['new']['document_root'].'/'.$log_folder);
            $app->system->chown($data['new']['document_root'].'/'.$log_folder,'root');
            $app->system->chgrp($data['new']['document_root'].'/'.$log_folder,'root');
            $app->system->chmod($data['new']['document_root'].'/'.$log_folder,0755);
            exec('mount --bind '.escapeshellarg('/var/log/ispconfig/httpd/'.$data['new']['domain']).' '.escapeshellarg($data['new']['document_root'].'/'.$log_folder));
            //* add mountpoint to fstab
            $fstab_line = '/var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/log    none    bind    0 0';
            $fstab_line = '/var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/'.$log_folder.'    none    bind    0 0';
            $app->system->replaceLine('/etc/fstab',$fstab_line,$fstab_line,1,1);
        }
        
@@ -532,11 +540,11 @@
        // setting a local var here
           
        // normally $conf['templates'] = "/usr/local/ispconfig/server/conf";
        if($this->action == 'insert' && $data['new']['type'] == 'vhost') {
            // Copy the error pages
        if($this->action == 'insert' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain')) {
            // Copy the error pages
            if($data['new']['errordocs']) {
                $error_page_path = escapeshellcmd($data['new']['document_root']).'/web/error/';
                $error_page_path = escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/error/';
                if (file_exists($conf['rootpath'] . '/conf-custom/error/'.substr(escapeshellcmd($conf['language']),0,2))) {
                    exec('cp ' . $conf['rootpath'] . '/conf-custom/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path);
                }
@@ -552,35 +560,35 @@
            }
            if (file_exists($conf['rootpath'] . '/conf-custom/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2))) {
                exec('cp ' . $conf['rootpath'] . '/conf-custom/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2).' '.escapeshellcmd($data['new']['document_root']).'/web/index.html');
                exec('cp ' . $conf['rootpath'] . '/conf-custom/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2).' '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/index.html');
            
            if(is_file($conf['rootpath'] . '/conf-custom/index/favicon.ico')) {
                exec('cp ' . $conf['rootpath'] . '/conf-custom/index/favicon.ico '.escapeshellcmd($data['new']['document_root']).'/web/');
                exec('cp ' . $conf['rootpath'] . '/conf-custom/index/favicon.ico '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
            }
            if(is_file($conf['rootpath'] . '/conf-custom/index/robots.txt')) {
                exec('cp ' . $conf['rootpath'] . '/conf-custom/index/robots.txt '.escapeshellcmd($data['new']['document_root']).'/web/');
                exec('cp ' . $conf['rootpath'] . '/conf-custom/index/robots.txt '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
                }
                if(is_file($conf['rootpath'] . '/conf-custom/index/.htaccess')) {
                    exec('cp ' . $conf['rootpath'] . '/conf-custom/index/.htaccess '.escapeshellcmd($data['new']['document_root']).'/web/');
                    exec('cp ' . $conf['rootpath'] . '/conf-custom/index/.htaccess '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
                }
            }
            else {
                if (file_exists($conf['rootpath'] . '/conf-custom/index/standard_index.html')) {
                    exec('cp ' . $conf['rootpath'] . '/conf-custom/index/standard_index.html '.escapeshellcmd($data['new']['document_root']).'/web/index.html');
                    exec('cp ' . $conf['rootpath'] . '/conf-custom/index/standard_index.html '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/index.html');
                }
                else {
                    exec('cp ' . $conf['rootpath'] . '/conf/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2).' '.escapeshellcmd($data['new']['document_root']).'/web/index.html');
                    if(is_file($conf['rootpath'] . '/conf/index/favicon.ico')) exec('cp ' . $conf['rootpath'] . '/conf/index/favicon.ico '.escapeshellcmd($data['new']['document_root']).'/web/');
                    if(is_file($conf['rootpath'] . '/conf/index/robots.txt')) exec('cp ' . $conf['rootpath'] . '/conf/index/robots.txt '.escapeshellcmd($data['new']['document_root']).'/web/');
                    if(is_file($conf['rootpath'] . '/conf/index/.htaccess')) exec('cp ' . $conf['rootpath'] . '/conf/index/.htaccess '.escapeshellcmd($data['new']['document_root']).'/web/');
                    exec('cp ' . $conf['rootpath'] . '/conf/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2).' '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/index.html');
                    if(is_file($conf['rootpath'] . '/conf/index/favicon.ico')) exec('cp ' . $conf['rootpath'] . '/conf/index/favicon.ico '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
                    if(is_file($conf['rootpath'] . '/conf/index/robots.txt')) exec('cp ' . $conf['rootpath'] . '/conf/index/robots.txt '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
                    if(is_file($conf['rootpath'] . '/conf/index/.htaccess')) exec('cp ' . $conf['rootpath'] . '/conf/index/.htaccess '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
                }
            }
            exec('chmod -R a+r '.escapeshellcmd($data['new']['document_root']).'/web/');
            exec('chmod -R a+r '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
            //** Copy the error documents on update when the error document checkbox has been activated and was deactivated before
        } elseif ($this->action == 'update' && $data['new']['type'] == 'vhost' && $data['old']['errordocs'] == 0 && $data['new']['errordocs'] == 1) {
            $error_page_path = escapeshellcmd($data['new']['document_root']).'/web/error/';
        } elseif ($this->action == 'update' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain') && $data['old']['errordocs'] == 0 && $data['new']['errordocs'] == 1) {
            $error_page_path = escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/error/';
            if (file_exists($conf['rootpath'] . '/conf-custom/error/'.substr(escapeshellcmd($conf['language']),0,2))) {
                exec('cp ' . $conf['rootpath'] . '/conf-custom/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path);
            }
@@ -610,12 +618,12 @@
        if($this->action == 'insert' || $data["new"]["system_user"] != $data["old"]["system_user"]) {
            // Chown and chmod the directories below the document root
            $this->_exec('chown -R '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root']).'/web');
            $this->_exec('chown -R '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder);
            // The document root itself has to be owned by root in normal level and by the web owner in security level 20
            if($web_config['security_level'] == 20) {
                $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root']).'/web');
                $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder);
            } else {
                $this->_exec('chown root:root '.escapeshellcmd($data['new']['document_root']).'/web');
                $this->_exec('chown root:root '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder);
            }
        }
@@ -639,8 +647,8 @@
                $app->system->chmod($data['new']['document_root'].'/tmp',0777);
            
                // Set Log directory to 755 to make the logs accessible by the FTP user
                if(realpath($data['new']['document_root'].'/log') == '/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log') {
                    $app->system->chmod($data['new']['document_root'].'/log',0755);
                if(realpath($data['new']['document_root'].'/'.$log_folder) == '/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log') {
                    $app->system->chmod($data['new']['document_root'].'/'.$log_folder,0755);
                }
                
                if($web_config['add_web_users_to_sshusers_group'] == 'y') {
@@ -670,9 +678,9 @@
                $app->system->chgrp($data['new']['document_root'],'root');
                $app->system->chown($data['new']['document_root'].'/cgi-bin',$username);
                $app->system->chgrp($data['new']['document_root'].'/cgi-bin',$groupname);
                if(realpath($data['new']['document_root'].'/log') == '/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log') {
                    $app->system->chown($data['new']['document_root'].'/log','root',false);
                    $app->system->chgrp($data['new']['document_root'].'/log',$groupname,false);
                if(realpath($data['new']['document_root'].'/'.$log_folder) == '/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log') {
                    $app->system->chown($data['new']['document_root'].'/'.$log_folder,'root',false);
                    $app->system->chgrp($data['new']['document_root'].'/'.$log_folder,$groupname,false);
                }
                $app->system->chown($data['new']['document_root'].'/ssl','root');
                $app->system->chgrp($data['new']['document_root'].'/ssl','root');
@@ -697,22 +705,25 @@
                $app->system->chmod($data['new']['document_root'].'/webdav',0755);
                $app->system->chmod($data['new']['document_root'].'/ssl',0755);
                $app->system->chmod($data['new']['document_root'].'/cgi-bin',0755);
                if(realpath($data['new']['document_root'].'/log') == '/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log') {
                    $app->system->chmod($data['new']['document_root'].'/log',0755);
                }
                
                // make temp directory writable for Apache and the website users
                $app->system->chmod($data['new']['document_root'].'/tmp',0777);
                
                // Set Log directory to 755 to make the logs accessible by the FTP user
                if(realpath($data['new']['document_root'].'/'.$log_folder) == '/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log') {
                    $app->system->chmod($data['new']['document_root'].'/'.$log_folder,0755);
                }
                $app->system->chown($data['new']['document_root'],'root');
                $app->system->chgrp($data['new']['document_root'],'root');
                $app->system->chown($data['new']['document_root'].'/cgi-bin',$username);
                $app->system->chgrp($data['new']['document_root'].'/cgi-bin',$groupname);
                if(realpath($data['new']['document_root'].'/log') == '/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log') {
                    $app->system->chown($data['new']['document_root'].'/log','root',false);
                    $app->system->chgrp($data['new']['document_root'].'/log','root',false);
                if(realpath($data['new']['document_root'].'/'.$log_folder) == '/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log') {
                    $app->system->chown($data['new']['document_root'].'/'.$log_folder,'root',false);
                    $app->system->chgrp($data['new']['document_root'].'/'.$log_folder,$groupname,false);
                }
                $app->system->chown($data['new']['document_root'].'/ssl','root');
                $app->system->chown($data['new']['document_root'].'/ssl','root');
                $app->system->chgrp($data['new']['document_root'].'/ssl','root');
                $app->system->chown($data['new']['document_root'].'/tmp',$username);
                $app->system->chgrp($data['new']['document_root'].'/tmp',$groupname);
@@ -725,19 +736,39 @@
                $app->system->chown($data['new']['document_root'].'/webdav',$username);
                $app->system->chgrp($data['new']['document_root'].'/webdav',$groupname);
            }
        }
        } elseif(($this->action == 'insert' && $data['new']['type'] == 'vhostsubdomain') or ($web_config['set_folder_permissions_on_update'] == 'y' && $data['new']['type'] == 'vhostsubdomain')) {
            if($web_config['security_level'] == 20) {
                $app->system->chmod($data['new']['document_root'].'/' . $web_folder,0710);
                $app->system->chown($data['new']['document_root'].'/' . $web_folder,$username);
                $app->system->chgrp($data['new']['document_root'].'/' . $web_folder,$groupname);
                $app->system->chown($data['new']['document_root'].'/' . $web_folder . '/error',$username);
                $app->system->chgrp($data['new']['document_root'].'/' . $web_folder . '/error',$groupname);
                $app->system->chown($data['new']['document_root'].'/' . $web_folder . '/stats',$username);
                $app->system->chgrp($data['new']['document_root'].'/' . $web_folder . '/stats',$groupname);
            } else {
                $app->system->chmod($data['new']['document_root'].'/' . $web_folder,0755);
                $app->system->chown($data['new']['document_root'].'/' . $web_folder,$username);
                $app->system->chgrp($data['new']['document_root'].'/' . $web_folder,$groupname);
                $app->system->chown($data['new']['document_root'].'/' . $web_folder . '/error',$username);
                $app->system->chgrp($data['new']['document_root'].'/' . $web_folder . '/error',$groupname);
                $app->system->chown($data['new']['document_root'].'/' . $web_folder . '/stats',$username);
                $app->system->chgrp($data['new']['document_root'].'/' . $web_folder . '/stats',$groupname);
            }
        }
        
        //* Protect web folders
        $app->system->web_folder_protection($data['new']['document_root'],true);
        // Change the ownership of the error log to the root user
        if(!@is_file('/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log')) exec('touch '.escapeshellcmd('/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log'));
        $app->system->chown('/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log','root');
        $app->system->chgrp('/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log','root');
        if($data['new']['type'] == 'vhost') {
            // Change the ownership of the error log to the root user
            if(!@is_file('/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log')) exec('touch '.escapeshellcmd('/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log'));
            $app->system->chown('/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log','root');
            $app->system->chgrp('/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log','root');
        }
        //* Write the custom php.ini file, if custom_php_ini fieled is not empty
        $custom_php_ini_dir = $web_config['website_basedir'].'/conf/'.$data['new']['system_user'];
        if($data['new']['type'] == 'vhostsubdomain') $custom_php_ini_dir .= '_' . $web_folder;
        if(!is_dir($web_config['website_basedir'].'/conf')) $app->system->mkdir($web_config['website_basedir'].'/conf');
        
        //* add open_basedir restriction to custom php.ini content, required for suphp only
@@ -777,8 +808,8 @@
        $vhost_data = $data['new'];
        //unset($vhost_data['ip_address']);
        $vhost_data['web_document_root'] = $data['new']['document_root'].'/web';
        $vhost_data['web_document_root_www'] = $web_config['website_basedir'].'/'.$data['new']['domain'].'/web';
        $vhost_data['web_document_root'] = $data['new']['document_root'].'/' . $web_folder;
        $vhost_data['web_document_root_www'] = $web_config['website_basedir'].'/'.$data['new']['domain'].'/' . $web_folder;
        $vhost_data['web_basedir'] = $web_config['website_basedir'];
        $vhost_data['security_level'] = $web_config['security_level'];
        $vhost_data['allow_override'] = ($data['new']['allow_override'] == '')?'All':$data['new']['allow_override'];
@@ -811,7 +842,7 @@
        if(@is_file($bundle_file)) $vhost_data['has_bundle_cert'] = 1;
        //$vhost_data['document_root'] = $data['new']['document_root'].'/web';
        //$vhost_data['document_root'] = $data['new']['document_root'].'/' . $web_folder;
        
        // Set SEO Redirect
        if($data['new']['seo_redirect'] != '' && ($data['new']['subdomain'] == 'www' || $data['new']['subdomain'] == '*')){
@@ -889,7 +920,7 @@
        }
        
        // get alias domains (co-domains and subdomains)
        $aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y'");
        $aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y' AND type != 'vhostsubdomain'");
        switch($data['new']['subdomain']) {
            case 'www':
                $server_alias[] .= 'www.'.$data['new']['domain'].' ';
@@ -1039,7 +1070,7 @@
            $php_open_basedir = ($data['new']['php_open_basedir'] == '')?$data['new']['document_root']:$data['new']['php_open_basedir'];
            $fcgi_tpl->setVar('open_basedir', escapeshellcmd($php_open_basedir));
            $fcgi_starter_script = escapeshellcmd($fastcgi_starter_path.$fastcgi_config['fastcgi_starter_script']);
            $fcgi_starter_script = escapeshellcmd($fastcgi_starter_path.$fastcgi_config['fastcgi_starter_script'].($data['new']['type'] == 'vhostsubdomain' ? '_web' . $data['new']['domain_id'] : ''));
            $app->system->file_put_contents($fcgi_starter_script,$fcgi_tpl->grab());
            unset($fcgi_tpl);
@@ -1051,18 +1082,25 @@
                        
            $tpl->setVar('fastcgi_alias',$fastcgi_config['fastcgi_alias']);
            $tpl->setVar('fastcgi_starter_path',$fastcgi_starter_path);
            $tpl->setVar('fastcgi_starter_script',$fastcgi_config['fastcgi_starter_script']);
            $tpl->setVar('fastcgi_starter_script',$fastcgi_config['fastcgi_starter_script'].($data['new']['type'] == 'vhostsubdomain' ? '_web' . $data['new']['domain_id'] : ''));
            $tpl->setVar('fastcgi_config_syntax',$fastcgi_config['fastcgi_config_syntax']);
        } else {
            //remove the php fastgi starter script if available
            if ($data['old']['php'] == 'fast-cgi') {
                $fastcgi_config = $app->getconf->get_server_config($conf['server_id'], 'fastcgi');
                $fastcgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$fastcgi_config['fastcgi_starter_path']);
                $fastcgi_starter_path = str_replace('[client_id]',$client_id,$fastcgi_starter_path);
                if (is_dir($fastcgi_starter_path)) {
                    exec('rm -rf '.$fastcgi_starter_path);
                }
                $fastcgi_config = $app->getconf->get_server_config($conf['server_id'], 'fastcgi');
                $fastcgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$fastcgi_config['fastcgi_starter_path']);
                $fastcgi_starter_path = str_replace('[client_id]',$client_id,$fastcgi_starter_path);
                if($data['old']['type'] == 'vhost') {
                    if (is_dir($fastcgi_starter_path)) {
                        exec('rm -rf '.$fastcgi_starter_path);
                    }
                } else {
                    $fcgi_starter_script = $fastcgi_starter_path.$fastcgi_config['fastcgi_starter_script'].'_web' . $data['old']['domain_id'];
                    if (file_exists($fcgi_starter_script)) {
                        exec('rm -f '.$fcgi_starter_script);
                    }
                }
            }
        }
        
@@ -1122,7 +1160,7 @@
            //$cgi_config = $app->getconf->get_server_config($conf['server_id'], 'cgi');
            $cgi_config['cgi_starter_path'] = $web_config['website_basedir'].'/php-cgi-scripts/[system_user]/';
            $cgi_config['cgi_starter_script'] = 'php-cgi-starter';
            $cgi_config['cgi_starter_script'] = 'php-cgi-starter'.($data['new']['type'] == 'vhostsubdomain' ? '_web' . $data['new']['domain_id'] : '');
            $cgi_config['cgi_bin'] = '/usr/bin/php-cgi';
            $cgi_starter_path = str_replace('[system_user]',$data['new']['system_user'],$cgi_config['cgi_starter_path']);
@@ -1157,7 +1195,7 @@
                $cgi_tpl->setVar('php_ini_path',escapeshellcmd($fastcgi_config['fastcgi_phpini_path']));
            }
            $cgi_starter_script = escapeshellcmd($cgi_starter_path.$cgi_config['cgi_starter_script']);
            $cgi_starter_script = escapeshellcmd($cgi_starter_path.$cgi_config['cgi_starter_script'].($data['new']['type'] == 'vhostsubdomain' ? '_web' . $data['new']['domain_id'] : ''));
            $app->system->file_put_contents($cgi_starter_script,$cgi_tpl->grab());
            unset($cgi_tpl);
@@ -1169,7 +1207,7 @@
            $app->system->chgrp($cgi_starter_script,$data['new']['system_group']);
            $tpl->setVar('cgi_starter_path',$cgi_starter_path);
            $tpl->setVar('cgi_starter_script',$cgi_config['cgi_starter_script']);
            $tpl->setVar('cgi_starter_script',$cgi_config['cgi_starter_script'].($data['new']['type'] == 'vhostsubdomain' ? '_web' . $data['new']['domain_id'] : ''));
        }
@@ -1288,11 +1326,11 @@
        }
        //* Create .htaccess and .htpasswd file for website statistics
        if(!is_file($data['new']['document_root'].'/web/stats/.htaccess') or $data['old']['document_root'] != $data['new']['document_root']) {
            if(!is_dir($data['new']['document_root'].'/web/stats')) $app->system->mkdir($data['new']['document_root'].'/web/stats');
        if(!is_file($data['new']['document_root'].'/' . $web_folder . '/stats/.htaccess') or $data['old']['document_root'] != $data['new']['document_root']) {
            if(!is_dir($data['new']['document_root'].'/' . $web_folder . '/stats')) $app->system->mkdir($data['new']['document_root'].'/' . $web_folder . '/stats');
            $ht_file = "AuthType Basic\nAuthName \"Members Only\"\nAuthUserFile ".$data['new']['document_root']."/.htpasswd_stats\nrequire valid-user";
            $app->system->file_put_contents($data['new']['document_root'].'/web/stats/.htaccess',$ht_file);
            $app->system->chmod($data['new']['document_root'].'/web/stats/.htaccess',0755);
            $app->system->file_put_contents($data['new']['document_root'].'/' . $web_folder . '/stats/.htaccess',$ht_file);
            $app->system->chmod($data['new']['document_root'].'/' . $web_folder . '/stats/.htaccess',0755);
            unset($ht_file);
        }
@@ -1308,7 +1346,7 @@
        }
        
        //* Create awstats configuration
        if($data['new']['stats_type'] == 'awstats' && $data['new']['type'] == 'vhost') {
        if($data['new']['stats_type'] == 'awstats' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain')) {
            $this->awstats_update($data,$web_config);
        }
        
@@ -1419,7 +1457,7 @@
            $apache_chrooted = false;
        }
        if($data['old']['type'] != 'vhost' && $data['old']['parent_domain_id'] > 0) {
        if($data['old']['type'] != 'vhost' && $data['old']['type'] != 'vhostsubdomain' && $data['old']['parent_domain_id'] > 0) {
            //* This is a alias domain or subdomain, so we have to update the website instead
            $parent_domain_id = intval($data['old']['parent_domain_id']);
            $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$parent_domain_id." AND active = 'y'");
@@ -1452,72 +1490,92 @@
            
            $app->system->unlink($vhost_file);
            $app->log('Removing vhost file: '.$vhost_file,LOGLEVEL_DEBUG);
            $docroot = escapeshellcmd($data['old']['document_root']);
            if($docroot != '' && !stristr($docroot,'..')) exec('rm -rf '.$docroot);
            //remove the php fastgi starter script if available
            if ($data['old']['php'] == 'fast-cgi') {
                $fastcgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$web_config['fastcgi_starter_path']);
                if (is_dir($fastcgi_starter_path)) {
                    exec('rm -rf '.$fastcgi_starter_path);
                }
            }
            if($data['old']['type'] == 'vhost') {
                $docroot = escapeshellcmd($data['old']['document_root']);
                if($docroot != '' && !stristr($docroot,'..')) exec('rm -rf '.$docroot);
            
            // remove PHP-FPM pool
            if ($data['old']['php'] == 'php-fpm') {
                $this->php_fpm_pool_delete($data,$web_config);
            }
                //remove the php fastgi starter script if available
                if ($data['old']['php'] == 'fast-cgi') {
                    $fastcgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$web_config['fastcgi_starter_path']);
                    if($data['old']['type'] == 'vhost') {
                        if (is_dir($fastcgi_starter_path)) {
                            exec('rm -rf '.$fastcgi_starter_path);
                        }
                    } else {
                        $fcgi_starter_script = $fastcgi_starter_path.$web_config['fastcgi_starter_script'].'_web'.$data['old']['domain_id'];
                        if (file_exists($fcgi_starter_script)) {
                            exec('rm -f '.$fcgi_starter_script);
                        }
                    }
                }
                // remove PHP-FPM pool
                if ($data['old']['php'] == 'php-fpm') {
                    $this->php_fpm_pool_delete($data,$web_config);
                }
            //remove the php cgi starter script if available
            if ($data['old']['php'] == 'cgi') {
                // TODO: fetch the date from the server-settings
                $web_config['cgi_starter_path'] = $web_config['website_basedir'].'/php-cgi-scripts/[system_user]/';
                //remove the php cgi starter script if available
                if ($data['old']['php'] == 'cgi') {
                    // TODO: fetch the date from the server-settings
                    $web_config['cgi_starter_path'] = $web_config['website_basedir'].'/php-cgi-scripts/[system_user]/';
                $cgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$web_config['cgi_starter_path']);
                if (is_dir($cgi_starter_path)) {
                    exec('rm -rf '.$cgi_starter_path);
                }
            }
                    $cgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$web_config['cgi_starter_path']);
                    if($data['old']['type'] == 'vhost') {
                        if (is_dir($cgi_starter_path)) {
                            exec('rm -rf '.$cgi_starter_path);
                        }
                    } else {
                        $cgi_starter_script = $cgi_starter_path.'php-cgi-starter_web'.$data['old']['domain_id'];
                        if (file_exists($cgi_starter_script)) {
                            exec('rm -f '.$cgi_starter_script);
                        }
                    }
                }
                $app->log('Removing website: '.$docroot,LOGLEVEL_DEBUG);
            $app->log('Removing website: '.$docroot,LOGLEVEL_DEBUG);
                // Delete the symlinks for the sites
                $client = $app->db->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['old']['sys_groupid']));
                $client_id = intval($client['client_id']);
                unset($client);
                $tmp_symlinks_array = explode(':',$web_config['website_symlinks']);
                if(is_array($tmp_symlinks_array)) {
                    foreach($tmp_symlinks_array as $tmp_symlink) {
                        $tmp_symlink = str_replace('[client_id]',$client_id,$tmp_symlink);
                        $tmp_symlink = str_replace('[website_domain]',$data['old']['domain'],$tmp_symlink);
                        // Remove trailing slash
                        if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1);
                        // create the symlinks, if not exist
                        if(is_link($tmp_symlink)) {
                            $app->system->unlink($tmp_symlink);
                            $app->log('Removing symlink: '.$tmp_symlink,LOGLEVEL_DEBUG);
                        }
                    }
                }
                // end removing symlinks
            } else {
                // vhost subdomain
            }
            // Delete the symlinks for the sites
            $client = $app->db->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['old']['sys_groupid']));
            $client_id = intval($client['client_id']);
            unset($client);
            $tmp_symlinks_array = explode(':',$web_config['website_symlinks']);
            if(is_array($tmp_symlinks_array)) {
                foreach($tmp_symlinks_array as $tmp_symlink) {
                    $tmp_symlink = str_replace('[client_id]',$client_id,$tmp_symlink);
                    $tmp_symlink = str_replace('[website_domain]',$data['old']['domain'],$tmp_symlink);
                    // Remove trailing slash
                    if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1);
                    // create the symlinks, if not exist
                    if(is_link($tmp_symlink)) {
                        $app->system->unlink($tmp_symlink);
                        $app->log('Removing symlink: '.$tmp_symlink,LOGLEVEL_DEBUG);
                    }
                }
            }
            // end removing symlinks
            // Delete the log file directory
            $vhost_logfile_dir = escapeshellcmd('/var/log/ispconfig/httpd/'.$data['old']['domain']);
            if($data['old']['domain'] != '' && !stristr($vhost_logfile_dir,'..')) exec('rm -rf '.$vhost_logfile_dir);
            $app->log('Removing website logfile directory: '.$vhost_logfile_dir,LOGLEVEL_DEBUG);
            //delete the web user
            $command = 'userdel';
            $command .= ' '.$data['old']['system_user'];
            exec($command);
            if($apache_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' '.$command);
            //* Remove the awstats configuration file
            if($data['old']['stats_type'] == 'awstats') {
                $this->awstats_delete($data,$web_config);
            }
            // Delete the log file directory
            $vhost_logfile_dir = escapeshellcmd('/var/log/ispconfig/httpd/'.$data['old']['domain']);
            if($data['old']['domain'] != '' && !stristr($vhost_logfile_dir,'..')) exec('rm -rf '.$vhost_logfile_dir);
            $app->log('Removing website logfile directory: '.$vhost_logfile_dir,LOGLEVEL_DEBUG);
            if($data['old']['type'] == 'vhost') {
                //delete the web user
                $command = 'userdel';
                $command .= ' '.$data['old']['system_user'];
                exec($command);
                if($apache_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' '.$command);
            }
            //* Remove the awstats configuration file
            if($data['old']['stats_type'] == 'awstats') {
                $this->awstats_delete($data,$web_config);
            }
            
            if($apache_chrooted) {
                $app->services->restartServiceDelayed('httpd','restart');
@@ -1595,10 +1653,13 @@
            return false;
        }
        
        $web_folder = 'web';
        if($website['type'] == 'vhostsubdomain') $web_folder = $website['web_folder'];
        //* Get the folder path.
        if(substr($folder['path'],0,1) == '/') $folder['path'] = substr($folder['path'],1);
        if(substr($folder['path'],-1) == '/') $folder['path'] = substr($folder['path'],0,-1);
        $folder_path = escapeshellcmd($website['document_root'].'/web/'.$folder['path']);
        $folder_path = escapeshellcmd($website['document_root'].'/' . $web_folder . '/'.$folder['path']);
        if(substr($folder_path,-1) != '/') $folder_path .= '/';
        
        //* Check if the resulting path is inside the docroot
@@ -1679,10 +1740,13 @@
            return false;
        }
        
        $web_folder = 'web';
        if($website['type'] == 'vhostsubdomain') $web_folder = $website['web_folder'];
        //* Get the folder path.
        if(substr($folder['path'],0,1) == '/') $folder['path'] = substr($folder['path'],1);
        if(substr($folder['path'],-1) == '/') $folder['path'] = substr($folder['path'],0,-1);
        $folder_path = realpath($website['document_root'].'/web/'.$folder['path']);
        $folder_path = realpath($website['document_root'].'/' . $web_folder . '/'.$folder['path']);
        if(substr($folder_path,-1) != '/') $folder_path .= '/';
        
        //* Check if the resulting path is inside the docroot
@@ -1715,15 +1779,18 @@
            return false;
        }
        
        $web_folder = 'web';
        if($website['type'] == 'vhostsubdomain') $web_folder = $website['web_folder'];
        //* Get the folder path.
        if(substr($data['old']['path'],0,1) == '/') $data['old']['path'] = substr($data['old']['path'],1);
        if(substr($data['old']['path'],-1) == '/') $data['old']['path'] = substr($data['old']['path'],0,-1);
        $old_folder_path = realpath($website['document_root'].'/web/'.$data['old']['path']);
        $old_folder_path = realpath($website['document_root'].'/' . $web_folder . '/'.$data['old']['path']);
        if(substr($old_folder_path,-1) != '/') $old_folder_path .= '/';
            
        if(substr($data['new']['path'],0,1) == '/') $data['new']['path'] = substr($data['new']['path'],1);
        if(substr($data['new']['path'],-1) == '/') $data['new']['path'] = substr($data['new']['path'],0,-1);
        $new_folder_path = escapeshellcmd($website['document_root'].'/web/'.$data['new']['path']);
        $new_folder_path = escapeshellcmd($website['document_root'].'/' . $web_folder . '/'.$data['new']['path']);
        if(substr($new_folder_path,-1) != '/') $new_folder_path .= '/';
        
        //* Check if the resulting path is inside the docroot
@@ -2075,9 +2142,11 @@
    private function awstats_update ($data,$web_config) {
        global $app;
        
        $web_folder = $data['new']['web_folder'];
        if($data['new']['type'] == 'vhost') $web_folder = 'web';
        $awstats_conf_dir = $web_config['awstats_conf_dir'];
        
        if(!is_dir($data['new']['document_root']."/web/stats/")) mkdir($data['new']['document_root']."/web/stats");
        if(!is_dir($data['new']['document_root']."/" . $web_folder . "/stats/")) mkdir($data['new']['document_root']."/" . $web_folder . "/stats");
        if(!@is_file($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf') || ($data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain'])) {
            if ( @is_file($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf') ) {
                $app->system->unlink($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf');
@@ -2093,8 +2162,8 @@
            $app->log('Created AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf',LOGLEVEL_DEBUG);
        }
        
        if(is_file($data['new']['document_root']."/web/stats/index.html")) $app->system->unlink($data['new']['document_root']."/web/stats/index.html");
        $app->system->copy("/usr/local/ispconfig/server/conf/awstats_index.php.master",$data['new']['document_root']."/web/stats/index.php");
        if(is_file($data['new']['document_root']."/" . $web_folder . "/stats/index.html")) $app->system->unlink($data['new']['document_root']."/" . $web_folder . "/stats/index.html");
        $app->system->copy("/usr/local/ispconfig/server/conf/awstats_index.php.master",$data['new']['document_root']."/" . $web_folder . "/stats/index.php");
    }
    
    //* Delete the awstats configuration file
server/plugins-available/nginx_plugin.inc.php
@@ -91,6 +91,8 @@
    // Handle the creation of SSL certificates
    function ssl($event_name,$data) {
        global $app, $conf;
        $app->uses('system');
        // load the server configuration options
        $app->uses('getconf');
@@ -99,9 +101,11 @@
            $app->log("CA path error, file does not exist:".$web_config['CA_path'].'/openssl.conf',LOGLEVEL_ERROR);    
        
        //* Only vhosts can have a ssl cert
        if($data["new"]["type"] != "vhost") return;
        if($data["new"]["type"] != "vhost" && $data["new"]["type"] != "vhostsubdomain") return;
        if(!is_dir($data['new']['document_root'].'/ssl')) exec('mkdir -p '.$data['new']['document_root'].'/ssl');
        // if(!is_dir($data['new']['document_root'].'/ssl')) exec('mkdir -p '.$data['new']['document_root'].'/ssl');
        if(!is_dir($data['new']['document_root'].'/ssl')) $app->system->mkdirpath($data['new']['document_root'].'/ssl');
        $ssl_dir = $data['new']['document_root'].'/ssl';
        $domain = $data['new']['ssl_domain'];
        $key_file = $ssl_dir.'/'.$domain.'.key.org';
@@ -119,7 +123,7 @@
                $rand_data .= md5(uniqid(microtime(),1));
                $rand_data .= md5(uniqid(microtime(),1));
            }
            file_put_contents($rand_file, $rand_data);
            $app->system->file_put_contents($rand_file, $rand_data);
            $ssl_password = substr(md5(uniqid(microtime(),1)), 0, 15);
@@ -134,11 +138,11 @@
        output_password        = $ssl_password
        [ req_distinguished_name ]
        C                      = ".$data['new']['ssl_country']."
        ST                     = ".$data['new']['ssl_state']."
        L                      = ".$data['new']['ssl_locality']."
        O                      = ".$data['new']['ssl_organisation']."
        OU                     = ".$data['new']['ssl_organisation_unit']."
        C                      = ".trim($data['new']['ssl_country'])."
        ST                     = ".trim($data['new']['ssl_state'])."
        L                      = ".trim($data['new']['ssl_locality'])."
        O                      = ".trim($data['new']['ssl_organisation'])."
        OU                     = ".trim($data['new']['ssl_organisation_unit'])."
        CN                     = $domain
        emailAddress           = webmaster@".$data['new']['domain']."
@@ -146,7 +150,7 @@
        challengePassword              = A challenge password";
            $ssl_cnf_file = $ssl_dir.'/openssl.conf';
            file_put_contents($ssl_cnf_file,$ssl_cnf);
            $app->system->file_put_contents($ssl_cnf_file,$ssl_cnf);
            $rand_file = escapeshellcmd($rand_file);
            $key_file = escapeshellcmd($key_file);
@@ -156,7 +160,7 @@
            $config_file = escapeshellcmd($ssl_cnf_file);
            $crt_file = escapeshellcmd($crt_file);
            if(is_file($ssl_cnf_file)) {
            if(is_file($ssl_cnf_file) && !is_link($ssl_cnf_file)) {
                
                exec("openssl genrsa -des3 -rand $rand_file -passout pass:$ssl_password -out $key_file 2048");
                exec("openssl req -new -passin pass:$ssl_password -passout pass:$ssl_password -key $key_file -out $csr_file -days $ssl_days -config $config_file");
@@ -175,16 +179,17 @@
            
            }
            exec('chmod 400 '.$key_file2);
            @unlink($config_file);
            @unlink($rand_file);
            $ssl_request = $app->db->quote(file_get_contents($csr_file));
            $ssl_cert = $app->db->quote(file_get_contents($crt_file));
            $app->system->chmod($key_file2,0400);
            @$app->system->unlink($config_file);
            @$app->system->unlink($rand_file);
            $ssl_request = $app->db->quote($app->system->file_get_contents($csr_file));
            $ssl_cert = $app->db->quote($app->system->file_get_contents($crt_file));
            $ssl_key2 = $app->db->quote($app->system->file_get_contents($key_file2));
            /* Update the DB of the (local) Server */
            $app->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert' WHERE domain = '".$data['new']['domain']."'");
            $app->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert', ssl_key = '$ssl_key2' WHERE domain = '".$data['new']['domain']."'");
            $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'");
            /* Update also the master-DB of the Server-Farm */
            $app->dbmaster->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert' WHERE domain = '".$data['new']['domain']."'");
            $app->dbmaster->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert', ssl_key = '$ssl_key2' WHERE domain = '".$data['new']['domain']."'");
            $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'");
        }
@@ -192,6 +197,8 @@
        if($data["new"]["ssl_action"] == 'save') {
            $ssl_dir = $data["new"]["document_root"]."/ssl";
            $domain = ($data["new"]["ssl_domain"] != '')?$data["new"]["ssl_domain"]:$data["new"]["domain"];
            $key_file = $ssl_dir.'/'.$domain.'.key.org';
            $key_file2 = $ssl_dir.'/'.$domain.'.key';
            $csr_file = $ssl_dir.'/'.$domain.".csr";
            $crt_file = $ssl_dir.'/'.$domain.".crt";
            //$bundle_file = $ssl_dir.'/'.$domain.".bundle";
@@ -211,6 +218,7 @@
            }
            /* Update the DB of the (local) Server */
            $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'");
            /* Update also the master-DB of the Server-Farm */
            $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'");
            $app->log('Saving SSL Cert for: '.$domain,LOGLEVEL_DEBUG);
@@ -228,9 +236,9 @@
                    exec("openssl ca -batch -config ".$web_config['CA_path']."/openssl.cnf -passin pass:".$web_config['CA_pass']." -revoke $crt_file");
                    $app->log("Revoking CA-signed SSL Cert for: $domain",LOGLEVEL_DEBUG);
                };
            unlink($csr_file);
            unlink($crt_file);
            //unlink($bundle_file);
            $app->system->unlink($csr_file);
            $app->system->unlink($crt_file);
            //$app->system->unlink($bundle_file);
            /* Update the DB of the (local) Server */
            $app->db->query("UPDATE web_domain SET ssl_request = '', ssl_cert = '' WHERE domain = '".$data['new']['domain']."'");
            $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'");
@@ -265,7 +273,7 @@
        
        if($this->action != 'insert') $this->action = 'update';
        if($data['new']['type'] != 'vhost' && $data['new']['parent_domain_id'] > 0) {
        if($data['new']['type'] != 'vhost' && $data['new']['type'] != 'vhostsubdomain' && $data['new']['parent_domain_id'] > 0) {
            $old_parent_domain_id = intval($data['old']['parent_domain_id']);
            $new_parent_domain_id = intval($data['new']['parent_domain_id']);
@@ -306,221 +314,17 @@
            $app->log('Websites cannot be owned by the root user or group.',LOGLEVEL_WARN);
            return 0;
        }
        //* If the client of the site has been changed, we have a change of the document root
        if($this->action == 'update' && $data['new']['document_root'] != $data['old']['document_root']) {
            //* Get the old client ID
            $old_client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['old']['sys_groupid']));
            $old_client_id = intval($old_client['client_id']);
            unset($old_client);
            //* Remove the old symlinks
            $tmp_symlinks_array = explode(':',$web_config['website_symlinks']);
            if(is_array($tmp_symlinks_array)) {
                foreach($tmp_symlinks_array as $tmp_symlink) {
                    $tmp_symlink = str_replace('[client_id]',$old_client_id,$tmp_symlink);
                    $tmp_symlink = str_replace('[website_domain]',$data['old']['domain'],$tmp_symlink);
                    // Remove trailing slash
                    if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1);
                    // create the symlinks, if not exist
                    if(is_link($tmp_symlink)) {
                        exec('rm -f '.escapeshellcmd($tmp_symlink));
                        $app->log('Removed symlink: rm -f '.$tmp_symlink,LOGLEVEL_DEBUG);
                    }
                }
            }
            //* Move the site data
            $tmp_docroot = explode('/',$data['new']['document_root']);
            unset($tmp_docroot[count($tmp_docroot)-1]);
            $new_dir = implode('/',$tmp_docroot);
            $tmp_docroot = explode('/',$data['old']['document_root']);
            unset($tmp_docroot[count($tmp_docroot)-1]);
            $old_dir = implode('/',$tmp_docroot);
            //* Check if there is already some data in the new docroot and rename it as we need a clean path to move the existing site to the new path
            if(@is_dir($data['new']['document_root'])) {
                rename($data['new']['document_root'],$data['new']['document_root'].'_bak_'.date('Y_m_d'));
                $app->log('Renaming existing directory in new docroot location. mv '.$data['new']['document_root'].' '.$data['new']['document_root'].'_bak_'.date('Y_m_d'),LOGLEVEL_DEBUG);
            }
            //* Create new base directory, if it does not exist yet
            if(!is_dir($new_dir)) exec('mkdir -p '.$new_dir);
            exec('mv '.$data['old']['document_root'].' '.$new_dir);
            $app->log('Moving site to new document root: mv '.$data['old']['document_root'].' '.$new_dir,LOGLEVEL_DEBUG);
            // Handle the change in php_open_basedir
            $data['new']['php_open_basedir'] = str_replace($data['old']['document_root'],$data['new']['document_root'],$data['old']['php_open_basedir']);
            //* Change the owner of the website files to the new website owner
            exec('chown --recursive --from='.escapeshellcmd($data['old']['system_user']).':'.escapeshellcmd($data['old']['system_group']).' '.escapeshellcmd($data['new']['system_user']).':'.escapeshellcmd($data['new']['system_group']).' '.$new_dir);
            //* Change the home directory and group of the website user
            $command = 'usermod';
            $command .= ' --home '.escapeshellcmd($data['new']['document_root']);
            $command .= ' --gid '.escapeshellcmd($data['new']['system_group']);
            $command .= ' '.escapeshellcmd($data['new']['system_user']);
            exec($command);
            if($nginx_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' '.$command);
        }
        //print_r($data);
        // Check if the directories are there and create them if necessary.
        if(!is_dir($data['new']['document_root'].'/web')) exec('mkdir -p '.$data['new']['document_root'].'/web');
        if(!is_dir($data['new']['document_root'].'/web/error') and $data['new']['errordocs']) exec('mkdir -p '.$data['new']['document_root'].'/web/error');
        //if(!is_dir($data['new']['document_root'].'/log')) exec('mkdir -p '.$data['new']['document_root'].'/log');
        if(!is_dir($data['new']['document_root'].'/ssl')) exec('mkdir -p '.$data['new']['document_root'].'/ssl');
        if(!is_dir($data['new']['document_root'].'/cgi-bin')) exec('mkdir -p '.$data['new']['document_root'].'/cgi-bin');
        if(!is_dir($data['new']['document_root'].'/tmp')) exec('mkdir -p '.$data['new']['document_root'].'/tmp');
        // Remove the symlink for the site, if site is renamed
        if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) {
            if(is_dir('/var/log/ispconfig/httpd/'.$data['old']['domain'])) exec('rm -rf /var/log/ispconfig/httpd/'.$data['old']['domain']);
            if(is_link($data['old']['document_root'].'/log')) unlink($data['old']['document_root'].'/log');
        }
        // Create the symlink for the logfiles
        if(!is_dir('/var/log/ispconfig/httpd/'.$data['new']['domain'])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data['new']['domain']);
        if(!is_link($data['new']['document_root'].'/log')) {
            exec('ln -s /var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/log');
            $app->log('Creating symlink: ln -s /var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/log',LOGLEVEL_DEBUG);
        }
        /*
        // Create the symlink for the logfiles
        // This does not work as vlogger cannot log trough symlinks.
        if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) {
            if(is_dir($data['old']['document_root'].'/log')) exec('rm -rf '.$data['old']['document_root'].'/log');
            if(is_link('/var/log/ispconfig/httpd/'.$data['old']['domain'])) unlink('/var/log/ispconfig/httpd/'.$data['old']['domain']);
        if(trim($data['new']['domain']) == '') {
            $app->log('domain is empty',LOGLEVEL_WARN);
            return 0;
        }
        
        // Create the symlink for the logfiles
        if(!is_dir($data['new']['document_root'].'/log')) exec('mkdir -p '.$data['new']['document_root'].'/log');
        if(!is_link('/var/log/ispconfig/httpd/'.$data['new']['domain'])) {
            exec('ln -s '.$data['new']['document_root'].'/log /var/log/ispconfig/httpd/'.$data['new']['domain']);
            $app->log('Creating symlink: ln -s '.$data['new']['document_root'].'/log /var/log/ispconfig/httpd/'.$data['new']['domain'],LOGLEVEL_DEBUG);
        }
        */
        // Get the client ID
        $client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['new']['sys_groupid']));
        $client_id = intval($client['client_id']);
        unset($client);
        // Remove old symlinks, if site is renamed
        if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) {
            $tmp_symlinks_array = explode(':',$web_config['website_symlinks']);
            if(is_array($tmp_symlinks_array)) {
                foreach($tmp_symlinks_array as $tmp_symlink) {
                    $tmp_symlink = str_replace('[client_id]',$client_id,$tmp_symlink);
                    $tmp_symlink = str_replace('[website_domain]',$data['old']['domain'],$tmp_symlink);
                    // Remove trailing slash
                    if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1);
                    // remove the symlinks, if not exist
                    if(is_link($tmp_symlink)) {
                        exec('rm -f '.escapeshellcmd($tmp_symlink));
                        $app->log('Removed symlink: rm -f '.$tmp_symlink,LOGLEVEL_DEBUG);
                    }
                }
            }
        }
        // Create the symlinks for the sites
        $tmp_symlinks_array = explode(':',$web_config['website_symlinks']);
        if(is_array($tmp_symlinks_array)) {
            foreach($tmp_symlinks_array as $tmp_symlink) {
                $tmp_symlink = str_replace('[client_id]',$client_id,$tmp_symlink);
                $tmp_symlink = str_replace('[website_domain]',$data['new']['domain'],$tmp_symlink);
                // Remove trailing slash
                if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1);
                //* Remove symlink if target folder has been changed.
                if($data['old']['document_root'] != '' && $data['old']['document_root'] != $data['new']['document_root'] && is_link($tmp_symlink)) {
                    unlink($tmp_symlink);
                }
                // create the symlinks, if not exist
                if(!is_link($tmp_symlink)) {
                    exec('ln -s '.escapeshellcmd($data['new']['document_root']).'/ '.escapeshellcmd($tmp_symlink));
                    $app->log('Creating symlink: ln -s '.$data['new']['document_root'].'/ '.$tmp_symlink,LOGLEVEL_DEBUG);
                }
            }
        }
        // Install the Standard or Custom Error, Index and other related files
        // /usr/local/ispconfig/server/conf is for the standard files
        // /usr/local/ispconfig/server/conf-custom is for the custom files
        // setting a local var here
        // normally $conf['templates'] = "/usr/local/ispconfig/server/conf";
        if($this->action == 'insert' && $data['new']['type'] == 'vhost') {
            // Copy the error pages
            if($data['new']['errordocs']) {
                $error_page_path = escapeshellcmd($data['new']['document_root']).'/web/error/';
                if (file_exists($conf['rootpath'].'/conf-custom/error/'.substr(escapeshellcmd($conf['language']),0,2))) {
                    exec('cp ' . $conf['rootpath'].'/conf-custom/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path);
                }
                else {
                    if (file_exists($conf['rootpath'].'/conf-custom/error/400.html')) {
                        exec('cp '. $conf['rootpath'].'/conf-custom/error/*.html '.$error_page_path);
                    }
                    else {
                        exec('cp ' . $conf['rootpath'] . '/conf/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path);
                    }
                }
                exec('chmod -R a+r '.$error_page_path);
            }
            if (file_exists($conf['rootpath'] . '/conf-custom/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2))) {
                exec('cp ' . $conf['rootpath'] . '/conf-custom/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2).' '.escapeshellcmd($data['new']['document_root']).'/web/index.html');
            if(is_file($conf['rootpath'] . '/conf-custom/index/favicon.ico')) {
                exec('cp ' . $conf['rootpath'] . '/conf-custom/index/favicon.ico '.escapeshellcmd($data['new']['document_root']).'/web/');
            }
            if(is_file($conf['rootpath'] . '/conf-custom/index/robots.txt')) {
                exec('cp ' . $conf['rootpath'] . '/conf-custom/index/robots.txt '.escapeshellcmd($data['new']['document_root']).'/web/');
                }
                if(is_file($conf['rootpath'] . '/conf-custom/index/.htaccess')) {
                    exec('cp ' . $conf['rootpath'] . '/conf-custom/index/.htaccess '.escapeshellcmd($data['new']['document_root']).'/web/');
                }
            }
            else {
                if (file_exists($conf['rootpath'] . '/conf-custom/index/standard_index.html')) {
                    exec('cp ' . $conf['rootpath'] . '/conf-custom/index/standard_index.html '.escapeshellcmd($data['new']['document_root']).'/web/index.html');
                }
                else {
                    exec('cp ' . $conf['rootpath'] . '/conf/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2).' '.escapeshellcmd($data['new']['document_root']).'/web/index.html');
                    if(is_file($conf['rootpath'] . '/conf/index/favicon.ico')) exec('cp ' . $conf['rootpath'] . '/conf/index/favicon.ico '.escapeshellcmd($data['new']['document_root']).'/web/');
                    if(is_file($conf['rootpath'] . '/conf/index/robots.txt')) exec('cp ' . $conf['rootpath'] . '/conf/index/robots.txt '.escapeshellcmd($data['new']['document_root']).'/web/');
                    if(is_file($conf['rootpath'] . '/conf/index/.htaccess')) exec('cp ' . $conf['rootpath'] . '/conf/index/.htaccess '.escapeshellcmd($data['new']['document_root']).'/web/');
                }
            }
            exec('chmod -R a+r '.escapeshellcmd($data['new']['document_root']).'/web/');
            //** Copy the error documents on update when the error document checkbox has been activated and was deactivated before
        } elseif ($this->action == 'update' && $data['new']['type'] == 'vhost' && $data['old']['errordocs'] == 0 && $data['new']['errordocs'] == 1) {
            $error_page_path = escapeshellcmd($data['new']['document_root']).'/web/error/';
            if (file_exists($conf['rootpath'] . '/conf-custom/error/'.substr(escapeshellcmd($conf['language']),0,2))) {
                exec('cp ' . $conf['rootpath'] . '/conf-custom/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path);
            }
            else {
                if (file_exists($conf['rootpath'] . '/conf-custom/error/400.html')) {
                    exec('cp ' . $conf['rootpath'] . '/conf-custom/error/*.html '.$error_page_path);
                }
                else {
                    exec('cp ' . $conf['rootpath'] . '/conf/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path);
                }
            }
            exec('chmod -R a+r '.$error_page_path);
            exec('chown -R '.$data['new']['system_user'].':'.$data['new']['system_group'].' '.$error_page_path);
        }  // end copy error docs
        $web_folder = 'web';
        $log_folder = 'log';
        if($data['new']['type'] == 'vhostsubdomain') {
            $web_folder = $data['new']['web_folder'];
            $log_folder .= '_web' . $data['new']['domain_id'];
        }
        // Create group and user, if not exist
        $app->uses('system');
@@ -555,13 +359,236 @@
        if($data['new']['system_user'] != '' && !$app->system->is_user($data['new']['system_user'])) {
            if($web_config['add_web_users_to_sshusers_group'] == 'y') {
                exec('useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname $fixed_uid_param -G sshusers $username -s /bin/false");
                if($nginx_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname $fixed_uid_param -G sshusers $username -s /bin/false");
                if($apache_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname $fixed_uid_param -G sshusers $username -s /bin/false");
            } else {
                exec('useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname $fixed_uid_param $username -s /bin/false");
                if($nginx_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname $fixed_uid_param $username -s /bin/false");
                if($apache_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname $fixed_uid_param $username -s /bin/false");
            }
            $app->log('Adding the user: '.$username,LOGLEVEL_DEBUG);
        }
        //* If the client of the site has been changed, we have a change of the document root
        if($this->action == 'update' && $data['new']['document_root'] != $data['old']['document_root']) {
            //* Get the old client ID
            $old_client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['old']['sys_groupid']));
            $old_client_id = intval($old_client['client_id']);
            unset($old_client);
            //* Remove the old symlinks
            $tmp_symlinks_array = explode(':',$web_config['website_symlinks']);
            if(is_array($tmp_symlinks_array)) {
                foreach($tmp_symlinks_array as $tmp_symlink) {
                    $tmp_symlink = str_replace('[client_id]',$old_client_id,$tmp_symlink);
                    $tmp_symlink = str_replace('[website_domain]',$data['old']['domain'],$tmp_symlink);
                    // Remove trailing slash
                    if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1);
                    // create the symlinks, if not exist
                    if(is_link($tmp_symlink)) {
                        exec('rm -f '.escapeshellcmd($tmp_symlink));
                        $app->log('Removed symlink: rm -f '.$tmp_symlink,LOGLEVEL_DEBUG);
                    }
                }
            }
            //* Move the site data
            $tmp_docroot = explode('/',$data['new']['document_root']);
            unset($tmp_docroot[count($tmp_docroot)-1]);
            $new_dir = implode('/',$tmp_docroot);
            $tmp_docroot = explode('/',$data['old']['document_root']);
            unset($tmp_docroot[count($tmp_docroot)-1]);
            $old_dir = implode('/',$tmp_docroot);
            //* Check if there is already some data in the new docroot and rename it as we need a clean path to move the existing site to the new path
            if(@is_dir($data['new']['document_root'])) {
                $app->system->rename($data['new']['document_root'],$data['new']['document_root'].'_bak_'.date('Y_m_d'));
                $app->log('Renaming existing directory in new docroot location. mv '.$data['new']['document_root'].' '.$data['new']['document_root'].'_bak_'.date('Y_m_d'),LOGLEVEL_DEBUG);
            }
            //* Create new base directory, if it does not exist yet
            if(!is_dir($new_dir)) $app->system->mkdirpath($new_dir);
            //exec('mv '.$data['old']['document_root'].' '.$new_dir);
            $app->system->rename($data['old']['document_root'],$new_dir);
            $app->log('Moving site to new document root: mv '.$data['old']['document_root'].' '.$new_dir,LOGLEVEL_DEBUG);
            // Handle the change in php_open_basedir
            $data['new']['php_open_basedir'] = str_replace($data['old']['document_root'],$data['new']['document_root'],$data['old']['php_open_basedir']);
            //* Change the owner of the website files to the new website owner
            exec('chown --recursive --from='.escapeshellcmd($data['old']['system_user']).':'.escapeshellcmd($data['old']['system_group']).' '.escapeshellcmd($data['new']['system_user']).':'.escapeshellcmd($data['new']['system_group']).' '.$new_dir);
            //* Change the home directory and group of the website user
            $command = 'usermod';
            $command .= ' --home '.escapeshellcmd($data['new']['document_root']);
            $command .= ' --gid '.escapeshellcmd($data['new']['system_group']);
            $command .= ' '.escapeshellcmd($data['new']['system_user']);
            exec($command);
            if($nginx_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' '.$command);
        }
        //print_r($data);
        // Check if the directories are there and create them if necessary.
        if(!is_dir($data['new']['document_root'].'/' . $web_folder)) $app->system->mkdirpath($data['new']['document_root'].'/' . $web_folder);
        if(!is_dir($data['new']['document_root'].'/' . $web_folder . '/error') and $data['new']['errordocs']) $app->system->mkdirpath($data['new']['document_root'].'/' . $web_folder . '/error');
        //if(!is_dir($data['new']['document_root'].'/'.$log_folder)) exec('mkdir -p '.$data['new']['document_root'].'/'.$log_folder);
        if(!is_dir($data['new']['document_root'].'/ssl')) $app->system->mkdirpath($data['new']['document_root'].'/ssl');
        if(!is_dir($data['new']['document_root'].'/cgi-bin')) $app->system->mkdirpath($data['new']['document_root'].'/cgi-bin');
        if(!is_dir($data['new']['document_root'].'/tmp')) $app->system->mkdirpath($data['new']['document_root'].'/tmp');
        //* Create the new private directory
        if(!is_dir($data['new']['document_root'].'/private')) {
            $app->system->mkdirpath($data['new']['document_root'].'/private');
            $app->system->chmod($data['new']['document_root'].'/private',0710);
            $app->system->chown($data['new']['document_root'].'/private',$username);
            $app->system->chgrp($data['new']['document_root'].'/private',$groupname);
        }
        // Remove the symlink for the site, if site is renamed
        if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) {
            if(is_dir('/var/log/ispconfig/httpd/'.$data['old']['domain'])) exec('rm -rf /var/log/ispconfig/httpd/'.$data['old']['domain']);
            if(is_link($data['old']['document_root'].'/'.$log_folder)) $app->system->unlink($data['old']['document_root'].'/'.$log_folder);
        }
        //* Create the log dir if nescessary and mount it
        if(!is_dir('/var/log/ispconfig/httpd/'.$data['new']['domain'])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data['new']['domain']);
        if(!is_dir($data['new']['document_root'].'/'.$log_folder) || is_link($data['new']['document_root'].'/'.$log_folder)) {
            if(is_link($data['new']['document_root'].'/'.$log_folder)) unlink($data['new']['document_root'].'/'.$log_folder);
            $app->system->mkdir($data['new']['document_root'].'/'.$log_folder);
            $app->system->chown($data['new']['document_root'].'/'.$log_folder,'root');
            $app->system->chgrp($data['new']['document_root'].'/'.$log_folder,'root');
            $app->system->chmod($data['new']['document_root'].'/'.$log_folder,0755);
            exec('mount --bind '.escapeshellarg('/var/log/ispconfig/httpd/'.$data['new']['domain']).' '.escapeshellarg($data['new']['document_root'].'/'.$log_folder));
            //* add mountpoint to fstab
            $fstab_line = '/var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/'.$log_folder.'    none    bind    0 0';
            $app->system->replaceLine('/etc/fstab',$fstab_line,$fstab_line,1,1);
        }
        // Get the client ID
        $client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['new']['sys_groupid']));
        $client_id = intval($client['client_id']);
        unset($client);
        // Remove old symlinks, if site is renamed
        if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) {
            $tmp_symlinks_array = explode(':',$web_config['website_symlinks']);
            if(is_array($tmp_symlinks_array)) {
                foreach($tmp_symlinks_array as $tmp_symlink) {
                    $tmp_symlink = str_replace('[client_id]',$client_id,$tmp_symlink);
                    $tmp_symlink = str_replace('[website_domain]',$data['old']['domain'],$tmp_symlink);
                    // Remove trailing slash
                    if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1);
                    // remove the symlinks, if not exist
                    if(is_link($tmp_symlink)) {
                        exec('rm -f '.escapeshellcmd($tmp_symlink));
                        $app->log('Removed symlink: rm -f '.$tmp_symlink,LOGLEVEL_DEBUG);
                    }
                }
            }
        }
        // Create the symlinks for the sites
        $tmp_symlinks_array = explode(':',$web_config['website_symlinks']);
        if(is_array($tmp_symlinks_array)) {
            foreach($tmp_symlinks_array as $tmp_symlink) {
                $tmp_symlink = str_replace('[client_id]',$client_id,$tmp_symlink);
                $tmp_symlink = str_replace('[website_domain]',$data['new']['domain'],$tmp_symlink);
                // Remove trailing slash
                if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1);
                //* Remove symlink if target folder has been changed.
                if($data['old']['document_root'] != '' && $data['old']['document_root'] != $data['new']['document_root'] && is_link($tmp_symlink)) {
                    $app->system->unlink($tmp_symlink);
                }
                // create the symlinks, if not exist
                if(!is_link($tmp_symlink)) {
//                    exec("ln -s ".escapeshellcmd($data["new"]["document_root"])."/ ".escapeshellcmd($tmp_symlink));
                    if ($web_config["website_symlinks_rel"] == 'y') {
                        $this->create_relative_link(escapeshellcmd($data["new"]["document_root"]), escapeshellcmd($tmp_symlink));
                    } else {
                        exec("ln -s ".escapeshellcmd($data["new"]["document_root"])."/ ".escapeshellcmd($tmp_symlink));
                    }
                    $app->log('Creating symlink: ln -s '.$data['new']['document_root'].'/ '.$tmp_symlink,LOGLEVEL_DEBUG);
                }
            }
        }
        // Install the Standard or Custom Error, Index and other related files
        // /usr/local/ispconfig/server/conf is for the standard files
        // /usr/local/ispconfig/server/conf-custom is for the custom files
        // setting a local var here
        // normally $conf['templates'] = "/usr/local/ispconfig/server/conf";
        if($this->action == 'insert' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain')) {
            // Copy the error pages
            if($data['new']['errordocs']) {
                $error_page_path = escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/error/';
                if (file_exists($conf['rootpath'] . '/conf-custom/error/'.substr(escapeshellcmd($conf['language']),0,2))) {
                    exec('cp ' . $conf['rootpath'] . '/conf-custom/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path);
                }
                else {
                    if (file_exists($conf['rootpath'] . '/conf-custom/error/400.html')) {
                        exec('cp '. $conf['rootpath'] . '/conf-custom/error/*.html '.$error_page_path);
                    }
                    else {
                        exec('cp ' . $conf['rootpath'] . '/conf/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path);
                    }
                }
                exec('chmod -R a+r '.$error_page_path);
            }
            if (file_exists($conf['rootpath'] . '/conf-custom/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2))) {
                exec('cp ' . $conf['rootpath'] . '/conf-custom/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2).' '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/index.html');
            if(is_file($conf['rootpath'] . '/conf-custom/index/favicon.ico')) {
                exec('cp ' . $conf['rootpath'] . '/conf-custom/index/favicon.ico '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
            }
            if(is_file($conf['rootpath'] . '/conf-custom/index/robots.txt')) {
                exec('cp ' . $conf['rootpath'] . '/conf-custom/index/robots.txt '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
                }
                if(is_file($conf['rootpath'] . '/conf-custom/index/.htaccess')) {
                    exec('cp ' . $conf['rootpath'] . '/conf-custom/index/.htaccess '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
                }
            }
            else {
                if (file_exists($conf['rootpath'] . '/conf-custom/index/standard_index.html')) {
                    exec('cp ' . $conf['rootpath'] . '/conf-custom/index/standard_index.html '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/index.html');
                }
                else {
                    exec('cp ' . $conf['rootpath'] . '/conf/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2).' '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/index.html');
                    if(is_file($conf['rootpath'] . '/conf/index/favicon.ico')) exec('cp ' . $conf['rootpath'] . '/conf/index/favicon.ico '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
                    if(is_file($conf['rootpath'] . '/conf/index/robots.txt')) exec('cp ' . $conf['rootpath'] . '/conf/index/robots.txt '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
                    if(is_file($conf['rootpath'] . '/conf/index/.htaccess')) exec('cp ' . $conf['rootpath'] . '/conf/index/.htaccess '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
                }
            }
            exec('chmod -R a+r '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
            //** Copy the error documents on update when the error document checkbox has been activated and was deactivated before
        } elseif ($this->action == 'update' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain') && $data['old']['errordocs'] == 0 && $data['new']['errordocs'] == 1) {
            $error_page_path = escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/error/';
            if (file_exists($conf['rootpath'] . '/conf-custom/error/'.substr(escapeshellcmd($conf['language']),0,2))) {
                exec('cp ' . $conf['rootpath'] . '/conf-custom/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path);
            }
            else {
                if (file_exists($conf['rootpath'] . '/conf-custom/error/400.html')) {
                    exec('cp ' . $conf['rootpath'] . '/conf-custom/error/*.html '.$error_page_path);
                }
                else {
                    exec('cp ' . $conf['rootpath'] . '/conf/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path);
                }
            }
            exec('chmod -R a+r '.$error_page_path);
            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)) {
@@ -577,29 +604,36 @@
        if($this->action == 'insert' || $data["new"]["system_user"] != $data["old"]["system_user"]) {
            // Chown and chmod the directories below the document root
            $this->_exec('chown -R '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root']).'/web');
            $this->_exec('chown -R '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder);
            // The document root itself has to be owned by root in normal level and by the web owner in security level 20
            if($web_config['security_level'] == 20) {
                $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root']).'/web');
                $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder);
            } else {
                $this->_exec('chown root:root '.escapeshellcmd($data['new']['document_root']).'/web');
                $this->_exec('chown root:root '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder);
            }
        }
        //* If the security level is set to high
        if(($this->action == 'insert' && $data['new']['type'] == 'vhost') or ($web_config['set_folder_permissions_on_update'] == 'y' && $data['new']['type'] == 'vhost')) {
            //* Check if we have the new private folder and create it if nescessary
            if(!is_dir($data['new']['document_root'].'/private')) $app->system->mkdir($data['new']['document_root'].'/private');
            if($web_config['security_level'] == 20) {
                $this->_exec('chmod 751 '.escapeshellcmd($data['new']['document_root']));
                $this->_exec('chmod 751 '.escapeshellcmd($data['new']['document_root']).'/*');
                $this->_exec('chmod 710 '.escapeshellcmd($data['new']['document_root'].'/web'));
                $app->system->chmod($data['new']['document_root'],0755);
                $app->system->chmod($data['new']['document_root'].'/web',0710);
                $app->system->chmod($data['new']['document_root'].'/webdav',0710);
                $app->system->chmod($data['new']['document_root'].'/private',0710);
                $app->system->chmod($data['new']['document_root'].'/ssl',0755);
                // make tmp directory writable for nginx and the website users
                $this->_exec('chmod 777 '.escapeshellcmd($data['new']['document_root'].'/tmp'));
                $app->system->chmod($data['new']['document_root'].'/tmp',0777);
            
                // Set Log symlink to 755 to make the logs accessible by the FTP user
                $this->_exec("chmod 755 ".escapeshellcmd($data["new"]["document_root"])."/log");
                // Set Log directory to 755 to make the logs accessible by the FTP user
                if(realpath($data['new']['document_root'].'/'.$log_folder) == '/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log') {
                    $app->system->chmod($data['new']['document_root'].'/'.$log_folder,0755);
                }
                if($web_config['add_web_users_to_sshusers_group'] == 'y') {
                    $command = 'usermod';
                    $command .= ' --groups sshusers';
@@ -624,7 +658,8 @@
                
                //* Chown all default directories
                $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root']));
                $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/cgi-bin'));
                $app->system->chown($data['new']['document_root'].'/cgi-bin',$username);
                $app->system->chgrp($data['new']['document_root'].'/cgi-bin',$groupname);
                $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/log'));
                $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/ssl'));
                $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/tmp'));
@@ -662,7 +697,25 @@
                $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/ssl'));
                $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/web'));
            }
        }
        } elseif(($this->action == 'insert' && $data['new']['type'] == 'vhostsubdomain') or ($web_config['set_folder_permissions_on_update'] == 'y' && $data['new']['type'] == 'vhostsubdomain')) {
            if($web_config['security_level'] == 20) {
                $app->system->chmod($data['new']['document_root'].'/' . $web_folder,0710);
                $app->system->chown($data['new']['document_root'].'/' . $web_folder,$username);
                $app->system->chgrp($data['new']['document_root'].'/' . $web_folder,$groupname);
                $app->system->chown($data['new']['document_root'].'/' . $web_folder . '/error',$username);
                $app->system->chgrp($data['new']['document_root'].'/' . $web_folder . '/error',$groupname);
                $app->system->chown($data['new']['document_root'].'/' . $web_folder . '/stats',$username);
                $app->system->chgrp($data['new']['document_root'].'/' . $web_folder . '/stats',$groupname);
            } else {
                $app->system->chmod($data['new']['document_root'].'/' . $web_folder,0755);
                $app->system->chown($data['new']['document_root'].'/' . $web_folder,$username);
                $app->system->chgrp($data['new']['document_root'].'/' . $web_folder,$groupname);
                $app->system->chown($data['new']['document_root'].'/' . $web_folder . '/error',$username);
                $app->system->chgrp($data['new']['document_root'].'/' . $web_folder . '/error',$groupname);
                $app->system->chown($data['new']['document_root'].'/' . $web_folder . '/stats',$username);
                $app->system->chgrp($data['new']['document_root'].'/' . $web_folder . '/stats',$groupname);
            }
        }
        // Change the ownership of the error log to the owner of the website
        if(!@is_file($data['new']['document_root'].'/log/error.log')) exec('touch '.escapeshellcmd($data['new']['document_root']).'/log/error.log');
@@ -675,7 +728,7 @@
        if(!is_dir($web_config['website_basedir'].'/conf')) mkdir($web_config['website_basedir'].'/conf');
        if(trim($data['new']['custom_php_ini']) != '') {
            $has_custom_php_ini = true;
            if(!is_dir($custom_php_ini_dir)) mkdir($custom_php_ini_dir);
            if(!is_dir($custom_php_ini_dir)) $app->system->mkdir($custom_php_ini_dir);
            $php_ini_content = '';
            if($data['new']['php'] == 'mod') {
                $master_php_ini_path = $web_config['php_ini_path_apache'];
@@ -687,13 +740,13 @@
                }
            }
            if($master_php_ini_path != '' && substr($master_php_ini_path,-7) == 'php.ini' && is_file($master_php_ini_path)) {
                $php_ini_content .= file_get_contents($master_php_ini_path)."\n";
                $php_ini_content .= $app->system->file_get_contents($master_php_ini_path)."\n";
            }
            $php_ini_content .= trim($data['new']['custom_php_ini']);
            file_put_contents($custom_php_ini_dir.'/php.ini',$php_ini_content);
            $php_ini_content .= str_replace("\r",'',trim($data['new']['custom_php_ini']));
            $app->system->file_put_contents($custom_php_ini_dir.'/php.ini',$php_ini_content);
        } else {
            $has_custom_php_ini = false;
            if(is_file($custom_php_ini_dir.'/php.ini')) unlink($custom_php_ini_dir.'/php.ini');
            if(is_file($custom_php_ini_dir.'/php.ini')) $app->system->unlink($custom_php_ini_dir.'/php.ini');
        }
        */
@@ -704,8 +757,9 @@
        $tpl->newTemplate('nginx_vhost.conf.master');
        $vhost_data = $data['new'];
        $vhost_data['web_document_root'] = $data['new']['document_root'].'/web';
        $vhost_data['web_document_root_www'] = $web_config['website_basedir'].'/'.$data['new']['domain'].'/web';
        //unset($vhost_data['ip_address']);
        $vhost_data['web_document_root'] = $data['new']['document_root'].'/' . $web_folder;
        $vhost_data['web_document_root_www'] = $web_config['website_basedir'].'/'.$data['new']['domain'].'/' . $web_folder;
        $vhost_data['web_basedir'] = $web_config['website_basedir'];
        
        // IPv6
@@ -930,7 +984,7 @@
        }
        
        // get alias domains (co-domains and subdomains)
        $aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y'");
        $aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y' AND type != 'vhostsubdomain'");
        switch($data['new']['subdomain']) {
            case 'www':
                $server_alias[] = 'www.'.$data['new']['domain'].' ';
@@ -1100,12 +1154,12 @@
        if($data['new']['subdomain'] != $data['old']['subdomain'] or $data['new']['active'] == 'n') {
            $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/900-'.$data['new']['domain'].'.vhost');
            if(is_link($vhost_symlink)) {
                unlink($vhost_symlink);
                $app->system->unlink($vhost_symlink);
                $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG);
            }
            $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/100-'.$data['new']['domain'].'.vhost');
            if(is_link($vhost_symlink)) {
                unlink($vhost_symlink);
                $app->system->unlink($vhost_symlink);
                $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG);
            }
        }
@@ -1125,21 +1179,21 @@
        if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) {
            $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/900-'.$data['old']['domain'].'.vhost');
            if(is_link($vhost_symlink)) {
                unlink($vhost_symlink);
                $app->system->unlink($vhost_symlink);
                $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG);
            }
            $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/100-'.$data['old']['domain'].'.vhost');
            if(is_link($vhost_symlink)) {
                unlink($vhost_symlink);
                $app->system->unlink($vhost_symlink);
                $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG);
            }
            $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/'.$data['old']['domain'].'.vhost');
            if(is_link($vhost_symlink)) {
                unlink($vhost_symlink);
                $app->system->unlink($vhost_symlink);
                $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG);
            }
            $vhost_file = escapeshellcmd($web_config['nginx_vhost_conf_dir'].'/'.$data['old']['domain'].'.vhost');
            unlink($vhost_file);
            $app->system->unlink($vhost_file);
            $app->log('Removing file: '.$vhost_file,LOGLEVEL_DEBUG);
        }
        
@@ -1154,7 +1208,7 @@
        }
        
        //* Create awstats configuration
        if($data['new']['stats_type'] == 'awstats' && $data['new']['type'] == 'vhost') {
        if($data['new']['stats_type'] == 'awstats' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain')) {
            $this->awstats_update($data,$web_config);
        }
        
@@ -1178,7 +1232,7 @@
                copy($vhost_file,$vhost_file.'.err');
                if(is_file($vhost_file.'~')) {
                    //* Copy back the last backup file
                    copy($vhost_file.'~',$vhost_file);
                    $app->system->copy($vhost_file.'~',$vhost_file);
                } else {
                    //* There is no backup file, so we create a empty vhost file with a warning message inside
                    file_put_contents($vhost_file,"# nginx did not start after modifying this vhost file.\n# Please check file $vhost_file.err for syntax errors.");
@@ -1196,8 +1250,7 @@
        }
        
        // Remove the backup copy of the config file.
        if(@is_file($vhost_file.'~')) unlink($vhost_file.'~');
        if(@is_file($vhost_file.'~')) $app->system->unlink($vhost_file.'~');
        //* Unset action to clean it for next processed vhost.
        $this->action = '';
@@ -1209,6 +1262,7 @@
        // load the server configuration options
        $app->uses('getconf');
        $app->uses('system');
        $web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
        //* Check if this is a chrooted setup
@@ -1218,7 +1272,7 @@
            $nginx_chrooted = false;
        }
        if($data['old']['type'] != 'vhost' && $data['old']['parent_domain_id'] > 0) {
        if($data['old']['type'] != 'vhost' && $data['old']['type'] != 'vhostsubdomain' && $data['old']['parent_domain_id'] > 0) {
            //* This is a alias domain or subdomain, so we have to update the website instead
            $parent_domain_id = intval($data['old']['parent_domain_id']);
            $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$parent_domain_id." AND active = 'y'");
@@ -1235,87 +1289,108 @@
            
            $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/'.$data['old']['domain'].'.vhost');
            if(is_link($vhost_symlink)){
                unlink($vhost_symlink);
                $app->system->unlink($vhost_symlink);
                $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG);
            }
            $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/900-'.$data['old']['domain'].'.vhost');
            if(is_link($vhost_symlink)){
                unlink($vhost_symlink);
                $app->system->unlink($vhost_symlink);
                $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG);
            }
            $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/100-'.$data['old']['domain'].'.vhost');
            if(is_link($vhost_symlink)){
                unlink($vhost_symlink);
                $app->system->unlink($vhost_symlink);
                $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG);
            }
            
            unlink($vhost_file);
            $app->system->unlink($vhost_file);
            $app->log('Removing vhost file: '.$vhost_file,LOGLEVEL_DEBUG);
            $docroot = escapeshellcmd($data['old']['document_root']);
            if($docroot != '' && !stristr($docroot,'..')) exec('rm -rf '.$docroot);
            //remove the php fastgi starter script and PHP-FPM pool definition if available
            if ($data['old']['php'] == 'fast-cgi') {
                $this->php_fpm_pool_delete($data,$web_config);
                $fastcgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$web_config['fastcgi_starter_path']);
                if (is_dir($fastcgi_starter_path)) {
                    exec('rm -rf '.$fastcgi_starter_path);
                }
            }
            if($data['old']['type'] == 'vhost') {
                $docroot = escapeshellcmd($data['old']['document_root']);
                if($docroot != '' && !stristr($docroot,'..')) exec('rm -rf '.$docroot);
            
            // remove PHP-FPM pool
            if ($data['old']['php'] == 'php-fpm') {
                $this->php_fpm_pool_delete($data,$web_config);
            }
                //remove the php fastgi starter script if available
                if ($data['old']['php'] == 'fast-cgi') {
                    $this->php_fpm_pool_delete($data,$web_config);
                    $fastcgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$web_config['fastcgi_starter_path']);
                    if($data['old']['type'] == 'vhost') {
                        if (is_dir($fastcgi_starter_path)) {
                            exec('rm -rf '.$fastcgi_starter_path);
                        }
                    } else {
                        $fcgi_starter_script = $fastcgi_starter_path.$web_config['fastcgi_starter_script'].'_web'.$data['old']['domain_id'];
                        if (file_exists($fcgi_starter_script)) {
                            exec('rm -f '.$fcgi_starter_script);
                        }
                    }
                }
                // remove PHP-FPM pool
                if ($data['old']['php'] == 'php-fpm') {
                    $this->php_fpm_pool_delete($data,$web_config);
                }
            //remove the php cgi starter script if available
            if ($data['old']['php'] == 'cgi') {
                // TODO: fetch the date from the server-settings
                $web_config['cgi_starter_path'] = $web_config['website_basedir'].'/php-cgi-scripts/[system_user]/';
                //remove the php cgi starter script if available
                if ($data['old']['php'] == 'cgi') {
                    // TODO: fetch the date from the server-settings
                    $web_config['cgi_starter_path'] = $web_config['website_basedir'].'/php-cgi-scripts/[system_user]/';
                $cgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$web_config['cgi_starter_path']);
                if (is_dir($cgi_starter_path)) {
                    exec('rm -rf '.$cgi_starter_path);
                }
            }
                    $cgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$web_config['cgi_starter_path']);
                    if($data['old']['type'] == 'vhost') {
                        if (is_dir($cgi_starter_path)) {
                            exec('rm -rf '.$cgi_starter_path);
                        }
                    } else {
                        $cgi_starter_script = $cgi_starter_path.'php-cgi-starter_web'.$data['old']['domain_id'];
                        if (file_exists($cgi_starter_script)) {
                            exec('rm -f '.$cgi_starter_script);
                        }
                    }
                }
                $app->log('Removing website: '.$docroot,LOGLEVEL_DEBUG);
            $app->log('Removing website: '.$docroot,LOGLEVEL_DEBUG);
                // Delete the symlinks for the sites
                $client = $app->db->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['old']['sys_groupid']));
                $client_id = intval($client['client_id']);
                unset($client);
                $tmp_symlinks_array = explode(':',$web_config['website_symlinks']);
                if(is_array($tmp_symlinks_array)) {
                    foreach($tmp_symlinks_array as $tmp_symlink) {
                        $tmp_symlink = str_replace('[client_id]',$client_id,$tmp_symlink);
                        $tmp_symlink = str_replace('[website_domain]',$data['old']['domain'],$tmp_symlink);
                        // Remove trailing slash
                        if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1);
                        // create the symlinks, if not exist
                        if(is_link($tmp_symlink)) {
                            $app->system->unlink($tmp_symlink);
                            $app->log('Removing symlink: '.$tmp_symlink,LOGLEVEL_DEBUG);
                        }
                    }
                }
                // end removing symlinks
            } else {
                // vhost subdomain
            }
            // Delete the symlinks for the sites
            $client = $app->db->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['old']['sys_groupid']));
            $client_id = intval($client['client_id']);
            unset($client);
            $tmp_symlinks_array = explode(':',$web_config['website_symlinks']);
            if(is_array($tmp_symlinks_array)) {
                foreach($tmp_symlinks_array as $tmp_symlink) {
                    $tmp_symlink = str_replace('[client_id]',$client_id,$tmp_symlink);
                    $tmp_symlink = str_replace('[website_domain]',$data['old']['domain'],$tmp_symlink);
                    // Remove trailing slash
                    if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1);
                    // create the symlinks, if not exist
                    if(is_link($tmp_symlink)) {
                        unlink($tmp_symlink);
                        $app->log('Removing symlink: '.$tmp_symlink,LOGLEVEL_DEBUG);
                    }
                }
            }
            // end removing symlinks
            // Delete the log file directory
            $vhost_logfile_dir = escapeshellcmd('/var/log/ispconfig/httpd/'.$data['old']['domain']);
            if($data['old']['domain'] != '' && !stristr($vhost_logfile_dir,'..')) exec('rm -rf '.$vhost_logfile_dir);
            $app->log('Removing website logfile directory: '.$vhost_logfile_dir,LOGLEVEL_DEBUG);
            //delete the web user
            $command = 'userdel';
            $command .= ' '.$data['old']['system_user'];
            exec($command);
            if($nginx_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' '.$command);
            //* Remove the awstats configuration file
            if($data['old']['stats_type'] == 'awstats') {
                $this->awstats_delete($data,$web_config);
            // Delete the log file directory
            $vhost_logfile_dir = escapeshellcmd('/var/log/ispconfig/httpd/'.$data['old']['domain']);
            if($data['old']['domain'] != '' && !stristr($vhost_logfile_dir,'..')) exec('rm -rf '.$vhost_logfile_dir);
            $app->log('Removing website logfile directory: '.$vhost_logfile_dir,LOGLEVEL_DEBUG);
            if($data['old']['type'] == 'vhost') {
                //delete the web user
                $command = 'userdel';
                $command .= ' '.$data['old']['system_user'];
                exec($command);
                if($nginx_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' '.$command);
            }
            //* Remove the awstats configuration file
            if($data['old']['stats_type'] == 'awstats') {
                $this->awstats_delete($data,$web_config);
            }
            
            $app->services->restartServiceDelayed('httpd','reload');
@@ -1348,10 +1423,13 @@
            return false;
        }
        
        $web_folder = 'web';
        if($website['type'] == 'vhostsubdomain') $web_folder = $website['web_folder'];
        //* Get the folder path.
        if(substr($folder['path'],0,1) == '/') $folder['path'] = substr($folder['path'],1);
        if(substr($folder['path'],-1) == '/') $folder['path'] = substr($folder['path'],0,-1);
        $folder_path = escapeshellcmd($website['document_root'].'/web/'.$folder['path']);
        $folder_path = escapeshellcmd($website['document_root'].'/' . $web_folder . '/'.$folder['path']);
        if(substr($folder_path,-1) != '/') $folder_path .= '/';
        
        //* Check if the resulting path is inside the docroot
@@ -1362,18 +1440,18 @@
        
        //* Create the folder path, if it does not exist
        if(!is_dir($folder_path)) {
            exec('mkdir -p '.$folder_path);
            chown($folder_path,$website['system_user']);
            chgrp($folder_path,$website['system_group']);
            $app->system->mkdirpath($folder_path);
            $app->system->chown($folder_path,$website['system_user']);
            $app->system->chgrp($folder_path,$website['system_group']);
        }
        
        //* Create empty .htpasswd file, if it does not exist
        if(!is_file($folder_path.'.htpasswd')) {
            touch($folder_path.'.htpasswd');
            chmod($folder_path.'.htpasswd',0755);
            chown($folder_path.'.htpasswd',$website['system_user']);
            chgrp($folder_path.'.htpasswd',$website['system_group']);
            $app->log('Created file'.$folder_path.'.htpasswd',LOGLEVEL_DEBUG);
            $app->system->chmod($folder_path.'.htpasswd',0755);
            $app->system->chown($folder_path.'.htpasswd',$website['system_user']);
            $app->system->chgrp($folder_path.'.htpasswd',$website['system_group']);
            $app->log('Created file '.$folder_path.'.htpasswd',LOGLEVEL_DEBUG);
        }
        
        /*
@@ -1424,10 +1502,13 @@
            return false;
        }
        
        $web_folder = 'web';
        if($website['type'] == 'vhostsubdomain') $web_folder = $website['web_folder'];
        //* Get the folder path.
        if(substr($folder['path'],0,1) == '/') $folder['path'] = substr($folder['path'],1);
        if(substr($folder['path'],-1) == '/') $folder['path'] = substr($folder['path'],0,-1);
        $folder_path = realpath($website['document_root'].'/web/'.$folder['path']);
        $folder_path = realpath($website['document_root'].'/' . $web_folder . '/'.$folder['path']);
        if(substr($folder_path,-1) != '/') $folder_path .= '/';
        
        //* Check if the resulting path is inside the docroot
@@ -1438,7 +1519,7 @@
        
        //* Remove .htpasswd file
        if(is_file($folder_path.'.htpasswd')) {
            unlink($folder_path.'.htpasswd');
            $app->system->unlink($folder_path.'.htpasswd');
            $app->log('Removed file '.$folder_path.'.htpasswd',LOGLEVEL_DEBUG);
        }
        
@@ -1458,15 +1539,18 @@
            return false;
        }
        
        $web_folder = 'web';
        if($website['type'] == 'vhostsubdomain') $web_folder = $website['web_folder'];
        //* Get the folder path.
        if(substr($data['old']['path'],0,1) == '/') $data['old']['path'] = substr($data['old']['path'],1);
        if(substr($data['old']['path'],-1) == '/') $data['old']['path'] = substr($data['old']['path'],0,-1);
        $old_folder_path = realpath($website['document_root'].'/web/'.$data['old']['path']);
        $old_folder_path = realpath($website['document_root'].'/' . $web_folder . '/'.$data['old']['path']);
        if(substr($old_folder_path,-1) != '/') $old_folder_path .= '/';
            
        if(substr($data['new']['path'],0,1) == '/') $data['new']['path'] = substr($data['new']['path'],1);
        if(substr($data['new']['path'],-1) == '/') $data['new']['path'] = substr($data['new']['path'],0,-1);
        $new_folder_path = escapeshellcmd($website['document_root'].'/web/'.$data['new']['path']);
        $new_folder_path = escapeshellcmd($website['document_root'].'/' . $web_folder . '/'.$data['new']['path']);
        if(substr($new_folder_path,-1) != '/') $new_folder_path .= '/';
        
        //* Check if the resulting path is inside the docroot
@@ -1490,14 +1574,14 @@
        }
            
        //* Create the folder path, if it does not exist
        if(!is_dir($new_folder_path)) exec('mkdir -p '.$new_folder_path);
        if(!is_dir($new_folder_path)) $app->system->mkdirpath($new_folder_path);
        
        if($data['old']['path'] != $data['new']['path']) {
        
            //* move .htpasswd file
            if(is_file($old_folder_path.'.htpasswd')) {
                rename($old_folder_path.'.htpasswd',$new_folder_path.'.htpasswd');
                $app->system->rename($old_folder_path.'.htpasswd',$new_folder_path.'.htpasswd');
                $app->log('Moved file '.$old_folder_path.'.htpasswd to '.$new_folder_path.'.htpasswd',LOGLEVEL_DEBUG);
            }
        
@@ -1527,7 +1611,7 @@
                    $website_auth_location['path'] .= '/';
                }
                $basic_auth_locations[] = array('htpasswd_location' => '/'.$website_auth_location['path'],
                                                'htpasswd_path' => $website['document_root'].'/web/'.$website_auth_location['path']);
                                                'htpasswd_path' => $website['document_root'].'/' . ($website['type'] == 'vhostsubdomain' ? $website['web_folder'] : 'web') . '/'.$website_auth_location['path']);
            }
        }
        return $basic_auth_locations;
@@ -1542,12 +1626,14 @@
    private function awstats_update ($data,$web_config) {
        global $app;
        
        $web_folder = $data['new']['web_folder'];
        if($data['new']['type'] == 'vhost') $web_folder = 'web';
        $awstats_conf_dir = $web_config['awstats_conf_dir'];
        
        if(!is_dir($data['new']['document_root']."/web/stats/")) mkdir($data['new']['document_root']."/web/stats");
        if(!is_dir($data['new']['document_root']."/" . $web_folder . "/stats/")) mkdir($data['new']['document_root']."/" . $web_folder . "/stats");
        if(!@is_file($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf') || ($data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain'])) {
            if ( @is_file($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf') ) {
                unlink($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf');
                $app->system->unlink($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf');
            }
            
            $content = '';
@@ -1556,12 +1642,12 @@
            $content .= "SiteDomain=\"".$data['new']['domain']."\"\n";
            $content .= "HostAliases=\"www.".$data['new']['domain']."  localhost 127.0.0.1\"\n";
            
            file_put_contents($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf',$content);
            $app->system->file_put_contents($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf',$content);
            $app->log('Created AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf',LOGLEVEL_DEBUG);
        }
        
        if(is_file($data['new']['document_root']."/web/stats/index.html")) unlink($data['new']['document_root']."/web/stats/index.html");
        copy("/usr/local/ispconfig/server/conf/awstats_index.php.master",$data['new']['document_root']."/web/stats/index.php");
        if(is_file($data['new']['document_root']."/" . $web_folder . "/stats/index.html")) $app->system->unlink($data['new']['document_root']."/" . $web_folder . "/stats/index.html");
        $app->system->copy("/usr/local/ispconfig/server/conf/awstats_index.php.master",$data['new']['document_root']."/" . $web_folder . "/stats/index.php");
    }
    
    //* Delete the awstats configuration file
@@ -1571,7 +1657,7 @@
        $awstats_conf_dir = $web_config['awstats_conf_dir'];
        
        if ( @is_file($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf') ) {
            unlink($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf');
            $app->system->unlink($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf');
            $app->log('Removed AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf',LOGLEVEL_DEBUG);
        }
    }
@@ -1611,7 +1697,8 @@
        
        if($data['new']['php'] == 'no'){
            if(@is_file($pool_dir.$pool_name.'.conf')){
                unlink($pool_dir.$pool_name.'.conf');
                $app->system->unlink($pool_dir.$pool_name.'.conf');
                //$reload = true;
            }
            if($data['old']['php'] != 'no'){
                if(!$default_php_fpm){
@@ -1630,7 +1717,7 @@
        if($data['new']['php_fpm_use_socket'] == 'y'){
            $use_tcp = 0;
            $use_socket = 1;
            if(!is_dir($socket_dir)) exec('mkdir -p '.$socket_dir);
            if(!is_dir($socket_dir)) $app->system->mkdirpath($socket_dir);
        } else {
            $use_tcp = 1;
            $use_socket = 0;
@@ -1699,7 +1786,7 @@
            
        $tpl->setLoop('custom_php_ini_settings', $final_php_ini_settings);
            
        file_put_contents($pool_dir.$pool_name.'.conf',$tpl->grab());
        $app->system->file_put_contents($pool_dir.$pool_name.'.conf',$tpl->grab());
        $app->log('Writing the PHP-FPM config file: '.$pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG);
        unset($tpl);
        
@@ -1708,7 +1795,7 @@
        if(substr($default_pool_dir,-1) != '/') $default_pool_dir .= '/';
        if($default_pool_dir != $pool_dir){
            if ( @is_file($default_pool_dir.$pool_name.'.conf') ) {
                    unlink($default_pool_dir.$pool_name.'.conf');
                    $app->system->unlink($default_pool_dir.$pool_name.'.conf');
                    $app->log('Removed PHP-FPM config file: '.$default_pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG);
                    $app->services->restartService('php-fpm','reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
            }
@@ -1719,7 +1806,7 @@
                if(substr($php_version['php_fpm_pool_dir'],-1) != '/') $php_version['php_fpm_pool_dir'] .= '/';
                if($php_version['php_fpm_pool_dir'] != $pool_dir){
                    if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) {
                        unlink($php_version['php_fpm_pool_dir'].$pool_name.'.conf');
                        $app->system->unlink($php_version['php_fpm_pool_dir'].$pool_name.'.conf');
                        $app->log('Removed PHP-FPM config file: '.$php_version['php_fpm_pool_dir'].$pool_name.'.conf',LOGLEVEL_DEBUG);
                        $app->services->restartService('php-fpm','reload:'.$php_version['php_fpm_init_script']);
                    }
@@ -1757,7 +1844,7 @@
        $pool_name = 'web'.$data['old']['domain_id'];
        
        if ( @is_file($pool_dir.$pool_name.'.conf') ) {
            unlink($pool_dir.$pool_name.'.conf');
            $app->system->unlink($pool_dir.$pool_name.'.conf');
            $app->log('Removed PHP-FPM config file: '.$pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG);
        }
        
@@ -1766,7 +1853,7 @@
        if(substr($default_pool_dir,-1) != '/') $default_pool_dir .= '/';
        if($default_pool_dir != $pool_dir){
            if ( @is_file($default_pool_dir.$pool_name.'.conf') ) {
                    unlink($default_pool_dir.$pool_name.'.conf');
                    $app->system->unlink($default_pool_dir.$pool_name.'.conf');
                    $app->log('Removed PHP-FPM config file: '.$default_pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG);
                    $app->services->restartService('php-fpm','reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
            }
@@ -1777,7 +1864,7 @@
                if(substr($php_version['php_fpm_pool_dir'],-1) != '/') $php_version['php_fpm_pool_dir'] .= '/';
                if($php_version['php_fpm_pool_dir'] != $pool_dir){
                    if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) {
                        unlink($php_version['php_fpm_pool_dir'].$pool_name.'.conf');
                        $app->system->unlink($php_version['php_fpm_pool_dir'].$pool_name.'.conf');
                        $app->log('Removed PHP-FPM config file: '.$php_version['php_fpm_pool_dir'].$pool_name.'.conf',LOGLEVEL_DEBUG);
                        $app->services->restartService('php-fpm','reload:'.$php_version['php_fpm_init_script']);
                    }
@@ -1911,4 +1998,4 @@
} // end class
?>
?>
server/plugins-available/nginx_reverseproxy_plugin.inc.php
@@ -63,7 +63,7 @@
        if($this->action != 'insert') $this->action = 'update';
        if($data['new']['type'] != 'vhost' && $data['new']['parent_domain_id'] > 0) {
        if($data['new']['type'] != 'vhost' && $data['new']['type'] != 'vhostsubdomain' && $data['new']['parent_domain_id'] > 0) {
            $old_parent_domain_id = intval($data['old']['parent_domain_id']);
            $new_parent_domain_id = intval($data['new']['parent_domain_id']);
@@ -130,7 +130,7 @@
        
        // get alias domains (co-domains and subdomains)
        $aliases = $app->dbmaster->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y'");
        $aliases = $app->dbmaster->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND type != 'vhostsubdomain' AND active = 'y'");
        $server_alias = array();
        switch($data['new']['subdomain']) {
            case 'www':
@@ -280,7 +280,7 @@
        $nginx_config = $app->getconf->get_server_config($conf['server_id'], 'web');
        if($data['old']['type'] == 'vhost') {
        if($data['old']['type'] == 'vhost' || $data['old']['type'] == 'vhostsubdomain') {
            //* This is a website
            // Deleting the vhost file, symlink and the data directory