changeset 85:efb93800fe10

Akismet: Légère mise à jour
author Franck Deroche <franck@defr.org>
date Fri, 23 Nov 2018 00:46:07 +0100
parents 0b635e3ae1a1
children e37ef9a81737
files includes/akismet.class.php
diffstat 1 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/includes/akismet.class.php	Fri Nov 23 00:45:27 2018 +0100
+++ b/includes/akismet.class.php	Fri Nov 23 00:46:07 2018 +0100
@@ -124,8 +124,8 @@
 	
 	
 	// Constructor
-	function AkismetHttpClient($host, $blogUrl, $apiKey, $port = 80) {
-		$this->host = $host;
+	function __construct($host, $blogUrl, $apiKey, $port = 80) {
+		$this->host = $apiKey . '.' . $host;
 		$this->port = $port;
 		$this->blogUrl = $blogUrl;
 		$this->apiKey = $apiKey;
@@ -139,7 +139,7 @@
 		if($this->con && !$this->isError(AKISMET_SERVER_NOT_FOUND)) {
 			$request  = 
 					strToUpper($type)." /{$this->akismetVersion}/$path HTTP/1.1\r\n" .
-					"Host: ".((!empty($this->apiKey)) ? $this->apiKey."." : null)."{$this->host}\r\n" .
+					"Host: {$this->host}\r\n" .
 					"Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" .
 					"Content-Length: ".strlen($request)."\r\n" .
 					"User-Agent: Akismet PHP4 Class\r\n" .
@@ -166,8 +166,8 @@
 	
 	// Connect to the Akismet server and store that connection in the instance variable $con
 	function _connect() {
-		if(!($this->con = @fsockopen($this->host, $this->port))) {
-			$this->setError(AKISMET_SERVER_NOT_FOUND, "Could not connect to akismet server.");
+		if(!($this->con = @fsockopen('ssl://' . $this->host, $this->port, $errno, $errstr))) {
+			$this->setError(AKISMET_SERVER_NOT_FOUND, "Could not connect to akismet server: " . $errstr);
 		}
 	}
 	
@@ -187,7 +187,7 @@
 // The controlling class. This is the ONLY class the user should instantiate in
 // order to use the Akismet service!
 class Akismet extends AkismetObject {
-	var $apiPort = 80;
+	var $apiPort = 443;
 	var $akismetServer = 'rest.akismet.com';
 	var $akismetVersion = '1.1';
 	var $http;
@@ -223,13 +223,13 @@
 	 * @param 	String[]	$comment	A formatted comment array to be examined by the Akismet service
 	 * @return	Akismet
 	 */
-	function Akismet($blogUrl, $apiKey, $comment = array()) {
+	function __construct($blogUrl, $apiKey, $comment = array()) {
 		$this->blogUrl = $blogUrl;
 		$this->apiKey  = $apiKey;
 		$this->setComment($comment);
 		
 		// Connect to the Akismet server and populate errors if they exist
-		$this->http = new AkismetHttpClient($this->akismetServer, $blogUrl, $apiKey);
+		$this->http = new AkismetHttpClient($this->akismetServer, $blogUrl, $apiKey, $this->apiPort);
 		if($this->http->errorsExist()) {
 			$this->errors = array_merge($this->errors, $this->http->getErrors());
 		}
@@ -385,4 +385,4 @@
 	
 	
 }
-?>
\ No newline at end of file
+?>