web development

How to install cruisecontrol/phpUnderControl in Debian Etch

This is how I install cruisecontrol/phpUnderControl, including all dependencies, in a fresh Debian Etch machine.

# add the backport mirror for java and subversion
echo "deb http://www.backports.org/debian etch-backports main contrib non-free" >> /etc/apt/sources.list

# add the backport mirror key
gpg --keyserver hkp://pgp.mit.edu --recv-keys 16BA136C
gpg --armor --export 16BA136C | apt-key add -

apt-get update

# install backports (java and subversion)
apt-get -t etch-backports install sun-java6-bin sun-java6-jre
apt-get -t etch-backports install subversion

# install apache (mainly for phpmyadmin) and php5 + cli
apt-get install apache2-mpm-prefork
apt-get install php5 php5-cli php5-dev
apt-get install php-pear make

# install xdebug (needed for phpunit)
pecl install xdebug
echo "zend_extension=/usr/lib/php5/20060613+lfs/xdebug.so" >> /etc/php5/cli/php.ini

# install phpunit and phpundercontrol via pear
pear upgrade --force pear
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear install phpunit/phpunit
pear install --force --alldeps channel://components.ez.no/Graph
pear install --force --alldeps channel://pear.phpunit.de/phpundercontrol-0.4.7

# get and extract cruisecontrol
apt-get install unzip wget
cd ~
wget http://freefr.dl.sourceforge.net/sourceforge/cruisecontrol/cruisecontrol-bin-2.8.2.zip
unzip cruisecontrol-bin-2.8.2.zip -d /opt
cd /opt
ln -s cruisecontrol-bin-2.8.2 cruisecontrol

# run phpundercontrol modifications against cruisecontrol
phpuc install /opt/cruisecontrol

# first testrun
cd /opt/cruisecontrol

Balsamiq Mockups – impressive software with an even more impressive story

mockups_fpaSince the first time I have seen Balsamiq Mockups, it rocked my world. It is now a pleasure to create mockups. With Mockups, this is a fast and intuitive process, for everyone. Yes, I like this tool as a developer, and I am sure that any non-developer will also like it as much!

There are a lot of shapes one can choose like a browser window, iphone window, any other window, webcontrols, etc. The result can be exported as PNG or saved as XML. With XML files one can even diff/merge mockups ;)

Short overview:

  • Create software mockups in minutes
  • Collaborate with your team
  • Focus on creating your product

The guy/company behind Mockups, Giacomo ‘Peldi’ Guilizzoni, is even more impressive. There is a very good interview over at 37 signals (see Sources):

“I never really understood the concept of building a company with the goal to sell it, or why one should have an ‘exit strategy.’ I just don’t get it. If you’re doing what you love, why would you want to ‘exit’? Maybe it’s because I am Italian, but I see nothing wrong with a business staying small in the long run. As long as we do great work, are happy to do it, and make people happy with it, I see no reason to change anything.”

Thank you again for the kind response to my email, Balsamiq Team, and the chance to review this very nice (and therefore rare) piece of software.


Moving to Feedburner

Just as a short notice, I moved my feed to feedburner. The new feed url is this: http://feeds2.feedburner.com/logaholic

I did this to “outsource” my feed traffic and improve statistics for analyzing what you like to read :)

Yes, I also moved the subscribe button/links to a more prominent position (top right, larger icon).

Update: Automagic redirection in place. You shouldn’t need to update anything ;)

Secure backups with push and pull strategies via amazon s3

Note: If you don’t want to or cannot by company-rule trust Amazon S3, this is probably not what you want to read.

I’m going to show you how one could improve the security of his production environment backups. In this setup the production environment can never harm any old backup. There is another offsite backup location if Amazon S3 should fail – for us being our office, this is also perfect for up-to-date testing/development database snapshots.

We will need two separate Amazon S3 accounts and any s3 console tool (like s3bash).

