| version 1.1, 2002/09/04 01:57:03 |
version 1.2, 2002/10/01 11:58:39 |
|
|
| with an ident server running will get their username and os type displayed, |
with an ident server running will get their username and os type displayed, |
| or an error message if no server is running. |
or an error message if no server is running. |
| |
|
| This script shows some of the methods available: user(), osType(), and |
This script shows some of the methods available: |
| identError(). |
user(), getOsType(), and identError() |
| */ |
*/ |
| |
|
| // TODO: change to require_once 'Net/Ident.php'; |
// TODO: change to require_once 'Net/Ident.php'; |
| require_once '../../Net_Ident/Ident.php'; |
require_once '../../Net_Ident/Ident.php'; |
| |
|
| // some users will be going through a proxy - this attempts to work out their real IP address: |
// some users will be going through a proxy - this attempts to work out their |
| |
// real IP address: |
| if (getenv('HTTP_X_FORWARDED_FOR') != '') { |
if (getenv('HTTP_X_FORWARDED_FOR') != '') { |
| $addr = getenv('HTTP_X_FORWARDED_FOR'); |
$addr = getenv('HTTP_X_FORWARDED_FOR'); |
| } else { |
} else { |
| $addr = $HTTP_SERVER_VARS['REMOTE_ADDR']; |
$addr = $_SERVER['REMOTE_ADDR']; |
| } |
} |
| |
|
| // Object construction |
// Object construction |
| $ident = new Net_Ident($addr, $HTTP_SERVER_VARS['REMOTE_PORT'], $HTTP_SERVER_VARS['SERVER_PORT']); |
$ident = new Net_Ident($addr, $_SERVER['REMOTE_PORT'], |
| |
$_SERVER['SERVER_PORT']); |
| |
|
| if (PEAR::isError($err = $ident->query())) { |
if (PEAR::isError($err = $ident->query())) { |
| die(htmlspecialchars($err->getMessage())); |
die(htmlspecialchars($err->getMessage())); |
| } |
} |
| |
|
| if ($ident->user() === false) { |
if ($ident->user() === false) { |
| print 'Ident query failed: '.htmlspecialchars($ident->identError()).'.<br>'."\n"; |
print 'Ident query failed: '.htmlspecialchars($ident->identError()) |
| |
.'.<br>'."\n"; |
| } else { |
} else { |
| print 'Ident query OK, username "'.htmlspecialchars($ident->user()) |
print 'Ident query OK, username "'.htmlspecialchars($ident->user()) |
| .'", operating system type "'.htmlspecialchars($ident->osType()).'".<br>'."\n"; |
.'", operating system type "'.htmlspecialchars($ident->getOsType()) |
| |
.'".<br>'."\n"; |
| } |
} |
| |
|
| ?> |
?> |