Commit | Line | Data |
---|---|---|
21c4e167 H |
1 | #!/bin/bash |
2 | #BHP - BASH Home Page - Library | |
3 | ||
4 | $_GET="$QUERY_STRING"; | |
5 | read _POST; | |
6 | if [ "$REQUEST_METHOD" == 'POST' ]; then | |
7 | QUERY_STRING="$POST"; | |
8 | fi | |
9 | ||
10 | QUERY_STRING='hl=cs&q=%C5%BElu%C5%A5ou%C4%8Dk%C3%BD+k%C3%BA%C5%88&btnG=Hledat&lr='; #debug-only | |
11 | ||
12 | echo -ne 'Content-type: text/html\n\n' | |
13 | ||
14 | urldecode() { | |
15 | echo -e $( echo "$@" | sed -e 's/+/ /g;s/%/\\x/g' ); | |
16 | } | |
17 | ||
18 | urlvalue() { | |
19 | if [[ ! -z "$2" ]]; then QUERY_STRING="$2"; fi; | |
20 | echo "$QUERY_STRING" | sed -e 's/&/\n/g'| while read i; do | |
21 | param="$(echo $i | cut -d = -f 1)"; param="$(urldecode $param)"; | |
22 | value="$(echo $i | cut -d = -f 2)"; value="$(urldecode $value)"; | |
23 | if [[ "$param" == "$1" ]]; then echo "$value"; break; fi; | |
24 | done; | |
25 | return 1; | |
26 | } | |
27 | ||
28 | urlvalue q | |
29 | echo "ret = $?"; | |
30 | urlvalue qos | |
31 | echo "ret = $?"; |