#!/usr/bin/perl

#use utf8;
use strict;
use CGI;

use Opals::Context;#use MARC::File::USMARC;

my $dbh = Opals::Context->dbh();
END { $dbh->disconnect(); }
my $cgi = CGI->new;
my $input = $cgi->Vars();

my $ubc= $input->{'ubc'};

my $resFmtStr="
<response>
    <status>%d</status>
    <error>%s</error>
    <firstname>%s</firstname>
    <lastname>%s</lastname>
</response>";

my($status,$error,$firstname,$lastname)=(0,"","","");
my $sth=$dbh->prepare("select firstname,lastname from opl_user where userbarcode=? || sid=?");
$sth->execute($ubc, $ubc);
if(($firstname,$lastname) =$sth->fetchrow_array){
    $status=1;
}
my $response= sprintf($resFmtStr,$status,$error,$firstname,$lastname);
print "Content-type: text/xml\n\n";
print $response;

