From: paul Date: Sat, 13 Jun 2015 14:15:12 +0000 (+0000) Subject: moved cgi components to different repository X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=14fe1abaa9b28764e4759db1d9f8bba910c38a3a;p=serve0 moved cgi components to different repository svn path=/trunk/; revision=51 --- diff --git a/action.sh b/action.sh deleted file mode 100755 index 0077575..0000000 --- a/action.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/zsh - -# Copyright 2014 Paul Hänsch -# -# This file is part of Serve0. -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0. If not, see . - -ACTION="$(echo "$_GET[\"action\"]" |egrep '^[a-zA-Z0-9_-]+$')" -ACTION="${_EXEC}/actions/${ACTION}.sh" -[ -x "$ACTION" ] || echo -n "Location: http://$HTTP_HOST/?page=error\n\n" - -. $ACTION diff --git a/cgi.sh b/cgi.sh deleted file mode 100755 index c70c4d2..0000000 --- a/cgi.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/zsh - -# Copyright 2014 Paul Hänsch -# -# This file is part of Serve0. -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0. If not, see . - -declare -A _GET -declare -A _POST -declare -A _REF - -cgi_get() { # parse HTTP GET string - echo "$QUERY_STRING" |tr '&' '\n' |while read query; do - key="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\1:')" - val="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\2:')" - _GET["$key"]="$(echo -e "$(echo "$val" |sed 's:+: :g;s:%:\\x:g')")" - done -} - -cgi_post() { # parse HTTP POST string - sed -u 1q |tr '&' '\n' |while read query; do - key="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\1:')" - val="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\2:')" - value="$(echo -e "$(echo "$val" |sed 's:+: :g;s:%:\\x:g')")" - if [ -n "$_POST[\"$key\"]" ]; then - n=0 - while [ -n "$_POST[\"$key$n\"]" ]; do n=$(($n + 1)); done - _POST["$key$n"]="$value" - else - _POST["$key"]="$value" - fi - #debug "_POST[$key] => $value" - done -} - -cgi_refdata() { # Parse GET data from referer - echo "$HTTP_REFERER" |cut -d'?' -f2- |tr '&' '\n' |while read query; do - key="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\1:')" - val="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\2:')" - _REF["$key"]="$(echo -e "$(echo "$val" |sed 's:+: :g;s:%:\\x:g')")" - done -} - -urlsave(){ - echo -E "$*" |sed 's:%:\%25:g;s:\?:\%3F:g;s:&:\%26:g;s:'\'':\%27:g;s: :\%20:g;s:!:\%21:g;s:(:\%28:g;s:):\%29:g;s:":\%22:g;' -} diff --git a/constants.sh b/constants.sh index 36c85bc..727952d 100755 --- a/constants.sh +++ b/constants.sh @@ -1,6 +1,6 @@ #!/bin/zsh -# Copyright 2014 Paul Hänsch +# Copyright 2014,2015 Paul Hänsch # # This file is part of Serve0. # @@ -21,3 +21,5 @@ alias _wiki="stx2any --no-template --link-abbrevs --quote -T html" [ -z "$_GET[\"page\"]" ] && _GET["page"]=list pagesize=100 file_pattern='^.*(mov|ts|mpg|mpeg|mp4|m4v|avi|mkv|flv|sfv|wmv|ogm|webm|iso|rmvb)$' + +data_dirs cache meta mp4 videos thumbs trash by_length transcoded diff --git a/index.cgi b/index.cgi deleted file mode 100755 index 40b67f1..0000000 --- a/index.cgi +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/zsh - -# Copyright 2014 Paul Hänsch -# -# This file is part of Serve0. -# -# Serve0 is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Serve0 is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Serve0. If not, see . - -export LC_ALL=C - -# basic functions -die() { - echo "$*" >/dev/stderr - exit 1 -} -debug() { #change to false to disable debugging - #true && echo "$*" >>debug - true && [ -n "$*" ] && echo -E "$*" >>/dev/stderr - true && [ -z "$*" ] && tee /dev/stderr -} - -# this program is supposed to be symlinked into a http root directory -# we will use the http root as object storage (data directory) and call sub -# programs from the directory in which the real executable resides -# therefore we need to identify the code and data directories _EXEC and _DATA -call="$0" -real="$(readlink -f $call)" -_EXEC="$(dirname "$real")" #execution directory -_DATA="$(dirname "$call")" #storage directory - -[ -w "$_DATA" ] && [ -d "$_DATA" ] || die "storage directory must be writable" - -# create directories for object storage -for each in "$_DATA"/{cache,meta,mp4,videos,thumbs,trash,by_length,transcoded}; do - [ ! -e "$each" ] && mkdir "$each" - [ -w "$each" ] && [ -d "$each" ] || die "storage $each must be a writable directory" -done - -# create htaccess file -[ -f .htaccess ] || cat >.htaccess <. - -echo -n "Content-Type: text/html;charset=utf-8\n\n" - -PAGE="$(echo "$_GET[\"page\"]" |egrep '^[a-zA-Z0-9_-]+$')" -PAGE="${_EXEC}/pages/${PAGE}.sh" -[ -x "$PAGE" ] || PAGE="${_EXEC}/pages/error.sh" - -NAVIGATION() { - for each in "${_EXEC}"/pages/*.sh; do - link="$(echo "$each" |sed -r "s:^.*/([^/]*)\.sh$:\1:")" - title="$($each title)" - [ -n "$title" ] && echo "/?page=$link $title" - done -} - -. ${_EXEC}/templates/frame.html.sh diff --git a/templates/download.html.sh b/templates/download.html.sh new file mode 100755 index 0000000..0bc4dbf --- /dev/null +++ b/templates/download.html.sh @@ -0,0 +1,69 @@ +# Copyright 2015 Paul Hänsch +# +# This file is part of Serve0 +# +# Serve0 is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Serve0 is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Serve0 If not, see . + +cat <