src/sanitize.php
/**
 * This function makes sure the value given is safe to use (free of code injections, etc.)
 *
 * @param $val string the value to check for safety
 * @return string the safe value to use, or false if it failed to make the value safe
 */
This function makes sure the value given is safe to use (free of code injections, etc.)
@param $val string the value to check for safety
@return string the safe value to use, or false if it failed to make the value safe
This function makes sure the value given is safe to use ( free of code injections etc . ) @param $val string the value to check for safety @return string the safe value to use or false if it failed to make the value safe
function sanitize($val)
{
    if (!preg_match_all("/^([\w]*[.()-\/,\s+]*[\x{0080}-\x{00FF}]*[\x{0040}]*)+$/", $val) && $val !== "") {
        return false;
    }
    $val = trim($val);
    $val = strip_tags($val);
    $pat = array("\r\n", "\n\r", "\n", "\r"); 
    $val = str_replace($pat, '', $val);
    $pat = array('/^\s+/', '/\s{2,}/', '/\s+\$/'); 
    $rep = array('', ' ', '');
    $val = preg_replace($pat, $rep, $val);
    return trim($val);
}
function sanitize ( $ val ) { if ( ! preg_match_all ( " /^([\w]*[.()-\/,\s+]*[\x{0080}-\x{00FF}]*[\x{0040}]*)+$/ " , $ val ) && $ val !== " " ) { return false ; } $ val = trim ( $ val ) ; $ val = strip_tags ( $ val ) ; $ pat = array ( " \r \n " , " \n \r " , " \n " , " \r " ) ; $ val = str_replace ( $ pat , '' , $ val ) ; $ pat = array ( '/^\s+/' , '/\s{2,}/' , '/\s+\$/' ) ; $ rep = array ( '' , ' ' , '' ) ; $ val = preg_replace ( $ pat , $ rep , $ val ) ; return trim ( $ val ) ; }
This function makes sure the value given is safe to use (free of code injections, etc.)
This function makes sure the value given is safe to use ( free of code injections etc . )
// remove returns // remove multiple whitespaces