]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/ipinfo.cgi
Forward Firewall: moved "firewall default behaviour" from firewall page to firewall...
[people/teissler/ipfire-2.x.git] / html / cgi-bin / ipinfo.cgi
index 38e90b08e559bc2474b3645a963c3fde7213a273..71098a2529f8ed1c1e71cee3cfef06f4c91200b0 100644 (file)
-#!/usr/bin/perl\r
-#\r
-# SmoothWall CGIs\r
-#\r
-# This code is distributed under the terms of the GPL\r
-#\r
-# (c) The SmoothWall Team\r
-#\r
-# (c) 2002 Josh Grubman <jg@false.net> - Multiple registry IP lookup code\r
-#\r
-# $Id: ipinfo.cgi,v 1.4.2.3 2005/02/22 22:21:56 gespinasse Exp $\r
-#\r
-\r
-use IO::Socket;\r
-use strict;\r
-\r
-# enable only the following on debugging purpose\r
-#use warnings;\r
-#use CGI::Carp 'fatalsToBrowser';\r
-\r
-require 'CONFIG_ROOT/general-functions.pl';\r
-require "${General::swroot}/lang.pl";\r
-require "${General::swroot}/header.pl";\r
-\r
-my %cgiparams=();\r
-\r
-&Header::showhttpheaders();\r
-\r
-&Header::getcgihash(\%cgiparams);\r
-\r
-$ENV{'QUERY_STRING'} =~s/&//g;\r
-my @addrs = split(/ip=/,$ENV{'QUERY_STRING'});\r
-\r
-my %whois_servers = ("RIPE"=>"whois.ripe.net","APNIC"=>"whois.apnic.net","LACNIC"=>"whois.lacnic.net");\r
-\r
-&Header::openpage($Lang::tr{'ip info'}, 1, '');\r
-\r
-&Header::openbigbox('100%', 'left');\r
-my @lines=();\r
-my $extraquery='';\r
-foreach my $addr (@addrs) {\r
-next if $addr eq "";\r
-       $extraquery='';\r
-       @lines=();\r
-       my $whoisname = "whois.arin.net";\r
-       my $iaddr = inet_aton($addr);\r
-       my $hostname = gethostbyaddr($iaddr, AF_INET);\r
-       if (!$hostname) { $hostname = $Lang::tr{'lookup failed'}; }\r
-\r
-       my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, Proto => 'tcp');\r
-       if ($sock)\r
-       {\r
-               print $sock "$addr\n";\r
-               while (<$sock>) {\r
-                       $extraquery = $1 if (/NetType:    Allocated to (\S+)\s+/);\r
-                       push(@lines,$_);\r
-               }\r
-               close($sock);\r
-               if ($extraquery) {\r
-                       undef (@lines);\r
-                       $whoisname = $whois_servers{$extraquery};\r
-                       my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, Proto => 'tcp');\r
-                       if ($sock)\r
-                       {\r
-                               print $sock "$addr\n";\r
-                               while (<$sock>) {\r
-                                       push(@lines,$_);\r
-                               }\r
-                       }\r
-                       else\r
-                       {\r
-                               @lines = ( "$Lang::tr{'unable to contact'} $whoisname" );\r
-                       }\r
-               }\r
-       }\r
-       else\r
-       {\r
-               @lines = ( "$Lang::tr{'unable to contact'} $whoisname" );\r
-       }\r
-\r
-       &Header::openbox('100%', 'left', $addr . ' (' . $hostname . ') : '.$whoisname);\r
-       print "<pre>\n";\r
-       foreach my $line (@lines) {\r
-               print &Header::cleanhtml($line,"y");\r
-       }\r
-       print "</pre>\n";\r
-       &Header::closebox();\r
-}\r
-\r
-print <<END\r
-<div align='center'>\r
-<table width='80%'>\r
-<tr>\r
-       <td align='center'><a href='$ENV{'HTTP_REFERER'}'>$Lang::tr{'back'}</a></td>\r
-</tr>\r
-</table>\r
-</div>\r
-END\r
-;\r
-\r
-&Header::closebigbox();\r
-\r
-&Header::closepage();\r
+#!/usr/bin/perl
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2010  IPFire Team  <info@ipfire.org>                          #
+#                                                                             #
+# This program 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 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+use IO::Socket;
+use strict;
+
+# enable only the following on debugging purpose
+#use warnings;
+#use CGI::Carp 'fatalsToBrowser';
+
+require '/var/ipfire/general-functions.pl';
+require "${General::swroot}/lang.pl";
+require "${General::swroot}/header.pl";
+
+my %cgiparams=();
+
+&Header::showhttpheaders();
+
+&Header::getcgihash(\%cgiparams);
+
+$ENV{'QUERY_STRING'} =~s/&//g;
+my @addrs = split(/ip=/,$ENV{'QUERY_STRING'});
+
+&Header::openpage($Lang::tr{'ip info'}, 1, '');
+
+&Header::openbigbox('100%', 'left');
+my @lines=();
+my $extraquery='';
+foreach my $addr (@addrs) {
+next if $addr eq "";
+       $extraquery='';
+       @lines=();
+       my $whoisname = "whois.arin.net";
+       my $iaddr = inet_aton($addr);
+       my $hostname = gethostbyaddr($iaddr, AF_INET);
+       if (!$hostname) { $hostname = $Lang::tr{'lookup failed'}; }
+
+       my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, Proto => 'tcp');
+       if ($sock)
+       {
+               print $sock "n $addr\n";
+               while (<$sock>) {
+                       $extraquery = $1 if (/ReferralServer: whois:\/\/(\S+)\s+/);
+                       push(@lines,$_);
+               }
+               close($sock);
+               if ($extraquery) {
+                       undef (@lines);
+                       $whoisname = $extraquery;
+                       my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, Proto => 'tcp');
+                       if ($sock)
+                       {
+                               print $sock "$addr\n";
+                               while (<$sock>) {
+                                       push(@lines,$_);
+                               }
+                       }
+                       else
+                       {
+                               @lines = ( "$Lang::tr{'unable to contact'} $whoisname" );
+                       }
+               }
+       }
+       else
+       {
+               @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";
+       &Header::closebox();
+}
+
+print <<END
+<div align='center'>
+<table width='80%'>
+<tr>
+       <td align='center'><a href='$ENV{'HTTP_REFERER'}'>$Lang::tr{'back'}</a></td>
+</tr>
+</table>
+</div>
+END
+;
+
+&Header::closebigbox();
+
+&Header::closepage();