% if ( $q ) {
<h2>WHOIS Results</h2>
% if ( $TicketObj && RT::IR::TicketType( Ticket => $TicketObj ) eq 'Incident' ) {
<form method="post" action="<% RT->Config->Get('WebPath') %>/RTIR/Tools/Lookup.html">
<input type="hidden" name="incidentid" value="<% $TicketObj->id %>" />
<input type="hidden" name="Subject" value="<% $TicketObj->Subject %>" />
% }
% }
% if ( $WhoisError ) {
<b><% $WhoisError %></b>
% }
<%PERL>
my $DoInvestigate = 0;
if ( $WhoisIterator ) {
    while ( my $obj = $WhoisIterator->next ) {
        my @lines_starting_with_space = grep /^(\s+)(\w+)/, $obj->content;
        if ( $handparse || $#lines_starting_with_space >= 4 ) { #we couldn't parse that. suck
            my $content = join "", $obj->content;
            $m->comp( '/Elements/MakeClicky',
                ticket        => $TicketObj,
                lookup_params => "ticket=". ($TicketObj? $TicketObj->id : 0) ."&server=$WhoisServer",
                content       => \$content,
            );
            $DoInvestigate = 1 if $content =~ /Requestorbox/ig;
</%PERL>
<pre><% $content |n %></pre><br />
%       } else {
Structured RIPE whois data returned. Click <a href="Lookup.html?q=<% $q |u %>&server=<% $WhoisServer |u %>&handparse=1">here</a> to manually parse this data.
<br />Warnings <% $obj->warnings %>
<br />errors <% $obj->errors %>
<hr />
%               foreach my $attribute ( $obj->attributes ) {
%                       foreach my $value ( $obj->$attribute() ) {
                               <b><%$attribute%></b>: 
% $m->comp('/Elements/MakeClicky', ticket => $TicketObj, lookup_params => "ticket=".$TicketObj->id, content => \$value);
<% $value |n %><br />
%                       }
%               }

%       }
% }
% }

%# Don't offer the option of Investigating to unless there are addresses
% if ( $DoInvestigate ) {
<& /Elements/Submit,
    Name => "InvestigateTo",
    Caption => loc("Investigate to selected addresses"),
    Label => loc("Investigate"),
&>
<& /Elements/Submit,
    Name => "InvestigateWithScriptedActions",
    Caption => loc("Investigate to selected addresses"),
    Label => loc("Investigate using scripted action"),
&>
% }
</form>
<%args>
$q =>  undef
$handparse => 1
$TicketObj => undef
$WhoisServer => undef
$server => undef
</%args>
<%init>
$WhoisServer = $server unless defined $WhoisServer;
unless ($WhoisServer) {
    return unless RT->Config->Get('RunWhoisRequestByDefault');
    $WhoisServer = RT::IR->FirstWhoisServer;
}

my ($WhoisIterator, $WhoisError) = RT::IR->WhoisLookup(
    Server => $WhoisServer,
    Query => $q,
    CurrentUser => $session{'CurrentUser'},
);

</%init>
