Update RBL check script with DB functions
RBL servers are in array $rbls in the script
we store them in DB
TO DO
get them from DB
$sql = "SELECT * FROM `rblservers` WHERE `use` = 'true'";
and place it in array
get clientnumbers from DB
$sqlclientsresult = "SELECT clientnr FROM `clients`";
for each client get ipaddresses to check
$ip is in the script now
We have a table ipaddress where all IP's are in, get them from table and do rblcheck for each
We store the IP as longip
$sqlclientsipsresult = "SELECT id, inet_ntoa(longip) as IP FROM `ipaddress` WHERE `clientid` = '" . $rowclients['clientnr'] . "' AND `test` = '1'";
$nu = gmdate($this->dateFormat, time());
Store the scan for the ip
listedinrbl is amount of RBL where IP is positive
INSERT INTO `rbltests` (`id`, `ipaddressid`, `datetime`, `listedinrbl`)
If listed store it rblpositive
INSERT INTO `rblpositive` (`ipid`, `rblserverid`, `datetimefirstfound`, `datetimelastfound`, `listed`)
INSERT INTO `rblpositive` (`ipid`, `rblserverid`, `datetimefirstfound`, `listed`) VALUES ('1', '8', '$nu', '1')
If solved
UPDATE `rblpositive` SET `datetimelastfound`='$nu', `listed`='0'
This script uses
$rev = join('.', array_reverse(explode('.', trim($ip))));
$lookup = sprintf('%s.%s', $rev, $rbl);
$listed = gethostbyname($lookup) !== $lookup;
for the tests
Another solution is:
$reversedIP = implode('.', array_reverse(explode ('.', $ip)));
// Do the DNS lookup
$result = "";
exec("nslookup " . $reversedIP . "." . $value, $result);
Please test which works best: fastest versus server load