Mail Index
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ApacheGallery] Cookie patch
Hi.
Attached is a patch that makes Apache::Gallery set a cookie if the user
chooses something else that the standard resolution.
I don't know if it works under mod_perl2, it has only been tested under
mod_perl1.
--
-René
--- Apache-Gallery-0.7/lib/Apache/Gallery.pm Sun Sep 7 19:30:31 2003
+++ /usr/local/share/perl/5.8.0/Apache/Gallery.pm Tue Sep 9 19:44:48 2003
@@ -48,6 +48,7 @@
use URI::Escape;
use POSIX;
use CGI;
+use CGI::Cookie;
use Data::Dumper;
@@ -391,14 +392,24 @@
# Check if the selected width is allowed
my @sizes = split (/ /, $r->dir_config('GallerySizes') ? $r->dir_config('GallerySizes') : '640 800 1024 1600');
+
+ my %cookies = fetch CGI::Cookie;
+
if ($cgi->param('width')) {
unless ((grep $cgi->param('width') == $_, @sizes) or ($cgi->param('width') == $original_size)) {
show_error($r, 200, "Invalid width", "The specified width is invalid");
return MP2 ? Apache::OK : Apache::Constants::OK;
}
+
$width = $cgi->param('width');
- }
- else {
+ my $cookie = new CGI::Cookie(-name => 'GallerySize', -value => $width, -expires => '+6M');
+ $r->header_out('Set-Cookie',$cookie);
+
+ } elsif ($cookies{'GallerySize'}) {
+
+ $width = $cookies{'GallerySize'}->value;
+
+ } else {
$width = $sizes[0];
}