///////////////////////////////////////////////////////////////////////////
//
// 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
?>
glasgow – 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.28May Update
http://c-aurich.de/wordpress/2011/05/may-update/
http://c-aurich.de/wordpress/2011/05/may-update/#respondSun, 29 May 2011 15:37:29 +0000http://c-aurich.de/wordpress/?p=322Continue reading "May Update"
]]>
After I wrote my last blog-post I had a lot of weeks full of work and travelling. As result of this I had no time to write anything new here. Now I just want to sum up the events of the last weeks.
After my girlfriend left Glasgow I had to finish some reports and assignments for the university. In the last two weeks of april we had to hand them in and for some classes we had to present our work.
For the first week in may I was in Germany to celebrate the wedding of my cousin. In the week I’ve been at home I also visited my girlfriend in Erfurt, where she worked at this time. There I shot a view pictures and videos to review her great new Canon IXUS 115. I uploaded these pictures and videos on my website and as youtube video.
After coming back to Glasgow I had to study for the last exams here. A totally new experience was to program complete VHDL programs on paper or to purely remember loads of formulae or how data transmission protocols (TCP,RTP) work including a lot of details about them.
By reading hackaday I got some new ideas for hiding information in audio files which I used to write a python script. This is just a fun-thing for challenging other people by mystery geocaches for example. Probably I will do one with this technique when I’m back at home.
]]>http://c-aurich.de/wordpress/2011/05/may-update/feed/0Aberfoyle
http://c-aurich.de/wordpress/2011/03/aberfoyle/
http://c-aurich.de/wordpress/2011/03/aberfoyle/#respondSun, 06 Mar 2011 23:31:06 +0000http://c-aurich.de/wordpress/?p=248Continue reading "Aberfoyle"]]>When I planned this trip I wantes to walk along a rout of about 20km, but when we arrived there the busdriver told us that the late bus I wanted to take is not operating on sundays. Unfortunately he was wrong, what the driver of the bus we took back told us – so we shortened our route without any good reason :-/ But it still was a really nice walk and we enjoyed the weather the whole day. It was over 10°C and sunny all the time!
]]>http://c-aurich.de/wordpress/2011/03/aberfoyle/feed/0Clyde walkway and Clyde falls
http://c-aurich.de/wordpress/2011/03/clyde-walkway-and-clyde-falls/
http://c-aurich.de/wordpress/2011/03/clyde-walkway-and-clyde-falls/#respondFri, 04 Mar 2011 08:42:57 +0000http://c-aurich.de/wordpress/?p=225Continue reading "Clyde walkway and Clyde falls"]]>At the second weekend of february some of my flatmates and me went to a long walk along the clyde. It’s not much to say about it – the pictures say more than 1000 words:
And here it is again: the track of our walk. It was a really long walk compared to the former trips, but it was also much flatter than ever and as the last times there was a beer waiting for us at the final destination.
]]>http://c-aurich.de/wordpress/2011/03/clyde-walkway-and-clyde-falls/feed/0Glengoyne Distillery
http://c-aurich.de/wordpress/2011/03/glengoyne-distillery/
http://c-aurich.de/wordpress/2011/03/glengoyne-distillery/#respondTue, 01 Mar 2011 22:52:08 +0000http://c-aurich.de/wordpress/?p=234At the first weekend of february we visited the first distillery since we are in Scotland. We chose one of the best rated Distillery here.
The tour around the destillery was quite interesting and the whisky is really tasty!
Thanks to my flatmate Michal, who made these photographs!
]]>http://c-aurich.de/wordpress/2011/03/glengoyne-distillery/feed/0Island Arran
http://c-aurich.de/wordpress/2011/01/island-arran/
http://c-aurich.de/wordpress/2011/01/island-arran/#commentsMon, 31 Jan 2011 21:49:09 +0000http://c-aurich.de/wordpress/?p=193Continue reading "Island Arran"]]>Last weekend we went to an island for the first time since we are here in scotland. Surprisingly there were much more trees than we have seen before on other places. Unfortunately there were clouds on top of the mountain, so on top of the mountain Goatfell we could just see the next few meters. But on our way up and down we have seen a lot of great nature. Just to give you an idea here are some pictures of it:
After I used my phone again for navigation and tracking of our route i can provide you with the way we walked. Simply because of the clouds on the top we took a wrong way for going down and when we noticed this we decided to go down there further instead of going up and searching for the right way. I can’t recomend this way in general but it may be fine if you want to find your own way. Some ways that are good to walk are on openstreetmap. I added 2 new ways on the island – one at the beach and one in the valley south-west to Goatfell.
]]>http://c-aurich.de/wordpress/2011/01/island-arran/feed/2Drymen and West Highland Way
http://c-aurich.de/wordpress/2011/01/179/
http://c-aurich.de/wordpress/2011/01/179/#commentsSun, 23 Jan 2011 18:43:39 +0000http://c-aurich.de/wordpress/?p=179Continue reading "Drymen and West Highland Way"]]>After the exams are over we wanted to do a little one-day trip. After some brainstorming we ended up in planning a trip to drymen, what is next to the trossachs national park. The weather was quite good on this day, but the fog was really heavy. But fortunately we were lucky to have a great view.
One interesting thing about this area is that it is the Highland Boundary Fault. Thanks to geocaching and wikipedia I know a bit more about this part of the scottish history now.
I recorded our route, so you can see exactly where we have been:
]]>http://c-aurich.de/wordpress/2011/01/179/feed/2Geocaching in Scotland
http://c-aurich.de/wordpress/2011/01/geocaching-in-scotland/
http://c-aurich.de/wordpress/2011/01/geocaching-in-scotland/#commentsMon, 03 Jan 2011 19:45:48 +0000http://c-aurich.de/wordpress/?p=155Continue reading "Geocaching in Scotland"]]>After I came back to Glasgow on the 27th I did a lot of geocaching with my girlfriend. We experienced Glasgow and Edinburgh by walking from cache to cache. It was a great way of showing her the city.
Today I searched for some caches and more or less I found that by accident: http://www.csft.org.uk/out_and_about/geocaching
It’s so great that these people make the forrest open for geocaching! In germany some owners of forrest remove caches if you don’t got the permission to place it there before. I love the policy of “Central Scotland Forest Trust”. That is the way to go if you want to make the nature an attractive competitor to pc games, televison etc.
And to make you happy, here are some photographs I took while we were on our geocaching tours:
]]>http://c-aurich.de/wordpress/2011/01/geocaching-in-scotland/feed/3Glasgow Firework Display
http://c-aurich.de/wordpress/2010/11/glasgow-firework-display/
http://c-aurich.de/wordpress/2010/11/glasgow-firework-display/#respondTue, 16 Nov 2010 06:00:11 +0000http://c-aurich.de/wordpress/?p=111Continue reading "Glasgow Firework Display"]]>Glasgow has a big firework each year. It seemed like everyone goes there or at least watches it from his windows at home. I expected some kind of a really big firework. But the only thing I got was a really long and quite nice firework. Nothing incredibly big or exciting. But I will stop complaining now. It was a nice evening. After the fireworks we went to eat burgers at one of our favorite restaurants here. On the way to it I took some more pictures.
]]>http://c-aurich.de/wordpress/2010/11/glasgow-firework-display/feed/0Visiting Scotland
http://c-aurich.de/wordpress/2010/11/visiting-scotland/
http://c-aurich.de/wordpress/2010/11/visiting-scotland/#respondFri, 12 Nov 2010 16:48:33 +0000http://c-aurich.de/wordpress/?p=79Continue reading "Visiting Scotland"]]>After some people called for pictures of my trips around scotland, here they are finally
The first batch of photos were taken in the first days I’ve been to Glasgow. In this time we visited the City a little bit.
The next few pictures are from our trip to loch lomond and (another trip) to ben lomond:
Some information about loch lomond and ben lomond could be found here:
Some more photographs will follow in the next days. It’s too much for one blog post
]]>http://c-aurich.de/wordpress/2010/11/visiting-scotland/feed/0weird security on campus
http://c-aurich.de/wordpress/2010/10/weird-security-on-campus/
http://c-aurich.de/wordpress/2010/10/weird-security-on-campus/#respondWed, 20 Oct 2010 17:21:03 +0000http://c-aurich.de/wordpress/?p=74Continue reading "weird security on campus"]]>I’d like to tell you about the security in the UK in this blog. For me the whole stuff is a little bit surprising, because I don’t know that from germany. But it seems like some students really need these advises I write about:
The village office of Strathclyde University seems to be very concerned about the students security. There was a “welcome meeting” where we were told how to behave in our flats to be secure regarding the fire and the personal security.
Just watch the videos (sorry, I had to split them, since youtube did not allow me to upload it as one video) – espacially from minute 10 of the first video:
There were also some fire fighters in our flat to explain how the smoke and fire detectors work. It is great to know, that there is somebody worrying about our safety, but sometime it is too much.
Next goodie ist the weekly fire alarm test. We have 3 tests in our lectures in each week. And additionally on wednesday morning, the only day I can stay in bed longer in the week, they test the alarm in our flat. Great job!