Handle port aliases & validate port before attempting to use, to prevent "erroring out"

Anyterm settings accept textual input for the port (useful: an alias can be specified, e.g., for fw ACL rules). 

However the code used to make the subsequent connection errors out nastily if an alias or non-port is used, since it assumes $port exists, is valid, and is already numeric -- but none of these are necessarily true, should assume and check "in case" that data is meaningful before slapping it into a URL.

This patch 
1) explicitly checks that a port is actually defined;
2) handles textual data such as a port alias; and 
3) provides at least rudimentary error handling for invalid data (like Unbound, an attempt to use the functional tab if data is bad, returns the user to the package "Settings" tab instead).