tazpanel diff lib/libtazpanel @ rev 81

Use httpd_helper parser (GET)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Apr 13 16:41:02 2011 +0200 (2011-04-13)
parents 7ac8e561d0a5
children 783e2405d384
line diff
     1.1 --- a/lib/libtazpanel	Tue Apr 12 04:24:35 2011 +0200
     1.2 +++ b/lib/libtazpanel	Wed Apr 13 16:41:02 2011 +0200
     1.3 @@ -3,6 +3,9 @@
     1.4  # Common functions for TazPanel CGI and cmdline interface
     1.5  #
     1.6  
     1.7 +# Get parameters with GET, POST and FILE functions
     1.8 +. /usr/bin/httpd_helper.sh
     1.9 +
    1.10  # Include gettext helper script.
    1.11  . /usr/bin/gettext.sh
    1.12  
    1.13 @@ -20,23 +23,6 @@
    1.14  		exit 1
    1.15  }
    1.16  
    1.17 -# TazPanel QUERY_STRING parser returns: CASE WANT VAR_1 VAR_4
    1.18 -# we use that to help get URL string variables and user names
    1.19 -query_string_parser() {
    1.20 -	id=0
    1.21 -	for var in $(echo "$QUERY_STRING" | sed s'@=@ @'g)
    1.22 -	do
    1.23 -		id=$((id + 1))
    1.24 -		var=${var#&}
    1.25 -		case "$id" in
    1.26 -			'1') CASE=${var% } ;;
    1.27 -			'2') WANT=${var% } ;;
    1.28 -			'3') VAR_1=${var% } ;;
    1.29 -			'4') VAR_2=${var% } ;;
    1.30 -		esac
    1.31 -	done
    1.32 -}
    1.33 -
    1.34  # Syntax highlighting for config file and SHell scripts
    1.35  # HTML entities: -e 's|&|\&amp;|g' -e 's|<|\&lt;|g' -e 's|>|\&gt;|g'
    1.36  syntax_highlighter() {
    1.37 @@ -115,10 +101,29 @@
    1.38  xhtml_header() {
    1.39  	cat ${PANEL}$HEADER | sed s/'- %TITLE%'/"$TITLE"/
    1.40  	if [ $DEBUG == "1" ]; then
    1.41 +		local i
    1.42 +		local j
    1.43 +		local x
    1.44 +		args=""
    1.45 +		for x in GET POST COOKIE ; do
    1.46 +			for i in $($x) ; do
    1.47 +				if [ $($x $i count) -gt 1 ]; then
    1.48 +					for j in $(seq 1 $($x $i count)); do
    1.49 +						args="$args $x($i,$j)='$($x $i $j)'"
    1.50 +					done
    1.51 +				else
    1.52 +					args="$args $x($i)='$($x $i)'"
    1.53 +				fi
    1.54 +			done
    1.55 +		done
    1.56 +		for i in $(FILE); do
    1.57 +			for j in name size type tmpname ; do
    1.58 +				args="$args FILE($i,$j)=$(FILE $i $j)"
    1.59 +			done
    1.60 +		done
    1.61  		cat << EOT
    1.62  <pre class='debug'>
    1.63 -QUERY_STRING="$QUERY_STRING"
    1.64 -CASE="$CASE" WANT="$WANT" VAR_1="$VAR_1"
    1.65 +QUERY_STRING="$QUERY_STRING"$args
    1.66  </pre>
    1.67  EOT
    1.68  	fi