[pLog-svn] r6191 - in plugins/branches/lifetype-1.2/akismet: . class/security
pwestbro at devel.lifetype.net
pwestbro at devel.lifetype.net
Thu Feb 28 05:54:50 EST 2008
Author: pwestbro
Date: 2008-02-28 05:54:49 -0500 (Thu, 28 Feb 2008)
New Revision: 6191
Modified:
plugins/branches/lifetype-1.2/akismet/class/security/Akismet.class.php
plugins/branches/lifetype-1.2/akismet/pluginakismet.class.php
Log:
Updated to the latest version of the php4 Akismet library
Modified: plugins/branches/lifetype-1.2/akismet/class/security/Akismet.class.php
===================================================================
--- plugins/branches/lifetype-1.2/akismet/class/security/Akismet.class.php 2008-02-27 10:24:24 UTC (rev 6190)
+++ plugins/branches/lifetype-1.2/akismet/class/security/Akismet.class.php 2008-02-28 10:54:49 UTC (rev 6191)
@@ -1,6 +1,6 @@
<?php
/**
- * 01.26.2006 12:29:28est
+ * 01.07.2008 22:32:28est
*
* Akismet PHP4 class
*
@@ -16,7 +16,7 @@
*
* $akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment);
*
- * if($akismet->isError()) {
+ * if($akismet->errorsExist()) {
* echo"Couldn't connected to Akismet server!";
* } else {
* if($akismet->isSpam()) {
@@ -28,8 +28,8 @@
* </code>
*
* @author Bret Kuhns {@link www.miphp.net}
- * @link http://www.miphp.net/blog/view/php4_akismet_class/
- * @version 0.3.3
+ * @link http://www.miphp.net/blog/view/new_akismet_class/
+ * @version 0.3.4
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
@@ -221,26 +221,13 @@
* @param String $blogUrl The URL to your own blog
* @param String $apiKey Your wordpress API key
* @param String[] $comment A formatted comment array to be examined by the Akismet service
+ * @return Akismet
*/
- function Akismet($blogUrl, $apiKey, $comment) {
+ function Akismet($blogUrl, $apiKey, $comment = array()) {
$this->blogUrl = $blogUrl;
$this->apiKey = $apiKey;
+ $this->setComment($comment);
- // Populate the comment array with information needed by Akismet
- $this->comment = $comment;
- $this->_formatCommentArray();
-
- if(!isset($this->comment['user_ip'])) {
- $this->comment['user_ip'] = ($_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR');
- }
- if(!isset($this->comment['user_agent'])) {
- $this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
- }
- if(!isset($this->comment['referrer'])) {
- $this->comment['referrer'] = $_SERVER['HTTP_REFERER'];
- }
- $this->comment['blog'] = $blogUrl;
-
// Connect to the Akismet server and populate errors if they exist
$this->http = new AkismetHttpClient($this->akismetServer, $blogUrl, $apiKey);
if($this->http->errorsExist()) {
@@ -287,6 +274,31 @@
/**
+ * Manually set the comment value of the instantiated object.
+ *
+ * @param Array $comment
+ * @return void
+ */
+ function setComment($comment) {
+ $this->comment = $comment;
+ if(!empty($comment)) {
+ $this->_formatCommentArray();
+ $this->_fillCommentValues();
+ }
+ }
+
+
+ /**
+ * Returns the current value of the object's comment array.
+ *
+ * @return Array
+ */
+ function getComment() {
+ return $this->comment;
+ }
+
+
+ /**
* Check with the Akismet server to determine if the API key is valid
*
* @access Protected
@@ -325,6 +337,27 @@
/**
+ * Fill any values not provided by the developer with available values.
+ *
+ * @return void
+ */
+ function _fillCommentValues() {
+ if(!isset($this->comment['user_ip'])) {
+ $this->comment['user_ip'] = ($_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR');
+ }
+ if(!isset($this->comment['user_agent'])) {
+ $this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
+ }
+ if(!isset($this->comment['referrer'])) {
+ $this->comment['referrer'] = $_SERVER['HTTP_REFERER'];
+ }
+ if(!isset($this->comment['blog'])) {
+ $this->comment['blog'] = $this->blogUrl;
+ }
+ }
+
+
+ /**
* Build a query string for use with HTTP requests
*
* @access Protected
Modified: plugins/branches/lifetype-1.2/akismet/pluginakismet.class.php
===================================================================
--- plugins/branches/lifetype-1.2/akismet/pluginakismet.class.php 2008-02-27 10:24:24 UTC (rev 6190)
+++ plugins/branches/lifetype-1.2/akismet/pluginakismet.class.php 2008-02-28 10:54:49 UTC (rev 6191)
@@ -32,7 +32,7 @@
$this->desc = "Akismet checks your comments against the Akismet web serivce to see if they look like spam or not.";
$this->author = "Paul Westbrook (Akismet php library provided by <a href=\"http://miphp.net/blog/view/php4_akismet_class\">Bret Kuhns</a>)";
$this->locales = Array( "en_UK" );
- $this->version = "20080107";
+ $this->version = "20080228";
if( $source == "admin" )
$this->initAdmin();
More information about the pLog-svn
mailing list