#!/usr/bin/perl -w # # stylesheet.cgi # John Simpson 2008-08-07 # # sets a cookie "stylesheet=___" which is used by stylesheet.shtml # to emit the proper stylesheet tag # ############################################################################### # # Copyright (C) 2008 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 3, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ############################################################################### require 5.003 ; use strict ; use POSIX qw ( strftime ) ; ############################################################################### # # configuration # list of allowable names. if requested name is not on this list, the first # item on the list will be used instead. my @names = qw ( black white ) ; ############################################################################### ############################################################################### ############################################################################### # # figure out what the user is asking for # if the value is not in the list, use the first item in the list instead. my $name = $names[0] ; my $want = ( $ENV{"PATH_INFO"} || "" ) ; $want =~ s|^/|| ; for my $z ( @names ) { if ( $want eq $z ) { $name = $want ; last ; } } ######################################## # where are we sending them? my $loc = ( $ENV{"HTTP_REFERER"} || "/" ) ; ######################################## # cookie expires in one year my @t = gmtime ; $t[5] ++ ; my $ex = strftime ( "%a, %d-%b-%Y %T GMT" , @t[0..5] ) ; ######################################## # send the cookie to the browser print <

$loc

EOF ######################################## # outta here exit 0 ;