note 59556 modified in function.fsockopen by danbrown
| From: | danbrown@php.net | Date: | Sun, 20 Jul 2008 19:38:38 +0000 |
| Subject: | note 59556 modified in function.fsockopen by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142307@lists.php.net to get a copy of this message | ||
This is an ident request example. If your client is running identd your real username will be known
by the server.
It is also usefull to identify people bypassing IP ACLs by using SOCKS proxy and dynamic IP
forwarding. If the socks proxy server uses ident (most unices do) you will know his real username.
For more information see RFC1413
Timeout of 2 seconds in the example may not be enough.
<?php
error_reporting(E_ALL);
$remip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
$remport = $HTTP_SERVER_VARS['REMOTE_PORT'];
ob_implicit_flush();
$fp = fsockopen($remip, 113, $errno, $errstr, 2);
if (!$fp) {
echo "$errstr ($errno)<br>\n";
exit;
}
else {
$out = "$remport, 80\r\n";
fwrite($fp, $out);
$answer=fgets($fp, 128);
}
fclose($fp);
$ansparts=explode(":",$answer);
$user=chop($ansparts[3]);
echo "You are $user@$remip:$remport";
?>
--was--
This is an ident request example. If your client is running identd your real username will be known
by the server.
It is also usefull to identify people bypassing IP ACLs by using SOCKS proxy and dynamic IP
forwarding. If the socks proxy server uses ident (most unices do) you will know his real username.
For more information see RFC1413
Timeout of 2 seconds in the example may not be enough.
<?
error_reporting(E_ALL);
$remip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
$remport = $HTTP_SERVER_VARS['REMOTE_PORT'];
ob_implicit_flush();
$fp = fsockopen($remip, 113, $errno, $errstr, 2);
if (!$fp) {
echo "$errstr ($errno)<br>\n";
exit;
}
else {
$out = "$remport, 80\r\n";
fwrite($fp, $out);
$answer=fgets($fp, 128);
}
fclose($fp);
$ansparts=explode(":",$answer);
$user=chop($ansparts[3]);
echo "You are $user@$remip:$remport";
?>
http://php.net/manual/en/function.fsockopen.php