Tired of seeing every flyff private server with such low security.
Step 1. Make a file called functions.php
Put this code inside it.
Then, put this at the beginning of every stand-alone php file on your site(ones that aren't linked to index.php).PHP Code:function mssql_escape($str){
$str = htmlentities($str);
if (ctype_alnum($str))
return $str;
else
return str_ireplace(array(';', '%', "'"), "", $str);
}
That's it. There are a lot of other methods of this, array_map, hex packing, individualized sanitizing functions, etc. I wrote that on the spot so feel free to correct anything.PHP Code:include 'functions.php';
foreach ($_GET as $key=>$getvar){ $_GET[$key] = mssql_escape($getvar); }
foreach ($_POST as $key=>$postvar){ $_POST[$key] = mssql_escape($postvar); }
If you want to let people use ' or any other special characters, you probably want to look into a function like this:
which ends up being a lot cleaner of a solution, but they both work fine for me. I'm not sure if it works in ODBC, which is what I use now, but feel free to use it on direct mssql connections.PHP Code:function mssql_escape($data) {
if(is_numeric($data))
return $data;
$unpacked = unpack('H*hex', $data);
return '0x' . $unpacked['hex'];
}
Enjoy.





