Replace deprecated header functions with wrappers in lib/compat.php