fi
}
+UPLOAD(){
+ local file="$1"
+ local boundary line last
+ local CONTENT_TYPE="$(HEADER Content-Type)"
+
+ [ ! "${CONTENT_TYPE}" -o "${CONTENT_TYPE##multipart/form-data;*}" ] && return 1
+
+ boundary="${CONTENT_TYPE#*; boundary=}"
+ boundary="${boundary%%;*}"
+
+ head -c "$CONTENT_LENGTH" \
+ | sed -nE '
+ /^--'"${boundary}"'\r?$/!b;
+ :A; n;
+ /^\r?$/!bA;
+ n;
+ :FILE
+ p; n;
+ /^--'"${boundary}"'(--)?\r?$/!bFILE;
+ :END
+ $q; n; bEND;
+ ' >"$file"
+ truncate -s $(( $(stat -c %s -- "$file") -2 )) -- "$file"
+}
[ "$REQUEST_METHOD" = POST ] && case "$(POST action)" in
update_video)
if [ ! "$USER_ID" ]; then
REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_NOTLOGGEDIN"
- elif [ "${CHANNEL_AUTHORS##*${USER_ID}*}" ]; then
+ elif ! AUTHOR; then
REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPDATE_NOTALLOWED"
elif update_video "$video" "$(POST name)" "$(POST description)" 0 0 0 \
"" "void" "$USER_ID" 0 ""; then
;;
esac
+if [ "$REQUEST_METHOD" = POST -a "$channel" -a "$video" ]; then
+ if ! AUTHOR; then
+ head -c "$CONTENT_LENGTH" >/dev/null
+ REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPLOAD_NOTALLOWED"
+ elif [ "$VIDEO_STATUS" != void ]; then
+ head -c "$CONTENT_LENGTH" >/dev/null
+ REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPLOAD_NOCLOBBER"
+ elif UPLOAD "$_DATA/$channel/$video.mp4"; then
+ update_video "$video" "$VIDEO_NAME" "$VIDEO_DESCRIPTION" 0 0 0 \
+ "$VIDEO_COVER" private "$VIDEO_UPOADER" "$VIDEO_HITS" \
+ "" ""
+ fi
+fi
+
if [ "$channel" -a "$video" -a "$action" = edit ]; then
yield_page "$VIDEO_NAME - Edit" "video edit" <<-EOF
[form .video .edit method=POST
elif [ "$channel" -a "$video" ]; then
yield_page "$VIDEO_NAME" "video edit" <<-EOF
[nav [a href="../../" Channels] - [a href="../" $(HTML "${CHANNEL_NAME:-(Unnamed Channel)}")] - [span $(HTML "${VIDEO_NAME:-(Unnamed Video)}")]
- $( [ "$USER_ID" -a ! "${CHANNEL_AUTHORS##*${USER_ID}*}" ] \
- && printf ' - [a href="edit" edit]'
- )
+ $(AUTHOR && printf ' - [a href="edit" edit]')
]
+ $( AUTHOR && [ $VIDEO_STATUS = void ] && printf '
+ [form .upload method=POST enctype="multipart/form-data"
+ [input type=file name=upload]
+ [submit "action" "video_upload" Upload]
+ ]')
+ $( [ $VIDEO_STATUS != void ] && printf '
+ [video
+ [source src="%s/video/%s/%s.mp4"]
+ ]' "$_BASE" "$channel" "$video"
+ )
[h1 .name $(HTML "$VIDEO_NAME")]
[div .description . ${VIDEO_DESCR_CACHE}]
EOF