Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add option to change server and port, usefull when we use different s…

…erver (like typepad)
  • Loading branch information...
commit b184820e4467ef910f11a2dd78d99950251d1650 1 parent 7b0497e
@ariews ariews authored Greenek committed
Showing with 11 additions and 2 deletions.
  1. +8 −2 classes/kohana/akismet.php
  2. +3 −0  config/akismet.php
View
10 classes/kohana/akismet.php
@@ -104,6 +104,12 @@ protected function setup(array $config = array())
$this->_config['blog'] = $config['blog'];
}
+ $this->_config['server'] = isset($config['server'])
+ ? $config['server'] : Akismet::AKISMET_HOST;
+
+ $this->_config['port'] = isset($config['port'])
+ ? $config['port'] : Akismet::AKISMET_PORT;
+
// Chainable method
return $this;
}
@@ -113,7 +119,7 @@ protected function setup(array $config = array())
*/
protected function connect()
{
- if ( ! ($this->_connection = @fsockopen(Akismet::AKISMET_HOST, Akismet::AKISMET_PORT)))
+ if ( ! ($this->_connection = @fsockopen($this->_config['server'], $this->_config['port'])))
{
throw new Exception("Could not connect to akismet server.");
}
@@ -141,7 +147,7 @@ protected function response($request, $path)
if ($this->_connection)
{
$http_request = "POST /1.1/$path HTTP/1.0\r\n"
- . "Host: ".(( ! empty($this->_key)) ? $this->_key."." : NULL).Akismet::AKISMET_HOST."\r\n"
+ . "Host: ".(( ! empty($this->_key)) ? $this->_key."." : NULL).$this->_config['server']."\r\n"
. "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n"
. "Content-Length: ".strlen($request)."\r\n"
. "User-Agent: ".Akismet::$_user_agent."\r\n"
View
3  config/akismet.php
@@ -8,4 +8,7 @@
*/
'key' => 'YOUR_API_KEY',
+ 'server' => 'rest.akismet.com',
+ 'port' => 80,
+
);
Please sign in to comment.
Something went wrong with that request. Please try again.