BxAntispamAkismet.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup Antispam Antispam
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Spam detection based on the message content and logged in user info - http://akismet.com
  13. */
  14. class BxAntispamAkismet extends BxDol
  15. {
  16. protected $oAkismet = null;
  17. public function __construct($iProfileID = 0)
  18. {
  19. parent::__construct();
  20. $sKey = getParam('bx_antispam_akismet_api_key');
  21. if ($sKey) {
  22. require_once (BX_DIRECTORY_PATH_PLUGINS . 'akismet/Akismet.class.php');
  23. $this->oAkismet = new Akismet(BX_DOL_URL_ROOT, $sKey);
  24. $aProfile = getProfileInfo($iProfileID);
  25. if ($aProfile) {
  26. $this->oAkismet->setCommentAuthor($aProfile['NickName']);
  27. $this->oAkismet->setCommentAuthorEmail($aProfile['Email']);
  28. $this->oAkismet->setCommentAuthorURL(getProfileLink($aProfile['ID']));
  29. }
  30. }
  31. }
  32. public function isSpam ($s, $sPermalink = false)
  33. {
  34. if (!$this->oAkismet)
  35. return false;
  36. $this->oAkismet->setCommentContent($s);
  37. if ($sPermalink)
  38. $this->oAkismet->setPermalink($sPermalink);
  39. return $this->oAkismet->isCommentSpam();
  40. }
  41. public function onPositiveDetection ($sExtraData = '')
  42. {
  43. $o = bx_instance('BxDolDNSBlacklists');
  44. $o->onPositiveDetection (getVisitorIP(), $sExtraData, 'akismet');
  45. }
  46. }
  47. /** @} */