Fix several scripts to avoid PHP warnings about deprecation and unset variables.