PHP.nl

tcpwrap_check

tcpwrap_check

Performs a tcpwrap check

bool **tcpwrap_check** string $daemon string $address string $user bool $nodns

This function consults the and files to check if access to service should be granted or denied for a client. daemon

daemonThe service name.

addressThe client remote address. Can be either an IP address or a domain name.

userAn optional user name.

nodns If looks like domain name then DNS is used to resolve it to IP address; set to true to avoid this. address``nodns

This function returns true if access should be granted, false otherwise.

Voorbeeld: Deny all connections from localhost

If your file contains:

php: 127.0.0.1

And your code looks like:

<?php
if (!tcpwrap_check('php', $_SERVER['REMOTE_ADDR'])) {
  die('You are not welcome here');
}
?>

For more details please consult hosts_access(3) man page.