This example makes it into the WTF Hall of Fame because it violates so many good design principles. Take a look at magdit.inc to get you started...
includes/magdit.incCan you spot the multiple WTF's in magdit.php? The most blatent ones are the use of eval()
(why?!), and at the end of the file where $magdit
is either "ja" (yes) or "nee" (no). I bet you're wondering what's the point of this code if it just ends?! There's also another WTF in there that's a doozy. Can you spot it? Read on, it gets worse...
In left_frame.php we see why magdit.inc ended so abruptly! It is used to reuse PHP logic! I particularly like how $magdit
is the hardest working variable in PHP. It's an integer then a string, then an integer again, etc.
Another thing that needs to be pointed out is the use of literals in the code. What does 6,7,12,13,14,15,29 really mean? Integer literals in code are the only thing more confusing than building a PHP application with billions of includes. This WTF makes me dizzy. Thanks again to Michael for sending it in, and we all pity you.
]]>I had to confirm that this was production code. It's always more funny, or tragic, when production code is bad. Thanks to Søren for sending this in.
What's the most efficient way to skip a few numbers? Well it's not this way! It's bad enough that 2, 3 and 4 are literals and not constants, but they also represent database logic. At least they didn't select *
and skip records with the wrong TypeId's.
On a more WTF note, I wonder what's inside header.inc.php. Especially since it is included into the code like nine times! Anybody know the difference between using include()
versus require()
?
Thanks to Stefan for sending this in.
]]>He tells me in Germany beer is nearly cheaper than water. In fact, I hear about the cheap beer a lot! I'm starting to suspect that the cheap beer and the number of German PHP WTFs I'm getting is not a coincidence.
This is today's WTF. There are a few newbie things but the WTF is where the array from mysql_fetch_row()
is separated into variables only to be immediately jammed into another array.
Thanks to elias for sending this in.
]]>I pray to the PHP gods! Please let me select a single field from a table! Please give me the modulus operator! I beg of thee!
Thanks to Wonko for sending this in.
"; if ($i==25 || $i==50 || $i==75 || $i==100 || $i==125 || $i==150 || $i==175 || $i==200 || $i==225 || $i==250 || $i==275 || $i==300|| $i==325 || $i==350 || $i==375 || $i==400 || $i==425 || $i==450 || $i==475 || $i==500 || $i==525 || $i==550 || $i==575 || $i==600 || $i==625) { $opp .= "On another note. The site will be moving to Drupal. I've migrated over all the posts and the comments and putting together the PHPWTF theme for it. It should be done by next week. The change will bring some notable improvements.
If you have any suggestions feel free to submit to them to [email protected], or you can just use the Submit WTF form. It all goes to the same place.
]]>Comments are submitter's:
]]>switch
is bad enough but using all those echo
makes me so angry. I pity all pour souls that have to work with code like this.
";
echo " <tr>";
echo " <td>";
echo " <form method=\"post\" type=\"text/css\" action=\"http://www.example.com/index.php?section=Replays\">";
echo " <select name=\"bewertung\" size=\"1\">";
for ($bew = 1 ; $bew <= 10 ; $bew++)
{
echo "<option>".$bew."</option>";
}
echo " </td>";
echo " <td>";
echo " <input type=\"submit\" value=\"Vote\" name=\"vote\">";
echo " </form>";
echo " </td>";
echo " </tr>";
echo "</table>";
?>]]>Personal Note: I had to work on some nasty code that put me in a foul mood today. However this cheered me up. I just have to keep repeating, "it can always get worse. It can always get worse!".
]]>list($as,$nl)=explode("0","array_slice0<br>\n");
I guess actually declaring the variables $as and $nl took too many lines of code.$am=str_replace('slic','merg',$as);
*no comment* while (($d=@fgetcsv($h,1000,";"))!==!true) {
I guess s/he doesn't know about false
if (($l1=@fopen($ll,chr(0162))) === (bool) 0) return $Il;
to be l33t you gotta use 0162 rather than 'r'. Not sure what to say about casting 0 to a boolean false other than it is pointless.if ($I1[(int)0==4]===$lI||(int)4==0) {
This is the worst use of casting I've ever seen. Especially since (int)0==4
and (int)4==0
will always be 0. Maybe it's more l33tness.Also thanks to everybody who submitted a WTF. Keep them coming! :)
1 ) { $usermenu = new Template( $_CONF['path_layout'] ); $usermenu->set_file( array( 'option' => 'useroption.thtml', 'current' => 'useroption_off.thtml' )); $usermenu->set_var( 'site_url', $_CONF['site_url'] ); $usermenu->set_var( 'layout_url', $_CONF['layout_url'] ); $usermenu->set_var( 'block_name', str_replace( '_', '-', 'user_block' )); if( empty( $title )) { $title = DB_getItem( $_TABLES['blocks'], 'title', "name='user_block'" ); } //.... ?>]]>There's nothing like doing 35 string operations in a SQL query to make sure your database server isn't slacking off.
]]>Short and not so sweet. Thanks to Piotr Budny for sending this in. Somebody complained that his web sites wasn't working so Piotr dug into it and found today's WTF! Yikes!
]]>This code checks the status of a bunch of Diablo II game servers and generates a pretty table that shows a server's status. Unfortunately the code runs really, really slow. Damn the Internet!
<style type="text/css"> <!-- ... --> </style> <p align="center" class="style1">Overall PKA Server Status</p> <table width="100%" border="0" align="center" cellspacing="0"> <tr bordercolor="#990000" bgcolor="#990000"> <td><strong>Diablo II Realms </strong></td> <td bgcolor="#FF0000"><span class="style5">Status</span></td> <td bgcolor="#660000"><strong>Diablo II Game Servers 1 </strong></td> <td bgcolor="#660000"> </td> <td bgcolor="#660000"><span class="style6">Diablo II Game Servers 2 </span></td> <td bgcolor="#660000"> </td> </tr> <tr> <td width="172">Diablo II Open Server is :</td> <td width="121"><?php if ($fp = @fsockopen("bnet.pkaclan.com","6112")) { echo "<img src=images/open.gif>"; } else { echo "<img src=images/closed.gif>"; } ?></td> ... </tr> <tr> <td>PKA Realm is :</td> <td><?php if ($fp = @fsockopen("bnet.pkaclan.com","6113")) { echo "<img src=images/open.gif>"; } else { echo "<img src=images/closed.gif>"; } ?></td> <td>D2GS PKA1.1(Soulzek):</td> <td><?php if ($fp = @fsockopen("68.56.114.98","4000")) { echo "<img src=images/open.gif>"; } else { echo "<img src=images/closed.gif>"; } ?></td> <td> </td> <td> </td> </tr> <tr> <td>PvP Realm is :</td> <td><?php if ($fp = @fsockopen("bnet.pkaclan.com","7113")) { echo "<img src=images/open.gif>"; } else { echo "<img src=images/closed.gif>"; } ?></td> <td>D2GS PvP1.09(<SPAN class=postbody>Shiznoo</SPAN>):</td> <td><?php if ($fp = @fsockopen("141.158.150.28","4000")) { echo "<img src=images/open.gif>"; } else { echo "<img src=images/closed.gif>"; } ?></td> <td> </td> <td> </td> </tr> <tr> <td>Ancestrall Recall Realm is :</td> <td><?php if ($fp = @fsockopen("bnet.pkaclan.com","8113")) { echo "<img src=images/open.gif>"; } else { echo "<img src=images/closed.gif>"; } ?></td> <td>D2GS AR1.10(Wallbot):</td> <td><?php if ($fp = @fsockopen("wow.pkaclan.com","4000")) { echo "<img src=images/open.gif>"; } else { echo "<img src=images/closed.gif>"; } ?></td> <td> </td> <td> </td> </tr> <tr> <td>Hell Unleashed Realm is : </td> <td><?php if ($fp = @fsockopen("bnet.pkaclan.com","9113")) { echo "<img src=images/open.gif>"; } else { echo "<img src=images/closed.gif>"; } ?></td> <td>D2GS HU1.10 (Gnecromancer): </td> <td><?php if ($fp = @fsockopen("24.71.57.148","4000")) { echo "<img src=images/open.gif>"; } else { echo "<img src=images/closed.gif>"; } ?></td> <td>D2GS HU1.10 (D2Classic): </td> <td><?php if ($fp = @fsockopen("69.133.108.231","4000")) { echo "<img src=images/open.gif>"; } else { echo "<img src=images/closed.gif>"; } ?></td> </tr> <tr bgcolor="#990000"> ... more of the same ...]]>