Sunday 29 July 2012

SquirrelMail issue and fix (Message Filtering and Multibyte Character display, for CentOS)

I'm happy with SquirrelMail even since I installed it.
(Check my previous post on postfix and dovecot)

Everything is working fine and no big deal really occured.
Until...
01 Start to manage Log-type Messages.
02 Start to compose / receiving multibyte messages...

Issue 01
It was not quite a problem when you think that you can just filter the message,
and move them into a specified folder.
But the problem is "Message Filter" is DISABLED in default.
Search through the web found the solution.
(Only available for the latest version of SquirrelMail?)

If you installed your SquirrelMail through EPEL-repo, you just need to execute:
# /usr/share/squirrelmail/config/conf.pl
Select "Plugin", Select "filter", Save your configuration and quit.
Now you will have "Message Filtering" on the Option Menu.
End of Issue 01.

Issue 02
Well, if you only compose your message using ONLY Alphabets.
Plus, if you do not have any contact that sents you multibyte character included messages.
This might not be an issue for you.

You are unable to view the message properly due to decoding issue. (everything is garbled)
Note that, if you switched your Display Option to that specified language,
you able to view the decoded message properly.
But in my case, I want my SquirrelMail default language as English.
As well I receives Japanese and Chinese messages.

Google's search result lead me to a solution,
where you need to modify the current source. (Japanese site, which says i8n.php is buggy, etc...)
Which i think is not a good idea to do so.
I continue to search for the clue until I fed up and decided to browse through the official site.
Well, what did you know. There is a miracle cure in the download section.
What you need to do is:
- Download "Extra Decoding Library" from the official site's download section.
- Extract the package.
- Copy and Replace the SquirrelMail's function/decode/ directory.

** You will need php-recode for "Extra Decoding Library". Skip this step if you already have it.
# yum install php-recode

Linux command:
01. Download.
# wget http://squirrelmail.org/countdl.php?fileurl=http%3A%2F%2Fprdownloads.sourceforge.net%2Fsquirrelmail%2Fsquirrelmail-decode-1.2.tar.gz

02. Extract and access directory.
# tar xzvf squirrelmail-decode-1.2.tar.gz
# cd squirrelmail-decode-1.2

03. Copy file (execute install, you will be prompted for SquirrelMail's directory: /usr/share/squirrelmail/)
# ./install

04. Check whether files are copied successfully.
# ll /usr/share/squirrelmail/functions/decode/

05. Restart httpd.(Might not needed?)
# service httpd graceful

And there you go.
You can now compose / receive multibyte message with no problem.
... Unless some new encoding method added ...

End of Issue 02.

Tuesday 24 July 2012

How to locate yourself using HTML5 Geolocation (obtain current location's latitue/longtitude)

To locate your current position.

What you need is just the following JavaScript code.


var coordinates;
function updatePosition(position) {
    var lat = position.coords.latitude;
    var lon = position.coords.longitude;
    coordinates = [lat, lon];
}

function handleError(positionError) {
    alert('Attempt to get location failed: ' + positionError.message);
}

var gps = navigator.geolocation;
gps.getCurrentPosition(updatePosition, handleError);
alert(coordinates);

Yeap, thats all what you need to get your current location's latitude and longtitude.
And it's works on ALMOST all browsers. (Argh,  android device before v2.1 not supported.)
Mind that, the latitude and longtitude obtained it's not 100% accurate.
It depends on ISP and carrier for the accuracy.

Example, PC browser that access through wired line ISP would obtain the nearest relay station's location. Where the wi-fi user gets a closer match.