Change variable server to HTTP_HOST, fixed bug for execution on PHP 5.4