Skip to content

Commit

Permalink
Merge pull request #14 from pointybeard/master
Browse files Browse the repository at this point in the history
Added IP Whitelist Feature
  • Loading branch information
brendo committed Aug 17, 2014
2 parents 94c7834 + 96f5fbb commit b1d5dd7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>maintenance</code>'), 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);
}
Expand Down Expand Up @@ -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');

Expand Down

0 comments on commit b1d5dd7

Please sign in to comment.