File: foo.cgi

package info (click to toggle)
condor 8.6.8~dfsg.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 79,476 kB
  • sloc: cpp: 649,368; perl: 108,260; python: 22,654; ansic: 20,588; sh: 19,729; fortran: 3,340; yacc: 1,844; makefile: 1,213; xml: 1,003; sql: 767; java: 703; ruby: 512; awk: 505; lex: 248; f90: 64; csh: 24
file content (38 lines) | stat: -rwxr-xr-x 994 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
#
# Parse the query string from the web server, such
# that each GET option ends up as $var_X, where
# X is the name of the option.
#
saveIFS=$IFS
IFS='=&'
parm=($QUERY_STRING)
IFS=$saveIFS
for ((i=0; i<${#parm[@]}; i+=2))
do
  declare var_${parm[i]}=${parm[i+1]}
done
#
# Process callback and jsonp options
#
if [[ -n "$var_callback" ]]; then jsonp="$var_callback"; fi
if [[ -n "$var_jsonp" ]]; then jsonp="$var_jsonp"; fi
#
# Process file option; default to file "foo.json" if not specified
#
if [[ -n "$var_file" ]]; then file="$var_file"; else file="foo"; fi
file=`basename $file`
file=${file//[^a-zA-Z0-9]/}.json
#
# Output HTTP header
#
echo "Content-Type: text/plain"
echo "Cache-Control:public, max-age=10"
echo "Last-Modified:" `TZ=GMT ls -l --time-style="+%a, %d %b %Y %T %Z" "$file" | cut -d' ' -f6-11`
echo
#
# Output content, converting JSON to JSONP if requested
#
if [[ -n "$jsonp" ]]; then echo "$jsonp"'(['; fi
cat "$file"
if [[ -n "$jsonp" ]]; then echo ']);'; fi