VirtueMart Custom Login Module in Joomla!

Here’s a short article on making a simple module to include on your Joomla! pages that displays login / logout links. I’m a Joomla! newbie so there might be better ways to accomplish this.

I was helping a friend-client to accomplish redirection to the same page after logout.

Here’s the basic code that you need to have in a module with the Jumi extension:

< ?php
    $user=& JFactory::getUser();
    if (!$user->guest)
        echo '<a href="index.php?option=com_user&task=logout&return=Lw">Logout</a>';
    else
        echo '<a href="index.php?page=account.index&option=com_virtuemart">Login</a>';
?>

The code above will redirect users to the root or uppermost level of the website.

Let’s say that your website is http://www.yourwebsite.com/ and your shopping page with VirtueMart is installed at a subfolder http://www.yourwebsite.com/shop/

The question is simply where you want your user to end up after logging out. If you need your users to end up at http://www.yourwebsite.com/ then you’re good to go. If you want your users to be redirected to the shop or a thank you page, here’s where you need to be a little creative.

You need to replace that “Lw” in the logout link to a different string. “Lw” is the base 64 representation of the character “/”. So this means that the user will be redirected to / which is http://www.yourwebsite.com/

A solution I came out with:

1
2
3
4
5
6
7
8
< ?php
    $redirect_to = '/shop/';
    $user=& JFactory::getUser();
    if (!$user->guest)
        echo '<a href="index.php?option=com_user&task=logout&return=' . base64_encode($redirect_to) . '">Logout</a>';
    else
        echo '<a href="index.php?page=account.index&option=com_virtuemart">Login</a>';
?>

So only line 2 needs to be changed. Let’s say you want users to be redirected to http://www.yourwebsite.com/thankyou.html here’s how you will change line 2:

2
    $redirect_to = '/thankyou.html';

If you’d like your users to simply be redirected to the same page where they clicked the logout link, here’s what you should do to line 2:

2
    $redirect_to = $_SERVER['REQUEST_URI'];

That’s simply it. At first, I totally forgot that I can use PHP’s base64_encode so I ended up confusing my friend with an online encoder so that he can replace the “Lw”.

One annoying thing that I wasn’t able to solve is the login page always displays the error message:

Error: You do not have permission to access the requested module.

I think Joomla! is trying to load VirtueMart too early and I can’t make it go away. Looking at the Internet a lot of other websites has this message displayed. If you know how this message can be removed without hacking the CSS or source code, please let me know and I’ll give you credit.

References:

  1. http://forum.virtuemart.net/index.php?topic=88802#msg290906
  2. http://forum.joomla.org/viewtopic.php?p=1457876

Sparrow and Shortmail

I’ve been pushing the limits of my mid-2010 13″ MacBook Pro lately, running all sort of applications and leaving them running. There has been occasions where the machine will freeze while it struggles to schedule the CPU time to all of the applications.

I use a lot of email, and by a lot I don’t mean 10 emails per day. No joke. The features of Apple Mail 5.0 are actually enough for my daily use but it does feel a little bit sluggish with 5 IMAP accounts.

Recently, I signed up to Shortmail via my Twitter account. The idea is nice. 500 characters max per email, straight to the point.

While casually browsing through my Twitter stream last night I saw people talking about setting up Sparrow to access Shortmail and sending attachments via Dropbox.

I was thinking, Shortmail is short, Sparrow is light. Combining them together should be nice… and since all of my email accounts are now running via IMAP, why not give Sparrow a try with Shortmail before using it for serious communications.

I downloaded Sparrow through the website to try it out, instead of buying it from the Mac App Store for $9.99

I was pleased that it only asked for my email address and password so I entered my Shortmail account details. It was nice. Shortmail’s logo was displayed on the screen. But it took ten minutes to sync my 3 messages. I don’t know what it was doing and I’m not sure whether the waiting time is caused by Shortmail servers or Sparrow itself.

One thing I hate the most is how markup is displayed in the preview lines in Sparrow. It’s not in Facebook’s email but markup are there for the first 2 emails.

I can understand if there are glitches in Shortmail as it’s still fresh but I don’t expect glitches from Sparrow. I wonder how long it would take for it to sync my gigs of emails from other email accounts. I can’t even imagine and I can’t afford to waste so much time.

