svn: /pear/packages/Bugtracker/trunk/ README include/akismet.php

From: Date: Tue, 02 Mar 2010 01:52:25 +0000
Subject: svn: /pear/packages/Bugtracker/trunk/ README include/akismet.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-9234@lists.php.net to get a copy of this message
rasmus Tue, 02 Mar 2010 01:52:25 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=295713 Log: Initial work to try Akismet to catch bug comment spam - not hooked up yet. akismet() can be called just like is_spam() Changed paths: U pear/packages/Bugtracker/trunk/README A pear/packages/Bugtracker/trunk/include/akismet.php Modified: pear/packages/Bugtracker/trunk/README =================================================================== --- pear/packages/Bugtracker/trunk/README 2010-03-02 01:50:22 UTC (rev 295712) +++ pear/packages/Bugtracker/trunk/README 2010-03-02 01:52:25 UTC (rev 295713) @@ -25,12 +25,17 @@ . HTTP . HTTP_Upload +- For Akismet support: + . Net_URL2 + . HTTP_Request2 + . Services_Akismet2 + - Preferred PEAR packages: . MDB2#mysqli - Command to install all: - # pear install MDB2 MDB2#mysql MDB2#mysqli DB_DataObject Text_CAPTCHA_Numeral Text_Diff Tree-beta HTTP HTTP_Upload + # pear install MDB2 MDB2#mysql MDB2#mysqli DB_DataObject Text_CAPTCHA_Numeral Text_Diff Tree-beta HTTP HTTP_Upload Net_URL2 HTTP_Request2 Services_Akismet2 - Database: . See README.UPGRADE_bugs.php.net Added: pear/packages/Bugtracker/trunk/include/akismet.php =================================================================== --- pear/packages/Bugtracker/trunk/include/akismet.php (rev 0) +++ pear/packages/Bugtracker/trunk/include/akismet.php 2010-03-02 01:52:25 UTC (rev 295713) @@ -0,0 +1,35 @@ +<?php +// This requires +// +// pear install channel://pear.php.net/Net_URL2-0.3.1 +// pear install channel://pear.php.net/HTTP_Request2-0.5.1 +// pear install channel://pear.php.net/Services_Akismet2-0.3.0 + +include 'Services/Akismet2.php'; + +function akismet($author,$authorEmail,$authorUri,$content) { + static $apiKey = getenv('AKISMET_KEY'); + + $comment = new Services_Akismet2_Comment(array( + 'author' => $author, + 'authorEmail' => $authorEmail, + 'authorUri' => $authorUri, + 'content' => $content + )); + + $isSpam = false; + try { + $akismet = new Services_Akismet2('http://bugs.php.net/', $apiKey); + if ($akismet->isSpam($comment)) { + $isSpam = true; + } + } catch (Services_Akismet2_InvalidApiKeyException $keyException) { + echo 'Invalid API key!'; + } catch (Services_Akismet2_HttpException $httpException) { + echo 'Error communicating with Akismet API server: ' . $httpException->getMessage(); + } catch (Services_Akismet2_InvalidCommentException $commentException) { + echo 'Specified comment is missing one or more required fields.' . $commentException->getMessage(); + } + + return $isSpam; +} Property changes on: pear/packages/Bugtracker/trunk/include/akismet.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native

« previous php.pear.core (#9234) next »