#!/bin/bash

case $1 in
	'on')
		;;
	'off')
		;;
	*)
		echo "Parameter missing: $0 <on/off>"
		exit 1
esac

for phpFile in `ls /etc/php/*/apache*/php.ini /etc/php/*/cli/php.ini`
do
	sed -i -e '/^error_reporting.*/d' -e '/^display_errors.*/d' $phpFile

	if [ "on" = "$1" ]
	then
		echo 'error_reporting = E_ALL
display_errors = On' >> $phpFile
	else
		echo 'error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off' >> $phpFile
	fi
done

/etc/init.d/apache2 restart