The production environment, with its own (restricted to put and get files) s3 user, will push backups to our s3 bucket. It is not allowed to delete backups there. It does not have any access to the offsite location. If someone gets access to our production environment, he can not delete our backups on s3 per their acl, and can never harm our offsite backups. This is kind of an one-way solution and represents the “push-strategy“.

The offsite location, with the second, full privileged s3 account, will pull the backups from s3 every night. There are also tools for backup verification and testing-environment updates. This is the “pull-strategy“. The offsite location has access to the production environment for maintenance task and deployment.

Small graphic:


I wanted to mention this setup since i read a blogpost about a worst case scenario:

“A huge flight sim site was hacked and destroyed this weekend  – avsim.com. An important lesson on why off-site backups are critical! They had two servers, and had a backup of A on B, and B on A. Both were taken out.”


  • Access to our office network/offsite backups would be bad.
  • Bruteforcing/getting access to our administrative S3 Account would be bad.
  • you have to trust Amazon with your data


Always combine different backup strategies and test your backups. One day you will need them!

Uncompressing Zip-files with subfolders in AIR applications via JavaScript

I am currently building an AIR application with JavaScript (jQuery + jQuery UI), one function downloads zipped files and has to extract the contents somewhere to the local filesystem. Since the files may contain subfolders, i didn’t find any working example supporting subfolders in the docs or via google.

I found an Adobe Tutorial for basic Zip files (see Sources), and after reading the zip specs there was just one small change to their code to get it working with subfolders.

The spec says that entries in the zip file which are directories just end with an ‘/’. Skipping them is the whole magic. (see line 48)

Thankfully, the air.FileStream autocreates director ies, so writing the files to the subfolders does not need any change to the code. I added a basepath as parameter to the outFile function, to complete the for me intuitive function unzipFile(sourceFile, targetPath).

Here is the code:

 function unzipFile(sourceFile, targetPath)
	var bytes = new air.ByteArray();
	var fileName = new String();
	var flNameLength;
	var xfldLength;
	var offset;
	var compSize;
	var uncompSize;
	var compMethod;
	var signature; 

	var zfile = air.File.applicationStorageDirectory.resolvePath(sourceFile);
	var zStream = new air.FileStream();
	zStream.open(zfile, air.FileMode.READ);
	bytes.endian = air.Endian.LITTLE_ENDIAN;

	while (zStream.position < zfile.size)
		// read fixed metadata portion of local file header
        zStream.readBytes(bytes, 0, 30);

		bytes.position = 0;
        signature = bytes.readInt();
        // if no longer reading data files, quit
        if (signature != 0x04034b50)

		bytes.position = 8;
        compMethod = bytes.readByte();  // store compression method (8 == Deflate)

		offset = 0;    // stores length of variable portion of metadata
        bytes.position = 26;  // offset to file name length
        flNameLength = bytes.readShort();    // store file name
        offset += flNameLength;     // add length of file name
        bytes.position = 28;    // offset to extra field length
        xfldLength = bytes.readShort();
        offset += xfldLength;    // add length of extra field

		// read variable length bytes between fixed-length header and compressed file data
        zStream.readBytes(bytes, 30, offset);

		bytes.position = 30;
        fileName = bytes.readUTFBytes(flNameLength); // read file name 

		if (fileName.substr(fileName.length - 1, 1) != '/')
			bytes.position = 18;
			compSize = bytes.readUnsignedInt(); // store size of compressed portion
			bytes.position = 22; // offset to uncompressed size
			uncompSize = bytes.readUnsignedInt(); // store uncompressed size 

			// read compressed file to offset 0 of bytes; for uncompressed files
			// the compressed and uncompressed size is the same
			zStream.readBytes(bytes, 0, compSize);

			if (compMethod == 8 ) // if file is compressed, uncompress
			outFile(targetPath, fileName, bytes); // call outFile() to write out the file

This is the outFile function which writes the uncompressed files to the local file system.

 function outFile(baseDir, fileName, data)
    var outFile = air.File.applicationStorageDirectory;
    outFile = outFile.resolvePath(baseDir+air.File.separator+fileName);
    var outStream = new air.FileStream();
    outStream.open(outFile, air.FileMode.WRITE);
    outStream.writeBytes(data, 0, data.length);


