From 8dc0f9dab6a36493078aa1bf4c2a3566f98ec70f Mon Sep 17 00:00:00 2001 From: Romain Gautier Date: Sun, 16 Nov 2014 16:20:02 +0100 Subject: [PATCH] updated windows detection --- index.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/index.php b/index.php index 7d5a777..af5e9fa 100644 --- a/index.php +++ b/index.php @@ -84,6 +84,7 @@ define('PATH_TO_DISPLAY', $path_to_display); define('WAMP_PATH', realpath($wamp_path).'\\'); +define('IS_WINDOWS', preg_match('#^(winnt|cygwin)$#i', PHP_OS)); /** @@ -546,15 +547,15 @@ function getVhosts($vhost_config_path) } // use apache_get_version - if ('Darwin' === PHP_OS) { + if (!IS_WINDOWS) { $vhost_default_conf = << ServerName PROJECT.localhost ServerAlias PROJECT.localhost.com - DocumentRoot "%s/PATH" - + DocumentRoot "%sPATH" + Options Indexes FollowSymLinks ExecCGI Includes AllowOverride All Require all granted @@ -562,21 +563,23 @@ function getVhosts($vhost_config_path) VHOST; $vhost_path_config = '/etc/apache2/extra/httpd-vhosts.conf'; + $slash = '/'; } else { $vhost_default_conf = << ServerName PROJECT.localhost ServerAlias PROJECT.localhost.com - DocumentRoot "%s/PATH" - + DocumentRoot "%sPATH" + allow from all VHOST; $vhost_path_config = WAMP_PATH.'vhost\PROJECT.conf'; + $slash = '\\'; } - $vhost_default_conf = sprintf($vhost_default_conf, realpath($path_to_display), realpath($path_to_display)); + $vhost_default_conf = sprintf($vhost_default_conf, realpath($path_to_display).$slash, realpath($path_to_display).$slash); $vhost_default_conf = htmlentities($vhost_default_conf); $vhost_default_conf = preg_replace('#PROJECT#', 'PROJECT', $vhost_default_conf); $vhost_default_conf = preg_replace('#PATH#', 'PATH', $vhost_default_conf); @@ -584,7 +587,7 @@ function getVhosts($vhost_config_path) } $hosts_path = '/etc/hosts'; -if (false !== strpos(strtolower(PHP_OS), 'cygwin')) { +if (IS_WINDOWS) { $hosts_path = 'C:\Windows\System32\drivers\etc\hosts'; } @@ -681,12 +684,10 @@ function getVhosts($vhost_config_path) Example vhost
- - - Add Include "vhost\*.conf" in %s', substr($apache_conf, 0, -10), substr($apache_conf, -10)); ?>
- + + Add Include "vhost\*.conf" in %s', substr($apache_conf, 0, -10), substr($apache_conf, -10)); ?>
- You must write this conf inside and create a directory /PATH
+ You must write this conf inside and create a directory PATH
Don't forget to add your domains in like 127.0.0.1 PROJECT.localhost.com PROJECT.localhost