The Daily WTF
I remember in some intro-level compsci class learning that credit card numbers were checksummed, and writing basic functions to validate those checksums as an exercize. I was young and was still using my “starter” credit card with a whopping limit of $500, so that was all news to me.
Alex‘s company had a problem processing credit cards: they rejected a lot of credit cards as being invalid. The checksum code seemed to be working fine, so what could the problem be? Well, the problem became more obvious when someone’s card worked one day, and stopped working the very next day, and they just so happened to be the first and last day of the month.
protected function validateExpirationCcDate($i_year, $i_month) { return (((int)strftime(‘%y’) <= $i_year) && ((int)strftime (‘%m’) <= $i_month))? true : false; }
This function is horrible; because it uses strftime (instead of taking the comparison date and
To read the full article click on the 'post' link at the top.