#!/bin/sh

php_conf="/usr/local/psa/admin/conf/php.ini"

filter_str='-.*/phpMyAdmin/.*'

filter_exists="`awk '/^[[:space:]]*apc.filters/ {print;}' < $php_conf | tail -1`"

if [ -z "$filter_exists" ]; then
	echo "apc.filters=\"$filter_str\"" >> $php_conf
	exit 0
fi

filter_correct="`echo $filter_exists | awk '/phpMyAdmin/ {print;}'`"
[ -n "$filter_correct" ] && exit 0

filter_empty="`echo $filter_exists | awk '/""/ {print;}'`"

if [ -n "$filter_empty" ]; then
	sed -i -e "s|^\([[:space:]]*apc\.filters.*\"\)\(\".*\)|\1$filter_str\2|g" $php_conf
else
	sed -i -e "s|^\([[:space:]]*apc\.filters.*\"\)\(.*\)\(\".*\)|\1\2,$filter_str\3|g" $php_conf
fi

