1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Search Engine Bot Reverse & Forward DNS Look Up

Discussion in 'PHP' started by T0PS3O, Nov 30, 2006.

  1. #1
    Google posted the principles of bot verification a while back. MSNbot can now be verified by the same method.

    Can we put our heads together and come up with a way to do this in PHP? Or is there any code out there already? I don't know how to do the DNS lookups, I can fetc IP and UA just fine but from there on....
     
    T0PS3O, Nov 30, 2006 IP
  2. wmtips

    wmtips Well-Known Member

    Messages:
    597
    Likes Received:
    69
    Best Answers:
    1
    Trophy Points:
    150
    #2
    You can use PHP function gethostbyaddr() to convert IP to host name.

    Test for your example IP

    
    <?
    echo gethostbyaddr('207.46.98.149');
    ?>
    
    PHP:
    returns livebot-207-46-98-149.search.live.com. Now you have all data for checking identity of bot :D
     
    wmtips, Nov 30, 2006 IP
  3. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #3
    OK so that would be the reverse DNS part right?

    BTW Looks like it should be gethostbyaddr() instead.

    Combine that with gethostbyname() and we're done.

    OTTOMH:

    
    $bot_hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $bot_ip = gethostbyname($bot_hostname);
    if ($_SERVER['REMOTE_ADDR'] == $bot_ip) {
    echo 'welcome friendly bot!';
    }
    else
    {
    echo 'piss off rogue bot!';
    die("You basterd!");
    }
    
    PHP:
     
    T0PS3O, Nov 30, 2006 IP
  4. wmtips

    wmtips Well-Known Member

    Messages:
    597
    Likes Received:
    69
    Best Answers:
    1
    Trophy Points:
    150
    #4
    Your code does not implement instructions you quoted in your first message, because it does not handle user agent.

    Your code just checks if "bot" has a dedicated IP address. (There are many hostings with many sites on the same IP).
     
    wmtips, Nov 30, 2006 IP
    T0PS3O likes this.
  5. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Aha (d'oh) I need to take the user agent and then match MSNbot with live.com, Googlebot with google.com etc. Thanks for correcting me!
     
    T0PS3O, Nov 30, 2006 IP
  6. everett sizemor

    everett sizemor Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for pointing out this thread to me TOPS3O. I'm subscribing and will be interested in seeing both actions (Reverse > Forward) automated by one or all of the analytics platforms out there as an "on demand" functionality.

    Hint Hint ;)
     
    everett sizemor, Dec 1, 2006 IP
  7. everett sizemor

    everett sizemor Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    everett sizemor, Dec 5, 2006 IP
  8. wmtips

    wmtips Well-Known Member

    Messages:
    597
    Likes Received:
    69
    Best Answers:
    1
    Trophy Points:
    150
    #8
    wmtips, Dec 5, 2006 IP
  9. eKstreme

    eKstreme Guest

    Messages:
    131
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #9
    eKstreme, Dec 7, 2006 IP