- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
This must have been the login page for the system used by Lehman Brothers to purchase real estate
Admin
Warning: $chumbawumba not equal $mambozambo in wongobongo::bingbing(boom, kaboom, woom)
Admin
When it came to me, the app was several years old and had been maintained/updated by quite a few developers who had come and gone. Originally it had been written for two hospitals, which shared an Informix database. Later it was expanded to include several additional hospitals, some of which used the Informix database and some of which used Oracle; and so the data access section had been cobbled together to perform separate queries and then massage these into a single display. This had been done quite hurriedly, to judge from the quality of the code, which was a sickening spaghetti mess of string manipulation to create SQL queries in-line based on a huge amount of criteria which may or may not have been specified by the user.
My first assignment was to update the application to add another hospital; one which used a SQL Server database.
Given the timeline, I had no choice but to go in and copy the style used by my mad scientist predecessors, patching and stitching and hacking until the thing on the slab twitched and shuddered and opened its jaundiced eye. I did so, but I explained to my manager the condition of the application and advised him that it was in dire need of a complete redesign and rewrite from the ground up. He was sympathetic and even went as far as authorizing the project; but it had no champion and was shelved as soon as something more important came up.
Fast-forward a year: the Informix database is being dropped and its data moved to the Oracle database. This means that all but one of the hospitals will now be using Oracle, with SQL Server the odd one out. At this time the application owners presented us with a request for some fairly extensive revisions to the data being displayed and to the UI. The project was fired up again, this time with a little muscle behind it, and I got the go-ahead to focus on abstracting the data access layer.
What does all this have to do with the quotes above? My point is that abstracting the data access will prevent the necessity of hacking and patching the application in the future event of more database changes. Suppose they merge the SQL Server data into Oracle? Suppose they add a hospital that uses MySql? It should only be necessary to rework the data access layer. The application should never even know which database is being accessed. It sends a request based on specified criteria, and it gets the results back and displays them. It's the ol' "black box" approach.
And that's why abstraction is a good thing.
Admin
In other words, basic computer programming knowledge should answer that question for you. It's the same reason we make functions to contain /any/ oft-repeated chunk of code.
Admin
I imagine you snipped out the comment which immediately preceeded this code:
// Replace the following with a proper user authentication mechanism once we've finished testing the application.
No? Oh dear.
Admin
Admin
It is easier to remeber once you realize that the one item in the db is in fact 'chumbawumba'
Admin
Admin
Rick Astley would never knock you down, so you wouldn't need to get back up again.
Admin
I just wanted to point out the while loop- only the last record in the user database is ever checked. So no need to worry about concurrent logins by different users!
Admin
Admin
It DOES rule out SQL injection vulnerabilities, though. :)
Admin
this was also my first thought... this looks like the kind of code you'd get from having someone work on a complicated logon solution for a few weeks, then drastically scaling back the requirements to such a degree it's easier to just chop out 90% of the code and leave what you see here.
it says he's using a sesion variable, so more than likely there's an unshown, overcomplicated session management system to match the oversimplified login system. actually, that type of out-of-band session passing back to index IS how you do single sign on (you can't set a $_SESSION var on the login server and have Apache give it to your app on another server without passing it somehow through the request from the browser. personally, i'd make custom headers instead of passing through $_GET, but whatever's clever.
Admin
"Dear Codey, I know you were expecting my book shop, or perhaps your uncle's little place in Marlow, but what with this internet thing absolutely killing the book trade, and the credit crunch putting a bit of a damper on the property market, we had to trade those in for a video on vegetarian cookery.
I hope you'll be pleased with the contents of the casket (enclosed) as a token of our love. Your uncle rummaged around in the tool box to try to find the wall wart, but we seem to have misplaced it somehow. Never mind. Lightning seems to work just as well, and it's so much more environmentally friendly, don't you think? The villagers offered to chip in with some firewood, which I think was simply sweet of them.
Your Auntie Wooly and Uncle Bish"
Mind you, I do think that "Look on my works, Ye mighty, and despair" sums up the code in the OP quite well.
Admin
Admin
simple you say? i'd argue that understanding the rightness "1+1=1" is beyond the ability of most humans, much less modern computers. ;)
also, if you "don't have to be right", and only care about simplicity, "1 + 1 = 1" can be represented in your program as a single symbol and it doesn't have to worry about symbolic meaning at all. if you have "1", "+", and "=" in your bag, though, and think you have a meaningful program, you're probably not talking about the mathematical/symbolic meaning either.
Admin
Admin
Brilliant. New meaning to the word simple! LOL
Jiff www.anonymize.us.tc
Admin
Admin
Very simple indeed... the password is actually the username.
Admin
And here I was thinking it was because Chumbawumba were a one(password)hit wonder.
Admin
Ive actually written something like this. For debugging purposes. With a big FAT waning in the config file to NOT turn it on unless you are beyond doubt sure its your testing server and you know what you are doing. With this bit, I refuse to believe this snippet was not wrapped in if(AUTH_DEBUG){<your simple bitA>}
Admin
$chumbawumba?
"I get kicked out, but I login again, they're never gonna keep me out..."
Reminds me of a guy we had who used to name all his variables after fish: $pilchard = $turbot + $halibut
Admin
so he checked the password against the user name? that IS 'simple'.
Admin
The real problem is that a lot of the crap that you see where people tried to write their own database abstraction functions is that they obviously didn't plan very well and it shows.
That being said, I usually use ADODB for all my PHP projects. Why reinvent parameterized queries or force my clients to use mysqli? Why waste time writing my own database abstraction layer when their is a proven one out there already?
To the original poster of this "real WTF": $object->query($sql); is 10:1 a call to the ADODB query method, not something home-grown.
Admin
Evil IT Resources page http://resursi.wordpress.com (IT management in Eastern Europe, HR, politics and other things)
Admin
To be honest, Bank of America's website is at least moderately well done.
And it works fine with Opera.
Admin
That code not only features Security Through Obscurity, it also has a great password policy. Assuming a new user gets added at least every 90 days!
Admin
I can do better than that... No user, no passwords, no content... Hell, I can do it without web page...
Setting a new standard for "simple" XD
Admin
Care to play a game of Hive? I'm absurdly good at that.
Admin
At least it is immune to an SQL injection attack.