Fixing some environment variable reading logic.

@mtdowling Was working on something and ran into an issue where it was not finding my HOME dir with `$_SERVER`, but it was finding it with `getenv()`. I think we need to always do `isset($_SERVER[...]) ? $_SERVER[...] : getenv(...)` in order to have max compatibility.