如何避免用户将localhost或127.0.0.1或self ip传递给loadHTML?

I have a simple function for checking the web site title:

$doc = new DOMDocument();
@$doc->loadHTMLFile($aUrl);
$xpath = new DOMXPath($doc);     

if(!isset($xpath->query('//title')->item(0)->nodeValue)) 
{             
     return FALSE;
}                              

return $xpath->query('//title')->item(0)->nodeValue;  

But if the user pass the localhost or 127.0.0.1, they can get my host data, I can make a simple guide to allow user input these value, but sometimes, I can't ensure the internal ip, like 192.168.11.2, how can I protect the site won't query back my host? Thank you.

add this line to begining

if( preg_match( "/^(http:\/\/)(localhost|127.0.0.1|{$_SERVER["SERVER_ADDR"]}|{$_SERVER["HTTP_HOST"]}|www.yourhost.net)/i", $aUrl )) die( 'error' );

it may help

127.0.0.1 or localhost for the external user will be their own computer / host set a condition, where you check the hostname is not $_SERVER['SERVER_ADDR'] or $_SERVER['SERVER_NAME']