]>
jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - misc/ip-whois-misc.php
3 function get_ip_whois($ip)
5 $w = get_ip_whois_from_server('whois.iana.org' , $ip);
7 preg_match("#whois:\s*([\w.]*)#si" , $w , $data);
9 $whois_server = $data[1];
10 $whois_data = get_ip_whois_from_server($whois_server , $ip);
15 function get_ip_whois_from_server($server , $ip)
18 $server = trim($server);
22 return Message
::Fail("Lookup failed: Could not find appropriate WHOIS server. Maybe you typed an incorrect IP?");
25 $f = fsockopen($server, 43, $errno, $errstr, 3); //Open a new connection
29 Message
::Fail("Lookup failed: Could not open socket");
32 // Set the timeout limit for read
33 if (!stream_set_timeout($f , 3))
35 return Message
::Fail("Lookup failed: Connection timed out");
38 // Send the IP to the whois server
41 $message = $ip . "\r\n";
46 if( !stream_set_timeout($f , 3))
48 return Message
::Fail("Lookup failed: Unable to stream_set_timeout");
51 // Set socket in non-blocking mode
52 stream_set_blocking ($f, 0 );
54 // If connection still valid
59 $data .= fread($f , 128);
63 // Now return the data
67 function generate_ip_whois_table($data)
70 <div
class="container-xl">
71 <table
class="table table-responsive-xl caption-top table-hover">
75 foreach ($d as $key => $val)
78 <tr
><th
><?php
echo htmlspecialchars($key); ?></th
><td
>
80 if (filter_var($val, FILTER_VALIDATE_EMAIL
))
81 $val = "<a href=\"mailto:$val\">$val</a>";
82 echo "<code>$val</code>";