DarkLord
21st February 2009, 11:45 AM
When I was approached by a colleague for an estimate on some PHP work, I insisted that i'll need to see some of the code first. The only background I had on the project was that it was a PHP site with a MySQL backend, and a pretty sizable user base.
When I received the code, the first thing that I noticed was an unreasonably large file called namelib.php. It was apparently intended to clean up users' first names...
<?
$name = $_GET['name'];
switch($name)
{
case "aafke":
echo "Aafke";
break;
case "aaron":
echo "Aaron";
break;
case "abbie":
echo "Abbie";
break;
case "abby":
echo "Abby";
break;
case "abdel":
echo "Abdel";
break;
case "abe":
echo "Abe";
break;
case "abeltje":
echo "Abeltje";
break;
/* Snip */
case "zora":
echo "Zora";
break;
case "zorah":
echo "Zorah";
break;
case "zuzana":
echo "Zuzana";
break;
case "zuzanna":
echo "Zuzanna";
break;
case "zuzanny":
echo "Zuzanny";
break;
default:
echo $name;
// Name not in the database yet, lowercase is better than nothing
}
?>
I couldn't help but LMAO and replaced thousands of lines of generated code with one easy line:
echo ucfirst($_GET['name']);
When I received the code, the first thing that I noticed was an unreasonably large file called namelib.php. It was apparently intended to clean up users' first names...
<?
$name = $_GET['name'];
switch($name)
{
case "aafke":
echo "Aafke";
break;
case "aaron":
echo "Aaron";
break;
case "abbie":
echo "Abbie";
break;
case "abby":
echo "Abby";
break;
case "abdel":
echo "Abdel";
break;
case "abe":
echo "Abe";
break;
case "abeltje":
echo "Abeltje";
break;
/* Snip */
case "zora":
echo "Zora";
break;
case "zorah":
echo "Zorah";
break;
case "zuzana":
echo "Zuzana";
break;
case "zuzanna":
echo "Zuzanna";
break;
case "zuzanny":
echo "Zuzanny";
break;
default:
echo $name;
// Name not in the database yet, lowercase is better than nothing
}
?>
I couldn't help but LMAO and replaced thousands of lines of generated code with one easy line:
echo ucfirst($_GET['name']);