Michal Čihař - Blog Archives for Website

Too much ads

Sorry I accidentally inserted Google Ads code twice on Gammu pages and didn't notice it for several days. It was not intentional and I really don't want to have site full of Ads.

Anyway I also decided to switch to smaller banners and see how they will work.

BTW: If you have interest in placing ads somewhere here, I'm open to your offers :-).

Community website

I'm considering about creating community site in Czech language for phpMyAdmin. However I don't want to build yet another custom CMS for that and would rather use something already written. Based on languages I know I prefer solution in PHP or Python. Current considerations count Plone, Joomla! and WordPress.

I worked with Plone/Zope some time ago and it worked quite well, but maybe I could try something else?

Fighting spam in phone database

As I already complained, spammers seem to like my phone database. It has not been a major problem so far, but I started to get about ten invalid records per day.

This forced be to find automatic solution to get rid of this. Inspired by recent article on root.cz, I wrote simmilar solution as is used on php.vrana.cz. It should not harm regullar users who have javascript enabled, others will have to fill in one extra field.

Spam in phone database

During regullar review of additions to phone database, I noticed that some people tried to add spam and links to their sites. I'm not going to add any further restrictions on database, but to make spammers life a bit harder, I added logging of IP addresses which I'm going to block if they attempt to add some links.

Fortuntely spam volume is htere low enogh to be still handled manualy.

New themes in demo

As Marc has recently commited some new themes into CVS, I finally forced myself to make automatic inclusion of new themes in demos (and snapshots). So now you can try all three new themes which has been added to CVS (Grid, Very small and Graphivore).

Multi language site with PHP and gettext

As announced yesterday, I started to translate my website to Czech. I take it mostly as experiment how to do such thing easily. I don't want ot maintain different pages for each language, so the logical step seemed to use gettext which I know for translating regullar applications.

Using gettext from PHP is quite easy. You can just follow documentation and you will get basic idea. Only tricky part was to set encoding so that messages are displayed correctly.

The whole magic that selects translation based on host name is few lines of PHP code:

$lang = 'en';
if (substr($_SERVER['HTTP_HOST'], 0, 3) == 'cz.') {
    $lang = 'cz';

    setlocale(LC_MESSAGES, 'cs_CZ.UTF-8');
    setlocale(LC_ALL, 'cs_CZ.UTF-8');
    bindtextdomain('website', 'locale');
    bind_textdomain_codeset('website', 'utf-8');
    textdomain('website');
    $_SERVER['HTTP_HOST'] = substr($_SERVER['HTTP_HOST'], 3);
}

You can see that is't just locales and gettext initialisation and cutting host name so that rest of code doesn't have to deal both possibilities.

The hardest work is to make all PHP pages use gettext instead of plain text constants and translate them. I will probably never convert whole site, but it is not needed and only parts can be translated using this approach without any additional effort.

Browser incompatibilities

Today I looked at menu on top of Wammu pages in MSIE and it was displayed completely differently than in Firefox. So another CSS hacking session had to begin to fix the menu look.

Fortunately I found ies4linux which easilly installed MSIE on my Linux computer so that I can test the beast without searching for some Windows installation.

Anyway now it looks almost same in both browsers (there are some minor glitches in MSIE which I'm going to ignore).

Started Czech translation of website

Today I finally setup gettext and started to convert some page to make use of it. Currently only Wammu page contains translated parts, but I will try to improve it in future as time permits.

Translation will only affect content of main domain, other subdomains as this blog or phpMyAdmin demo will remain in English.

Site troubles

I was few days offline and it looks like it was ideal situation to apply Murphys law and break thinks on my website. Bug tracker was not able to log you in or if you managed this step, you could not post anything. This issue seems to be caused by some bug in lighttpd which I'm not able to reproduce on my devel machine (most probably because of it is 32-bit and server is 64-bit).

phpMyAdmin demo server didn't work at all because somebody hardly break mysql database and my restore scripts didn't properly handle this situation.

Right now everything should be back working, please report if there are any other issues remaining.

MSIE hacks

Okay it looks like I again found some bug in my favourite browser. There seems to be something wrong in border handling which makes subsequent blocks to have reverse indentation of left border widht.

So instead of simple:

body.blog blockquote {
    border-left: 0.5em solid #BBB;
}

I have to use:

body.blog blockquote {
    border-left: 0.5em solid #BBB;
    /* Following need to be in for MSIE */
    border-top: 0.5em solid #EEE;
    border-right: 0.5em solid #EEE;
    border-bottom: 0.5em solid #EEE;
}