Mercurial > hg > chronicle
comparison cgi-bin/comments.cgi @ 205:e0ef0f218600
Updated CGI script a little
author | Steve Kemp <steve@steve.org.uk> |
---|---|
date | Mon, 14 Apr 2008 19:07:05 +0100 |
parents | 887a460d77d5 |
children | 52326e71a41e |
comparison
equal
deleted
inserted
replaced
204:1d4f3be0e000 | 205:e0ef0f218600 |
---|---|
33 use POSIX qw(strftime); | 33 use POSIX qw(strftime); |
34 | 34 |
35 | 35 |
36 | 36 |
37 # | 37 # |
38 # The directory to store comments in | 38 # The directory to store comments in. |
39 # | |
40 # NOTE: This should be writeable to the www-data user, and shouldn't | |
41 # be inside your web-root - or you open up a security hole. | |
39 # | 42 # |
40 # my $COMMENT = "/home/www/comments/"; | 43 # my $COMMENT = "/home/www/comments/"; |
41 # | 44 # |
42 my $COMMENT = $ENV{'DOCUMENT_ROOT'} . "../comments/"; | 45 my $COMMENT = $ENV{'DOCUMENT_ROOT'} . "../comments/"; |
43 | 46 |
51 | 54 |
52 # | 55 # |
53 # Get the parameters from the request. | 56 # Get the parameters from the request. |
54 # | 57 # |
55 my $cgi = new CGI(); | 58 my $cgi = new CGI(); |
56 my $name = $cgi->param('name') || undef; | 59 my $name = $cgi->param('name') || undef; |
57 my $mail = $cgi->param('mail') || undef; | 60 my $mail = $cgi->param('mail') || undef; |
58 my $body = $cgi->param('body') || undef; | 61 my $body = $cgi->param('body') || undef; |
59 my $id = $cgi->param('id') || undef; | 62 my $id = $cgi->param('id') || undef; |
60 my $cap = $cgi->param('captcha') || undef; | 63 my $cap = $cgi->param('captcha') || undef; |
61 my $ajax = $cgi->param("ajax") || 0; | 64 my $ajax = $cgi->param("ajax") || 0; |
62 | 65 |
63 | 66 |
64 # | 67 # |
65 # If any are missing just redirect back to the blog homepage. | 68 # If any are missing just redirect back to the blog homepage. |
66 # | 69 # |
134 | 137 |
135 # | 138 # |
136 # Open the file. | 139 # Open the file. |
137 # | 140 # |
138 my $file = $COMMENT . "/" . $id . "." . $timestr; | 141 my $file = $COMMENT . "/" . $id . "." . $timestr; |
139 $file =~ s/[ \t]//g; | 142 $file =~ s/[^a-z0-9]/_/gi; |
140 | 143 |
141 open( FILE, ">", $file ); | 144 open( FILE, ">", $file ); |
142 print FILE "Name: $name\n"; | 145 print FILE "Name: $name\n"; |
143 print FILE "Mail: $mail\n"; | 146 print FILE "Mail: $mail\n"; |
144 print FILE "User-Agent: $ENV{'HTTP_USER_AGENT'}\n"; | 147 print FILE "User-Agent: $ENV{'HTTP_USER_AGENT'}\n"; |