#!/bin/sh -e

max=1440

if which php5 >/dev/null 2>&1 && [ -e /etc/php5/apache2/php.ini ]; then
  cur=$(php5 -c /etc/php5/apache2/php.ini -d "error_reporting='E_ALL & ~E_DEPRECATED'" -r 'print ini_get("session.gc_maxlifetime");')
  [ -z "$cur" ] && cur=0
  [ "$cur" -gt "$max" ] && max=$cur
else
        for ini in /etc/php5/*/php.ini; do
          cur=$(sed -n -e 's/^[[:space:]]*session.gc_maxlifetime[[:space:]]*=[[:space:]]*\([0-9]\+\).*$/\1/p' $ini 2>/dev/null || true);
          [ -z "$cur" ] && cur=0
          [ "$cur" -gt "$max" ] && max=$cur
        done
fi

echo $(($max/60))

exit 0
