]> git.donarmstrong.com Git - debbugs.git/blob - cgi/cookies.cgi
[project @ 2005-08-11 08:57:00 by ajt]
[debbugs.git] / cgi / cookies.cgi
1 #!/usr/bin/perl -w
2
3 use strict;
4 use POSIX qw(strftime);
5 require './common.pl';
6
7 $ENV{"HTTP_COOKIES"} = "";
8 my %param = readparse();
9
10 my $clear = (defined $param{"clear"} && $param{"clear"} eq "yes");
11 my @time_now = gmtime(time());
12 my $time_future = strftime("%a, %d-%b-%Y %T GMT",
13                         59, 59, 23, 31, 11, $time_now[5]+10);
14 my $time_past = strftime("%a, %d-%b-%Y %T GMT",
15                         59, 59, 23, 31, 11, $time_now[5]-10);
16
17 my @cookie_options = qw(repeatmerged terse reverse trim);
18
19 print "Content-Type: text/html; charset=utf-8\n";
20
21 for my $c (@cookie_options) {
22     if (defined $param{$c}) {
23         printf "Set-Cookie: %s=%s; expires=%s; domain=%s; path=/\n",
24              $c, $param{$c}, $time_future, "bugs.debian.org";
25     } elsif ($clear) {
26         printf "Set-Cookie: %s=%s; expires=%s; domain=%s; path=/\n",
27              $c, "", $time_past, "bugs.debian.org";
28     }
29 }
30 print "\n";
31 print "<p>Cookies set!\n";
32 for my $c (@cookie_options) {
33     if (defined $param{$c}) {
34         printf "<br>Set %s=%s\n", $c, $param{$c};
35     } elsif ($clear) {
36         printf "<br>Cleared %s\n", $c;
37     } else {
38         printf "<br>Didn't touch %s (use clear=yes to clear)\n", $c;
39     }
40 }