Article 6GYFX CodeSOD: Evaluating Perks

CodeSOD: Evaluating Perks

by
Remy Porter
from The Daily WTF on (#6GYFX)

Today's anonymous submitter works for a company that handles customer rewards perks. It's handling thousands of dollars of transactions a day, which isn't a huge amount, but it's certainly non-trivial.

Now, there's a conversion formula from points to dollars: points/100*1.7. Now how would someone implement this complex formula in PHP? Well, our submitter's predecessor did it this way:

$divfactor = 100;$multfactor = 1.7;$vcvalue = $points;$divoperation = "/";$multoperation = "*";$valcalc = eval('return '.$vcvalue.$divoperation.$divfactor.$multoperation.$multfactor.';');

Was this an attempt at obfuscation? Because it didn't work. I understand exactly what the code is doing. But I'm also left wondering... why. What did they hope to gain?

It's forever a mystery.

otter-icon.png [Advertisement] Continuously monitor your servers for configuration changes, and report when there's configuration drift. Get started with Otter today!
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments