#!/usr/bin/perl

use CGI qw/:standard/;

$q = new CGI;

#
# logout will close the connection.
# 
#print "Content-Type: text/plain\r\nConnection: close\r\n\r\n";
# or not ..
print "Content-Type: text/plain\r\n\r\n";

print <<EOH;
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0
     epp-1.0.xsd">
EOH


print "\n<!-- This is the logout handler script\n\n";
print "\tInteresting ENV parameters:\n";
print map { "\t\t$_\t$ENV{$_}\n"} ( qw{ QUERY_STRING REMOTE_ADDR REQUEST_URI SCRIPT_NAME });
print "  -->";


#print "\n\nCGI parameters: \n";
#@names = $q->param;
#print map { "$_\t" . $q->param($_) . "\n"} (@names);

my $cltrid = $q->param("clTRID");

$cltrid = "not-given" unless (defined($cltrid));

print <<EOM;


  <response>
    <result code="1500">
      <msg lang="en">User $ENV{REMOTE_USER} logged out. Closing Connection.</msg>
    </result>
    <trID>
      <clTRID>$cltrid</clTRID>
    </trID>
  </response>
EOM

print "\n</epp>";


