Skip to content

Instantly share code, notes, and snippets.

@eto4detak
Created May 24, 2017 09:55
Show Gist options
  • Save eto4detak/15cb9e50257533c84463bf47480ee2aa to your computer and use it in GitHub Desktop.
Save eto4detak/15cb9e50257533c84463bf47480ee2aa to your computer and use it in GitHub Desktop.
socket
<?php
// $sock = fsockopen("localhost",80);
// if (!$sock) {
// echo "$errstr ($errno)<br>\n";
// }
// else {
// fputs ($sock, "GET /startHtml.html HTTP/1.0\n\n");
// while (!feof($sock))
// {
// echo fgets ($sock);
// }
// fclose ($sock);
// }
$ip = getenv("REMOTE_ADDR");
//echo "$ID" . "<BR>";
$sock = fsockopen("whois.ripe.net",43,$errno,$errstr);
if (!$sock)
{
echo "$errstr ($errno)<br>\n";
return;
}
else
{
fputs($sock, $ip."\r\n");
while (!feof($sock))
{
echo (str_replace(":", ":&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;",
fgets($sock,128)) . "<br>");
}
fclose ($sock);
}
echo "<br>" . "==============================================" . "<br>";
$hosts = gethostbynamel('www.onliner.by');
echo "ip: www.onliner.by = ";
print_r($hosts);
echo "<br>" . "==============================================" . "<br>";
$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
echo "доменное имя: ";
echo $host;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment