fixes #83: Class-named constructors in Akisment plugin; also: PHP warnings fixed
This commit is contained in:
		
							parent
							
								
									bdf9e780e1
								
							
						
					
					
						commit
						5ad886b894
					
				@ -1,4 +1,5 @@
 | 
				
			|||||||
<?php
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Akismet anti-comment spam service
 | 
					 * Akismet anti-comment spam service
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@ -49,12 +50,19 @@
 | 
				
			|||||||
 * @link http://www.achingbrain.net/
 | 
					 * @link http://www.achingbrain.net/
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class Akismet {
 | 
					class Akismet {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $version = '0.2';
 | 
						var $version = '0.2';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $wordPressAPIKey;
 | 
						var $wordPressAPIKey;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $blogURL;
 | 
						var $blogURL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $comment;
 | 
						var $comment;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $apiPort;
 | 
						var $apiPort;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $akismetServer;
 | 
						var $akismetServer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $akismetVersion;
 | 
						var $akismetVersion;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// This prevents some potentially sensitive information from being sent accross the wire.
 | 
						// This prevents some potentially sensitive information from being sent accross the wire.
 | 
				
			||||||
@ -73,13 +81,15 @@ class Akismet {
 | 
				
			|||||||
		'PHP_SELF'
 | 
							'PHP_SELF'
 | 
				
			||||||
	);
 | 
						);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
	 * @throws Exception An exception is thrown if your API key is invalid.
 | 
						 * @throws Exception An exception is thrown if your API key is invalid.
 | 
				
			||||||
	 *	@param	string	Your WordPress API key.
 | 
						 * @param
 | 
				
			||||||
	 *	@param	string	$blogURL			The URL of your blog.
 | 
						 *        	string Your WordPress API key.
 | 
				
			||||||
 | 
						 * @param string $blogURL
 | 
				
			||||||
 | 
						 *        	The URL of your blog.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	function Akismet($blogURL, $wordPressAPIKey) {
 | 
						function __construct($blogURL, $wordPressAPIKey) {
 | 
				
			||||||
		$this->blogURL = $blogURL;
 | 
							$this->blogURL = $blogURL;
 | 
				
			||||||
		$this->wordPressAPIKey = $wordPressAPIKey;
 | 
							$this->wordPressAPIKey = $wordPressAPIKey;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -111,15 +121,13 @@ class Akismet {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	function http_post($request, $host, $path) {
 | 
						function http_post($request, $host, $path) {
 | 
				
			||||||
		$http_request  = 
 | 
							$http_request = "POST " . $path . " HTTP/1.0\r\n" . //
 | 
				
			||||||
				"POST " . $path . " HTTP/1.0\r\n" .
 | 
							"Host: " . $host . "\r\n" . //
 | 
				
			||||||
				"Host: " . $host . "\r\n" .
 | 
							"Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" . //
 | 
				
			||||||
				"Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" .
 | 
							"Content-Length: " . strlen($request) . "\r\n" . //
 | 
				
			||||||
				"Content-Length: " . strlen($request) . "\r\n" .
 | 
							"User-Agent: Akismet PHP5 Class " . $this->version . " | Akismet/1.11\r\n" . //
 | 
				
			||||||
				"User-Agent: Akismet PHP5 Class " . $this->version . " | Akismet/1.11\r\n" .
 | 
							"\r\n" . //
 | 
				
			||||||
				"\r\n" .
 | 
							$request;
 | 
				
			||||||
				$request
 | 
					 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$socketWriteRead = new SocketWriteRead($host, $this->apiPort, $http_request);
 | 
							$socketWriteRead = new SocketWriteRead($host, $this->apiPort, $http_request);
 | 
				
			||||||
		$socketWriteRead->send();
 | 
							$socketWriteRead->send();
 | 
				
			||||||
@ -183,7 +191,8 @@ class Akismet {
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * To override the user IP address when submitting spam/ham later on
 | 
						 * To override the user IP address when submitting spam/ham later on
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
	 *	@param string $userip	An IP address.  Optional.
 | 
						 * @param string $userip
 | 
				
			||||||
 | 
						 *        	An IP address. Optional.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	function setUserIP($userip) {
 | 
						function setUserIP($userip) {
 | 
				
			||||||
		$this->comment ['user_ip'] = $userip;
 | 
							$this->comment ['user_ip'] = $userip;
 | 
				
			||||||
@ -192,7 +201,8 @@ class Akismet {
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * To override the referring page when submitting spam/ham later on
 | 
						 * To override the referring page when submitting spam/ham later on
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
	 *	@param string $referrer	The referring page.  Optional.
 | 
						 * @param string $referrer
 | 
				
			||||||
 | 
						 *        	The referring page. Optional.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	function setReferrer($referrer) {
 | 
						function setReferrer($referrer) {
 | 
				
			||||||
		$this->comment ['referrer'] = $referrer;
 | 
							$this->comment ['referrer'] = $referrer;
 | 
				
			||||||
@ -201,7 +211,8 @@ class Akismet {
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * A permanent URL referencing the blog post the comment was submitted to.
 | 
						 * A permanent URL referencing the blog post the comment was submitted to.
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
	 *	@param string $permalink	The URL.  Optional.
 | 
						 * @param string $permalink
 | 
				
			||||||
 | 
						 *        	The URL. Optional.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	function setPermalink($permalink) {
 | 
						function setPermalink($permalink) {
 | 
				
			||||||
		$this->comment ['permalink'] = $permalink;
 | 
							$this->comment ['permalink'] = $permalink;
 | 
				
			||||||
@ -266,8 +277,8 @@ class Akismet {
 | 
				
			|||||||
	function setAkismetVersion($akismetVersion) {
 | 
						function setAkismetVersion($akismetVersion) {
 | 
				
			||||||
		$this->akismetVersion = $akismetVersion;
 | 
							$this->akismetVersion = $akismetVersion;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Utility class used by Akismet
 | 
					 * Utility class used by Akismet
 | 
				
			||||||
@ -285,21 +296,33 @@ class Akismet {
 | 
				
			|||||||
 * @link http://www.achingbrain.net/
 | 
					 * @link http://www.achingbrain.net/
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class SocketWriteRead {
 | 
					class SocketWriteRead {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $host;
 | 
						var $host;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $port;
 | 
						var $port;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $request;
 | 
						var $request;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $response;
 | 
						var $response;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $responseLength;
 | 
						var $responseLength;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $errorNumber;
 | 
						var $errorNumber;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var $errorString;
 | 
						var $errorString;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 *	@param	string	$host			The host to send/receive data.
 | 
						 *
 | 
				
			||||||
	 *	@param	int		$port			The port on the remote host.
 | 
						 * @param string $host
 | 
				
			||||||
	 *	@param	string	$request		The data to send.
 | 
						 *        	The host to send/receive data.
 | 
				
			||||||
	 *	@param	int		$responseLength	The amount of data to read.  Defaults to 1160 bytes.
 | 
						 * @param int $port
 | 
				
			||||||
 | 
						 *        	The port on the remote host.
 | 
				
			||||||
 | 
						 * @param string $request
 | 
				
			||||||
 | 
						 *        	The data to send.
 | 
				
			||||||
 | 
						 * @param int $responseLength
 | 
				
			||||||
 | 
						 *        	The amount of data to read. Defaults to 1160 bytes.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	function SocketWriteRead($host, $port, $request, $responseLength = 1160) {
 | 
						function __construct($host, $port, $request, $responseLength = 1160) {
 | 
				
			||||||
		$this->host = $host;
 | 
							$this->host = $host;
 | 
				
			||||||
		$this->port = $port;
 | 
							$this->port = $port;
 | 
				
			||||||
		$this->request = $request;
 | 
							$this->request = $request;
 | 
				
			||||||
@ -316,8 +339,7 @@ class SocketWriteRead {
 | 
				
			|||||||
	function send() {
 | 
						function send() {
 | 
				
			||||||
		$this->response = '';
 | 
							$this->response = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$fs = fsockopen($this->host, $this->port, $this->errorNumber, $this->errorString, 
 | 
							$fs = fsockopen($this->host, $this->port, $this->errorNumber, $this->errorString, AKISMET_TIMEOUT);
 | 
				
			||||||
						AKISMET_TIMEOUT);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if ($this->errorNumber != 0) {
 | 
							if ($this->errorNumber != 0) {
 | 
				
			||||||
			trigger_error('Error connecting to host: ' . $this->host . ' Error number: ' . $this->errorNumber . ' Error message: ' . $this->errorString, E_USER_ERROR);
 | 
								trigger_error('Error connecting to host: ' . $this->host . ' Error number: ' . $this->errorNumber . ' Error message: ' . $this->errorString, E_USER_ERROR);
 | 
				
			||||||
@ -364,5 +386,6 @@ class SocketWriteRead {
 | 
				
			|||||||
	function getErrorString() {
 | 
						function getErrorString() {
 | 
				
			||||||
		return $this->errorString;
 | 
							return $this->errorString;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
?>
 | 
					?>
 | 
				
			||||||
@ -62,7 +62,7 @@ if (class_exists('AdminPanelAction')) {
 | 
				
			|||||||
			$this->smarty->assign('akismetconf', $akismetconf);
 | 
								$this->smarty->assign('akismetconf', $akismetconf);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		function onsubmit() {
 | 
							function onsubmit($data = null) {
 | 
				
			||||||
			global $fp_config;
 | 
								global $fp_config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if ($_POST ['wp-apikey']) {
 | 
								if ($_POST ['wp-apikey']) {
 | 
				
			||||||
 | 
				
			|||||||
@ -8,7 +8,7 @@
 | 
				
			|||||||
{html_form}
 | 
					{html_form}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	<h4><label for="wp-apikey">{$plang.apikey}</label></h4>
 | 
						<h4><label for="wp-apikey">{$plang.apikey}</label></h4>
 | 
				
			||||||
	<p><input id="wp-apikey" type="text" name="wp-apikey" value="{$akismetconf.apikey}" /> 
 | 
						<p><input id="wp-apikey" type="text" name="wp-apikey" value="{$akismetconf.apikey|default:''}" /> 
 | 
				
			||||||
	<input type="submit" value="{$plang.submit}"/> </p>
 | 
						<input type="submit" value="{$plang.submit}"/> </p>
 | 
				
			||||||
	<p> {$plang.whatis} </p>
 | 
						<p> {$plang.whatis} </p>
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user