Jump to content

Check that the host name is not an ip address


jackr1909

Recommended Posts

Hi, i have this code

print get_domain("http://www.somedomain.com"); 

function get_domain($url)
{
  $pieces = parse_url($url);
  $domain = isset($pieces['host']) ? $pieces['host'] : '';
  if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
    return $regs['domain'];
  }
  return false;
}
mysql_query("INSERT INTO table VALUES('', '$domain')");

 

And i want to check that the www.somedomain.com is not an ipaddress or localhost (i.e.

localhost,

127.*.*.*,  - Local

192.168.*.* -LAN

or *.*.*.* (as an ip) - Actual IP

 

Any help would be much appreciated

 

 

thanks,

 

jack

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.