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 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2003
    Location
    USA
    Posts
    99
    Thanks
    24
    Thanked 0 Times in 0 Posts

    Users Online IP/Page

    http://elouai.com/users.php

    I'm using this and it seems to work great, except it's not adding the IP or the page to the sql db. Can anyone figure this out??

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    That code is really old. I mean, pre 4.2 old.
    $REMOTE_ADDR only exists where a register_globals environment exists. Use $_SERVER['REMOTE_ADDR'] to retrieve the IP.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    If you want to add the IP to the database, you need to add it in your login script, so if the login is successful, update a row in the user database like adda row called, "loginIP" and use the UPDATE clause everytime they login using $_SERVER['REMOTE_ADDR'] to add the ip in the db.

    like
    PHP Code:
    mysql_query("UPDATE `users` SET `loginIP` = '".$_SERVER['REMOTE_ADDR']."' WHERE `user` = '".$usernameHere."'"); 
    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]

  • #4
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    Also if a user has passed through a proxy server, $_SERVER['REMOTE_ADDR'] would contain the IP address of the proxy server.

    In this case (if the proxy is not anonymous), the proxy server could send the original user IP address in a separate header, which you could get from $_SERVER["HTTP_X_FORWARDED_FOR"]. So you could also consider saving the value obtained from $_SERVER["HTTP_X_FORWARDED_FOR"] (if any).
    Last edited by SKDevelopment; 08-30-2009 at 02:03 PM.

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by SKDevelopment View Post
    Also if a user has passed through a proxy server, $_SERVER['REMOTE_ADDR'] would contain the IP address of the proxy server.

    In this case (if the proxy is not anonymous), the proxy server could send the original user IP address in a separate header, which you could get from $_SERVER["HTTP_X_FORWARDED_FOR"]. So you could also consider saving the value obtained from $_SERVER["HTTP_X_FORWARDED_FOR"] (if any).
    Yep, that is true. There is also HTTP_FROM and HTTP_VIA, but I've never seen the latter used before. I think I have seen HTTP_FROM in use once.
    When using the HTTP_X_FORWARDED_FOR if the user is using an internal proxy on their network, you can check to see if its an internal IP as well: 10.*, 192.168.* or 172.16.* - 172.31.*. If it is, dump it and go with HTTP_VIA if it exists or REMOTE_ADDR.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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