-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomment-insert.php
More file actions
60 lines (48 loc) · 1.85 KB
/
comment-insert.php
File metadata and controls
60 lines (48 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/*
* comment.php 04/04/2010
* Version 0.1
*/
require("inc/config.php");
include("inc/class/core.class.php");
include("inc/microakismet-1.2/class.microakismet.inc.php");
$comment = new Comments();
//get POST variable
$name = addslashes($_POST['name']);
$email = addslashes($_POST['email']);
$website = addslashes($_POST['website']);
$comment = addslashes(strip_tags($_POST['comment'],'<a>'));
$post_id = $_POST['post_id'];
$ip = $_SERVER['REMOTE_ADDR'];
$user_agent = $_SERVER['HTTP_USER_AGENT'];
// Now check if the comment is spam with Akismet
$vars = array();
// Mandatory fields of information
$vars["user_ip"] = $ip;
$vars["user_agent"] = $user_agent;
// The body of the message to check, the name of the person who
// posted it, and their email address
$vars["comment_content"] = $comment;
$vars["comment_author"] = $name;
$vars["comment_author_email"] = $email;
$akismet = new MicroAkismet("$akismet_key","$tld","$tUrl");
// Check if it's spam
if ($akismet->check($vars)) {
//it's a spam
$sql = "insert into `$tprefix"."_comments` ( `post_id` , `name` , `email` , `website`,`comment`,`ip` ,`user_agent`, `status` ) values ('$post_id','$name','$email','$website','$comment','$ip','$user_agent','U')"; //echo $sql;
}
else {
// it's not a spam
$sql = "insert into `$tprefix"."_comments` ( `post_id` , `name` , `email` , `website`,`comment`,`ip` ,`user_agent`, `status` ) values ('$post_id','$name','$email','$website','$comment','$ip','$user_agent','P')";//echo $sql;
}
/*insert the comment into the comments table if all verification passed
statuses : U unpublished
P published
D deleted
A awaiting moderation
*/
//echo $sql;
$db->query($sql);
//END OF METADATA PROCESSING
echo "<META http-equiv='refresh' content='0; url=". $_SERVER['HTTP_REFERER']."'>";
$db->close();