Änderungen

Zur Navigation springen Zur Suche springen
→‎Code: alter code
Zeile 8: Zeile 8:  
}
 
}
 
</pre>
 
</pre>
 +
 +
=Code_alt (haesslich,aber tricky!)=
 +
fkt_decode_url () {                                    # SENS: convert encoded URL to normal (e.g. %20 = space , %40 = @-Symbol )                         
 +
        s=$(echo "$1" | sed -e "s/+/%20/g")            # ARG1: (maybe) dirty string                                                   
 +
        echo -n ${s%%%*}                                # OUT1: unescaped string
 +
                                                   
 +
        if [ -n "$s" ] && [ "$s" != "${s#*%}" ]; then
 +
                IFS=\%                                                             
 +
                set ${s#*%}                                                                                             
 +
                unset IFS                                                           
 +
                                                                                   
 +
                for i in "$@"; do
 +
                        echo -n -e "\\x$(echo $i | dd bs=1 count=2 2>&-)"                       
 +
                        echo -n ${i#??}                                                     
 +
                done                                                                   
 +
        fi                               
 +
}
 +
 +
fkt_read_browsers_query_string () {    # SENS: read and sanitize/convert query-string to useable vars (e.g. ?A=1&B=2 changes to correct setted vars A and B)
 +
                                        # ARG1: string, query string                             
 +
        local QUERY_STRING="$1"                                                                                                                 
 +
        local DAEMON="fkt_read_browsers_query_string"                                                                                               
 +
        local VARS=""                                                                                                                               
 +
                                                                                                                   
 +
        if [ -z "$QUERY_STRING" ]; then                                                                                 
 +
                fkt_log "$DAEMON" "Zero query!" 1                                                                       
 +
                return                                                                                           
 +
        else                                                                           
 +
                fkt_log "$DAEMON" "Exploring query \"$QUERY_STRING\"" 1                                                         
 +
        fi                                                                                                                           
 +
                                                                                                                                     
 +
        IFS=\&                                                                                                               
 +
        set ${QUERY_STRING%%[^%&=+-:@-_a-z~]*}                                                                     
 +
        unset IFS                                                                                                   
 +
        fkt_log "$DAEMON" "Escaping query \"$*\"" 1                                                                                                               
 +
        VARS="$(echo $* | sed -e 's/ /"; /g' -e 's/=/="/g' -e 's/$/"/g')"                                                                                         
 +
        fkt_log "$DAEMON" "Escaping query \"$VARS\"" 1                                                             
 +
        VARS="$(httpd -d "$VARS")"                                                                                         
 +
        fkt_log "$DAEMON" "Evaluating query \"$VARS\"" 1                                                               
 +
        eval "$VARS"                                                                                                               
 +
}
    
=Erklaerung=
 
=Erklaerung=

Navigationsmenü