X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=index.cgi;h=e7323cf6452c193fcbb923ed60f0dfc5045cfcc8;hb=29b06964286c147a372ece76e52a92f0a9577c4f;hp=f540aedc7e3156bceb0113af0a4ee70ef4361051;hpb=b3c60467e133ca6f948e1df737c999f17d5b1bef;p=rawnet diff --git a/index.cgi b/index.cgi index f540aed..e7323cf 100755 --- a/index.cgi +++ b/index.cgi @@ -1,13 +1,12 @@ #!/bin/sh +USER_REGISTRATION=false USER_REQUIREEMAIL=false . "${_EXEC:-${0%/*}}"/cgilite/cgilite.sh . "$_EXEC"/cgilite/session.sh nocookie . "$_EXEC"/cgilite/users.sh -PATH_INFO="$(PATH "/${PATH_INFO#${_BASE}}")" - export MD_HTML="false" if [ "$(which awk)" ]; then markdown() { awk -f "$_EXEC/cgilite/markdown.awk"; } @@ -15,6 +14,47 @@ else markdown() { busybox awk -f "$_EXEC/cgilite/markdown.awk"; } fi +checked(){ + local check="$1"; shift 1; + for comp in "$@"; do + if [ "$check" = "$comp" ] || [ "$check" -eq "$comp" ]; then + printf 'checked="checked"' + break; + fi 2>/dev/null + done +} +selected(){ + local check="$1"; shift 1; + for comp in "$@"; do + if [ "$check" = "$comp" ] || [ "$check" -eq "$comp" ]; then + printf 'selected="selected"' + break; + fi 2>/dev/null + done +} + +w_user_login(){ + if [ ! "$USER_ID" ]; then + cat <<-EOF + [form #user_login .login method=POST + [label Login] + [input name=uname placeholder="Username or Email" autocomplete=off] + [input type=password name=pw placeholder="Passphrase"] + [submit "action" "user_login" Login] + $([ "$USER_REGISTRATION" = true ] && printf '[a href="%s/register/" Register]' "$_BASE") + ] + EOF + elif [ "$USER_ID" ]; then + cat <<-EOF + [form #user_login .logout method=POST + [p Logged in as [span . $(HTML ${USER_NAME})]] + $([ "$USER_REGISTRATION" != true ] && printf '[a href="%s/invite/" Invite Friend]' "$_BASE") + [submit "action" "user_logout" Logout] + ] + EOF + fi +} + yield_page(){ title="${1:-RAW:NET}" page="$2" printf '%s\r\n' 'Content-Type: text/html; charset=utf-8' \ @@ -65,6 +105,15 @@ case ${PATH_INFO} in $(w_user_recover) EOF ;; + /invite/) + yield_page 'RAW:NET Invite User' invite <<-EOF + $(w_user_invite) + EOF + ;; + /video/*/*.mp4|/video/*/*_thumb.jpg) + . "${_EXEC}/cgilite/file.sh" + FILE "${_DATA}/${PATH_INFO#/video/}" + ;; /|/channel/*) . "${_EXEC}/page_channel.sh";; /playlist/*) . "${_EXEC}/page_playlist.sh";; /search/*) . "${_EXEC}/page_search.sh";;