. // // Alexey A.Znayev, znaeff@mail.ru, http://xbsoft.org, http://xbsoft.ru // /////////////////////////////////////////////////////////////////////////// // This file contains public class DNSBL // This class performs IP address check in spam blocking lists as described // on http://ru.wikipedia.org/wiki/RBL class DNSBL { private $_aCheckers = array( // list of checkers available for individual checking 'spamhaus' => array('.zen.spamhaus.org', true), //available for group checking with 'all' key 'spamcop' => array('.bl.spamcop.net', true), //available for group checking with 'all' key 'dsbl' => array('.list.dsbl.org', false), //not available for group checking with 'all' key 'ordb' => array('.relays.ordb.org', false), //not available for group checking with 'all' key 'sorbs' => array('.dnsbl.sorbs.net', false), //not available for group checking with 'all' key 'njabl' => array('.dnsbl.njabl.org', false) //not available for group checking with 'all' key ); // AZ - 1. Key 'all' is illegal // AZ - 2. Most of spammer IP addresses is covered by 'spamhaus' & 'spamcop' (and they are fast), // some of the rest may not work sometimes, you can make them group checking available after individual testing private $_sDefaultChecker = 'spamhaus'; /////////////////////////////////////////////////////////////////////////// // CheckSpamIP - check IP for spam in checkers : given, default or all available for group checking (may be slow) // parameters: // string $ip - ip address // string $checker - checker name or 'all' or nothing // returns: // true when IP exitsts in spam-lists of $checker or at least one of all checkers // false when not or when ip address is local or not correct public function CheckSpamIP($ip, $checker = ''){ if(empty($ip)) return false; if(preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $ip) != 1) return false; $octets = explode('.', $ip); if($octets[0] == '127') return false; if($octets[0] == '10') return false; if($octets[0] == '192' && $octets[0] == '168') return false; if($octets[0] == '169' && $octets[0] == '254') return false; // ms windows if((int)$octets[0] > 255 || (int)$octets[1] > 255 || (int)$octets[2] > 255 || (int)$octets[3] > 255 ) return false; $ret_val = false; $PTR = implode(array_reverse($octets), '.'); if($checker === 'all'){ foreach(array_values($this->_aCheckers) as $c){ if($c[1]){ $ret_val = $ret_val || $this->_CheckDNSAnswer(dns_get_record($PTR . $c[0], DNS_A)); } if($ret_val) break; } }else if(array_key_exists($checker, $this->_aCheckers)){ $ret_val = $this->_CheckDNSAnswer(dns_get_record($PTR . $this->_aCheckers[$checker][0], DNS_A)); }else{ $ret_val = $this->_CheckDNSAnswer(dns_get_record($PTR . $this->_aCheckers[$this->_sDefaultChecker][0], DNS_A)); } return $ret_val; } /////////////////////////////////////////////////////////////////////////// // GetCheckers - gets list of available checker names // returns: // array of strings public function GetCheckers(){ return array_keys($this->_aCheckers); } /////////////////////////////////////////////////////////////////////////// // GetGroupCheckers - gets list of checker names available for group checking with 'all' key // returns: // array of strings public function GetGroupCheckers(){ $ret_val = array(); foreach(array_keys($this->_aCheckers) as $k) if($this->_aCheckers[$k][1]) array_push($ret_val, $k); return $ret_val; } /////////////////////////////////////////////////////////////////////////// // GetDefaultChecker - gets default checker name // returns: // string public function GetDefaultChecker(){ return $this->_sDefaultChecker; } /////////////////////////////////////////////////////////////////////////// // SetDefaultChecker - sets default checker name // parameters: // string $new_checker - new default checker name // returns: // true when success // false when failed ($new_checker is not in the list of available checker names) public function SetDefaultChecker($new_checker){ if(array_key_exists($new_checker, $this->_aCheckers)){ $this->_sDefaultChecker = $new_checker; return true; }else{ return false; } } /////////////////////////////////////////////////////////////////////////// // EnableGroupChecking - sets checker available for group checking // parameters: // string $checker - checker name // returns: // true when success ($checker is included) // false when failed ($checker is not in the list of available checker names) public function EnableGroupChecking($checker){ if(array_key_exists($checker, $this->_aCheckers)){ $this->_aCheckers[$checker][1] = true; return true; }else{ return false; } } /////////////////////////////////////////////////////////////////////////// // DisableGroupChecking - sets checker not available for group checking // parameters: // string $checker - checker name // returns: // true when success ($checker is excluded) // false when failed ($checker is not in the list of available checker names) public function DisableGroupChecking($checker){ if(array_key_exists($checker, $this->_aCheckers)){ $this->_aCheckers[$checker][1] = false; return true; }else{ return false; } } // private methods /////////////////////////////////////////////////////////////////////////// // _CheckDNSAnswer - checks DNS-server answer for 127.0.0.* values // returns: // true when success // false when failed private function _CheckDNSAnswer($dns_answer){ if(!is_array($dns_answer)) return false; $len = count($dns_answer); if($len <= 0) return false; for($i=0; $i<$len; $i++){ $obj = $dns_answer[$i]; if(!(is_object($obj) || is_array($obj))) return false; $ip_str = $obj['ip']; if(!is_string($ip_str)) return false; $pos = strpos($ip_str, '127.0.0.'); if($pos !== false) return true; } return false; } } // end of class DNSBL ?> Comments for bits and pieces https://blog.fabian-affolter.ch primary Fedora and some negligibilities...hauptsächlich Fedora und ein paar Nebensächlichkeiten... Thu, 28 Nov 2013 15:21:15 +0000 hourly 1 https://wordpress.org/?v=4.9.25 Comment on MQTT and Desktop notifications by Natanael Copa https://blog.fabian-affolter.ch/mqtt-and-desktop-notifications/#comment-1795 Thu, 28 Nov 2013 15:21:15 +0000 http://fabian-affolter.ch/blog/?p=2690#comment-1795 I just wrote a tiny C application, mqtt-exec, to execute commands on mqtt messages.

