3 . "$_EXEC/db_channel.sh"
6 channel='' video='' action=''
8 path_info="${path_info#/channel/}"
9 if [ "$(checkid "${path_info%%/*}")" ]; then
10 channel="${path_info%%/*}"
11 path_info="${path_info#*/}"
13 if [ "$(checkid "${path_info%%/*}")" ]; then
14 video="${path_info%%/*}"
15 path_info="${path_info#*/}"
20 read_channel "$channel" \
21 && vid_db="${_DATA}/${CHANNEL_ID}/videos.db"
24 if [ "$CHANNEL_ID" -a "$USER_ID" -a ! "${CHANNEL_AUTHORS##*${USER_ID}*}" ]; then
32 # ID NAME DESCRIPTION RESX RESY LENGTH COVER STATUS UPLOADER HITS
34 [ "$REQUEST_METHOD" = POST ] && case "$(POST action)" in
36 channel="$(POST channel |checkid)"
37 if [ ! "$USER_ID" ]; then
38 REDIRECT "${_BASE}/channel/#ERROR_NEWCHANNEL_NOTALLOWED"
39 elif new_channel "$channel"; then
40 REDIRECT "${_BASE}/channel/$channel/edit"
42 REDIRECT "${_BASE}/channel/#ERROR_NEWCHANNEL_NOLOCK"
46 if [ ! "$channel" ]; then
47 REDIRECT "${_BASE}/channel/#ERROR_NOCHANNEL"
48 elif [ ! "$USER_ID" ]; then
49 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_NOTLOGGEDIN"
51 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_UPDATE_NOTALLOWED"
52 elif update_channel "$channel" "name=$(POST name)" \
53 "description=$(POST description)" \
54 "authors=$USER_ID"; then
55 REDIRECT "${_BASE}/channel/$CHANNEL_ID/"
57 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_UPDATE_NOLOCK"
60 update_channel_cancel)
61 REDIRECT "${_BASE}/channel/$CHANNEL_ID/"
64 video="$(POST video |checkid)"
67 && mkdir -p -- "${_DATA}/$CHANNEL_ID/"
69 if [ ! "$video" ]; then
70 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_INVALID_ID"
71 elif [ ! "$channel" ]; then
72 REDIRECT "${_BASE}/channel/#ERROR_NOCHANNEL"
73 elif [ ! "$USER_ID" ]; then
74 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_NOTLOGGEDIN"
76 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_UPDATE_NOTALLOWED"
77 elif new_video "$video"; then
78 REDIRECT "${_BASE}/channel/$CHANNEL_ID/${video}/"
80 REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_NEWVIDEO_NOLOCK"
87 local VIDEO_ID VIDEO_NAME VIDEO_DESCRIPTION VIDEO_RESX VIDEO_RESY \
88 VIDEO_LENGTH VIDEO_COVER VIDEO_STATUS VIDEO_UPLOADER VIDEO_HITS \
89 VIDEO_DESCR_CACHE VIDEO_FUTUREUSE
92 VIDEO_LENGTH="${VIDEO_LENGTH%.*}"
93 [ "${VIDEO_STATUS}" = public ] || AUTHOR || return 0
95 thumb="${_BASE}/video/${CHANNEL_ID}/${VIDEO_ID}.thumb.jpg"
96 [ "$NAME" = \\ ] && NAME="(Unnamed Video)"
97 printf '[div .video .thumb
98 [a href="%s/channel/%s/%s/"
100 [figure [img src="%s" alt=""]]
101 [span .duration . %i:%02i]
102 [div .description . %s]
104 ]' "$_BASE" "$CHANNEL_ID" "$VIDEO_ID" \
105 "$(HTML "${VIDEO_NAME:-(Unnamed Video)}")" \
107 "$((VIDEO_LENGTH / 60))" "$((VIDEO_LENGTH % 60))" \
108 "$(UNSTRING "$DESCR_CACHE")"
116 local CHANNEL_ID CHANNEL_NAME CHANNEL_DESCRIPTION CHANNEL_LOGO \
117 CHANNEL_THEME CHANNEL_AUTHORS CHANNEL_DESCR_CACHE CHANNEL_FUTUREUSE
119 [ "$USER_ID" ] && cat <<-EOF
120 [form .channel .newchannel method=POST
121 [hidden "channel" "$(timeid)"]
122 [submit "action" "newchannel" New Channel]
126 [ -f "$chan_db" -a -r "$chan_db" ] \
127 && while read_channel; do
128 vid_db="${_DATA}/${CHANNEL_ID}/videos.db"
133 [h2 [a href="${_BASE}/channel/${CHANNEL_ID}/" $(HTML "${CHANNEL_NAME:-(Unnamed Channel)}")]]
134 ${CHANNEL_DESCR_CACHE}
136 [ -f "$vid_db" -a -r "$vid_db" ] \
137 && while w_video; do :; done <"$vid_db"
144 if [ "$channel" -a "$video" ]; then
145 . ${_EXEC}/page_video.sh
146 elif [ "$channel" -a "$action" = edit ]; then
147 AUTHOR || REDIRECT "${_BASE}/$CHANNEL_ID/#ERROR_EDIT_NOTALLOWED"
148 yield_page "$CHANNEL_NAME - Edit" "channel edit" <<-EOF
149 [form .channel .edit method=POST
150 [input name="name" value="$(HTML "$CHANNEL_NAME")" placeholder="Channel Name" autocomplete=off]
151 [textarea name="description" placeholder="Description" . $(HTML "$CHANNEL_DESCRIPTION")]
152 [submit "action" "update_channel" . Update]
153 [submit "action" "update_channel_cancel" . Cancel]
156 elif [ "$channel" ]; then
157 yield_page "$CHANNEL_NAME" "channel" <<-EOF
158 [nav [a href="../" Channels] - [span $(HTML "${CHANNEL_NAME:-(Unnamed Channel)}")]
159 $(AUTHOR && printf ' - [a href="edit" edit]')
161 [h1 .name $(HTML "$CHANNEL_NAME")]
162 [div .description . ${CHANNEL_DESCR_CACHE}]
166 [form .video .newvideo method=POST
167 [hidden "video" "%s"]
168 [submit "action" "newvideo" New Video]
170 [ -f "$vid_db" -a -r "$vid_db" ] \
171 && while w_video "$ID"; do :; done <"$vid_db"
175 yield_page "Channels" "channels" <<-EOF