Unable to resolve user IP

When I am entering a link from facebook to my site its counted as unique IP
for some reason this function resolves the facebook IP and not the user IP…
this is the function I use

function getRealIpAddr()
    if (!empty($_SERVER['HTTP_CLIENT_IP']))   
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))  
    return $ip;

How can I find out the real user IP ?

You cannot. If Facebook is working as a proxy for the user then you will only ever get Facebook’s IP.
Which is probably done for good reason.