- 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
Frist of all, some pendantry : you can do it, but you have to put the if()s in the right order (i.e. check for showitems before you check for showitem, and so on).
Of course, that's a horrible maintenance load, because every new "page" has to be checked against every existing page to make sure that every if() chain is constructed correctly.
Admin
TRWTF is not splitting once and doing a switch, in which case this isn't really that bad. Fortunately you don't need to worry about scaling . . .
Admin
I particularly like how it just creates a form that does nothing if the URL isn't one that it handles.
Admin
All the routes in that application lead to the same place: they're a highway to (maintenance) hell.
Admin
TCDR (Too confusing, didn't read.)
Admin
Oh no, this is already a nightmare
Admin
I don't see a collission with longer strings. It's doing an equality check with the rest of the URL, not a string search.
However, it means you can't have any additional parameters after
=XXX
because they'll be included inREQUEST_URI
.Admin
It's doing a substrnof a specific length (e.g., 0-6 for upload), at least for all but the first two items, so that would return the same thing for upload and upload_image
Admin
TRWTF is not using Regex with an XML config file to define the routes.
Admin
I cleaned it up a bit for you guys:
I have to apologize for the names of the variables; I really couldn't came up with anything better haha
Addendum 2024-02-21 14:50: I just noticed: For both "routes" adduser and edituser the form name is adduser. Looks like someone failed with their copy&pasting&rewriting.
Admin
You know what, if we already go the super wacko route of routingness, why not embrace it with a glorious switch:
Yeah, there's no way to make this thing even look pretty; guess the only proper way to do this is to either go .htaccess or use Klein or something similar.
Admin
We all read about the inner platform antipattern. We all talk about how bad it is.
And we all are still shocked when we encounter it in the wild.
Admin
Why substr in all but first two instances has the third argument?
Admin
Every time I see code like this, I start thinking about the Pixar film Ratatouille, and Chef Gusteau‘s assertion that “Anyone can cook”…
Just like in the film, it’s also true that (with PHP, at least), “Anyone can code” - but sometimes, what gets created looks more like the developer was bashing on the keyboard while a rat was pulling his hair.
I call this sort of code “Ratatouille Code” - I’m waiting on the sequel to the films before coming up with a new definition of “Spaghetti Code”