From f9c955a82a33160b8563548b9c49e5ce0f4f2e34 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Fri, 28 Apr 2023 19:57:52 +0000 Subject: [PATCH] - Fixed port redirection for URL behind proxy --- src/ControlStructure/SectionToken.php | 21 +++++++++------------ src/Extension/UrlExtension.php | 7 ++++++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/ControlStructure/SectionToken.php b/src/ControlStructure/SectionToken.php index 2b0eac5..85c6d54 100644 --- a/src/ControlStructure/SectionToken.php +++ b/src/ControlStructure/SectionToken.php @@ -62,13 +62,13 @@ class SectionToken implements ControlStructure { $order = $options['order'] ?? "count(\$___class__template->sectionList[$name]['$action'])"; - return "sectionList[$name] ??= [ 'prepend' => [], 'append' => [], 'default' => [] ];". + return "sectionList[$name] ??= [ 'prepend' => [], 'append' => [], 'default' => [] ];" . "\$___class__template->sectionList[$name]['$action'][] = [ 'order' => $order, - 'callback' => function() use (\$picea, \$___class__template, \$___global_variables, \$___variables, \$__event) {". - "extract(\$___global_variables); extract(\$___variables, \EXTR_OVERWRITE); - \$___class__template->sectionStack[] = $name; - \$__event->eventExecute(\Picea\Event\Builder\ClassTemplateRenderSection::class, $name);?>"; + 'callback' => function() use (\$picea, \$___class__template, \$___global_variables, \$___variables, \$__event) {" . + "extract(\$___global_variables); extract(\$___variables, \EXTR_OVERWRITE);" . + "\$___class__template->sectionStack[] = $name;" . + "\$__event->eventExecute(\Picea\Event\Builder\ClassTemplateRenderSection::class, $name);?>"; } protected function printEndSection($context) : string @@ -76,13 +76,10 @@ class SectionToken implements ControlStructure { $section = array_pop($context->sections); $build = $context->extendFrom ? "!empty(\$___class__template->sectionStack) && \$___class__template->renderSection({$section['name']}, false);" : "\$___class__template->renderSection({$section['name']}, false);"; - return <<eventExecute(\Picea\Event\Builder\ClassTemplateRenderSectionDone::class, {$section['name']}); - array_pop(\$___class__template->sectionStack); }]; - $build - ?> - PHP; + return "eventExecute(\Picea\Event\Builder\ClassTemplateRenderSectionDone::class, {$section['name']});" . + "array_pop(\$___class__template->sectionStack); }];" . + $build . + "?>"; } } \ No newline at end of file diff --git a/src/Extension/UrlExtension.php b/src/Extension/UrlExtension.php index 5708236..91eceec 100644 --- a/src/Extension/UrlExtension.php +++ b/src/Extension/UrlExtension.php @@ -195,7 +195,12 @@ PATTERN; protected function domain() : string { - $port = $this->isDefaultPort() ? "" : ":" . $_SERVER['SERVER_PORT']; + if ( ! empty($_SERVER['HTTP_X_FORWARDED_PROTO']) || ! empty($_SERVER['HTTP_X_FORWARDED_SSL']) ) { + $port = ""; + } + else { + $port = $this->isDefaultPort() ? "" : ":" . $_SERVER['SERVER_PORT']; + } return strtolower($this->appUrl ? $this->appUrl . $port : $_SERVER['HTTP_HOST']); }