Looks likes it’s going to be a while before I am convinced to try Sparrow again. I am glad I didn’t rush to buy the app for $9.99 in the Mac App Store. For now, I’m leaving it to AppZapper to cleanup!

Update 16 December 2011 11:15 AM GMT+8

Less than an hour ago, I received a shortmail from Shortmail telling me that they are working on a new version of their IMAP service that should make a difference. This is great news for those who prefer using Shortmail service via regular email clients. From @Shortmail‘s timeline I can see that they are responding to many users about improving the IMAP service.

Keep up the good work! By the way, my Shortmail address is romantikaname [at] shortmail [dot] com

Thanks for the shortmail! This is nice, and it shows that you are serious about what you do!

For the record, I was more disappointed with Sparrow displaying ugly markup on the preview pane.

Delayed Yahoo! Messenger Custom Message Updates

Borrowing Google’s term – I have lately been using a flaky connection when connecting to the Internet. What I noticed is that my Yahoo! Messenger list becomes static and no custom messages are being updated. When I looked at my friend’s list, the custom message I set wasn’t showing. I was also not able to see when people get online or offline. I’m using Yahoo! Messenger 9.0.0.2161 for Windows.

I’ve tried all that I can think of – changing connection preferences, clearing message archives because I thought they grew too big, and up to the extent of reinstalling the whole application. I even blamed Symantec Endpoint Protection for it.

I found a simple remedy today – disable the “Always sign in to my mobile phone when I sign out of Messenger“. I have always thought that this option is convenient, especially when someone wants to convey a message for me when I’m not online. Well, okay I admit being lazy as this can easily be done by clicking on “Sign in to <cellphone number>” in the menu.

It turns out that the server is confused when you are online/offline so frequently – flaky connection. It’s a bug, yes.

Why am I not using Pidgin? Because I still want to separate my identities with the “send-as” functionality. With Pidgin I always revealed my identities to different group of people, and I don’t like it. I’ll reuse it once this feature is added.

So if you’re facing the same issue and have the option turned on, try to disable it.

Sun xVM VirtualBox 2.1.0

While doing some work I accidentally saw that there is an update available for VirtualBox. I was still using version 1 so I decided to download it and test it out myself. In older versions running on Windows I often get corrupted OS images after an upgrade. Not anymore. My CentOS, Debian, and Ubuntu virtual machines booted fine and faster.

Also, the host interface is now automatically bridged so there is no need for manual bridge setup at the OS level anymore. I don’t really have time to investigate further but I was shocked to see the battery meter inside the Ubuntu virtual machine was gauging the correct battery level. How cool is that?

[singlepic=7,600,800]

And here’s the meter while charging.

[singlepic=8,600,800]

The accuracy is amazing. There must be some kind of hardware interfacing between the host and guest OS provided by the new VirtualBox.

Line Numbers in EPIC + Eclipse

When I was using Europa I was baffled by the inability to get line numbers to be displayed in my Perl source codes (using EPIC). Since PDT 2.0 has been released I decided to upgrade to Ganymede (3.4.1) but I still face the same issue:

eclipse-epic-line-numbers

I was thinking that the right-click context menu might be defective so I decided to thoroughly dig the preferences.

eclipse-epic-line-numbers-eclipse-editor

Guess what? Nothing happened. I finally realized that there is a separate setting honored by EPIC:

eclipse-epic-line-numbers-epic-editor

Now I am happy. Is this only my problem or anyone out there is facing the same issue?

My overall experience so far with Ganymede is great. The software update menu works faster and the dependency solver no longer freezes my machine. Bravo to the Eclipse Foundation. I decided to upgrade my Aptana plugin as well. Let’s see how it goes.

OCRopus and Tesseract Binaries

After I wrote about Ocropus and Tesseract in July, I received 4 requests for the binaries. Two requested using the comments and two requested via email.

The truth is that it ain’t easy to upload files that big because my upload speed is 1/4 of my download speed. It’s worst today (see the previous post).

However since I promised to upload them here they are, uploaded in rapidshare. I am avoiding to use my hosting bandwidth just in case these become too popular.

