From 4b6c0e31385f5f27a151088c0a2b614495c4e589 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 14 Oct 2021 12:47:50 -0400 Subject: initial commit, including theme --- ...ing-akismet-in-php4-to-defeat-comment-spam.html | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 content/posts/2006-03-04-using-akismet-in-php4-to-defeat-comment-spam.html (limited to 'content/posts/2006-03-04-using-akismet-in-php4-to-defeat-comment-spam.html') diff --git a/content/posts/2006-03-04-using-akismet-in-php4-to-defeat-comment-spam.html b/content/posts/2006-03-04-using-akismet-in-php4-to-defeat-comment-spam.html new file mode 100644 index 0000000..6de39cb --- /dev/null +++ b/content/posts/2006-03-04-using-akismet-in-php4-to-defeat-comment-spam.html @@ -0,0 +1,46 @@ +--- +date: "2006-03-04T04:00:46Z" +title: Using Akismet in PHP4 to Defeat Comment Spam +--- + +

I've been having comment spam problems on my personal page. +Wordpress uses Akismet for comment spam filtering now-a-days, +and there are bindings for several languages, including PHP5, +Python, and Ruby. The Akismet API documentation +documentation has a PHP4-friendly code snippet, but a quick +Google search didn't turn up any full-blown PHP4 bindings, +so I wrote my own. Here's an example of the API:

+ +
#
+# Check comment using Akismet (http://akismet.com/).  Returns true for
+# spam, and false for ham.
+#
+function is_comment_spam($news_id, $name, $email, $url, $comment) {
+  global $AKISMET_CONFIG;
+
+  # populate comment information
+  $comment_data = array(
+    'user_ip'               => $_SERVER['REMOTE_ADDR'],
+    'user_agent'            => $_SERVER['HTTP_USER_AGENT'],
+    'referrer'              => $_REQUEST['REFERER'],
+    'permalink'             => "http://paulduncan.org/?id=$news_id",
+    'comment_type'          => 'comment',
+    'comment_author'        => $name,
+    'comment_author_email'  => $email,
+    'comment_author_url'    => $url,
+    'comment_content'       => $comment,
+  );
+
+  # create akismet handle
+  $ak = new Akismet($AKISMET_CONFIG['api_key'], 
+                    $AKISMET_CONFIG['blog']);
+
+  # return akismet result (true for spam, false for ham)
+  return $ak->check_comment($comment_data);
+}
+
+ +

Download php4-akismet-0.1.tar.gz (Signature)

+ +

Update: Fixed a minor typo in the example.

+ -- cgit v1.2.3