View | Details | Raw Unified | Return to bug 36867
Collapse All | Expand All

(-)a/opac/ilsdi.pl (-26 / +27 lines)
Lines 161-196 my $out; Link Here
161
unless ( C4::Context->preference('ILS-DI') ) {
161
unless ( C4::Context->preference('ILS-DI') ) {
162
    $out->{'code'}    = "NotAllowed";
162
    $out->{'code'}    = "NotAllowed";
163
    $out->{'message'} = "ILS-DI is disabled.";
163
    $out->{'message'} = "ILS-DI is disabled.";
164
}
164
} else {
165
165
166
# If the remote address is not allowed, redirect to 403
166
    # If the remote address is not allowed, redirect to 403
167
my @AuthorizedIPs = split( /,/, C4::Context->preference('ILS-DI:AuthorizedIPs') );
167
    my @AuthorizedIPs = split( /,/, C4::Context->preference('ILS-DI:AuthorizedIPs') );
168
if (@AuthorizedIPs) {    # If no filter set, allow access to everybody
168
    if (@AuthorizedIPs) {    # If no filter set, allow access to everybody
169
    my $authorized = 0;
169
        my $authorized = 0;
170
    foreach my $ip (@AuthorizedIPs) {
170
        foreach my $ip (@AuthorizedIPs) {
171
        my $netmask = Net::Netmask->new2($ip);
171
            my $netmask = Net::Netmask->new2($ip);
172
        if ( $netmask && $netmask->match( $ENV{REMOTE_ADDR} ) ) {
172
            if ( $netmask && $netmask->match( $ENV{REMOTE_ADDR} ) ) {
173
            $authorized = 1;
173
                $authorized = 1;
174
            last;
174
                last;
175
            }
175
        }
176
        }
176
    }
177
        unless ($authorized) {
177
    unless ($authorized) {
178
            $out->{'code'}    = "NotAllowed";
179
            $out->{'message'} = "Unauthorized IP address: $ENV{REMOTE_ADDR}.";
180
        }
181
    } else {
178
        $out->{'code'}    = "NotAllowed";
182
        $out->{'code'}    = "NotAllowed";
179
        $out->{'message'} = "Unauthorized IP address: $ENV{REMOTE_ADDR}.";
183
        $out->{'message'} = "Unauthorized IP address: $ENV{REMOTE_ADDR}.";
184
185
        print XMLout(
186
            $out,
187
            noattr        => 1,
188
            nosort        => 1,
189
            xmldecl       => '<?xml version="1.0" encoding="UTF-8" ?>',
190
            RootName      => "ilsdi",
191
            SuppressEmpty => 1
192
        );
193
        exit 0;
180
    }
194
    }
181
} else {
195
182
    $out->{'code'}    = "NotAllowed";
183
    $out->{'message'} = "Unauthorized IP address: $ENV{REMOTE_ADDR}.";
184
185
    print XMLout(
186
        $out,
187
        noattr        => 1,
188
        nosort        => 1,
189
        xmldecl       => '<?xml version="1.0" encoding="UTF-8" ?>',
190
        RootName      => "ilsdi",
191
        SuppressEmpty => 1
192
    );
193
    exit 0;
194
}
196
}
195
197
196
my $service = $cgi->param('service') || "ilsdi";
198
my $service = $cgi->param('service') || "ilsdi";
197
- 

Return to bug 36867