Minor changes to CGI interface.
[newgopher.git] / public_gopher / script.pl
blob70114f6c12b9e95d91ea1dd325ac9da186ac13d0
1 #!/usr/bin/perl
3 if ($ENV{"QUERY_STRING"}) {
4 # Request
5 $cookie = $ENV{"QUERY_STRING"};
6 $data_size = $ENV{"CONTENT_SIZE"} || 1024;
7 $data_read = 0;
9 $data_read = read(STDIN, $data, $data_size);
11 $target = 's'.$ENV{"GOPHER_SELECTOR"}."\t"."gadl"."\t\t\r\n";
12 $buffer = "";
14 @lines = split /\n/, $data;
16 foreach $line (@lines) {
18 ($key, $val) = split /:/, $line;
19 $key =~ s/\s//;
20 $val =~ s/^\s*//;
22 $key =~ tr/A-Z/a-z/;
24 $buffer .= " FORM [$key] = $val \n";
27 $buffer .= "Thank you for your submission! \r\n";
28 #$buffer .= $data;
30 $mimetype = 'text/plain';
31 } else {
32 # Form
33 $cookie = rand();
35 $target = 's'.$ENV{"GOPHER_SELECTOR"}."\t".$cookie."\t\t\r\n";
36 $buffer = "";
38 $buffer .= $target;
39 $buffer .= "Username: \nPassword: \nE-Mail: \n";
41 $mimetype = 'application/x-interactive';
44 $size = length $buffer;
45 print $size."\t".$mimetype."\r\n";
46 print $buffer;