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 164-174
unless ( C4::Context->preference('ILS-DI') ) {
Link Here
|
164 |
|
165 |
|
165 |
# If the remote address is not allowed, redirect to 403 |
166 |
# If the remote address is not allowed, redirect to 403 |
166 |
my @AuthorizedIPs = split(/,/, C4::Context->preference('ILS-DI:AuthorizedIPs')); |
167 |
my @AuthorizedIPs = split(/,/, C4::Context->preference('ILS-DI:AuthorizedIPs')); |
167 |
if ( @AuthorizedIPs # If no filter set, allow access to everybody |
168 |
if ( @AuthorizedIPs ){ # If no filter set, allow access to everybody |
168 |
and not any { $ENV{'REMOTE_ADDR'} eq $_ } @AuthorizedIPs # IP Check |
169 |
my $authorized = 0; |
169 |
) { |
170 |
foreach my $ip (@AuthorizedIPs){ |
170 |
$out->{'code'} = "NotAllowed"; |
171 |
my $netmask = Net::Netmask->new2($ip); |
171 |
$out->{'message'} = "Unauthorized IP address: ".$ENV{'REMOTE_ADDR'}."."; |
172 |
if ( $netmask && $netmask->match($ENV{'REMOTE_ADDR'}) ){ |
|
|
173 |
$authorized = 1; |
174 |
last; |
175 |
} |
176 |
} |
177 |
unless ($authorized){ |
178 |
$out->{'code'} = "NotAllowed"; |
179 |
$out->{'message'} = "Unauthorized IP address: ".$ENV{'REMOTE_ADDR'}."."; |
180 |
} |
172 |
} |
181 |
} |
173 |
|
182 |
|
174 |
my $service = $cgi->param('service') || "ilsdi"; |
183 |
my $service = $cgi->param('service') || "ilsdi"; |
175 |
- |
|
|