#!/bin/sh # Helper for switching skins # "skin.cgi?name=foo": select skin "foo" # "skin.cgi?reset=1": reset to default SKIN_DIR=/usr/share/skin CR=$'\r' invalid_skin() { local name=$1 source /usr/lib/libmodcgi.sh cgi --id=skin cgi_begin 'Skins' [ $# -gt 0 ] && print_error "$(lang de:"'$name' ist kein gültiger Skin." en:"'$name' is not a valid skin." )" echo "
$(lang de:"Es stehen folgende Skins zur Auswahl (benötigt Cookies):" en:"Please choose from the following skins (cookies required):" )" echo "
$(lang de:"Zurück zum Standard-Skin" en:"Switch back to default skin" )
" cgi_end exit } default_skin=legacy set_skin() { local name=$1 cookie_redir "skin=$name; Path=/; Max-Age=$((20*365*24*3600))" } reset_skin() { cookie_redir "skin=${default_skin}; Path=/; Max-Age=0" } redir_target=/cgi-bin/skin.cgi cookie_redir() { cat << EOF Status: 302 Found${CR} Set-Cookie: $1${CR} Location: ${redir_target}${CR} ${CR} EOF exit } eval "$(modcgi name:reset skin)" [ -n "${SKIN_RESET+1}" ] && reset_skin [ -z "${SKIN_NAME+1}" ] && invalid_skin case $SKIN_NAME in ""|*[^A-Za-z0-9_]*) invalid_skin "$SKIN_NAME" ;; *) [ ! -d "$SKIN_DIR/$SKIN_NAME" ] && invalid_skin "$SKIN_NAME" ;; esac set_skin "$SKIN_NAME"