From bec3776a5065a5026936ab2b7d77bbe60a52ddac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 9 Jan 2020 04:05:32 +0100 Subject: [PATCH] date sanitizing, cache invalidation --- therapies/update_therapy.sh | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/therapies/update_therapy.sh b/therapies/update_therapy.sh index ec8ccdc..406f4f9 100755 --- a/therapies/update_therapy.sh +++ b/therapies/update_therapy.sh @@ -26,7 +26,40 @@ tempfile="$_DATA/temp/${tpy}.tpy" # serialize POST array into file for key in $(POST_KEYS); do - [ "$key" != imagedata ] && printf %s:%s\\n "$key" "$(POST "$key" |sed ':X;N;$!bX; s;\n;\\n;g;')" + case "$key" in + imagedata) true ;; + session*_date) + value="$(POST "$key" |sed ':X;N;$!bX; s;\n;\\n;g;')" + y=0 mon=0 dom=0 + case $value in + *.*.*) IFS=. read dom mon y <<-END + ${value} + END + ;; + *.*.) IFS=. read dom mon <<-END + ${value} + END + ;; + */*/*) IFS=/ read mon dom y <<-END + ${value} + END + ;; + */*) IFS=/ read mon dom <<-END + ${value} + END + ;; + *-*-*) IFS=- read y mon dom <<-END + ${value} + END + ;; + esac + [ ! "$y" ] && y="$(date +%Y)" + [ "$y" -gt 0 -a "$y" -lt 100 ] && y="$((y + 2000))" + date -d "${y}-${mon}-${dom}" + && printf %s:%s\\n "$key" "$(date -d "${y}-${mon}-${dom}" +%F)" \ + || printf %s:\\n "$key" + ;; + *) printf %s:%s\\n "$key" "$(POST "$key" |sed ':X;N;$!bX; s;\n;\\n;g;')" ;; + esac done >"$tempfile" if [ "$(POST delete_session)" ]; then @@ -65,5 +98,6 @@ elif [ "$(POST imagedata)" ]; then fi mv "$tempfile" "$tpyfile" +rm -f "${_DATA}/cache/${tpy%%.*}.vcf.cache" REDIRECT "/therapies/${tpy%.*}/${tpy#*.}" -- 2.39.2