Strange php problem where session_start hangs

We encountered a very strange problem in the office today where PHP’s session_start() function would appear to randomly hang. In the end the problem turned out to be that if you start a session on one script and then that script never completes executing, it will lock the session. So if you try to access the same session from a different script, your script will appear freeze indefinitely.

Ubuntu Dapper on a Fujitsu Siemens Amilo 7400 laptop

My friend recently asked me to reinstall his Amilo 7400 laptop as it was covered in spyware. So I thought I would take the opportunity to convert him to Linux by installing Ubuntu. At the time, Breezy Badger was the latest release, and after hours of fiddling trying to get his centrino wireless interface to work, I decided that the process of connecting to wireless networks was just too complicated on Linux for a novice user, and so I gave up.

A couple of months passed and when Dapper Drake was released, I heard that there was now a graphical network manager for gnome that could handle wpa encrypted wireless networks, so I thought I would give it another shot.

All I can say is, what an improvement! I still had to do a bit of fiddling to get the software switch for the wireless card to come on automatically, but I’m now confident that he will be able to use the gnome network manager to connect to wireless networks easily.

Here’s the steps I took to get it all working: First, to get the software wireless radio switch to come on, you need to load a kernel module:

 modprobe fsam7400 radio=1

Once this is loaded, you can test it works by running a wireless network scan

 iwlist scan

To get the kernel module loading on start up you need to add it to /etc/modules

 vim /etc/modules
 fsam7400 radio=1

You then need to install the gnome-network-manager package.

 sudo apt-get update
 sudo apt-get install network-manager-gnome

And that’s basically it! I then proceeded to add other useful applications (thunberbird, realplayer, amsn etc..) using Automatix which installs everything for you.

Google Translate adds Chinese, Japanese, Korean and Arabic

I just noticed today that Google has added 4 more languages to its translation tools. Although current tagged as a BETA service, you can now translate in:

  • English to Arabic BETA
  • English to Japanese BETA
  • English to Korean BETA
  • English to Chinese (Simplified) BETA

    So test it out, I have translated “Google adds four new languages to its web translation tool” into each of the new languages:

  • توضع اربع لغات جديده اضافه الي ادوات الترجمه علي (Arabic)
  • Googleは網翻訳用具に4つの新しい言語を加える (Japanese)
  • Google는 그것의 웹 번역 도구에 4개의 새로운 언어를 추가한다 (Korean)
  • 谷歌增加4个新的网络语言翻译工具 (Simplified Chinese)

    I have no idea how accurate the translations are, so if any native speakers could verify them that would be great!

    If you are wondering how I managed to get the foreign characters from Google translate on to my blog, well I couldn’t just copy and paste from the source, so I made a tool that converts foreign characters into html special characters.

  • Installing PDFlib on Fedora Core 4

    First up I had to download the package from the pecl repository via pear

    pear install pdflib
    But that gave me an error sh: phpize: command not found, so I had to install phpize. This appears to be part of the php-pecl-pdo-devel.i386 package. So installed this with yum
    
    yum install php-pecl-pdo-devel
    

    I then tried installing pdflib through pear again, but this time it had a different complaint aclocal: command not found. So apparently I need the automake package.

    yum install automake
    

    I try installing pdflib again, but this time it complains about no c compliler found! So then I try install gcc

    yum install gcc
    

    Installing SQL-ledger on Fedora Core 3

    If you get a No Database Drivers available! error when trying to install SQL-ledger, it is most likely because you haven’t installed the perl/postgresql drivers. With FC3 you can install them through:

    yum install perl-DBD-Pg
    

    These weren’t the only difficulties I encountered with the sql-ledger installation process, so I have detailed the steps I took here:

    yum install postgresql postgresql-server php-pgsql postgresql-pl perl-DBD-Pg
    

    Then download and run the sql-ledger setup script

    mkdir /usr/local/sql-ledger
    cd /usr/local/sql-ledger
    wget http://www.sql-ledger.org/source/setup.perl
    chmod +x setup.perl
    ./setup.perl
    

    Follow the on-screen prompts, and then once that has completed you will have to setup the database user etc..

    su postgres
    createuser sql-ledger
    createdb sql-ledger
    createlang plpgsql template1
    

    You will then probably need to change the security settings of postgresql to trust local users, I did this by editing pg_hba.conf and changing the authentication to

       local           all        all           trust
    

    Finally you should visit the http://localhost/sql-ledger/admin.pl script in your webbrowser to complete the setup.

    PHP Classes / Objects vs Functions

    We’ve been having a big debate in our office recently on whether we should be using Classes and Objects as a method of best practice in our PHP coding standards, or whether instead we should stick to using functions and avoid objects like the plague. I have been searching the web for other peoples views on the issue, and I eventually found this great article over on zend.com. You should read it if only for the comical but accurate descriptions of the procedural fanatic and the object fanatic.

    Zend Technologies – Articles – The Best Tool For The Job: OO versus Procedural Programming in PHP

    The general conclusion is that there is a time and a place for both programming methods, with procedural techniques better suited for building low overhead, tight and fast code, whereas object orientated techniques are better for making code that is re-useable and more flexible.

    Ubuntu Dapper Drake and WPA Encrypted Wifi

    I tried to get WPA wifi working on Breezy Badger with a Amilo M7400 laptop a while back and although it worked in the end, it was a bit of a nightmare getting there. However, it seems that with the new Dapper Drake release they have made the process a little easier with the network-manager-gnome package. Read this article on Ubuntu Dapper Drake and WPA-Encrypted Wireless at fredericiana for further information.