cvs: pearweb /include/Damblan Trackback.php /public_html/trackback trackback.php

From: Date: Fri, 11 Mar 2005 15:28:25 +0000
Subject: cvs: pearweb /include/Damblan Trackback.php /public_html/trackback trackback.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-cvs+get-30197@lists.php.net to get a copy of this message
toby Fri Mar 11 10:28:25 2005 EDT Modified files: /pearweb/include/Damblan Trackback.php /pearweb/public_html/trackback trackback.php Log: * Added spam check. http://cvs.php.net/diff.php/pearweb/include/Damblan/Trackback.php?r1=1.8&r2=1.9&ty=u Index: pearweb/include/Damblan/Trackback.php diff -u pearweb/include/Damblan/Trackback.php:1.8 pearweb/include/Damblan/Trackback.php:1.9 --- pearweb/include/Damblan/Trackback.php:1.8 Tue Mar 1 10:41:48 2005 +++ pearweb/include/Damblan/Trackback.php Fri Mar 11 10:28:24 2005 @@ -1,6 +1,7 @@ <?php require_once 'Services/Trackback.php'; +require_once 'Net/DNSBL.php'; class Damblan_Trackback extends Services_Trackback { @@ -32,6 +33,10 @@ var $_repostCount = 3; // In which timespan? var $_repostTimespan = 600; // 10 minutes + // Blacklists to check, when a trackback is received. + var $_blacklists = array( + 'bl.spamcop.net' + ); /** * Constructor @@ -65,6 +70,23 @@ } /** + * Check if the sending host is blacklisted. + * This method will be moved to Services_Trackback soon. + * + * @access public + * @return mixed True, if the host is not listed, otherwise PEAR::Error. + */ + function checkSpam() + { + $dnsbl = new Net_DNSBL(); + $dnsbl->setBlacklists($this->_blacklists); + if ($dnsbl->isListed($this->_ip)) { + return PEAR::raiseError('Your host seems to be listed as a known spam host. If your trackback is rejected by mistake, please contact pear-webmaster@lists.phph.net.'); + } + return true; + } + + /** * Get number of all in all available trackbacks. * * http://cvs.php.net/diff.php/pearweb/public_html/trackback/trackback.php?r1=1.8&r2=1.9&ty=u Index: pearweb/public_html/trackback/trackback.php diff -u pearweb/public_html/trackback/trackback.php:1.8 pearweb/public_html/trackback/trackback.php:1.9 --- pearweb/public_html/trackback/trackback.php:1.8 Tue Mar 1 05:15:41 2005 +++ pearweb/public_html/trackback/trackback.php Fri Mar 11 10:28:25 2005 @@ -17,7 +17,7 @@ | Authors: Tobias Schlitt <toby@php.net> | | | +----------------------------------------------------------------------+ - $Id: trackback.php,v 1.8 2005/03/01 10:15:41 toby Exp $ + $Id: trackback.php,v 1.9 2005/03/11 15:28:25 toby Exp $ */ require_once 'Damblan/Trackback.php'; require_once 'Damblan/Mailer.php'; @@ -71,6 +71,11 @@ echo Services_Trackback::getResponseError($res->getMessage(), 1); } +// Check blacklists +$res = $trackback->checkSpam(); +if (PEAR::isError($res)) { + echo Services_Trackback::getResponseError($res->getMessage(), 1); +} $res = $trackback->save($dbh); if (PEAR::isError($res)) {

« previous php.pear.cvs (#30197) next »