Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    dpc
    dpc is offline
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using exec function to get rDNS info, is there a better way?

    I'm trying to get dns info for any sites that visit my page, but it seems to lag a bit. Here is my code:

    Code:
    $rdns_code = exec('dig +noall +answer -x '.getenv('REMOTE_ADDR'));
    Is there a better way of doing this? Also, I'm using php4.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    dig isn't very fast, and even less so if you are running it on every request. You could try gethostbyaddr(), but I'm not sure that is going to be any faster. In general looking up the remote host on every request is a bad idea.

  • #3
    Regular Coder
    Join Date
    Sep 2007
    Location
    Grahamstown, South Africa
    Posts
    237
    Thanks
    6
    Thanked 17 Times in 17 Posts
    I reckon, store the ip addresses in a temporary table.

    Then, run a cron job, which implements some form of caching to translate the ip addresses into domain names. The caching wont help a truckload in this case, but 100mb or so of cache in a db translates to quite a few ip addresses -> domain names.

    I assume you are doing this for statistical purposes? If not, the cron job solution would probably not be viable to you as I then assume you need the data in real time.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •