Somehow $_SERVER[\'REMOTE_ADDR\'] returns an empty string, i have the same code (as part of a script) running on multiple servers and it works everywhere else,
if you're behind a proxy server, you can use $_SERVER['HTTP_X_FORWARDED_FOR'] or $_SERVER['HTTP_CLIENT_IP'] instead of $_SERVER['REMOTE_ADDR'].
this will depends on how your proxy is configured.