Archive for the ‘Programming Techniques’ Category

MySQL comparison catch: ‘abc’ = 00

Monday, May 25th, 2009

I was shocked to find a weakness in my authentication library today. It was possible to get around the password check if you knew the username. All you had to do was to enter 00 as the password. Or you just entered 00 as the username too and you got authenticated as the first user.
(more…)

Dealing with different configuration for development and production box

Friday, December 12th, 2008

All right, this isn’t exactly a rocket science, it’s just something I use and find very handy.

We all develop (and test) on one computer and deploy to a different computer to make the changes live. Having to run the application in two different environments brings a challenge of using different configuration based on where the application runs.
(more…)

Calculating time difference in months as a decimal number

Wednesday, October 8th, 2008

There’s a number of functions out there for calculating the length of time in months but they only provide integer results. MySQL can do it too, for instance. But what if you need to get a precise number?

2008-11-15 minus 2008-10-01 can’t be one if you’re calculating rent. It must be 1.466…

(more…)

How to concatenate two object attributes and assign the result to a variable

Tuesday, March 4th, 2008

All right, this is really no rocket science it’s just something I needed and took me some time to figure out.

  1. {assign var="fullName" value="`$human->first` `$human->last`"}

or more robust version:

  1. {capture assign="fullName"}
  2. {$human->first} {$human->last}
  3. {/capture}

Date formatting in Smarty

Wednesday, September 26th, 2007

If you use the so called, German date format (day of month. month. year) you may have wondered how to achieve it with Smarty - without the leading zeroes for month.
(more…)