X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=handlers%2F20_attachment.sh;h=efc66f1b77f714fa4ed6afcfc25030c2e87b8258;hb=7af38aed3e2f4d019b371da3ec58a41457173248;hp=1cf4c53eb2f92b5027068447358a7167a19dd51d;hpb=e80c289e4e82f70c9e7426c6c1d3c71c8a42046e;p=shellwiki diff --git a/handlers/20_attachment.sh b/handlers/20_attachment.sh index 1cf4c53..efc66f1 100755 --- a/handlers/20_attachment.sh +++ b/handlers/20_attachment.sh @@ -1,5 +1,7 @@ #!/bin/sh +. "$_EXEC/cgilite/file.sh" + attachment_convert(){ local attpath="$1" local cachepath="${attpath%/#attachments/*}/#cache/${attpath#*/#attachments/}" @@ -64,10 +66,13 @@ attachment_convert(){ case ${PATH_INFO} in */\[attachment\]/) + REDIRECT "${_BASE}${PATH_INFO%/}" + ;; + */\[attachment\]) tsid="$(POST session_key)"; tsid="${tsid%% *}" attachment_delete="$(POST delete)" - if [ "${CONTENT_TYPE%%;*}" = "multipart/form-data" ] && acl_write "${PATH_INFO%\[attachment\]/}"; then + if [ "${CONTENT_TYPE%%;*}" = "multipart/form-data" ] && acl_write "${PATH_INFO%\[attachment\]}"; then . "$_EXEC/multipart.sh" multipart_cache @@ -82,10 +87,10 @@ case ${PATH_INFO} in return 0 fi - mkdir -p "$_DATA/pages/${PATH_INFO%/\[attachment\]/}/#attachments/" + mkdir -p "$_DATA/pages/${PATH_INFO%/\[attachment\]}/#attachments/" n=1; while filename=$(multipart_filename "file" "$n"); do filename="$(printf %s "$filename" |tr /\\0 __)" - multipart "file" "$n" >"$_DATA/pages/${PATH_INFO%/\[attachment\]/}/#attachments/$filename" + multipart "file" "$n" >"$_DATA/pages/${PATH_INFO%/\[attachment\]}/#attachments/$filename" n=$((n + 1)) done rm -- "$multipart_cachefile" @@ -96,14 +101,14 @@ case ${PATH_INFO} in head -c $((CONTENT_LENGTH)) >/dev/null return 0 elif [ "$attachment_delete" -a "$SESSION_ID" = "$tsid" ]; then - rm -- "$_DATA/pages/${PATH_INFO%/\[attachment\]/}/#attachments/$attachment_delete" + rm -- "$_DATA/pages/${PATH_INFO%/\[attachment\]}/#attachments/$attachment_delete" REDIRECT "${_BASE}${PATH_INFO}" elif [ "$attachment_delete" ]; then printf 'Refresh: %i\r\n' 4 theme_error 403 return 0 - elif acl_read "${PATH_INFO%\[attachment\]/}"; then - theme_attachments "${PATH_INFO%\[attachment\]/}" + elif acl_read "${PATH_INFO%\[attachment\]}"; then + theme_attachments "${PATH_INFO%\[attachment\]}" return 0 else theme_error 404