preinheimer / xhprof

XHGUI is a GUI for the XHProf PHP extension, using a database backend, and pretty graphs to make it easy to use and interpret.
Other
833 stars 185 forks source link

Unable to profile URL behind CDN/Load Balancer (e.g. Cloudflare) #100

Open tperalta82 opened 7 years ago

tperalta82 commented 7 years ago

On header.php: if ($controlIPs === false || in_array($_SERVER['REMOTE_ADDR'], $controlIPs) || PHP_SAPI == 'cli')

This will not be vaild if behind reverse proxy e.g: cloudflare / varnish / others

Should be something like this: function getUserIP() { $client = @$_SERVER['HTTP_CLIENT_IP']; $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; $remote = $_SERVER['REMOTE_ADDR'];

if(filter_var($client, FILTER_VALIDATE_IP))
{
    $ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
    $ip = $forward;
}
else
{
    $ip = $remote;
}

return $ip;

}

aik099 commented 7 years ago

Agreed. Please send a PR, where IP address detection will be made using new function.