PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Alexey Znaev  >  DNSBL  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: DNSBL example
Class: DNSBL
Check spam IP address in DNS black lists
Author: By
Last change: New class features are shown.
Date: 4 years ago
Size: 2,834 bytes
 

Contents

Class file image Download
<?
require_once 'DNSBL.php';
$ip = '217.66.146.36'; // I got this from my mail server logs at Friday 2011-05-13 :-)
                        // You can find another one
echo "Spammer IP = " . $ip . "\n\n";


$dnsbl = new DNSBL(); // instance of DNSBL

$checkers = $dnsbl->GetCheckers(); // get checkers list
echo "all checkers are : \n";
var_dump($checkers);
echo
"\n";


$def_checker = $dnsbl->GetDefaultChecker(); // get default checker

echo "individual checking by default ('" . $def_checker . "') : ";
if(
$dnsbl->CheckSpamIP($ip)){ // check IP in default checker
   
echo('spam');
}else{
    echo(
'not spam');
}
echo
"\n\n";



$checker = 'spamcop'; // new checker name

echo "individual checking by '" . $checker . "' : ";
if(
$dnsbl->CheckSpamIP($ip, $checker)){ // check IP in this checker
   
echo('spam');
}else{
    echo(
'not spam');
}
echo
"\n\n";



$dnsbl->SetDefaultChecker($checker); // set default checker to new name
echo "set new default checker to '" . $checker . "'\n";

$def_checker = $dnsbl->GetDefaultChecker(); // get default checker once again to validate new setting

echo "individual checking by new default ('" . $def_checker . "') : ";
if(
$dnsbl->CheckSpamIP($ip)){ // check IP in default checker once again
   
echo('spam');
}else{
    echo(
'not spam');
}
echo
"\n\n";



$checker = 'all'; // set checker to 'all' (all checkers available for group checking)


$all = $dnsbl->GetGroupCheckers();
echo
"default checkers for group checking are : \n";
var_dump($all);
echo
"group checking by group ('" . $checker . "') : ";
if(
$dnsbl->CheckSpamIP($ip, $checker)){ // check IP in all checkers available for group checking,
                        // method returns true when IP exists in one checker at least
   
echo('spam');
}else{
    echo(
'not spam');
}
echo
"\n\n";



$dnsbl->EnableGroupChecking('njabl'); // set 'njabl' available for group checking
echo "include 'njabl' to group checking\n";

$all = $dnsbl->GetGroupCheckers();
echo
"new checkers for group checking are : \n";
var_dump($all);
echo
"group checking by group ('" . $checker . "') : ";
if(
$dnsbl->CheckSpamIP($ip, $checker)){ // check IP in all checkers available for group checking,
                        // method returns true when IP exists in one checker at least
   
echo('spam');
}else{
    echo(
'not spam');
}
echo
"\n\n";



$dnsbl->DisableGroupChecking('spamhaus'); // set 'spamhaus' NOT available for group checking
echo "exclude 'spamhaus' from group checking\n";

$all = $dnsbl->GetGroupCheckers();
echo
"new checkers for group checking are : \n";
var_dump($all);
echo
"group checking by group ('" . $checker . "') : ";
if(
$dnsbl->CheckSpamIP($ip, $checker)){ // check IP in all checkers available for group checking,
                        // method returns true when IP exists in one checker at least
   
echo('spam');
}else{
    echo(
'not spam');
}
echo
"\n\n";

?>