tbrehm
2011-09-21 a2156eb5923b4065d29ad164baa038238091cd49
Added new namevirtualhost port functions to the installer and apache plugin.
7 files modified
101 ■■■■ changed files
install/dist/lib/fedora.lib.php 22 ●●●● patch | view | raw | blame | history
install/dist/lib/opensuse.lib.php 22 ●●●● patch | view | raw | blame | history
install/lib/installer_base.lib.php 20 ●●●● patch | view | raw | blame | history
interface/web/admin/form/server_ip.tform.php 6 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_server_ip.lng 1 ●●●● patch | view | raw | blame | history
server/conf/apache_ispconfig.conf.master 3 ●●●● patch | view | raw | blame | history
server/plugins-available/apache2_plugin.inc.php 27 ●●●● patch | view | raw | blame | history
install/dist/lib/fedora.lib.php
@@ -521,14 +521,28 @@
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        
        // copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf');
        $content = rf("tpl/apache_ispconfig.conf.master");
        $records = $this->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ".$conf["server_id"]." AND virtualhost = 'y'");
        $content = rf('tpl/apache_ispconfig.conf.master');
        $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
        if(is_array($records) && count($records) > 0) {
            foreach($records as $rec) {
                $content .= "NameVirtualHost ".$rec["ip_address"].":80\n";
                $content .= "NameVirtualHost ".$rec["ip_address"].":443\n";
                if($rec['ip_type'] == 'IPv6') {
                    $ip_address = '['.$rec['ip_address'].']';
                } else {
                    $ip_address = $rec['ip_address'];
                }
                $ports = explode(',',$rec['virtualhost_port']);
                if(is_array($ports)) {
                    foreach($ports as $port) {
                        $port = intval($port);
                        if($port > 0 && $port < 65536 && $ip_address != '') {
                            $content .= 'NameVirtualHost '.$ip_address.":".$port."\n";
                        }
                    }
                }
            }
        }
        $content .= "\n";
        wf($vhost_conf_dir.'/ispconfig.conf',$content);
        
install/dist/lib/opensuse.lib.php
@@ -535,14 +535,28 @@
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        
        //copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf');
        $content = rf("tpl/apache_ispconfig.conf.master");
        $records = $this->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ".$conf["server_id"]." AND virtualhost = 'y'");
        $content = rf('tpl/apache_ispconfig.conf.master');
        $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
        if(is_array($records) && count($records) > 0) {
            foreach($records as $rec) {
                $content .= "NameVirtualHost ".$rec["ip_address"].":80\n";
                $content .= "NameVirtualHost ".$rec["ip_address"].":443\n";
                if($rec['ip_type'] == 'IPv6') {
                    $ip_address = '['.$rec['ip_address'].']';
                } else {
                    $ip_address = $rec['ip_address'];
                }
                $ports = explode(',',$rec['virtualhost_port']);
                if(is_array($ports)) {
                    foreach($ports as $port) {
                        $port = intval($port);
                        if($port > 0 && $port < 65536 && $ip_address != '') {
                            $content .= 'NameVirtualHost '.$ip_address.":".$port."\n";
                        }
                    }
                }
            }
        }
        $content .= "\n";
        wf($vhost_conf_dir.'/ispconfig.conf',$content);
        
install/lib/installer_base.lib.php
@@ -1145,15 +1145,29 @@
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        // copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf');
        $content = rf('tpl/apache_ispconfig.conf.master');
        $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
        if(is_array($records) && count($records) > 0) {
            foreach($records as $rec) {
                $content .= 'NameVirtualHost '.$rec['ip_address'].":80\n";
                $content .= 'NameVirtualHost '.$rec['ip_address'].":443\n";
                if($rec['ip_type'] == 'IPv6') {
                    $ip_address = '['.$rec['ip_address'].']';
                } else {
                    $ip_address = $rec['ip_address'];
                }
                $ports = explode(',',$rec['virtualhost_port']);
                if(is_array($ports)) {
                    foreach($ports as $port) {
                        $port = intval($port);
                        if($port > 0 && $port < 65536 && $ip_address != '') {
                            $content .= 'NameVirtualHost '.$ip_address.":".$port."\n";
                        }
                    }
                }
            }
        }
        $content .= "\n";
        wf($vhost_conf_dir.'/ispconfig.conf',$content);
interface/web/admin/form/server_ip.tform.php
@@ -137,7 +137,11 @@
        'virtualhost_port' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^([0-9]{1,5}\,{0,1}){1,}$/i',
                                                        'errmsg'=> 'error_port_syntax'),
                                    ),
            'default'    => '80,443',
            'value'        => '',
            'separator'    => '',
            'width'        => '15',
interface/web/admin/lib/lang/en_server_ip.lng
@@ -7,4 +7,5 @@
$wb["virtualhost_port_txt"] = 'HTTP Ports';
$wb["ip_error_wrong"] = 'The IP address is invalid';
$wb["ip_error_unique"] = 'The IP address must be unique';
$wb["error_port_syntax"] = 'Invalid chars in port field, please enter only comma separated numbers. Example: 80,443';
?>
server/conf/apache_ispconfig.conf.master
@@ -50,7 +50,6 @@
Alias /awstats-icon "/usr/share/awstats/icon"
<tmpl_loop name="ip_adresses">
NameVirtualHost {tmpl_var name="ip_address"}:80
NameVirtualHost {tmpl_var name="ip_address"}:443
NameVirtualHost {tmpl_var name="ip_address"}:{tmpl_var name="port"}
</tmpl_loop>
server/plugins-available/apache2_plugin.inc.php
@@ -1181,9 +1181,30 @@
        $tpl = new tpl();
        $tpl->newTemplate('apache_ispconfig.conf.master');
        $records = $app->db->queryAllRecords('SELECT * FROM server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
        if(count($records) > 0) {
            $tpl->setLoop('ip_adresses',$records);
        $records_out= array();
        if(is_array($records)) {
            foreach($records as $rec) {
                if($rec['ip_type'] == 'IPv6') {
                    $ip_address = '['.$rec['ip_address'].']';
                } else {
                    $ip_address = $rec['ip_address'];
                }
                $ports = explode(',',$rec['virtualhost_port']);
                if(is_array($ports)) {
                    foreach($ports as $port) {
                        $port = intval($port);
                        if($port > 0 && $port < 65536 && $ip_address != '') {
                            $records_out[] = array('ip_address' => $ip_address, 'port' => $port);
                        }
                    }
                }
            }
        }
        if(count($records_out) > 0) {
            $tpl->setLoop('ip_adresses',$records_out);
        }
        $vhost_file = escapeshellcmd($web_config['vhost_conf_dir'].'/ispconfig.conf');