Log In | Users | Register
Welcome to Foswiki... Users, Groups
Go
Edit | Attach | New | Raw | Delete | History | Print | Tools
NB. This document only applies to versions of censornet lower than 1.7.

This describes how to add a required length of reason in the unblock request form.

Ok, first you need to log into the censornet command line as root.

Next, and vitally you MUST make a backup. On the censornet command line, type:

mkdir /root/backup
cp -p /usr/share/cnv4/en.dict /root/backup
cp -p /usr/share/cnv4/templates/error.html /root/backup

Now we need to edit the english dictionary file in censornet. This is a sensitive file, as censornet itterates through the lines in here one by one. I can't stress strongly enough here: DO NOT ADD ANY LINES TO THIS FILE! Please make sure you just add text to the existing lines and DON'T press enter. On the command line, type:

nano /usr/share/cnv4/en.dict

Now it gets complicated. If you aren't familiar with linux or command line editors, you'll have to bear with me here. In nano, we need to search for "reason". To do this press ctrl-w and type reason. Now search through the file for all the HTML <input type=text> tags where the name="reason". Next to the name= part of the tag, add:

id="reason"

if it doesn't already exist. Make sure you do ALL the <input> tags named "reason" and that you DON'T ADD ANY LINES!

Now look for the <form> tag that the <input> tag belongs to. <form action='http://$PROXY_IP_ADDRESS$/censornet/request_unblock.php'

In the onSubmit portion add "return validateReasonLength();" before "this.submit_button.disabled=true;" so it looks like:

onSubmit='return validateReasonLength();this.submit_button.disabled=true;'

Save and exit and restart censornet by running:

/etc/init.d/cnv4 restart

Now we need to edit the template. To do this, run:

nano /usr/share/cnv4/templates/error.html

In the <script></script> tag add:

function validateReasonLength() {
var reason = document.getElementById('reason').value.length;
if(reason < 4) {
alert("Please enter a reason with at least 4 characters.");
return false;
}
return true;
}

Please note, I just used "4" as a random figure. You can choose to make this as long or short as you want.

Finally, if censornet stops working or starts behaving strangely after editting these files, you've done something wrong. To restore it back to the way it was, do:

cp -p /root/backup/en.dict /usr/share/cnv4/
cp -p /root/backup/error.html /usr/share/cnv4/templates/
/etc/init.d/cnv4 restart

-- Main.mick - 09 Mar 2010

Changed by Main.mick on 09 Mar 2010 - 14:35 - r1
Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback
Syndicate this site RSSATOM