SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    usa
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    show visitor IP Info, location, etc etc

    Looking for php script which show the the visitor the info about their
    IP
    Location
    etc etc

    just like here

    http://ip-address.domaintools.com/

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,150
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    network functions

    PHP has quite a few Network functions. Why not just get the values and echo them?

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    usa
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    PHP has quite a few Network functions. Why not just get the values and echo them?
    thanks for reply ..
    I know its simple but I am not a php programmer ..
    just like to know if any one already prepared a script so that I can use ..

    I won;t mind a small fee for a script if it is little more advanced ..

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,150
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    network functions

    Using PHP's network functions and predefined variables can't be simpler. http://us2.php.net/network If you can figure out how to integrate someone else's code, you can do this yourself. Check out the documentation and you'll find "contributed" examples. eg. http://us2.php.net/manual/en/function.gethostbyaddr.php
    PHP Code:
    <?php
    $hostname 
    gethostbyaddr($_SERVER['REMOTE_ADDR']);
     
    echo 
    $hostname;
    ?>
    http://us2.php.net/manual/en/function.gethostbyname.php
    PHP Code:
    <?php
    $ip 
    gethostbyname('www.example.com');

    echo 
    $ip;
    ?>
    http://us2.php.net/manual/en/functio...ostbynamel.php
    PHP Code:
    <?php
      $hosts 
    gethostbynamel('www.example.com');
      
    print_r($hosts);
    ?>
    To get the array of information you can combine the example code into something like
    PHP Code:
    <?php
    $hostname 
    gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $hosts gethostbynamel("$hostname");
    echo 
    $hosts;
    ?>
    This will give you more information than you want. Then just access the array info you're interested in.
    The other information is available from PHP's predefined variables http://us2.php.net/manual/en/reserved.variables.php eg.
    $_SERVER['REQUEST_METHOD']
    $_SERVER['REQUEST_TIME']
    $_SERVER['HTTP_ACCEPT']
    $_SERVER['HTTP_CONNECTION']
    $_SERVER['HTTP_USER_AGENT']
    $_SERVER['SERVER_PORT']
    etc. etc.
    Then the last bit (a llittle more complex) can only be done client-side using javascript (and vbscript) it would be something like http://www.oreillynet.com/pub/a/java...detection.html
    To check for a given plug-in, simply call one of the following functions, which will return a value of either "true" (if the plug-in is there) or "false" (if the plug-in is not there or could not be detected):

    * detectQuickTime()
    * detectFlash()
    * detectDirector()
    * detectWindowsMedia()
    * detectReal()

    For example, to check for the existence of the QuickTime plug-in, you could do the following:

    var quickTimeIsInstalled = detectQuickTime();
    if(quickTimeIsInstalled)
    alert('You have the QuickTime plug-in.');
    *Note* As for the "location" on page you linked to, I don't know what they used, but it's wrong. They say I'm from Marion, but I'm not. (see left under avatar).
    The browser info is also obtained client-side using various DOM javascript. eg.
    HTML Code:
    <script type="text/javascript">
    function getDimensions(){
    var scrollLeft,scrollTop;
    // scrollLeft: The distance between the horizontal scrollbar 
    // with the left edge of the frame.
    // scrollTop:  The distance between the vertical scrollbar
    // with the top edge of the frame. 
    
    // Get the scroll value from different browsers.
    // Determine the browser type first. 
    // And then get the value from the particular property.		
    if (window.pageYOffset){  
    	scrollTop = window.pageYOffset 
    } else if(document.documentElement && document.documentElement.scrollTop){ 
    	scrollTop = document.documentElement.scrollTop; 
    } else if(document.body){ 
    	scrollTop = document.body.scrollTop; 
    } 
    
    if(window.pageXOffset){ 
    	scrollLeft=window.pageXOffset 
    } else if(document.documentElement && document.documentElement.scrollLeft){ 
    	scrollLeft=document.documentElement.scrollLeft; 
    } else if(document.body){ 
    	scrollLeft=document.body.scrollLeft; 
    }
    
    var windowWidth,windowHeight; // frame width & height
    
    if(window.innerWidth){ 
    	windowWidth=window.innerWidth; 
    } else if(document.documentElement && document.documentElement.clientWidth){ 
    	windowWidth=document.documentElement.clientWidth; 
    } else if(document.body){ 
    	windowWidth=document.body.offsetWidth; 
    } 
    
    if(window.innerHeight){ 
    	windowHeight=window.innerHeight; 
    } else if(document.documentElement && document.documentElement.clientHeight){ 
    	windowHeight=document.documentElement.clientHeight; 
    } else if(document.body){ 
    	windowHeight=document.body.clientHeight; 
    }
    
    alert("scrollLeft " + scrollLeft + "\n" + "scrollTop " + scrollTop + "\n" + "windowWidth " + windowWidth + "\n" + "windowHeight " + windowHeight);
    }
    </script>

  5. #5
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,150
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    visitor info

    If the above over-whelms you (even when broken down into bite-sized portions) you should make a detailed list specifying exactly what info you what and post a thread in the "looking to hire" forum. I'm sure someone with more time than I have would be more than willing to put something together for you at a relatively inexpensive price. Of course if you need it to be styled into your site's look it might be a bit more invloved too.

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    usa
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey Mittineague, thanks a lot for your response

    Let me see what I can do ..
    I wish, I have ready php file to use directly on the site ..


Bookmarks

Posting Permissions

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