Jump to content

User filtering


bamfon

Recommended Posts

Well I am now getting around to updating  some of the CMS that I have done, and I wanted to know whats the thoughts on the user filtering below.

Is there anything I could do to make it better or would it do its job fine as it is and no need to update?

<?php
//cleaning the user inputing anit Sql attack
function nice_escape($unescapedString)
{
    if (get_magic_quotes_gpc())
    {
        $unescapedString = stripslashes($unescapedString);
    }
	$unescapedString=strip_tags($unescapedString);
    $semiEscapedString = mysqli_real_escape_string($unescapedString);
    $escapedString = addcslashes($semiEscapedString, "%_");
	

    return $escapedString;
} 
function nice_output($escapedString)
{
    $patterns = array();
    $patterns[0] = '/\\\%/';
    $patterns[1] = '/\\\_/';
    $replacements = array();
    $replacements[0] = '%';
    $replacements[1] = '_';
    $output = preg_replace($patterns, $replacements, $escapedString);
    
    return $output;
} 


function cleanup($string)
{
$out = nice_output(nice_escape($string));
return $out;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/279687-user-filtering/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.