Never Forget To Turn Dansguardian Back On After A Cyberspacejaywalk

Channel: Linux
Abstract: then you won't want to replace your original template.html because then your customisation would be lost. In such a situation back it up first with an
Never Forget To Turn Dansguardian Back On After A Cyberspacejaywalk

Keyword filters block unwanted web pages on the basis of potentially unwelcome words found in them. However, to be sure that a page is indeed offensive, keyword filters nowadays are not designed to block sites on the basis of just about any potentially unwanted word. Instead they measure the number of potentially unwanted phrases and often the number of times they occur so as to allow a limited number of occurrences in pages such as those on anatomy, forms requiring gender information, crime reports, statistical reports, administrative information, art etc. Dansguardian is the leading free keyword blocker on Linux systems and it uses this method known as a weighed keyword score. Moreover while a Dansguardian server controls website access client systems on the network need not run Linux. They can run practically any operating system and access the Internet through the Dansguardian proxy.

Now, people who use or administer a web content filter know very well that there are situations when a filter accidentally blocks an acceptable site or even an unreviewed site. There are also sites which we may want to visit at a given time and block at other times or just block for certain users and this may not always be repetitive or predictable providing scope of a coded solution. The simple solution, however dubious-looking is often to turn off filtering completely, usually accomplished by connecting to the Internet directly without using the Dansguardian proxy. This situation is most common on standalone home systems where a grown-up may suddenly want unrestricted access for a few minutes, but may present itself on networks too, especially when the administrator suddenly wants unrestricted access from the Internet gateway for a few minutes. Then it is of paramount importance that when this unrestricted cyberspacewalk ends, the administrator must turn Dansguardian back on!! But what if they forget? http://d.yourfilter.org a.k.a. Reminder for Dansguardian addresses this problem. With a little tweaking of your Dansguardian installation, followed by setting your homepage to http://d.yourfilter.org you are reminded every time you fire up your browser whether you are connecting to the Internet through your Dansguardian proxy or bypassing Dansguardian. How it is done follows.

For illustration, lets assume you are using the language UK English. This would mean your customisable block page is /etc/dansguardian/languages/ukenglish/template.html. If you're using some other language please replace the path to template.html with the path you are using for your language. Next RENAME your template.html to something like template.old.html unless you are using a custom template.html. Do not just back it up. Rename it with root privileges! Any one of these two commands may do it for you.

sudo mv /etc/dansguardian/languages/ukenglish/template.html /etc/dansguardian/languages/ukenglish/template.old.html

su -c 'mv /etc/dansguardian/languages/ukenglish/template.html /etc/dansguardian/languages/ukenglish/template.old.html'

Now if you are not using a customised template.html simply download to its location the file http://d.yourfilter.org/template.html with the help of the following commands entered in any terminal window with root privileges.

cd /etc/dansguardian/languages/ukenglish/

sudo wget http://d.yourfilter.org/template.html

If you're not a sudoer but can use su -c then replace the line immediately above with the following line.

su -c 'wget http://d.yourfilter.org/template.html'

In either case you may be prompted for a password so supply that.

However, if you are using a customised block page with your installation of Dansguardian, then you won't want to replace your original template.html because then your customisation would be lost. In such a situation back it up first with any one of the following two command which works for you.

sudo cp /etc/dansguardian/languages/ukenglish/template.html /etc/dansguardian/languages/ukenglish/template.old.htm

su -c 'cp /etc/dansguardian/languages/ukenglish/template.html /etc/dansguardian/languages/ukenglish/template.old.html'

Next, open your template.html for editing with any one of the following two commands which works for you.

sudo gedit /etc/dansguardian/languages/ukenglish/template.html
su -c 'gedit /etc/dansguardian/languages/ukenglish/template.html'

Now, insert the following block of code just after the opening <head> tag in template.html

<!--READ-ONLY. INSERT THIS BLOCK JUST AFTER OPENING <head> TAG IN SOURCE CODE OF /etc/dansguardian/languages/ukenglish/template.html-->
<script type="text/JavaScript">
var blocked_pg_url = '-URL-';
var blocked_cats='-CATEGORIES-';
if(blocked_pg_url.indexOf('webcategory.in')>=0){
	essence=1;
	essence*=(blocked_cats.indexOf('Bad words')>=0)?2:1;
	essence*=(blocked_cats.indexOf('Malware')>=0)?3:1;
	essence*=(blocked_cats.indexOf('Nudism')>=0)?5:1;
	essence*=(blocked_cats.indexOf('Pornogra')>=0)?7:1;
	essence*=(blocked_cats.indexOf('Proxies')>=0)?11:1;
	essence*=(blocked_cats.indexOf('Warez')>=0)?13:1;
	xtra=1;
	xtra*=(blocked_cats.indexOf('Gore')>=0)?2:1;
	xtra*=(blocked_cats.indexOf('Illegal Drugs')>=0)?3:1;
	xtra*=(blocked_cats.indexOf('Drug Advocacy')>=0)?5:1;
	xtra*=(blocked_cats.indexOf('Intolerance')>=0)?7:1;
	xtra*=(blocked_cats.indexOf('Peer-to-peer')>=0)?11:1;
	xtra*=(blocked_cats.indexOf('Violence')>=0)?13:1;
	go='http://d.yourfilter.org/result-iframe.php?alien=out&u=' + encodeURIComponent(blocked_pg_url) + '&essence=' + essence + '&xtra=' + xtra;
	self.location.href=go;
} // ends if(blocked_pg_url...)
</script>
<!--READ-ONLY BLOCK ENDS HERE. DO NOT MODIFY ANYTHING WITHIN THIS BLOCK-->

Save your changes and close your text editor. In fact you could have used any text editor in place of Gedit. Then open a terminal and restart the Dansguardian service with any one of the following two commands which works for you.

sudo service dansguardian restart
su -c 'service dansguardian restart'

On older systems, a different command may be required to restart Dansguardian. If you don't know the command and can't get sufficient help, rebooting also works. Now make sure that your browser is accessing the Internet through the Dansguardian manual proxy.

Set your homepage to http://d.yourfilter.org and make sure your browser automatically opens the homepage whenever started. Do not use multiple homepages. Close and reopen your browser. http://d.yourfilter.org will tell you in plain English how your Dansguardian is configured including what website categories are allowed and what are blocked. Now, if you disable Dansguardian and access the Internet directly, whenever you start your browser, http://d.yourfilter.org will tell you in plain English that you don't have a content filter guarding your browser!! Try this too.

If you access the Internet bypassing Dansguardian and forget to turn it back on before shutting down your PC, the next time you start your web browser you will be reminded by your homepage that there is no active content filter in a fraction of a second, and before you can visit any other website. And when Dansguardian blocks a dirty website, your customised block page will also show up as always!

Ref From: howtoforge

Related articles