Lines 27-32
use C4::Context;
Link Here
|
27 |
use List::MoreUtils qw(any); |
27 |
use List::MoreUtils qw(any); |
28 |
use XML::Simple; |
28 |
use XML::Simple; |
29 |
use CGI qw ( -utf8 ); |
29 |
use CGI qw ( -utf8 ); |
|
|
30 |
use Net::Netmask; |
30 |
|
31 |
|
31 |
=head1 DLF ILS-DI for Koha |
32 |
=head1 DLF ILS-DI for Koha |
32 |
|
33 |
|
Lines 156-166
unless ( C4::Context->preference('ILS-DI') ) {
Link Here
|
156 |
|
157 |
|
157 |
# If the remote address is not allowed, redirect to 403 |
158 |
# If the remote address is not allowed, redirect to 403 |
158 |
my @AuthorizedIPs = split(/,/, C4::Context->preference('ILS-DI:AuthorizedIPs')); |
159 |
my @AuthorizedIPs = split(/,/, C4::Context->preference('ILS-DI:AuthorizedIPs')); |
159 |
if ( @AuthorizedIPs # If no filter set, allow access to everybody |
160 |
if ( @AuthorizedIPs ){ # If no filter set, allow access to everybody |
160 |
and not any { $ENV{'REMOTE_ADDR'} eq $_ } @AuthorizedIPs # IP Check |
161 |
my $authorized = 0; |
161 |
) { |
162 |
foreach my $ip (@AuthorizedIPs){ |
162 |
$out->{'code'} = "NotAllowed"; |
163 |
my $netmask = Net::Netmask->new2($ip); |
163 |
$out->{'message'} = "Unauthorized IP address: ".$ENV{'REMOTE_ADDR'}."."; |
164 |
if ( $netmask && $netmask->match($ENV{'REMOTE_ADDR'}) ){ |
|
|
165 |
$authorized = 1; |
166 |
last; |
167 |
} |
168 |
} |
169 |
unless ($authorized){ |
170 |
$out->{'code'} = "NotAllowed"; |
171 |
$out->{'message'} = "Unauthorized IP address: ".$ENV{'REMOTE_ADDR'}."."; |
172 |
} |
164 |
} |
173 |
} |
165 |
|
174 |
|
166 |
my $service = $cgi->param('service') || "ilsdi"; |
175 |
my $service = $cgi->param('service') || "ilsdi"; |
167 |
- |
|
|