///////////////////////////////////////////////////////////////////////////
//
// DNSBL - Spam IP address checker.
// Copyright (C) 2011 Alexey A.Znayev
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// 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
?>
Uncategorized – Christian Aurich
http://c-aurich.de/wordpress
all about my personal interestsWed, 15 Jun 2016 20:21:23 +0000en-UShourly1https://wordpress.org/?v=4.7.28Brother P-touch QL570 on Raspberry Pi
http://c-aurich.de/wordpress/2016/06/brother-p-touch-ql570-on-raspberry-pi/
http://c-aurich.de/wordpress/2016/06/brother-p-touch-ql570-on-raspberry-pi/#commentsWed, 15 Jun 2016 20:21:23 +0000http://c-aurich.de/wordpress/?p=460Continue reading "Brother P-touch QL570 on Raspberry Pi"
]]>
I just wanted to use a Brother P-touch QL570 printer on a Raspberry Pi that is used as “Desktop PC” replacement for web-based applications.
Here is how to setup the printer:
1. connect the printer to power and to the PI (via USB)
2. install cups and the printer driver on the pi: sudo apt-get install cups printer-driver-ptouch
3. set up user rights: sudo usermod -aG lpadmin pi
This steps enables you to access cups administration pages in the next step
4. install the printer in cups:
– open a browser and go to http://localhost:631
– when asked for a password use user “pi” and password “raspberry”
– add a new printer, select the QL570 which is locally connected
– use the driver for QL550 when asked for the driver you want to use
5. finish – enjoy printing
]]>http://c-aurich.de/wordpress/2016/06/brother-p-touch-ql570-on-raspberry-pi/feed/4Building a current / flux probe for contactless measurements
http://c-aurich.de/wordpress/2012/04/building-a-current-flux-probe-for-contactless-measurements/
http://c-aurich.de/wordpress/2012/04/building-a-current-flux-probe-for-contactless-measurements/#respondMon, 23 Apr 2012 21:02:00 +0000http://c-aurich.de/wordpress/?p=401Continue reading "Building a current / flux probe for contactless measurements"]]>In the last weeks I followed an idea to measure current without the need to cut the wires or even open a pcb trace. The solution i came up with is a hall effect based measurement.
If you do not like to open the full arcitle here you can review the basic schematic as well as to see a foto of my first prototype:
The first but still impressing measurement:
]]>http://c-aurich.de/wordpress/2012/04/building-a-current-flux-probe-for-contactless-measurements/feed/0day 3 of embedded world
http://c-aurich.de/wordpress/2012/03/day-3-of-embedded-world/
http://c-aurich.de/wordpress/2012/03/day-3-of-embedded-world/#respondThu, 01 Mar 2012 19:46:01 +0000http://c-aurich.de/wordpress/?p=388Continue reading "day 3 of embedded world"]]>OSADL
The final day of the exhibition “embedded world” was a bit less exhausting. We spend some time speaking to the people of the stand linux meets industry. This organisation is supporting big companies running and developing open source software as well as spreading the open source thinking.
The rest of my day was quite relaxed… we walked around a bit and talked to several companies as well as some people who were interested in the project leobots.
All in all the exhibition was a big success for the team as well as for me. We all got some great impressions what the embedded industry is like at the moment.
]]>http://c-aurich.de/wordpress/2012/03/day-3-of-embedded-world/feed/0day 2 of embedded world
http://c-aurich.de/wordpress/2012/02/day-2-of-embedded-world/
http://c-aurich.de/wordpress/2012/02/day-2-of-embedded-world/#respondWed, 29 Feb 2012 22:09:58 +0000http://c-aurich.de/wordpress/?p=382Continue reading "day 2 of embedded world"]]>source: http://www.embedded-world.de/de/presse/mediacenter/download/
Today I spoke to some companies that I might work for in saxony. There are quite a lot of them, that I did not know before or I did not know that they also develop hardware themselves. This is why today was a great success for me. But on the other hand the days get more and more exhausting – fortunately the exhibition ends one hour earlier tomorrow. I’m very tired right now…
After the official end of the visitor opening times there were some parties at the microsoft and ebv stand among others. Thanks to them for providing some food and drinks for us while playing music! Also thanks to the “open source meets industry” guys who are always worth talking to! Especially I was enjoying to meet Benedikt Sauter (http://embedded-projects.net/) finally after following his work since several years now.
One thing I want to show you finally is an automatic solver for the rubik cube. Basically they built a lego mindstorms robot that handles all the turning and used a smartphone to capture the recent state of the cube. These two elements are combined by a pc that solves the game and controlls the robot while capturing the images form the smartphone:
]]>http://c-aurich.de/wordpress/2012/02/day-2-of-embedded-world/feed/0day 1 of embedded world
http://c-aurich.de/wordpress/2012/02/day-1-of-embedded-world/
http://c-aurich.de/wordpress/2012/02/day-1-of-embedded-world/#respondTue, 28 Feb 2012 20:56:56 +0000http://c-aurich.de/wordpress/?p=378Continue reading "day 1 of embedded world"]]>Today was the start of the exhibition embedded world. I’ve met a lot of interesting people and got some offers for the practical semester starting this september. I will visit some other halls tomorrow.
Because I’m at the exhibition with the leobots team, I was also going around the halls with the robot and talking to some of the sponsors and companies who might become sponsors.
]]>http://c-aurich.de/wordpress/2012/02/day-1-of-embedded-world/feed/0day 0 of embedded world
http://c-aurich.de/wordpress/2012/02/day-0-of-embedded-world/
http://c-aurich.de/wordpress/2012/02/day-0-of-embedded-world/#respondMon, 27 Feb 2012 21:13:16 +0000http://c-aurich.de/wordpress/?p=374Continue reading "day 0 of embedded world"]]>Today I travelled to Nuremberg with the other participants of our exhibition stand. We arrived really early about 4pm and equipped our stand for the tomorrow starting show.
Afterwards I went to my hostel room. I took a bed at A&O Hostel in the city center of nuremberg. It is next to the main station. As far as I can judge until now it is great.
After unpacking my stuff into the tiny locker in the room, I went to buy some food. On the way to the supermarket I came along a shop that was selling used stuff. I noticed a tripod in the shop windows. They sold a really nice looking one for only 29€, so it had to buy it at this bargain Just a picture with my crappy mobile phone cam:
When I came back to the Hostel I tried to connect to the internet. Seems that simyo delays the booking of the umts flatrates by some hours, so that I started whatching a movie. Some minutes later a roommate arrived – he came directly from india. He is going to visit the same exhibition, so we talked a while until we decided to go to a bar and have a beer and talk about the different cultures…
]]>http://c-aurich.de/wordpress/2012/02/day-0-of-embedded-world/feed/0flickr photostream
http://c-aurich.de/wordpress/2011/09/flickr-photostream/
http://c-aurich.de/wordpress/2011/09/flickr-photostream/#respondWed, 07 Sep 2011 18:20:34 +0000http://c-aurich.de/wordpress/?p=328Only a short note this time: I just added a widget to the sidebar that shows my recent photos. I got a Nikon D5000 about one month ago, so I hope to update this regularly with amazing photos
]]>http://c-aurich.de/wordpress/2011/09/flickr-photostream/feed/0Kylerhea hills (2nd day on Isle of Skye)
http://c-aurich.de/wordpress/2011/04/kylerhea-hills-2nd-day-on-isle-of-skye/
http://c-aurich.de/wordpress/2011/04/kylerhea-hills-2nd-day-on-isle-of-skye/#respondThu, 14 Apr 2011 09:00:09 +0000http://c-aurich.de/wordpress/?p=288Continue reading "Kylerhea hills (2nd day on Isle of Skye)"]]>On our second day on the Isle of Skye we went to the south of the island. There we wanted to walk along a nice route for a day trip. Unfortunately the weather was really bad with heavy wind and permanent rain from the side (yes, it was raining horizontally). Another problem was that a part of the group was not used to walk so much and so they were totaly exhausted from the walk the day before. One of them said “fuck you Chris” when he saw the ascend I planned to go up.
To make the trip enjoyable for all of us we decided to take another route. We decided to take a route along the foot of the hills and try to get up somewhere. When we reached one of the smaller summits the wind was directly blowing towards us and was so strong that it was even hard to go forward. At this point we decided to go back.
Unfortunately it was to rainy all the time to make more good photographs. But as usual here is the GPS-Track:
]]>http://c-aurich.de/wordpress/2011/04/kylerhea-hills-2nd-day-on-isle-of-skye/feed/0Erster Eintrag
http://c-aurich.de/wordpress/2010/08/erster-eintrag/
http://c-aurich.de/wordpress/2010/08/erster-eintrag/#respondThu, 05 Aug 2010 12:54:03 +0000http://c-aurich.de/wordpress/?p=5Continue reading "Erster Eintrag"]]>nachdem meine Webseite c-aurich.de nun schon Ewigkeiten brach lag, habe ich mich dazu entschlossen ihr wieder ein wenig Leben einzuhauchen. Einen Anlass dazu gibt es natürlich auch: rund um das Auslandsstudium, das ich in Glasgow angehen werde, wird es genug zu schreiben geben. Es geht zwar erst am 14.09. los, aber es gibt jetzt schon ein paar Sachen, über die ich schreiben könnte/werde.
Da es zur Zeit noch ziemlich viel zu tun gibt, muss ich erstmal sehen, wann ich dazu komme zu bloggen.