summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
df71d6c)
svn path=/trunk/; revision=55
# along with CGIlite. If not, see <http://www.gnu.org/licenses/>.
# ksh and zsh workaround
# along with CGIlite. If not, see <http://www.gnu.org/licenses/>.
# ksh and zsh workaround
-set -o posix -o OCTAL_ZEROES 2>&-
+# set -o posix # ksh, not portable
+setopt -o OCTAL_ZEROES 2>&-
if [ "$REQUEST_METHOD" = POST -a "${HTTP_CONTENT_LENGTH:=${CONTENT_LENGTH:=0}}" -gt 0 ]; then
cgilite_post="$(head -c "$HTTP_CONTENT_LENGTH")"
fi
cgilite_count(){
if [ "$REQUEST_METHOD" = POST -a "${HTTP_CONTENT_LENGTH:=${CONTENT_LENGTH:=0}}" -gt 0 ]; then
cgilite_post="$(head -c "$HTTP_CONTENT_LENGTH")"
fi
cgilite_count(){
- printf "$(
- case $1 in
- GET) printf %s "${QUERY_STRING}";;
- POST) printf %s "?${cgilite_post}";;
- REF) printf %s "?${HTTP_REFERER#*\?}";;
- esac \
- | grep -Eo '[&?]'"$2"'=[^&]*' \
- | wc -l
- )"
+ case $1 in
+ GET) printf %s "${QUERY_STRING}";;
+ POST) printf %s "?${cgilite_post}";;
+ REF) printf %s "?${HTTP_REFERER#*\?}";;
+ esac \
+ | grep -Eo '[&?]'"$2"'=[^&]*' \
+ | wc -l
-GET(){
- cgilite_value GET $@
-}
-GET_no(){
- cgilite_count GET $1
-}
+GET(){ cgilite_value GET $@; }
+GET_COUNT(){ cgilite_count GET $1; }
-POST(){
- cgilite_value POST $@
-}
-POST_no(){
- cgilite_count POST $1
-}
+POST(){ cgilite_value POST $@; }
+POST_COUNT(){ cgilite_count POST $1; }
-REF(){
- cgilite_value REF $@
-}
-REF_no(){
- cgilite_count REF $1
-}
+REF(){ cgilite_value REF $@; }
+REF_COUNT(){ cgilite_count REF $1; }
# HTML Entity Coding
# Prints UTF-8 string as decimal Unicode Code Points
# Useful for escaping user input for use in HTML text and attributes
# HTML Entity Coding
# Prints UTF-8 string as decimal Unicode Code Points
# Useful for escaping user input for use in HTML text and attributes
# Code every character in URL escape hex format
# except alphanumeric ascii
# Code every character in URL escape hex format
# except alphanumeric ascii
-redirect(){
- printf '%s\r\n\r\n' "Location: $(urlsafe $*)"
- exit 0
-}
-
-set_cookie(){
- session|0) expire='';;
- ''|default) expire="$(LANG=C date -d "+ 1 week" +'%a, %d %b %Y %T %Z')";;
- *) expire="$(LANG=C date -d "$1" +'%a, %d %b %Y %T %Z' 2>&-)";;
+ ''|0|session) expire='';;
+ [+-][0-9]*) expire="$(date -R -d @$(($(date +%s) + $1)))";;
+ *) expire="$(date -R -d "$1")";;
[ $# -ge 3 ] && shift 2 && printf '; %s' "$@"
printf '\r\n'
}
[ $# -ge 3 ] && shift 2 && printf '; %s' "$@"
printf '\r\n'
}
+
+REDIRECT(){
+ printf 'Location: %s\r\n\r\n' "$*"
+ exit 0
+}