Merge pull request #911 from lbryio/web_visitor_logging

added HTTP_X_FORWARDED_FOR check because we are behind varnish proxy.
This commit is contained in:
Mark 2018-12-31 17:18:01 -05:00 committed by GitHub
commit 7bac695fb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,7 +36,7 @@ class Session
Response::addPostRenderCallback(function () {
$site_visitor_id = key_exists(static::USER_ID, $_SESSION) ? $_SESSION[static::USER_ID] : '';
$response = LBRY::logWebVisitor(static::SITE_ID, $site_visitor_id, $_SERVER['REMOTE_ADDR']);
$response = LBRY::logWebVisitor(static::SITE_ID, $site_visitor_id, static::getOriginalIp());
if (!is_null($response)
&& key_exists('data', $response)
&& key_exists('visitor_id', $response['data'])) {
@ -111,4 +111,9 @@ class Session
{
static::unsetNamespace(static::NAMESPACE_FLASH_REMOVE);
}
public static function getOriginalIp()
{
return $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? null;
}
}