Downloads:
Tesseract binaries e7c90901a896eb44ffb500d4e8831bdf
Ocropus binaries c46466b7626436d797425f09e5b2fc7f

To install Tesseract you only need the normal make installed:

$ tar xfvz tesseract-2.01-compiled.tar.gz
$ cd tesseract-2.01
$ make install

To install Ocropus you would need Jam. Download and install it.

After jam has been installed:

$ tar xfvz ocropus-0.2-compiled.tar.gz
$ cd ocropus-0.2
$ jam install

Please take note that this is an old version of Ocropus (0.2) there is a new version available (0.3.1). The same goes for Tesseract (2.01 compared to 2.03). I simply have no time to work on the new version and I am not going to use it for my OCR related personal project.

And oh yes… please remember that since these were compiled under Cygwin you will definitely need to run them with Cygwin DLL due to dynamic linking.

I don’t have any guarantee or support whatsoever for the files, and you are using them at your own risk. These are NOT official builds.

Enjoy!

Flash Uploader Error

I was using YUI Uploader for a personal project and it works very well on my development notebook and server. However when the code is live on the server the Flash uploader failed with this error message:

[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2038"]

After a while I realized that it must be something server-side because when I used WireShark to see the traffic the server returns Error 500. The traffic is not captured by Firebug because it is Flash traffic.

The culprit is ModSecurity, a third party module used by most hosting companies. ModSecurity is a web application firewall that can work either embedded into Apache or as a reverse proxy.

A quick fix to allow uploads is to include these in the .htaccess file. These handle different Apache and ModSecurity versions and since we include the IfModule directive if the module is unavailable no error will be thrown. This relieves the need to consider what version of Apache and ModSecurity is used on the server.

For this example the script that handles the upload is named upload.php.

# Apache 1.x and ModSecurity 1.x
<IfModule mod_security.c>
   <Files upload.php>
      SecFilterEngine Off
      SecFilterScanPOST Off
   </Files>
</IfModule>

# Apache 2.x and ModSecurity 1.x
<IfModule security_module>
   <Files upload.php>
      SecFilterEngine Off
      SecFilterScanPOST Off
   </Files>
</IfModule>

# Apache 2.x and ModSecurity 2.x
<IfModule security2_module>
   <Files upload.php>
      SecRuleEngine Off
      SecRequestBodyAccess Off
   </Files>
</IfModule>

That’s it! This fixes the Flash uploader problem.

By the way it might be useful to let you know that this issue was encountered on a server hosted under the Ebiz Linux package by Exabytes.

OpenVZ On Ubuntu Or Debian

As a SysAdmin I have been using OpenVZ since it was introduced, and trust me it has not always been this easy. I used to take care of 20 physical servers with yearly replacement of about 5 machines. Since some of the servers are running different Linux distributions and different hardware it was decided that to standardize all servers, OpenVZ was to be deployed so that all of them are running Debian stable.

OpenVZ is container-based virtualization for Linux and it only separates the different guest servers in terms of resources. This differ from other implementations such as VMware, Xen, and VirtualBox where these involve hardware virtualization. Because of this, the guests called VE or VPS have the same kernel version and can only run Linux. What distribution as guest? The choice is yours.

Undoubtedly most of you have heard of Virtuozzo – it’s running OpenVZ. As a matter of fact the company that produces Virtuozzo is the one funding and supporting the development of OpenVZ.

The fact that it can run any distribution you like means that you can study and learn how to maintain different distributions. Even the littlest difference can confuse a rookie SysAdmin, for example:

  • Debian apache’s init script is distributed as /etc/init.d/apache and /etc/init.d/apache2 while in CentOS it’s called /etc/init.d/httpd
  • In Debian to change init scripts and runlevels we use update-rc.d while in CentOS we use chkconfig even though they both do the same exact thing

There are many other differences in terms of implementation that I rather not discuss here.

Click on Continue Reading if you’re interested to read more…
Continue reading OpenVZ On Ubuntu Or Debian

Google Chrome: More Findings

Actually, if you really watch the 52-minutes video or read the whole manual you might already know about these cool features. And then again maybe not. I didn’t have the time to go thorough with the documents / videos so I am just documenting based on casual use.

One of most obvious feature would be the “Inspect element” contextual menu. As a Firebug user this screen is no stranger to me.

I have not figured out whether Chrome can display real time resources such as JavaScripts and CSS loading like what Firebug does in its “Net” panel.

Another interesting feature I just discovered is the “Open link in incognito window” contextual menu that will appear every time a right click is done on a link.
Continue reading Google Chrome: More Findings

Google Chrome: My Findings So Far

Like Rizal, I was also thrilled to try out Google Chrome when I saw the posts in nazham.com and dirn.name.

I am simply discussing my initial findings, and we all know it’s Beta. This is by no means an official or detailed review. This is what I have encountered so far while using it casually.
Continue reading Google Chrome: My Findings So Far

OCRopus and Tesseract

A friend pointed me to an open source project called OCRopus because I am currently working on a project related to OCR. Commercial OCR solutions ain’t cheap and you can really dig a hole in your pocket trying to get a good OCR solution. It’s neither the price of the hardware nor the software that is high but the amount of work that needs to be done to make sure a correct output is obtained.

Most OCR solutions need a vast amount of time to train the software to correctly identify characters. Artificial Intelligence can help but not now, not today, not yet.

OCRopus is not the one who recognize the character itself but it relies on Tesseract. OCRopus provides layout analysis, pluggable character recognition, statistical natural language modeling, and multi-lingual capabilities. Sounds really good doesn’t it? Tesseract is the OCR engine that OCRopus uses.

Most of the project is tested and developed on Ubuntu, but if your platform has binutils and build tools you’re good to go. I believe it is also possible to build using Microsoft Visual Studio on Windows and of course MingGW. I went for the easiest option since I only have 2 hours to spare and I already have Cygwin on my system.

I first installed libraries header files (libpng-devel, libtiff-devel, libjpeg-devel) and build tools (gcc, make, g++, autoconf) and then built tesseract with the normal ./configure && make && make install method. To build OCRopus there is a need for Perforce Jam. Jam is actually Just Another Make. I find it a little funny when I have to build Jam using make. Oh well. OCRopus is built with ./configure && jam && jam install and it went pretty well.

To run them don’t forget to download the language files for your target language otherwise it will complain: Unable to load unicharset file /usr/local/share/tessdata/eng.unicharset

I ran my tests with standard LUA scripts that came with OCRopus (located in /usr/local/share/ocropus/scripts/) with the command ocroscript.exe rec-tess input_image > output.html

I created a 10 line Word Document with different fonts and printed it to a PDF. Using Adobe Photoshop I saved it to a JPG image. Then I gradually resized the image to the smallest I can get some output with.

To see the tests and results, click on Continue Reading.

Continue reading OCRopus and Tesseract

Maildir Storage in Thunderbird

I am doing research before deployment of a Postfix + Dovecot HA cluster tomorrow morning, on converting existing mailboxes to Maildir format. The existing mail server is running Sendmail + Unidentified POP3 on a Fedora Core 2 box. It’s ancient and that’s why my client need it to be scrapped or turned into something else.

Maildir will certainly help a lot in improving performance and avoiding the need to think about mailbox slowness and lock-ups that is a normal problem with mbox.

As an avid Thunderbird user since the project was started years ago and since Firefox 3 have just been released, I can’t avoid wondering whether Thunderbird is considering adding an option for Maildir storage in version 3. Of course, this have no relation whatsoever with the servers mentioned above. For those who are unfamiliar with Thunderbird, it currently store mailboxes in the mbox format.

Searching high and low for an answer, I don’t see any mention of Maildir, anywhere. However Thunderbird 3 looks promising in terms of feel and usability. Mac users will be very happy that Thunderbird 3 is a native Cocoa application and integration will be better. Other platforms will have to make peace with Gecko 1.9.

I’m too lazy to become a tester this time around so I am just going to wait. What about you?

Welcome Firefox 3; Good Bye Google Browser Sync

Following from Firefox 3 download day yesterday, I was eager to try out the new, all-improved Firefox 3. As a matter of fact, I am writing this post in Firefox 3.

There is certainly a significant improvement in speed and responsiveness, and the overall feel have changed. It’s a lot more elegant now.

However it’s sad to learn that Google will no longer update its Google Browser Sync service to support Firefox 3.

I’ve now migrated to Foxmarks. So far it works very well. One thing I shall miss is the password sync option which I use for low risk sites such as private torrent trackers.

Other add-ons that are available for upgrade includes Firebug, Alexa Sparky, Google Notebook, Google Toolbar and of course, Foxmarks 🙂

Anyway, bravo to Firefox for a job well done.

innotek VirtualBox

During the course of my daily work, I sometimes need to run multiple OS at once. I used to rely a lot on VMware to run Debian and CentOS on my Windows notebook. The problem with the free VMware server is that it is damn slow, and at startup it takes a few minutes before the VMware authentication service finish working.

One day during a nicotine session my friend Haidir asked me “why don’t you use VirtualBox?”. Oh man! I recall bumping over some articles about VirtualBox in magazines but I guess it slipped my mind.

Starting from that day, bye VMware and hello VirtualBox!

I am surprised on the feel of VirtualBox – it is too light to be a fully functional virtualization product. But it is.

Comparing directly to VMware server (free version) VirtualBox does not introduce any kind of lag at all to my machine. CPU usage never reaches 100% with normal usage of the guest boxes:

VirtualBox running Debian and CentOS

I loooooove the shared folder feature. Sure, you’ll have to compile kernel modules for the virtualbox functions but it’s easy and you can always remove gcc and make later if you want.

A little note about networking, is that when you use only NAT networking with the host you will be able to do a “port forwarding” setup from the host (so that when you access a particular port on the host you are accessing the guest). Look for it in the documentation.


"C:\Program Files\innotek VirtualBox\VBoxManage" setextradata "CentOS" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/CentOSHTTP/Protocol" TCP
"C:\Program Files\innotek VirtualBox\VBoxManage" setextradata "CentOS" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/CentOSHTTP/GuestPort" 80
"C:\Program Files\innotek VirtualBox\VBoxManage" setextradata "CentOS" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/CentOSHTTP/HostPort" 80

In the commands above a port 80 on host is forwarded to port 80 on guest. Cool feature. However I want to demonstrate a hidden problem that might help some of you out there.

On my machine, IIS is running on port 80 (don’t ask me why). Meaning port 80 can’t be used by VirtualBox anymore. This will cause the virtual machine to crash when it tries to activate the network interface:

Virtual Box Crash Port In Use

(I purposely captured along the JIT message, normal users might see a normal Send Error to Microsoft dialog).

VirtualBox will display the virtual machine status as “Aborted”:

VirtualBox Aborted

What you can do next is decide on which port you really want to use on the host. In my case I can simply stop IIS on my host machine if I really want to use port 80.

This is neither a big issue with VirtualBox, nor is a critical defect – it’s just a bit annoying. Perhaps next versions can detect used port before powering on the virtual machine 🙂

But then again, I am using this for my personal work and learn environment. For serious use and production, you might want to consider vm ware hosting for a more reliable solution.

Eclipse PDT, Zend Framework, PHPUnit

I am currently in love and coding some personal projects using Eclipse PDT with the Zend Framework as foundation. Unit testing is accomplished using PHPUnit.

I love the ability of Eclipse to be extended with plugins so that I can have intelligent code completion and integrated subversion client. To my surprise, Eclipse runs very well on my seasoned 4 years old notebook.

I am a learner by practice so late last year I tried to penetrate the Ruby team at my company. However I didn’t make it because of company re-organization so requisitions were suspended (or something like that). I guess Ruby and I was just not meant to be together.

Eclipse PDT

Zend Framework really helps a lot in building applications really quick minus the bells and whistles of nice graphics. I am incompetent when it comes to creating nice graphics with Photoshop. 🙁

I am relatively very new to the MVC concept but I am very comfortable with it. It was just recently that I realize the importance of unit testing.

I must grab the unit testing concepts very quickly because I have just moved into a new role as a release engineer for a week. 🙂

On another development, I was also doing some Flash ActionScript 2.0 a couple of weeks ago and experimented on the XMLSocket object. The Flash movie connects to a server, and since I needed threading I decided to use Java. Eclipse is also superb with Java codes since I think it was originally meant to be a Java IDE.

Signing off.