mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
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:
commit
7bac695fb5
1 changed files with 7 additions and 2 deletions
|
@ -34,9 +34,9 @@ class Session
|
||||||
static::setNamespace(static::NAMESPACE_DEFAULT, $oldSession);
|
static::setNamespace(static::NAMESPACE_DEFAULT, $oldSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
Response::addPostRenderCallback(function(){
|
Response::addPostRenderCallback(function () {
|
||||||
$site_visitor_id = key_exists(static::USER_ID, $_SESSION) ? $_SESSION[static::USER_ID] : '';
|
$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)
|
if (!is_null($response)
|
||||||
&& key_exists('data', $response)
|
&& key_exists('data', $response)
|
||||||
&& key_exists('visitor_id', $response['data'])) {
|
&& key_exists('visitor_id', $response['data'])) {
|
||||||
|
@ -111,4 +111,9 @@ class Session
|
||||||
{
|
{
|
||||||
static::unsetNamespace(static::NAMESPACE_FLASH_REMOVE);
|
static::unsetNamespace(static::NAMESPACE_FLASH_REMOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getOriginalIp()
|
||||||
|
{
|
||||||
|
return $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue