Update of /cvsroot/php-blog/serendipity/bundled-libs/Net
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8545/bundled-libs/Net
Modified Files:
DNSBL.php
Log Message:
MFH
Index: DNSBL.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/bundled-libs/Net/DNSBL.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- DNSBL.php 21 Nov 2004 15:32:06 -0000 1.1
+++ DNSBL.php 22 Nov 2004 08:12:51 -0000 1.2
@@ -21,7 +21,8 @@
/**
* PEAR::Net_DNSBL
*
- * This class acts as interface to generic Realtime Blocking Lists (RBL)
+ * 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
@@ -29,14 +30,19 @@
* @author Sebastian Nohn <seb...@no...>
* @package Net_DNSBL
* @license http://www.php.net/license/3_0.txt
- * @version 0.2
+ * @version 0.3
*/
require_once 'Net/CheckIP.php';
class Net_DNSBL {
/**
- * @var string[]
+ * Array of blacklists.
+ *
+ * Contain 1-n blacklists to use for checking the status of a
+ * host.
+ *
+ * @var array
* @access protected
*/
var $blacklists = array('sbl-xbl.spamhaus.net',
@@ -44,29 +50,37 @@
/**
* Set the blacklist to a desired blacklist.
- *
- * @param string[] $blacklists
+ *
+ * @param array Array of blacklists to use. May contain only one element.
* @access public
+ * @return bool true if the operation was successful
*/
function setRBL($blacklists) {
- $this->blacklists = $blacklists;
- }
+ if (is_array($blacklists)) {
+ $this->blacklists = $blacklists;
+ return true;
+ } else {
+ return false;
+ } // if
+ } // function
/**
* Get the blacklists.
*
* @access public
+ * @return array Currently set blacklists.
*/
function getRBL() {
return $this->blacklists;
}
- /**
- * Checks if the supplied URL is listen in one or more of
- * the RBLs
+ /**
+ * Checks if the supplied Host is listen in one or more of the
+ * RBLs
*
- * @param string $host
+ * @param string Host to check for being listed.
* @access public
+ * @return boolean true if the checked host is listed in some blacklist.
*/
function isListed($host) {
@@ -77,7 +91,7 @@
if ($result != $this->getHostForLookup($host, $blacklist)) {
$isListed = true;
- //if the URL was listed we don't need to check other RBLs,
+ //if the Host was listed we don't need to check other RBLs,
break;
} // if
@@ -85,7 +99,16 @@
return $isListed;
} // function
-
+
+ /**
+ * Get thublice host to lookup. Lookup a host if neccessary and get the
+ * complete FQDN to lookup
+ *
+ * @param string Host OR IP to use for building the lookup.
+ * @param string Blacklist to use for building the lookup.
+ * @access protected
+ * @return string Ready to use host to lookup
+ */
function getHostForLookup($host, $blacklist) {
if (!Net_CheckIP::check_ip($host)) {
$ip = gethostbyname($host);
@@ -93,13 +116,28 @@
$ip = $host;
}
- return $this->buildLookUpUrl( $ip, $blacklist );
+ return $this->buildLookUpHost($ip, $blacklist);
} // function
- function buildLookUpUrl($ip, $blacklist) {
+ /**
+ * Build the host to lookup from an IP.
+ *
+ * @param string IP to use for building the lookup.
+ * @param string Blacklist to use for building the lookup.
+ * @access protected
+ * @return string Ready to use host to lookup
+ */
+ function buildLookUpHost($ip, $blacklist) {
return $this->reverseIp($ip).'.'.$blacklist;
} // function
+ /**
+ * Reverse the order of an IP. 127.0.0.1 -> 1.0.0.127
+ *
+ * @param string IP to reverse.
+ * @access protected
+ * @return string Reversed IP
+ */
function reverseIp($ip) {
return implode('.', array_reverse(explode('.', $ip)));
} // function
|