The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
Only Allow Whitelisted IP's ? - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 4.4 (https://userspice.com/forums/forumdisplay.php?fid=27)
+--- Thread: Only Allow Whitelisted IP's ? (/showthread.php?tid=1329)



Only Allow Whitelisted IP's ? - truemama - 02-07-2019

Hey Guys,

I see that it's possible to black list and white list IPs.

Is it possible to only allow whitelisted IPs to login...i.e. lock the whole system down apart from whitelisted IP's?

Cheers,

Matt


RE: Only Allow Whitelisted IP's ? - mudmin - 02-07-2019

There are a few ways you can handle this.

//go to users/maintenance.php and delete the line
if($settings->site_offline==0) Redirect::to($us_url_root.'index.php');

Then just go to usersc/includes/head_tags.php
At the bottom, open your php tag and use one of the two of these if statements

//if you want a massive amount of IPs that you can control from the dashboard, you can do
if($currentPage != 'maintenance.php'){//prevent redirect loops
$ip = ipCheck();
$check = $db->query("SELECT ip FROM us_ip_whitelist WHERE ip = ?",[$ip])->count();
if($check < 1){
Redirect::to($us_url_root.'users/maintenance.php');
}
}

//if you only want a few ip's to visit the site, then putting them in an array is a little faster
$ips = [
'127.0.0.1','192.168.95.153'
];
if($currentPage != 'maintenance.php'){//prevent redirect loops
$ip = ipCheck();
if(!in_array($ip,$ips)){
Redirect::to($us_url_root.'users/maintenance.php');
}
}