#!/bin/sh

diff=/usr/bin/diff
[ -x "/usr/local/bin/colordiff" ] && diff="/usr/local/bin/colordiff"

extlist="spl sqlite recode mysqli mysql imap sockets pspell xml"
extini="/usr/local/etc/php/extensions.ini"
extold="${extini}.old"
exttmp="$(mktemp -t extensions.ini)"
trap "rm -f '${exttmp}'" exit hup int term kill

echo -n "
=>"
filter_regexp="("
for ext in ${extlist}
do
  var=HAS_${ext}
  eval $var=$(/usr/bin/egrep -c "^extension=${ext}.so$" ${extini})
  [ "$(eval echo "\${$var}")" -gt 0 ] && echo -n " ${ext}"
  filter_regexp="${filter_regexp}^extension=${ext}.so$|"
done
filter_regexp="$(echo "${filter_regexp}" | /usr/bin/sed -e 's/|$/)/')"
echo -e "\n"

/usr/bin/egrep -v "${filter_regexp}" "${extini}" | sort | uniq > "${exttmp}"

for ext in ${extlist}
do
  var="$(eval echo \${HAS_${ext}})"
  [ "${var}" -gt 0 ] && echo "extension=${ext}.so" >> "${exttmp}"
done

if /usr/bin/cmp -s "${exttmp}" "${extini}"
then
  echo "No changes."
else
  /bin/cp -v "${extini}" "${extold}"
  /bin/cp -v "${exttmp}" "${extini}"
  ${diff} -ur "${extold}" "${extini}" | less -R
fi

PHP Warning

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead:"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead"

Warning: "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead:"