3 for n in "$@"; do case ${n%%=*} in
4 data) _DATA="${n#data=}";;
5 exec) _EXEC="${n#exec=}";;
6 base) _BASE="${n#base=}";;
7 debug) DEBUG="${n#debug=}";;
10 [ ! "${_EXEC%/}" ] && _EXEC="$(realpath "${0%/*}")" || _EXEC="${_EXEC%/}"
11 [ ! "${_DATA%/}" ] && _DATA="${PWD%/}" || _DATA="${_DATA%/}"
13 [ "$DEBUG" ] && exec 2>>"$DEBUG"
15 mkdir -p "${_DATA}/cache" "${_DATA}/mappings" "${_DATA}/export" "${_DATA}/lock" "${_DATA}/ical" "${_DATA}/vcard" "${_DATA}/therapies"
17 . "$_EXEC/cgilite/cgilite.sh"
18 . "$_EXEC/cgilite/session.sh"
22 _PATH="$(PATH "/${PATH_INFO}")"
23 _PATH="${_PATH#${_BASE}}"
26 message="$(COOKIE message)"
27 [ "$message" ] && SET_COOKIE 0 message=''
30 if [ "$1" = "$2" ] || [ "$1" -eq "$2" ]; then
31 printf 'checked="checked"'
35 if [ "$1" = "$2" ] || [ "$1" -eq "$2" ]; then
36 printf 'selected="selected"'
41 local class="$1" style="$2"
42 printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
46 [meta name="viewport" content="width=device-width"]
47 [link rel="stylesheet" type="text/css" href="%s/cgilite/common.css"]
48 [link rel="stylesheet" type="text/css" href="%s/style.css"]
49 ' "${_BASE}" "${_BASE}"
50 [ -n "$style" ] && printf '
51 [link rel="stylesheet" type="text/css" href="%s"]
54 ] [body #top class="%s"
56 [ "$message" ] && printf '[p #message\n%s\n]' "$(l10n "$message")"
60 | "${_EXEC}/cgilite/html-sh.sed"
64 topdir="/${topdir%%/*}"
67 "/") REDIRECT "${_BASE}/cards/"
70 if [ -d "${_EXEC}/${_PATH}" -a -x "${_EXEC}/${_PATH}/index.cgi" ]; then
71 . "${_EXEC}/${_PATH}/index.cgi"
72 elif [ -f "${_EXEC}/${_PATH}" -a -x "${_EXEC}/${_PATH}" ]; then
74 elif [ -f "${_EXEC}/${_PATH}" -a -r "${_EXEC}/${_PATH}" ]; then
75 . "$_EXEC/cgilite/file.sh"
76 FILE "${_EXEC}/${_PATH}"
77 elif [ -d "${_EXEC}/${topdir}" -a -x "${_EXEC}/${topdir}/index.cgi" ]; then
78 . "${_EXEC}/${topdir}/index.cgi"
80 printf '%s\r\n' 'Status: 404 Not Found' 'Content-Length: 0' ''