Perchè non usi semplicemente $_SERVER['REMOTE_ADDR'] oppure $_SERVER['HTTP_HOST']?