/ PHP

Previous Article

PHP Function IP if behind a proxy

Next Article

Following from my last post, here is the method to get your IP address if you are behind a proxy.

function getRealIPAddr() {
    // check ip from share internet
    if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
        $ip=$_SERVER["HTTP_CLIENT_IP"];
    } elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
        // to check ip is pass from proxy
        $ip=$_SERVER["HTTP_X_FORWARDED_FOR"];
    } else {
        $ip=$_SERVER["REMOTE_ADDR"];
    }
    return $ip;
}

As this method gets more accurate results it is better to use this than the previous function.

Avatar of Clive Walkden

Clive Walkden

Latest Articles

Linux

Output All Users Cron Jobs

If you want to check all users cron jobs this little command will output them to the command line

Magento 2

Magento 2 admin password history reset

Do you want to clear the password history on your staging test site (not recommended for live)?

Linux

How to see files changed on a certain date

As a sysadmin you often need to see which files have been modified on a certain date.