X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=scripts%2FRFID-JSONP-server.pl;h=f29c638262586f47c38991455af544e9dd7d5b7f;hb=5f2e55f0a56d3ea9dd7f360445e17c2c523933d0;hp=298ff177aac5134c1ddcf7e7b1c0d21d7a99f541;hpb=0322ec7c429d2abc2020326e0ca09225f75be478;p=Biblio-RFID.git diff --git a/scripts/RFID-JSONP-server.pl b/scripts/RFID-JSONP-server.pl index 298ff17..f29c638 100755 --- a/scripts/RFID-JSONP-server.pl +++ b/scripts/RFID-JSONP-server.pl @@ -37,6 +37,10 @@ my $sip2 = { password => 'viva2koha', loc => 'FFZG', }; +my $afi = { + secure => 0xDA, + unsecure => 0xD7, +}; use Getopt::Long; @@ -220,7 +224,7 @@ sub http_server { warn "PROGRAM $tag $content\n"; $rfid->write_blocks( $tag => $content ); - $rfid->write_afi( $tag => chr( $param->{$p} =~ /^130/ ? 0xDA : 0xD7 ) ); + $rfid->write_afi( $tag => chr( $param->{$p} =~ /^130/ ? $afi->{secure} : $afi->{unsecure} ) ); } print $client "HTTP/1.0 $status $method\r\nLocation: $server_url\r\n\r\n"; @@ -263,12 +267,18 @@ sub http_server { $hash = sip2_message("63000${ts} AO$loc|AA$patron|AC$password|"); } elsif ( $method eq 'checkout' ) { - my ($patron,$barcode) = split(/\//, $args, 2); + my ($patron,$barcode,$sid) = split(/\//, $args, 3); $hash = sip2_message("11YN${ts} AO$loc|AA$patron|AB$barcode|AC$password|BON|BIN|"); + if ( substr( $hash->{fixed}, 2, 1 ) == 1 ) { + $rfid->write_afi( $sid => chr( $afi->{unsecure} ) ); + } } elsif ( $method eq 'checkin' ) { - my $barcode = $args; + my ($patron,$barcode,$sid) = split(/\//, $args, 3); $hash = sip2_message("09N${ts}${ts}AP|AO${loc}|AB$barcode|AC|BIN|"); + if ( substr( $hash->{fixed}, 2, 1 ) == 1 ) { + $rfid->write_afi( $sid => chr( $afi->{secure} ) ); + } } else { print $client "HTTP/1.0 500 $method not implemented\r\n\r\n"; }