CGIComment cookie patch
2005/01/06 filed under /nanobloggerA lot of blogs have the abillity to add comments. My blog uses CGIComment for that. Unfortunately, that script doesn't support cookies to store the user's info. This patch will "fix" that. Please note that it's a nasty hack, so make sure you keep a backup of your original cgicomment.pl around!
--- CGIComment-1.1/cgicomment.pl Tue Feb 10 12:29:32 2004
+++ cgicomment.pl Fri Jan 6 22:01:56 2005
@@ -253,6 +253,18 @@
{
# differs from LoadCommentInfo in that the information is fetched
# from the web input form
+ ($CommentInfo{'cookieauthor'},
+ $CommentInfo{'cookieemail'},
+ $CommentInfo{'cookiesite'}) = split(';;', $cgi->cookie('blog'))
+ if($cgi->cookie('blog'));
+
+ $CommentInfo{'cookieauthor'} = $cgi->param('author')
+ if($cgi->param('author'));
+ $CommentInfo{'cookieemail'} = $cgi->param('email')
+ if($cgi->param('email'));
+ $CommentInfo{'cookiesite'} = $cgi->param('site')
+ if($cgi->param('site'));
+
$CommentInfo{'article'} = filterUserInput($cgi->param('article'));
$CommentInfo{'email'} = filterUserInput($cgi->param('email')) || '';
@@ -736,7 +748,15 @@
}
-print "Content-type: text/html\n\n";
+FetchCommentInfo();
+
+my $cookie = $cgi->cookie(-name => 'blog',
+ -value => ($CommentInfo{'cookieauthor'}||'').";;".
+ ($CommentInfo{'cookieemail'}||'') .";;".
+ ($CommentInfo{'cookiesite'}||''),
+ -expires=>'+1y');
+
+print $cgi->header(-cookie=>$cookie);
$CommentInfo{'basedir'} = $basedir;


