Asked  7 Months ago    Answers:  5   Viewed   29 times

Possible Duplicate:
Function to get user ip address


$ipaddress = $_SERVER["REMOTE_ADDR"];

echo "Your IP is $ipaddress!";


I was told this way of getting ip address has issues such as being able to fool. Is there a better way to gather ip address? looking for tutorials of better way to get ip address?



$_SERVER['REMOTE_ADDR'] is the only reliable IP address you'll get - it's extracted directly from the TCP stack and is where the current connection was established from. This means if the user is connecting via a proxy, you'll get the proxy's address, not the user's.

Any of the other header-based ones are unreliable, as HTTP headers are trivial to forge. You can use the information from them, if you'd like, as long as you don't TRUST it.

Wednesday, March 31, 2021
answered 7 Months ago

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario:

Related usability ticket:

P.S. The WI-18388 ticket is already fixed in v8.0

Wednesday, March 31, 2021
answered 7 Months ago

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Saturday, May 29, 2021
answered 5 Months ago

Well, your function should behave as expected, but here are some suggestions:

// lowercase first letter of functions. It is more standard for PHP
function getIP() 
    // populate a local variable to avoid extra function calls.
    // NOTE: use of getenv is not as common as use of $_SERVER.
    //       because of this use of $_SERVER is recommended, but 
    //       for consistency, I'll use getenv below
    $tmp = getenv("HTTP_CLIENT_IP");
    // you DON'T want the HTTP_CLIENT_ID to equal unknown. That said, I don't
    // believe it ever will (same for all below)
    if ( $tmp && !strcasecmp( $tmp, "unknown"))
        return $tmp;
    $tmp = getenv("HTTP_X_FORWARDED_FOR");
    if( $tmp && !strcasecmp( $tmp, "unknown"))
        return $tmp;
    // no sense in testing SERVER after this. 
    // $_SERVER[ 'REMOTE_ADDR' ] == gentenv( 'REMOTE_ADDR' );
    $tmp = getenv("REMOTE_ADDR");
    if($tmp && !strcasecmp($tmp, "unknown"))
        return $tmp;
Wednesday, July 28, 2021
answered 3 Months ago

If you have your own DNS server you can block domains from resolving. Here is a guide to block domains in Bind DNS server.

To get all the IP addresses there is no way. What you can do is, install dig. It's available in linux but not in windows.

Then time to time enter dig It'll show you all the resolved IPs from DNS cache.

See my result

$ dig A

; <<>> DiG 9.7.0-P1 <<>> A
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13442
;; flags: qr rd ra; QUERY: 1, ANSWER: 16, AUTHORITY: 0, ADDITIONAL: 0

;                   IN      A

;; ANSWER SECTION:            83      IN      A            83      IN      A            83      IN      A            83      IN      A            83      IN      A            83      IN      A            83      IN      A            83      IN      A            83      IN      A            83      IN      A            83      IN      A            83      IN      A            83      IN      A            83      IN      A            83      IN      A            83      IN      A

;; Query time: 0 msec
;; WHEN: Sat Feb 18 22:26:58 2012
;; MSG SIZE  rcvd: 285
Sunday, September 5, 2021
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :