Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added IP Whitelist Feature #14

Merged
merged 3 commits into from
Aug 17, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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