With my app and notify-send you can do it with:
mqtt-exec -h $broker -t $topic -- notifiy-send -i network-server "MQTT message:"

]]>
Comment on The lineinfile module of Ansible by GrrrOby https://blog.fabian-affolter.ch/the-lineinfile-module-of-ansible/#comment-1784 Fri, 22 Nov 2013 16:24:07 +0000 http://fabian-affolter.ch/blog2/?p=2428#comment-1784 Thanks, helped me a lot!

]]>
Comment on DBAN und PXE by generious https://blog.fabian-affolter.ch/dban-und-pxe/#comment-1768 Sat, 09 Nov 2013 13:36:03 +0000 http://fabian-affolter.ch/blog2/?p=2280#comment-1768 This worked for me under windows 2012 ( WDS server )

# Option 7 – DBAN
LABEL Disk Wipe
MENU LABEL Disk Wipe DBAN
kernel /images/hirens/memdisk
append iso initrd=/images/dban/dban-2.2.7_i586.iso

Thanks Fabian

]]>
Comment on Samsung SL-C410W by br https://blog.fabian-affolter.ch/samsung-sl-c410w/#comment-1762 Mon, 04 Nov 2013 11:59:23 +0000 http://fabian-affolter.ch/blog/?p=2788#comment-1762 Hi, Fabian!
Next time you can try to replace photo drum (not cartridge even!) with another one, which you can buy for ex. on ebay or aliexpress for a couple of dollars.

Replacing only malfunctioning components saves your money and our Earth.

]]>
Comment on Samsung SL-C410W by rom1dep https://blog.fabian-affolter.ch/samsung-sl-c410w/#comment-1759 Sun, 03 Nov 2013 21:31:56 +0000 http://fabian-affolter.ch/blog/?p=2788#comment-1759 Hi ! 🙂
This may be worth reading:
http://tamytro.org/blog/howto-samsung-spl-laser-printer-linux/
(well, I didn’t check if it fully applies to your printer/driver but since it’s about ULD…)

]]>
Comment on Samsung SL-C410W by Cristian Ciupitu https://blog.fabian-affolter.ch/samsung-sl-c410w/#comment-1758 Sat, 02 Nov 2013 23:00:56 +0000 http://fabian-affolter.ch/blog/?p=2788#comment-1758 Gotta love this kind of Linux “support”. It looks like there’s no cheap printer with an open source driver for Linux, preferably one included upstream.

]]>
Comment on Uepaa by Uepaa, schon wieder. | bits and pieces https://blog.fabian-affolter.ch/uepaa/#comment-1751 Sun, 27 Oct 2013 18:42:29 +0000 http://fabian-affolter.ch/blog/?p=2770#comment-1751 […] scheint sich ein Redakteur bei 20min richtig in die Sache mit Uepaa verbissen zu haben. Wenn es ein paar nette Videos auf der Webseite hat, gibt es sofort einen […]

]]>
Comment on The lineinfile module of Ansible by Tapan https://blog.fabian-affolter.ch/the-lineinfile-module-of-ansible/#comment-1747 Thu, 24 Oct 2013 02:41:19 +0000 http://fabian-affolter.ch/blog2/?p=2428#comment-1747 Excellent…

]]>
Comment on Banner grabbing by Banner grabbing 4 | bits and pieces https://blog.fabian-affolter.ch/banner-grabbing/#comment-1725 Sat, 12 Oct 2013 13:00:50 +0000 http://fabian-affolter.ch/blog2/?p=2361#comment-1725 […] the past I wrote already several times about simple web server banner grabbing methodes (1, 2, 3). siege is an http load testing and benchmarking utility which is able to perform a banner […]

]]>
Comment on Name für Fedora 9 by Fedora Release names | bits and pieces https://blog.fabian-affolter.ch/name-fur-fedora-9/#comment-1702 Wed, 02 Oct 2013 14:59:08 +0000 http://fabian-affolter.ch/blog2/name-fur-fedora-9/#comment-1702 […] Fedora Core 1 till 5 were ok. Then came names I liked and some I didn’t. With F9 were some funny names in the list.  With “Beefy Miracle” we reached the low point, very close to the Ubuntu […]

]]>