note 59556 deleted from function.fsockopen by cmb
| From: | cmb@php.net | Date: | Sun, 07 Jul 2019 07:49:05 +0000 |
| Subject: | note 59556 deleted from function.fsockopen by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211490@lists.php.net to get a copy of this message | ||
Note Submitter: sivann at cs dot ntua dot gr
----
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";
?>