Holy SQL Batman!
Submitted by phrax on Mon, 2004-11-01 15:16.
Bad Architecture
Thanks to Alex @ The Daily WTF for forwarding this to me. This little chunk of code comes from a home made discussion forum. Too bad I didn't get this before Halloween because it's high on the scary factor.
There's nothing like doing 35 string operations in a SQL query to make sure your database server isn't slacking off.
<?php
function Odcesti($slovo,$nazevsloupce)
{
$exp = explode(" ", strtolower($slovo));
$query = implode("%", $exp);
$query=StrTr($query,
"\xC1\xC8\xCF\xC9\xCC\xCD\xBC\xD2\xD3\xD4\xD8\x8A".
"\x8D\xDA\xD9\xDD\x8E\xE1\xE8\xEF\xE9\xEC\xED".
"\xBE\xF2\xF4\xF3\xF8\x9A\x9D\xFA\xF9\xFD\x9E",
"acdeeilnoorstuuyzacdeeilnoorstuuyz");
return " LOWER(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE($nazevsloupce,
'\xC1','a'),'\xC8','c'),'\xCF','d'),'\xC9','e'),'\xCC','e'),
'\xCD','i'),'\xBC','l'),'\xD2','n'),'\xD3','o'),'\xD4','o'),
'\xD8','r'),'\x8A','s'),'\x8D','t'),'\xDA','u'),'\xD9','u'),
'\xDD','y'),'\x8E','z'),'\xE1','a'),'\xE8','c'),'\xEF','d'),
'\xE9','e'),'\xEC','e'),'\xED','i'),'\xBE','l'),'\xF2','n'),
'\xF4','o'),'\xF3','o'),'\xF8','r'),'\x9A','s'),'\x9D','t'),
'\xFA','u'),'\xF9','u'),'\xFD','y'),'\x9E','z')) like '%$query%'";
}
?>