annotate submit_comment.php @ 112:cf31bf5fce72 default tip

Author of the blog post as mail header for efficient spam filtering
author Dirk Olmes <dirk.olmes@codedo.de>
date Tue, 06 Sep 2022 07:04:11 +0200
parents a30aee3f6158
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
1 <?php
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
2 function get_slug()
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
3 {
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
4 $slug = htmlspecialchars($_POST['Slug']);
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
5 if (empty($slug))
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
6 {
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
7 die('POST request did not include value for required key "Slug"');
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
8 }
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
9 return $slug;
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
10 }
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12 if ($_SERVER['REQUEST_METHOD'] == 'POST')
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13 {
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
14 $recipient = 'blog@xanthippe.ping.de';
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
15 $slug = get_slug();
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
16
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
17 $author = htmlspecialchars($_POST['Author']);
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
18 $comment = htmlspecialchars($_POST['Comment']);
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
19 $date = date('Y-m-d H:i:s');
112
cf31bf5fce72 Author of the blog post as mail header for efficient spam filtering
Dirk Olmes <dirk.olmes@codedo.de>
parents: 35
diff changeset
20 $header = 'X-Comment-Author: ' . $author;
35
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
21
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
22 $message = 'Author: ' . $author . PHP_EOL
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
23 . 'Date: ' . $date . PHP_EOL . PHP_EOL
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
24 . $comment;
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
25
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
26 $subject = 'New blog post comment on article ' . $slug;
112
cf31bf5fce72 Author of the blog post as mail header for efficient spam filtering
Dirk Olmes <dirk.olmes@codedo.de>
parents: 35
diff changeset
27 mail($recipient, $subject, $message, $header);
35
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
28
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
29 ?>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
30
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
31 <html>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
32 <head>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
33 <title>Your comment was posted</title>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
34 </head>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
35 <body>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
36 <h1>Thank you</h1>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
37 <p>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
38 Your comment was posted and will appear on the blog as soon as a moderator has reviewed it.
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
39 </p>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
40 <a href="http://xanthippe.duckdns.org/blog/">Back to the blog</a>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
41 </body>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
42 </html>
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
43
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
44 <?php
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
45 }
a30aee3f6158 simple form handler for submitting a comment. This script just forwards the comment via
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
46 ?>