Mercurial > hg > chronicle
comparison cgi-bin/comments.cgi @ 175:887a460d77d5
Ran through perltidy
author | Steve Kemp <steve@steve.org.uk> |
---|---|
date | Tue, 01 Apr 2008 20:47:13 +0100 |
parents | 4d2f0d6866e5 |
children | e0ef0f218600 |
comparison
equal
deleted
inserted
replaced
174:4b0b1944e6bb | 175:887a460d77d5 |
---|---|
47 my $TO = 'weblog@steve.org.uk'; | 47 my $TO = 'weblog@steve.org.uk'; |
48 my $FROM = 'weblog@steve.org.uk'; | 48 my $FROM = 'weblog@steve.org.uk'; |
49 | 49 |
50 | 50 |
51 | 51 |
52 | |
53 | |
54 | |
55 # | 52 # |
56 # Get the parameters from the request. | 53 # Get the parameters from the request. |
57 # | 54 # |
58 my $cgi = new CGI(); | 55 my $cgi = new CGI(); |
59 my $name = $cgi->param('name') || undef; | 56 my $name = $cgi->param('name') || undef; |
60 my $mail = $cgi->param('mail') || undef; | 57 my $mail = $cgi->param('mail') || undef; |
61 my $body = $cgi->param('body') || undef; | 58 my $body = $cgi->param('body') || undef; |
62 my $id = $cgi->param('id') || undef; | 59 my $id = $cgi->param('id') || undef; |
63 my $cap = $cgi->param('captcha') || undef; | 60 my $cap = $cgi->param('captcha') || undef; |
64 my $ajax = $cgi->param( "ajax" ) || 0; | 61 my $ajax = $cgi->param("ajax") || 0; |
65 | 62 |
66 | 63 |
67 # | 64 # |
68 # If any are missing just redirect back to the blog homepage. | 65 # If any are missing just redirect back to the blog homepage. |
69 # | 66 # |
70 if ( !defined( $name ) || !length( $name ) || | 67 if ( !defined($name) |
71 !defined( $mail ) || !length( $mail ) || | 68 || !length($name) |
72 !defined( $body ) || !length( $body ) || | 69 || !defined($mail) |
73 !defined( $id ) || !length( $id ) ) | 70 || !length($mail) |
71 || !defined($body) | |
72 || !length($body) | |
73 || !defined($id) | |
74 || !length($id) ) | |
74 { | 75 { |
75 if ( $ajax ) | 76 if ($ajax) |
76 { | 77 { |
77 print "Content-type: text/html\n\n"; | 78 print "Content-type: text/html\n\n"; |
78 print "Missing fields.\n"; | 79 print "Missing fields.\n"; |
79 } | 80 } |
80 else | 81 else |
85 } | 86 } |
86 | 87 |
87 # | 88 # |
88 # Does the captcha value contain text? If so spam. | 89 # Does the captcha value contain text? If so spam. |
89 # | 90 # |
90 if ( defined( $cap ) && length( $cap ) ) | 91 if ( defined($cap) && length($cap) ) |
91 { | 92 { |
92 if ( $ajax ) | 93 if ($ajax) |
93 { | 94 { |
94 print "Content-type: text/html\n\n"; | 95 print "Content-type: text/html\n\n"; |
95 print "Missing fields.\n"; | 96 print "Missing fields.\n"; |
96 } | 97 } |
97 else | 98 else |
111 # Otherwise save them away. | 112 # Otherwise save them away. |
112 # | 113 # |
113 # | 114 # |
114 # ID. | 115 # ID. |
115 # | 116 # |
116 if ( $id =~ /^(.*)[\/\\](.*)$/ ){ | 117 if ( $id =~ /^(.*)[\/\\](.*)$/ ) |
117 $id=$2; | 118 { |
119 $id = $2; | |
118 } | 120 } |
119 | 121 |
120 | 122 |
121 # | 123 # |
122 # Show the header | 124 # Show the header |
139 open( FILE, ">", $file ); | 141 open( FILE, ">", $file ); |
140 print FILE "Name: $name\n"; | 142 print FILE "Name: $name\n"; |
141 print FILE "Mail: $mail\n"; | 143 print FILE "Mail: $mail\n"; |
142 print FILE "User-Agent: $ENV{'HTTP_USER_AGENT'}\n"; | 144 print FILE "User-Agent: $ENV{'HTTP_USER_AGENT'}\n"; |
143 print FILE "IP-Address: $ENV{'REMOTE_ADDR'}\n"; | 145 print FILE "IP-Address: $ENV{'REMOTE_ADDR'}\n"; |
144 print FILE "\n"; | 146 print FILE "\n"; |
145 print FILE $body; | 147 print FILE $body; |
146 close( FILE ); | 148 close(FILE); |
147 | 149 |
148 | 150 |
149 # | 151 # |
150 # Send a mail. | 152 # Send a mail. |
151 # | 153 # |
152 if ( length($TO) && length($FROM) ) | 154 if ( length($TO) && length($FROM) ) |
153 { | 155 { |
154 open ( SENDMAIL, "|/usr/lib/sendmail -t -f $FROM"); | 156 open( SENDMAIL, "|/usr/lib/sendmail -t -f $FROM" ); |
155 print SENDMAIL "To: $TO\n"; | 157 print SENDMAIL "To: $TO\n"; |
156 print SENDMAIL "From: $FROM\n"; | 158 print SENDMAIL "From: $FROM\n"; |
157 print SENDMAIL "Subject: New Comment [$id]\n"; | 159 print SENDMAIL "Subject: New Comment [$id]\n"; |
158 print SENDMAIL "\n\n"; | 160 print SENDMAIL "\n\n"; |
159 print SENDMAIL `cat $file`; | 161 print SENDMAIL `cat $file`; |
160 close( SENDMAIL ); | 162 close(SENDMAIL); |
161 } | 163 } |
162 | 164 |
163 # | 165 # |
164 # Now show the user the thanks message.. | 166 # Now show the user the thanks message.. |
165 # | 167 # |
166 if ( $cgi->param( "ajax" ) ) | 168 if ( $cgi->param("ajax") ) |
167 { | 169 { |
168 print <<EOF; | 170 print <<EOF; |
169 <h3>Comment Submitted</h3> | 171 <h3>Comment Submitted</h3> |
170 <blockquote> | 172 <blockquote> |
171 <p>Thanks for your comment, it will be made live when the queue is moderated next.</p> | 173 <p>Thanks for your comment, it will be made live when the queue is moderated next.</p> |