Jump to content

[SOLVED] IP part match


Cep

Recommended Posts

Thanks :)

 

So the following should work then,

    if (preg_match("65\.54\.188.\(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)", $ipaddress)) {
      $ipaddress = $ipaddress." - MSN Search Bot";
      $user_name = "Bot";
    }
    
    if (preg_match("65\.249\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).\(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)", $ipaddress)) {
       $ipaddress = $ipaddress." - Google Crawler Bot";
       $user_name = "Bot";
    }

 

It should work but I get a delimiter error.

 

 

 

Oops no I got it sorted now should be,

 

    if (preg_match("/65.54.188.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/", $ipaddress)) {
      $ipaddress = $ipaddress." - MSN Search Bot";
      $user_name = "Bot";
    }

    if (preg_match("/65.249.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/", $ipaddress)) {
       $ipaddress = $ipaddress." - Google Crawler Bot";
       $user_name = "Bot";
    }

 

Cheers for your help! :)

Link to comment
https://forums.phpfreaks.com/topic/52315-solved-ip-part-match/#findComment-258130
Share on other sites

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.