From 056352e51e5d888bb65d49c64118d563f91cd0cf Mon Sep 17 00:00:00 2001 From: Alistair Kearney Date: Tue, 12 Aug 2014 12:35:16 +1000 Subject: [PATCH 1/3] Added IP whitelist feature. Accepts space separated list of IP addresses and saves to maintenance_mode->ip_whitelist in the config which is then compared to REMOTE_ADDR. --- extension.driver.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/extension.driver.php b/extension.driver.php index be5ef96..ab771a9 100755 --- a/extension.driver.php +++ b/extension.driver.php @@ -74,6 +74,14 @@ public function appendPreferences($context) { // Append help $group->appendChild(new XMLElement('p', __('Maintenance mode will redirect all visitors, other than developers, to the specified maintenance page. To specify a maintenance page, give a page a type of maintenance'), array('class' => 'help'))); + // IP White list + $label = Widget::Label(__('IP Whitelist')); + $label->appendChild(Widget::Input('settings[maintenance_mode][ip_whitelist]', Symphony::Configuration()->get('ip_whitelist', 'maintenance_mode'))); + $group->appendChild($label); + + // Append help + $group->appendChild(new XMLElement('p', __('Any user that has an IP listed above will be granted access. This eliminates the need to allow a user backend access. Separate each with a space.'), array('class' => 'help'))); + // Append new preference group $context['wrapper']->appendChild($group); } @@ -170,6 +178,13 @@ public function __appendType($context) { public function __checkForMaintenanceMode($context) { if(!Symphony::Engine()->isLoggedIn() && Symphony::Configuration()->get('enabled', 'maintenance_mode') == 'yes'){ + // Check the IP white list + $whitelist = Symphony::Configuration()->get('ip_whitelist', 'maintenance_mode'); + if(strlen(trim($whitelist)) > 0){ + $whitelist = explode(' ', $whitelist); + if(in_array($_SERVER['REMOTE_ADDR'], $whitelist)) return; + } + // Find custom maintenance page $row = PageManager::fetchPageByType('maintenance'); From fecffdb46a1415042ebb56bc0953d6f5dec861e1 Mon Sep 17 00:00:00 2001 From: Alistair Kearney Date: Tue, 12 Aug 2014 12:39:53 +1000 Subject: [PATCH 2/3] Fixed code indentation introduced by previous commit. --- extension.driver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extension.driver.php b/extension.driver.php index ab771a9..1342245 100755 --- a/extension.driver.php +++ b/extension.driver.php @@ -75,9 +75,9 @@ public function appendPreferences($context) { $group->appendChild(new XMLElement('p', __('Maintenance mode will redirect all visitors, other than developers, to the specified maintenance page. To specify a maintenance page, give a page a type of maintenance'), array('class' => 'help'))); // IP White list - $label = Widget::Label(__('IP Whitelist')); - $label->appendChild(Widget::Input('settings[maintenance_mode][ip_whitelist]', Symphony::Configuration()->get('ip_whitelist', 'maintenance_mode'))); - $group->appendChild($label); + $label = Widget::Label(__('IP Whitelist')); + $label->appendChild(Widget::Input('settings[maintenance_mode][ip_whitelist]', Symphony::Configuration()->get('ip_whitelist', 'maintenance_mode'))); + $group->appendChild($label); // Append help $group->appendChild(new XMLElement('p', __('Any user that has an IP listed above will be granted access. This eliminates the need to allow a user backend access. Separate each with a space.'), array('class' => 'help'))); From 96f5fbb32a7d960905552ff2f53757dd20e899f2 Mon Sep 17 00:00:00 2001 From: Alistair Kearney Date: Tue, 12 Aug 2014 12:40:46 +1000 Subject: [PATCH 3/3] Fixed code indentation introduced by previous commit. --- extension.driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension.driver.php b/extension.driver.php index 1342245..385f0d9 100755 --- a/extension.driver.php +++ b/extension.driver.php @@ -79,7 +79,7 @@ public function appendPreferences($context) { $label->appendChild(Widget::Input('settings[maintenance_mode][ip_whitelist]', Symphony::Configuration()->get('ip_whitelist', 'maintenance_mode'))); $group->appendChild($label); - // Append help + // Append help $group->appendChild(new XMLElement('p', __('Any user that has an IP listed above will be granted access. This eliminates the need to allow a user backend access. Separate each with a space.'), array('class' => 'help'))); // Append new preference group