Running AIR Applications straight from Eclipse (Windows) without plugins

1. Run > External Tools > External Tools Configurations…

2. Add new (External Program) Configuration

3. Main Tab:


  • Location: Point to your Adobe Air SDK\bin\adl.exe
  • Working Directory: Point to your project folder (i did this via variable in the screenshot)
  • Arguments: your main application configuration, usually application.xml

4. Finished. Run!

If you don’t see the “Program” entry in 2), check if your eclipse filters it here:


Apache, SSL and phpUnderControl

After installing phpUnderControl I wanted to use my existing apache, running with ssl, to proxy requests to the “java stuff”. After failing with various mod_proxy reverse proxying attempts I learned how to use mod_rewrite for this purpose.

ProxyPreserveHost on
RewriteEngine on

RequestHeader Set Proxy-keysize 512
RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
RequestHeader Set Host example.org:443

RewriteRule ^/$ /cruisecontrol/ [R,L]

RewriteRule ^/cruisecontrol$ /cruisecontrol/ [R,L]
RewriteRule ^/cruisecontrol/(.*) http://localhost:8080/cruisecontrol/$1 [P,L]

RewriteRule ^/dashboard$ /dashboard/ [R,L]
RewriteRule ^/dashboard/(.*) http://localhost:8080/dashboard/$1 [P,L]

Unfortunately, phpUnderControl didn’t get the baseURL right with this setup. I didn’t want to dive into mod_jk yet, which I had read should also work (or be the more clean/generic solution), so i poked at the phpUnderControl code with grep. And now it just works fine.

You have to edit the files error.jsp, index.jsp, main.jsp and old_index.jsp in /opt/cruisecontrol/webapps/cruisecontrol/: Just place your https-url in the baseURL strings (https://example.org/cruisecontrol/).

The CruiseControl dashboard (/dashboard) does not need any tweaking for https.

One could even add any apache authentication module in front of phpUnderControl now ;)

Improving HTTP Authentication

Do you use HTTP Authentication anywhere in your webapplication? Today I discovered something that could also be useful for you.

The plusserver member control panel uses HTTP Authentication, and the errorpage replacement for the HTTP 401 authentication failed page (press cancel on the login) is replaced with a simple form with two elements: username and a button “receive lost password”.

This is the most useful errorpage-replacement i have ever seen yet ;) You could also add a link to a faq for common questions/problems there.

Review: Lightweight PHP5 OOP MVC framework “simples” by Daniel ’smacks’ Harrington

This is a small review of Daniel ’smacks’ Harringtons beta php5 oop mvc framework “simples”. He sent me this comment yesterday:

Hi Karsten,

dein Beitrag ist zwar schon etwas her, steht aber bei Google zum Thema Micro-Framework ziemlich weit oben. Da ich gerade ebenfalls in der Situation war und etwas einfaches wie Sinatra für PHP gesucht und nichts ansprechendes gefunden habe, hab ich mich letztendlich hingesetzt und selber etwas zusammengestrickt.

Es hört auf den Namen “simples”, bietet Routing, MVC und ein bischen mehr, bietet aber z.B. keine Datenbank-Unterstützung an und kommt mit recht wenig Code aus. Da es bis jetzt noch keine Doku gibt, lohnt es sich auch mal im Code zu stöbern.

Feedback ist immer willkommen!

Ps. Das Ganze bitte noch als Beta betrachten. Für den produktiven Einsatz ist es bisher noch nicht gedacht.

He says that in his search for a lightweight php mvc framework, he didn’t find anything that satisfied his needs, and so he started to write his own. It is called “simples”, is still beta, has no comments, no documentation, no database support, but offers mvc, routing, “and some more”. It is not meant for production usage at the moment.

The first thing I noticed is that all of the configuration is done via constants. I don’t think a framework, which will be only one part of an application, should pollute global scope (even constants) too much, if at all. One improvement could be to add a prefix to the configuration (smacks_*), but I highly prefer a config class, which loads its content based on an environment (which itself could be set via ONE prefixed constant) via xml or php files. You can have different configurations for different purposes this way, and just have to switch the environment somewhere.

Another point considering ‘namespaces’ (in a general, not the php 5.3 namespaces way) is, that all “simples” framework classes also don’t have a prefix. You don’t want collisions there.

I also miss autoloading (do I always want to load anything? no.) and a response object.

All in all, the most important point is: Why should I want to use simples? I don’t see one point which is outstanding somehow… yet ;)

My very own LAMP development tool list for windows

Today i’d like to share my very own LAMP (Linux Apache Mysql PHP) development tool list for windows.

I don’t really care if it is Windows XP 32 or Vista 64, if the system supports all the hardware my workstation has (i.e. more than 4gb ram -> Vista 64).

Tier one tools (misc dev tools):

  • Mozilla Firefox – browser
    • Firebug – developer plugin: “Firebug integrates with Firefox to put a wealth of web development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.”
      • Firephp – Firebug extension: “FirePHP enables you to log to your Firebug Console using a simple PHP method call. All data is sent via response headers and will not interfere with the content on your page. FirePHP is ideally suited for AJAX development where clean JSON and XML responses are required.”
      • Yslow – Firebug extension “performance”: “YSlow analyzes web pages and why they’re slow based on Yahoo!’s rules for high performance web sites.”
    • Selenium IDE – developer plugin “test automation”: “Selenium IDE is an integrated development environment for Selenium tests. It is implemented as a Firefox extension, and allows you to record, edit, and debug tests. Selenium IDE includes the entire Selenium Core, allowing you to easily and quickly…”
    • Firegestures – usability plugin: “A customizable mouse gestures extension which enables you to execute various commands and user scripts with five types of gestures.”
  • Scite – lightweight, extremely fast text editor, including syntax highlighting, folding, tabbed interface
  • Zend Studio/Eclipse (main IDE) – full featured IDE
    • PDT – PHP Development Tools
    • Mylyn – task & planning tools, issue/bug tracker integration
    • Subversive – subversion plugin
  • PuTTY – ssh/telnet tool: “PuTTY is a free implementation of Telnet and SSH for Win32 and Unix platforms, along with an xterm terminal emulator.”
  • WinSCP – sftp/scp tool: “WinSCP is an open source free SFTP client and FTP client for Windows. Legacy SCP protocol is also supported. Its main function is safe copying of files between a local and a remote computer.”
  • Total Commander – file manager, ftp tool, two file windows
  • WinRAR – archiver for rar/zip/tar/gz/…
  • TrueCrypt – highly secure, portable data storage: “Free open-source disk encryption software for Windows Vista/XP, Mac OS X, and Linux”
  • TortoiseSVN – subversion client: “A Subversion client, implemented as a windows shell extension.”
  • VMware Workstation – virtual machines
    • LAMP vm
      • Xdebug – debug helpers: The Xdebug extension helps you debugging your script by providing a lot of valuable debug information.”
      • phpMyAdmin – web-based database administration: “phpMyAdmin is a free software tool written in PHP intended to handle the administration of MySQL over the World Wide Web. phpMyAdmin supports a wide range of operations with MySQL. The most frequently used operations are supported by the user interface (managing databases, tables, fields, relations, indexes, users, permissions, etc), while you still have the ability to directly execute any SQL statement.”

Tier two tools (specific dev tools):

Tier three tools (communication/support):

  • Microsoft Outlook (if Exchange is available) – emails, calendar
  • Mozilla Thunderbird – emails, calendar
  • UltraVNC – remote desktop, direct connection
  • TeamViewer – remote desktop through firewalls, easy and fast setup – very good for helping “not so experienced” users
  • Miranda IM – lightweight IM client (icq, aim, msn, jabber, …)
  • mIRC – “the” IRC client
  • Skype – voice chat

Tier four tools (music/media)

Windows Settings:

  • fixed taskbar with quicklaunch (icons have always the same order), visible time and no “hide unused icons” stuff