diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php index 96dd7dce5..dc3153262 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php @@ -39,10 +39,10 @@ static public function getFromSocket( $socket ) { return null; } switch( $version ) { - case '4.0': - return Mage::getModel( - 'turpentine/varnish_configurator_version4', - array( 'socket' => $socket ) ); + case '4.0': + return Mage::getModel( + 'turpentine/varnish_configurator_version4', + array( 'socket' => $socket ) ); case '3.0': return Mage::getModel( @@ -209,17 +209,17 @@ protected function _getNormalizeHostTarget() { * @return string */ public function getAllowedHostsRegex() { - $hosts = array(); - foreach( Mage::app()->getStores() as $store ) { - $hosts[] = parse_url( $store->getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB , false ), PHP_URL_HOST ); - } - - $hosts = array_values(array_unique( $hosts )); - + $hosts = array(); + foreach( Mage::app()->getStores() as $store ) { + $hosts[] = parse_url( $store->getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB , false ), PHP_URL_HOST ); + } + + $hosts = array_values(array_unique( $hosts )); + $pattern = '('.implode('|', array_map("preg_quote", $hosts)).')'; - return $pattern; + return $pattern; } - + /** * Get the base url path regex * @@ -292,7 +292,7 @@ protected function _getDefaultBackend() { 'first_byte_timeout' => $timeout . 's', 'between_bytes_timeout' => $timeout . 's', ); - if ( Mage::getStoreConfigFlag( 'turpentine_vcl/backend/load_balancing' ) ) { + if ( Mage::getStoreConfigFlag( 'turpentine_vcl/backend/load_balancing' ) != 'no' ) { return $this->_vcl_director( 'default', $default_options ); } else { return $this->_vcl_backend( 'default', @@ -313,7 +313,7 @@ protected function _getAdminBackend() { 'first_byte_timeout' => $timeout . 's', 'between_bytes_timeout' => $timeout . 's', ); - if ( Mage::getStoreConfigFlag( 'turpentine_vcl/backend/load_balancing' ) ) { + if ( Mage::getStoreConfigFlag( 'turpentine_vcl/backend/load_balancing' ) != 'no' ) { return $this->_vcl_director( 'admin', $admin_options ); } else { return $this->_vcl_backend( 'admin', @@ -821,7 +821,7 @@ protected function _getTemplateVars() { 'admin_frontname' => $this->_getAdminFrontname(), 'normalize_host_target' => $this->_getNormalizeHostTarget(), 'url_base_regex' => $this->getBaseUrlPathRegex(), - 'allowed_hosts_regex' => $this->getAllowedHostsRegex(), + 'allowed_hosts_regex' => $this->getAllowedHostsRegex(), 'url_excludes' => $this->_getUrlExcludes(), 'get_param_excludes' => $this->_getGetParamExcludes(), 'get_param_ignored' => $this->_getIgnoreGetParameters(), @@ -872,7 +872,7 @@ protected function _getTemplateVars() { if( Mage::getStoreConfig( 'turpentine_vcl/normalization/cookie_target' ) ) { $vars['normalize_cookie_target'] = $this->_getNormalizeCookieTarget(); } - + $customIncludeFile = $this->_getCustomIncludeFilename(); if( is_readable( $customIncludeFile ) ) { $vars['custom_vcl_include'] = file_get_contents( $customIncludeFile );