Remove PHP4 based checks, and move to filter_var.

PHP4 has been dead for a long time, we can safely use filter_var.

I haven't checked whether this works yet.