Skip to content

getVisitIp() does not support IPv6 #25

@ghost

Description

I am having problems with the getVisitIp() function, which does not support IPv6, because it uses preg_match with an IPv4 expression.

I modified the getVisitIp() to:

function getVisitIp() {
    $ipKeys = array(
        'HTTP_X_FORWARDED_FOR',
        'HTTP_CLIENT_IP',
        'HTTP_CF_CONNECTING_IP',
    );
    foreach($ipKeys as $ipKey) {
        if (isset($_SERVER[$ipKey]) && $_SERVER[$ipKey]!="")
            return $_SERVER[$ipKey];
    }
    return arrayValue($_SERVER, 'REMOTE_ADDR');
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions