Archive for 2010

Published by Niels on 08 Apr 2010

Computable door de bocht

Ik heb me net heerlijk zitten ergeren aan een artikel op de Computable website. De stelling is dat het introduceren (het gebruik wordt niet eens genoemd), van Linux in een bedrijfsomgeving verborgen kosten met zich mee brengt. Dat zou helemaal waar kunnen zijn, maar de auteurs Johan Zwiekhorst en Jozef Schildermans van Data TestLab slaan volgens mij op een aantal punten behoorlijk door. De argumenten op een rijtje:

  • Bovendien is opensourcesoftware minder populair dan Windows, zodat vandalen het vooralsnog grotendeels met rust laten…Echt waar? Zouden de onderzoekers wel eens een gekeken hebben naar de echte getallen over Open Source? Apache, iemand? PHP? Java? Bovendien gaat het begrip Open Source veel verder dan alleen het operating system, dus het begint al door appels met peren te vergelijken.
  • Zoals je waarschijnlijk wel weet, bestaan er honderden Linux-distributies. De toon lijkt nu wel gezet. Feitelijk en tendentieus.
  • De basis van die bundel is de linux kernel: die is hetzelfde voor iedereen. Daarbovenop komt het GNU/Linux platform. Kennis van GNU/Linux ontbreekt blijkbaar bij de auteurs: de kernel is niet bij alle distributies hetzelfde. Ze zijn wel gebaseerd op dezelfde broncode, maar vaak aangepast door de maker van de distributie om zo goed mogelijk aan te sluiten bij de doelgroep van de distributie. De opmerking dat het GNU/Linux platform erbovenop komt is natuurlijk onzin. Het heet GNU/Linux omdat een Linux kernel wordt gecombineerd met de GNU applicaties om een operating system te maken. Richard Stallman zal het niet waarderen dat de GNU applicaties GNU/Linux worden genoemd.
  • Als je een Windows-gebaseerde server draait, dan moet je die clientlicenties betalen ongeacht het gebruikte desktopsysteem. Wat een raar argument. Als het een homogene Windows-omgeving is, moet er ook voor zowel de client als de server licenties betaald worden. Bij Linux ben je in ieder geval nog het bedrag voor het desktop operating system kwijt.
  • Zo blijkt het erg moeilijk om computers van A-merken te kopen zonder Windows erop. Dat is alleen Microsoft aan te rekenen. Dus feitelijk weer juist, maar het lijkt mij eerder een argument om zo snel mogelijk te stoppen met het gebruik van Microsoft producten, want daardoor wordt blijkbaar de prijs van apparatuur onnodig opgejaagd.

Afgezien van de hierboven beschreven argumenten, staat het artikel bovendien vol met taal- en/of typefouten. Ik ben benieuwd naar het vervolg op dit artikel op 12 april, maar gezien de argumentaties in dit artikel vrees ik het ergste.

Published by Niels on 02 Apr 2010

Error: Cannot modify header information…

If PHP ever gives you the following error (I just encountered it while developing with the Yii Framework):

Cannot modify header information - headers already sent by

Then you probably injected some whitespace somewhere in your output. The easiest way to avoid that is by not using the PHP closing tag ‘?>‘ at the end of PHP source files. Some people are against that but if I look into the sources for Yii and read the Zend Framework Programmer’s Reference Guide then it is obviously a well established method of avoiding the mentioned error.

Published by Niels on 23 Feb 2010

Forcing a Yii application to authenticate

I wanted my Yii based application to force users to authenticate. After studying the forums, the manuals and searching the web the solution came to me just as I was about to go to bed. It is dead simple: just make sure that the only action a default user can perform is actionLogin(). See the code below on how to accomplish this:

<?php
 
class SiteController extends Controller
{
    /**
     * @return array action filters
     */
    public function filters()
    {
        return array(
            'accessControl', // perform access control for CRUD operations
        );
    }
 
    /**
     * Specifies the access control rules.
     * This method is used by the 'accessControl' filter.
     * @return array access control rules
     */
    public function accessRules()
    {
        return array(
            array('allow',  // allow all users to perform 'login'
                'actions'=>array('login'),
                'users'=>array('*'),
            ),
            array('allow', // allow authenticated user to perform any action
                'users'=>array('@'),
            ),
            array('deny',  // deny all users
                'users'=>array('*'),
            ),
        );
    }
 
    // The rest of the SiteController implementation
 
}
 
?>

I am not sure if this is the best possible solution, but since it is simple and elegant I am inclined to think it is.

Published by Niels on 07 Feb 2010

Just blogging again

A lot has happened the last couple of years. This has kept me busy and did not leave me with much desire to keep this blog up to data. And just when you think I will blog tomorrow, tomorrow has gone. And when tomorrow has gone, two years are gone.

But while I was enjoying a presentation on Identi.ca at FOSDEM I all of a sudden had the idea that now would be a good time to start again. So I joined Identi.ca and added this entry to this site. Expect more in the very near future. Being on-line feels like fun again.