Comunitatea PHP Romania
 

 
Introduction

Introduction

Introduction -- Introduction to Net_DNSBL

Description

PEAR::Net_DNSBL provides an easy way to check if a given Host or URL is listed on an DNS-based Blackhole List (DNSBL, Real-time Blackhole List or RBL) or Spam URI Realtime Blocklist (SURBL).

Please not that this currently only works with IPv4 IPs.

Usage

Let's start with a simple example to check if the remote host is listed in two blacklists:

<?php
require_once 'Net/DNSBL.php';
$dnsbl = new Net_DNSBL();
$remoteIP = $_SERVER['REMOTE_ADDR'];
$remoteIP = '81.70.69.193';
$dnsbl->setBlacklists(array('sbl-xbl.spamhaus.org', 'bl.spamcop.net'));
if ($dnsbl->isListed($remoteIP)) {
    // do something
}
?>

This example shows how to check if an URL is listed in a SURBL:

<?php
require_once 'Net/DNSBL/SURBL.php';
$surbl = new Net_DNSBL_SURBL();
if ($surbl->isListed($addData['url'])) {
    // do something
}
?>
An example how to extract URLS from a text can be found on http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php and be used this way:
<?php
foreach ($extracted_urls as $surbl_check_url) {
    if ($surbl->isListed($surbl_check_url)) {
        // do something
        break;
    }
}
?>

Let's get some details, if our host is listed:

<?php
require_once 'Net/DNSBL.php';
$dnsbl = new Net_DNSBL();
$dnsbl->setBlacklists(array('sbl-xbl.spamhaus.org', 'bl.spamcop.net'));
if ($dnsbl->isListed($_SERVER['REMOTE_ADDR'])) {
   var_dump($dnsbl->getDetails($_SERVER['REMOTE_ADDR']));
   var_dump($dnsbl->getTxt($_SERVER['REMOTE_ADDR']));
   var_dump($dnsbl->getListingBl($_SERVER['REMOTE_ADDR']));
   var_dump($dnsbl->getListingRecord($_SERVER['REMOTE_ADDR']);
}
?>

Ultimele discutii in forum RSS Forum

Ultimele articole Ultimele articole

Top membri

Pirahna Pirahna
la birou
carco carco
Bucuresti
Birkoff Birkoff
Bucuresti
mihaitha mihaitha
Sibiu
Mascka Mascka
Braila
gabysolomon gabysolomon
Bacau
whooper whooper
Toronto ON
raul_ raul_
dechim dechim
Drobeta Turnu Severin
Amenthes Amenthes

Newsletter


Email:
 inscriere
 renuntare
 
 Arhiva newsletter

Parteneriat

Copyright © 2001-2008 PHP Romania Add PHPRomania to Google Add PHPRomania to Del.icio.us Add PHPRomania to Stumbleupon Add PHPRomania to Yahoo! Add PHPRomania to Digg Add PHPRomania to Blink Bad Credit Loan | Mobile Phones | eBay | Gas Suppliers | Apply for Credit Card
Ads: Partener Way2Web Nework: gazduire web | inregistrare domenii | web design | imobiliare | web hosting
Powered by Simplis