Update of /cvsroot/php-blog/serendipity/bundled-libs/Net
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7626/bundled-libs/Net
Added Files:
DNSBL.php
Log Message:
Updated serendipity_event_spamblock to the new Networking::Net_DNSBL package
--- NEW FILE: DNSBL.php ---
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PEAR::Net_DNSBL |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004 Sebastian Nohn <seb...@no...> |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | li...@ph... so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Sebastian Nohn <seb...@no...> |
// +----------------------------------------------------------------------+
//
// $Id: DNSBL.php,v 1.1 2004/11/21 15:32:06 nohn Exp $
/**
* PEAR::Net_DNSBL
*
* This class acts as interface to generic Realtime Blocking Lists (RBL)
*
* Net_RBL looks up an supplied host if it's listed in 1-n supplied
* Blacklists
*
* @author Sebastian Nohn <seb...@no...>
* @package Net_DNSBL
* @license http://www.php.net/license/3_0.txt
* @version 0.2
*/
require_once 'Net/CheckIP.php';
class Net_DNSBL {
/**
* @var string[]
* @access protected
*/
var $blacklists = array('sbl-xbl.spamhaus.net',
'bl.spamcop.net');
/**
* Set the blacklist to a desired blacklist.
*
* @param string[] $blacklists
* @access public
*/
function setRBL($blacklists) {
$this->blacklists = $blacklists;
}
/**
* Get the blacklists.
*
* @access public
*/
function getRBL() {
return $this->blacklists;
}
/**
* Checks if the supplied URL is listen in one or more of
* the RBLs
*
* @param string $host
* @access public
*/
function isListed($host) {
$isListed = false;
foreach ($this->blacklists as $blacklist) {
$result = gethostbyname($this->getHostForLookup($host, $blacklist));
if ($result != $this->getHostForLookup($host, $blacklist)) {
$isListed = true;
//if the URL was listed we don't need to check other RBLs,
break;
} // if
} // foreach
return $isListed;
} // function
function getHostForLookup($host, $blacklist) {
if (!Net_CheckIP::check_ip($host)) {
$ip = gethostbyname($host);
} else {
$ip = $host;
}
return $this->buildLookUpUrl( $ip, $blacklist );
} // function
function buildLookUpUrl($ip, $blacklist) {
return $this->reverseIp($ip).'.'.$blacklist;
} // function
function reverseIp($ip) {
return implode('.', array_reverse(explode('.', $ip)));
} // function
} // class
?>
|