2007-07-19 12:40:05 +02:00
|
|
|
<?php
|
2008-02-25 03:10:37 +01:00
|
|
|
/**
|
2010-05-09 22:11:00 +02:00
|
|
|
* The SSAkismet class provides spam detection for comments using http://akismet.com/.
|
|
|
|
* In order to use it, you must get an API key, which you can get free for non-commercial use by signing
|
|
|
|
* up for a http://www.wordpress.com account. Commercial keys can be bought at http://akismet.com/commercial/.
|
|
|
|
*
|
|
|
|
* To enable spam detection, set your API key in _config.php.
|
|
|
|
* The following lines should be added to **mysite/_config.php**
|
|
|
|
* (or to the _config.php in another folder if you're not using mysite).
|
|
|
|
*
|
|
|
|
* <code>
|
|
|
|
* SSAkismet::setAPIKey('<your-key>');
|
|
|
|
* </code>
|
|
|
|
*
|
|
|
|
* You can then view spam for a page by appending <i>?showspam=1</i> to the url, or use the {@link CommentAdmin} in the CMS.
|
|
|
|
*
|
|
|
|
* @see http://demo.silverstripe.com/blog Demo of SSAkismet in action
|
|
|
|
*
|
2008-02-25 03:10:37 +01:00
|
|
|
* @package cms
|
|
|
|
* @subpackage comments
|
|
|
|
*/
|
2007-07-19 12:40:05 +02:00
|
|
|
class SSAkismet extends Akismet {
|
|
|
|
private static $apiKey;
|
2007-08-10 04:14:56 +02:00
|
|
|
private static $saveSpam = true;
|
2007-07-19 12:40:05 +02:00
|
|
|
|
|
|
|
static function setAPIKey($key) {
|
|
|
|
self::$apiKey = $key;
|
|
|
|
}
|
|
|
|
|
|
|
|
static function isEnabled() {
|
|
|
|
return (self::$apiKey != null) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static function setSaveSpam($save = true) {
|
|
|
|
SSAkismet::$saveSpam = $save;
|
|
|
|
}
|
|
|
|
|
|
|
|
static function getSaveSpam() {
|
|
|
|
return SSAkismet::$saveSpam;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct(Director::absoluteBaseURL(), self::$apiKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|