Fixed error with undefined HTTP_USER_AGENT thanks to Enrique Cordero.