Changed localhost detection to be compatible with PHP versions below 5.4