document.write('<div class="php" style="font-family: monospace;"><br />');
document.write('<br />');
document.write('<span style="color: #000000; font-weight: bold;">&lt;?php</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> anti_injection<span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$user</span>, <span style="color: #0000ff;">$pass</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># We\'ll first get rid of any special characters using a simple regex statement.</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># After that, we\'ll get rid of any SQL command words using a string replacment.</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$banlist</span> = <a target="_blank"&nbsp; href="http://www.php.net/array"><span style="color: #000066;">array</span></a> <span style="color: #66cc66;">&#40;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;insert&quot;</span>, <span style="color: #ff0000;">&quot;select&quot;</span>, <span style="color: #ff0000;">&quot;update&quot;</span>, <span style="color: #ff0000;">&quot;delete&quot;</span>, <span style="color: #ff0000;">&quot;distinct&quot;</span>, <span style="color: #ff0000;">&quot;having&quot;</span>, <span style="color: #ff0000;">&quot;truncate&quot;</span>, <span style="color: #ff0000;">&quot;replace&quot;</span>,<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;handler&quot;</span>, <span style="color: #ff0000;">&quot;like&quot;</span>, <span style="color: #ff0000;">&quot; as &quot;</span>, <span style="color: #ff0000;">&quot;or &quot;</span>, <span style="color: #ff0000;">&quot;procedure&quot;</span>, <span style="color: #ff0000;">&quot;limit&quot;</span>, <span style="color: #ff0000;">&quot;order by&quot;</span>, <span style="color: #ff0000;">&quot;group by&quot;</span>, <span style="color: #ff0000;">&quot;asc&quot;</span>, <span style="color: #ff0000;">&quot;desc&quot;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// ---------------------------------------------</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <a target="_blank"&nbsp; href="http://www.php.net/eregi"><span style="color: #000066;">eregi</span></a> <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;[a-zA-Z0-9]+&quot;</span>, <span style="color: #0000ff;">$user</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$user</span> = <a target="_blank"&nbsp; href="http://www.php.net/trim"><span style="color: #000066;">trim</span></a> <span style="color: #66cc66;">&#40;</span> <a target="_blank"&nbsp; href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a> <span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$banlist</span>, <span style="color: #ff0000;">\'\'</span>, <a target="_blank"&nbsp; href="http://www.php.net/strtolower"><span style="color: #000066;">strtolower</span></a> <span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$user</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$user</span> = <span style="color: #000000; font-weight: bold;">NULL</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// ---------------------------------------------</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Now to make sure the given password is an alphanumerical string</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># devoid of any special characters. strtolower() is being used</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># because unfortunately, str_ireplace() only works with PHP5.</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <a target="_blank"&nbsp; href="http://www.php.net/eregi"><span style="color: #000066;">eregi</span></a> <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;[a-zA-Z0-9]+&quot;</span>, <span style="color: #0000ff;">$pass</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$pass</span> = <a target="_blank"&nbsp; href="http://www.php.net/trim"><span style="color: #000066;">trim</span></a> <span style="color: #66cc66;">&#40;</span> <a target="_blank"&nbsp; href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a> <span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$banlist</span>, <span style="color: #ff0000;">\'\'</span>, <a target="_blank"&nbsp; href="http://www.php.net/strtolower"><span style="color: #000066;">strtolower</span></a> <span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$pass</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$pass</span> = <span style="color: #000000; font-weight: bold;">NULL</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// ---------------------------------------------</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Now to make an array so we can dump these variables into the SQL query.</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># If either user or pass is NULL (because of inclusion of illegal characters),</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># the whole script will stop dead in its tracks.</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$array</span> = <a target="_blank"&nbsp; href="http://www.php.net/array"><span style="color: #000066;">array</span></a> <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">\'user\'</span> =&gt; <span style="color: #0000ff;">$user</span>, <span style="color: #ff0000;">\'pass\'</span> =&gt; <span style="color: #0000ff;">$pass</span> <span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// ---------------------------------------------</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <a target="_blank"&nbsp; href="http://www.php.net/in_array"><span style="color: #000066;">in_array</span></a> <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">NULL</span>, <span style="color: #0000ff;">$array</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a target="_blank"&nbsp; href="http://www.php.net/die"><span style="color: #000066;">die</span></a> <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">\'Invalid use of login and/or password. Please use a normal method.\'</span> <span style="color: #66cc66;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$array</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />');
document.write('<span style="color: #000000; font-weight: bold;">?&gt;</span><br />');
document.write('<br />');
document.write('&nbsp;</div>');
document.write('<br />&nbsp;<br /><div style="font-size: 12px">Brought to you by the community at <a href="http://www.bytemycode.com/snippets/snippet/462/1/" target="_blank">byteMyCode</a>.</div>');
