Revision: 7386
          http://sourceforge.net/p/ipcop/svn/7386
Author:   owes
Date:     2014-03-31 04:35:39 +0000 (Mon, 31 Mar 2014)
Log Message:
-----------
Add AfriNIC. Add color and more clearer errors/warnings if lookup fails.

Modified Paths:
--------------
    ipcop/trunk/html/cgi-bin/ipinfo.cgi
    ipcop/trunk/updates/2.1.3/ROOTFILES.i486-2.1.3

Modified: ipcop/trunk/html/cgi-bin/ipinfo.cgi
===================================================================
--- ipcop/trunk/html/cgi-bin/ipinfo.cgi 2014-03-29 08:20:30 UTC (rev 7385)
+++ ipcop/trunk/html/cgi-bin/ipinfo.cgi 2014-03-31 04:35:39 UTC (rev 7386)
@@ -1,12 +1,23 @@
 #!/usr/bin/perl
 #
-# SmoothWall CGIs
+# This file is part of the IPCop Firewall.
 #
-# This code is distributed under the terms of the GPL
+# IPCop is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
 #
+# IPCop is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with IPCop.  If not, see <http://www.gnu.org/licenses/>.
+#
 # (c) The SmoothWall Team
-#
 # (c) 2002 Josh Grubman <j...@false.net> - Multiple registry IP lookup code
+# (c) 2014, the IPCop team
 #
 # $Id$
 #
@@ -31,7 +42,12 @@
 $ENV{'QUERY_STRING'} =~s/&//g;
 my @addrs = split(/ip=/,$ENV{'QUERY_STRING'});
 
-my %whois_servers = 
("RIPE"=>"whois.ripe.net","APNIC"=>"whois.apnic.net","LACNIC"=>"whois.lacnic.net");
+my %whois_servers = (
+    "AfriNIC" => "whois.afrinic.net",
+    "APNIC"   => "whois.apnic.net",
+    "LACNIC"  => "whois.lacnic.net",
+    "RIPE"    => "whois.ripe.net",
+);
 
 &Header::openpage($Lang::tr{'ip info'}, 1, '');
 
@@ -43,19 +59,31 @@
 
     $extraquery='';
     @lines=();
+    my $iaddr = inet_aton($addr);
+    if (! defined($iaddr) ) {
+        &Header::openbox('100%', 'left', $Lang::tr{'lookup failed'}, 'error');
+        print $Lang::tr{'invalid address'} . ": ". &Header::cleanhtml($addr) . 
"<br />";
+        &add_back();
+        &Header::closebox();
+        next;
+    }
     my $whoisname = "whois.arin.net";
-    my $iaddr = inet_aton($addr);
     my $hostname = gethostbyaddr($iaddr, AF_INET);
 
-    if (!$hostname) { 
-        $hostname = $Lang::tr{'lookup failed'}; 
+    if (!$hostname) {
+        &Header::openbox('100%', 'left', $Lang::tr{'lookup failed'}, 
'warning');
+        print $Lang::tr{'lookup failed'} . ": ". &Header::cleanhtml($addr) . 
"<br /><hr />";
     }
+    else {
+        &Header::openbox('100%', 'left', $addr . ' (' . $hostname . ') : 
'.$whoisname);
+    }
 
     my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, 
Proto => 'tcp');
     if ($sock) {
         print $sock "$addr\n";
         while (<$sock>) {
             $extraquery = $1 if (/NetType:\s+Allocated to (\S+)\s+/);
+            $extraquery = $1 if (/NetType:\s+Transferred to (\S+)\s+/);
             push(@lines,$_);
         }
         close($sock);
@@ -79,23 +107,26 @@
         @lines = ( "$Lang::tr{'unable to contact'} $whoisname" );
     }
 
-    &Header::openbox('100%', 'left', $addr . ' (' . $hostname . ') : 
'.$whoisname);
     print "<pre>\n";
     foreach my $line (@lines) {
         print &Header::cleanhtml($line,"y");
     }
     print "</pre>\n";
 
+    &add_back();
+    &Header::closebox();
+}
+
+&Header::closebigbox();
+
+&Header::closepage();
+
+sub add_back {
+
     if (defined($ENV{'HTTP_REFERER'})) {
         # Offer 'back' if there is a referer
         print "<hr /><div align='left'>";
         print "<a href='$ENV{'HTTP_REFERER'}'><img src='/images/back.png' 
alt='$Lang::tr{'back'}' title='$Lang::tr{'back'}' /></a>";
         print "</div>";
     }
-
-    &Header::closebox();
 }
-
-&Header::closebigbox();
-
-&Header::closepage();

Modified: ipcop/trunk/updates/2.1.3/ROOTFILES.i486-2.1.3
===================================================================
--- ipcop/trunk/updates/2.1.3/ROOTFILES.i486-2.1.3      2014-03-29 08:20:30 UTC 
(rev 7385)
+++ ipcop/trunk/updates/2.1.3/ROOTFILES.i486-2.1.3      2014-03-31 04:35:39 UTC 
(rev 7386)
@@ -1,6 +1,7 @@
 ## please place IPCop files first, then packages sorted by alphabetical order
 /etc/profile
 /etc/rc.d/rc.sysinit
+/home/httpd/cgi-bin/ipinfo.cgi
 /home/httpd/cgi-bin/logproxy.cgi
 /home/httpd/cgi-bin/logsystem.cgi
 /home/httpd/cgi-bin/proxy.cgi

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
_______________________________________________
Ipcop-svn mailing list
Ipcop-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipcop-svn

Reply via email to