diff --git a/install/install.php b/install/install.php index 90b09a5f..a0d120df 100644 --- a/install/install.php +++ b/install/install.php @@ -602,8 +602,11 @@ if(isset($_POST['installstep']) // and lets insert the default ip and port - $query = 'INSERT INTO `%s` SET `ip` = \'%s\', `port` = \'80\' '; - $query = sprintf($query, TABLE_PANEL_IPSANDPORTS, $db->escape($serverip)); + $query = "INSERT INTO `".TABLE_PANEL_IPSANDPORTS."` + SET `ip`= '".$db->escape($serverip)."', + `port` = '80', + `vhostcontainer` = '1', + `vhostcontainer_servername_statement` = '1'"; $db->query($query); $defaultip = $db->insert_id(); diff --git a/scripts/jobs/cron_tasks.inc.http.10.apache.php b/scripts/jobs/cron_tasks.inc.http.10.apache.php index b8a11444..f9df5fa6 100644 --- a/scripts/jobs/cron_tasks.inc.http.10.apache.php +++ b/scripts/jobs/cron_tasks.inc.http.10.apache.php @@ -121,11 +121,33 @@ class apache { $this->virtualhosts_data[$vhosts_filename].= '' . "\n"; + /** + * add 'real'-vhost content here, like doc-root :) + */ + $mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__)))); + $this->virtualhosts_data[$vhosts_filename].= 'DocumentRoot "'.$mypath.'"'."\n"; + if($row_ipsandports['vhostcontainer_servername_statement'] == '1') { $this->virtualhosts_data[$vhosts_filename].= ' ServerName ' . $this->settings['system']['hostname'] . "\n"; } + /** + * dirprotection, see #72 + */ + $this->virtualhosts_data[$vhosts_filename].= "\t\n"; + $this->virtualhosts_data[$vhosts_filename].= "\t\tAllow from all\n"; + $this->virtualhosts_data[$vhosts_filename].= "\t\tOptions -Indexes\n"; + $this->virtualhosts_data[$vhosts_filename].= "\t\n"; + + $this->virtualhosts_data[$vhosts_filename].= "\t\n"; + $this->virtualhosts_data[$vhosts_filename].= "\t\tOrder Deny,Allow\n"; + $this->virtualhosts_data[$vhosts_filename].= "\t\tDeny from All\n"; + $this->virtualhosts_data[$vhosts_filename].= "\t\n"; + /** + * end of dirprotection + */ + if($row_ipsandports['specialsettings'] != '') { $this->virtualhosts_data[$vhosts_filename].= $row_ipsandports['specialsettings'] . "\n"; diff --git a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php index 3bf9ceda..f804d00f 100644 --- a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php +++ b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php @@ -68,7 +68,7 @@ class lighttpd public function createIpPort() { - $query = "SELECT `id`, `ip`, `port`, `listen_statement`, `namevirtualhost_statement`, `vhostcontainer`, " . " `vhostcontainer_servername_statement`, `specialsettings`, `ssl`, `ssl_cert_file` " . " FROM `" . TABLE_PANEL_IPSANDPORTS . "` ORDER BY `ip` ASC, `port` ASC"; + $query = "SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` ORDER BY `ip` ASC, `port` ASC"; $result_ipsandports = $this->db->query($query); while($row_ipsandports = $this->db->fetch_array($result_ipsandports)) @@ -100,7 +100,31 @@ class lighttpd $this->lighttpd_data[$vhost_filename].= 'server.port = ' . $port . "\n"; $this->lighttpd_data[$vhost_filename].= 'server.bind = "' . $ip . '"' . "\n"; } - + + if($row_ipsandports['vhostcontainer'] == '1') + { + $myhost = str_replace('.', '\.', $this->settings['system']['hostname']); + $this->lighttpd_data[$vhost_filename].= '# Froxlor default vhost' . "\n"; + $this->lighttpd_data[$vhost_filename].= '$HTTP["host"] =~ "^(?:www\.|)' . $myhost . '$" {' . "\n"; + + $mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__)))); + $this->lighttpd_data[$vhost_filename].= ' server.document-root = "'.$mypath.'"'."\n"; + + /** + * dirprotection, see #72 + */ + $this->lighttpd_data[$vhost_filename].= ' $HTTP["url"] =~ "^/(actions|install|lib|lng|scripts|temp)" {' . "\n"; + $this->lighttpd_data[$vhost_filename].= ' url.access-deny = ("")' . "\n"; + $this->lighttpd_data[$vhost_filename].= ' }' . "\n"; + + if($row_ipsandports['specialsettings'] != '') + { + $this->lighttpd_data[$vhost_filename].= $row_ipsandports['specialsettings'] . "\n"; + } + + $this->lighttpd_data[$vhost_filename].= '}' . "\n"; + } + if($row_ipsandports['ssl'] == '1') { $this->lighttpd_data[$vhost_filename].= 'ssl.engine = "enable"' . "\n"; @@ -116,7 +140,7 @@ class lighttpd if($vhosts !== null && is_array($vhosts) && isset($vhosts[0])) { foreach($vhosts as $vhost) { - $this->lighttpd_data[$vhost_filename].= ' include "vhosts/'.basename($vhost).'"'."\n"; + $this->lighttpd_data[$vhost_filename].= ' include "'.$vhost.'"'."\n"; } } diff --git a/templates/admin/ipsandports/ipsandports_edit.tpl b/templates/admin/ipsandports/ipsandports_edit.tpl index 8f9b3897..7d83c7f9 100644 --- a/templates/admin/ipsandports/ipsandports_edit.tpl +++ b/templates/admin/ipsandports/ipsandports_edit.tpl @@ -43,15 +43,11 @@ $header $namevirtualhost_statement - {$lng['admin']['ipsandports']['create_vhostcontainer']}: -
{$lng['panel']['not_supported']}lighttpd
- + {$lng['admin']['ipsandports']['create_vhostcontainer']}: $vhostcontainer - {$lng['admin']['ownvhostsettings']}:
{$lng['serversettings']['default_vhostconf']['description']} -
{$lng['panel']['not_supported']}lighttpd
- + {$lng['admin']['ownvhostsettings']}:
{$lng['serversettings']['default_vhostconf']['description']}