Added ord_match (), removed bad_chars_file (), modified bad_chars () to be much less picky

This commit is contained in:
zone 2001-06-25 01:25:47 +00:00
parent 05dcabb900
commit 16a71e4ea4

View File

@ -87,22 +87,29 @@ function borkb ($size, $enclosed = NULL, $return = 0)
function bad_chars ($string, $return = 0) function bad_chars ($string, $return = 0)
{ {
if (preg_match("-([\\\|/|\||\?|\`|\@|\#|\$|%|\&|\*|\(|\)|\[|\{|\]|\}|\;|\:|\"|\'|\<|\>|\,|\ ])-", $string, $badchars)) if (preg_match("-([\\\|/|<|>|\"])-", $string, $badchars))
$rstring = $badchars[1]; $rstring = $badchars[1];
return trim ((eor ($rstring, $return))); return trim ((eor ($rstring, $return)));
} }
### ###
# Check for and return the first character that can't be used in a file or directory name # Match character in string using ord ().
### ###
function bad_chars_file ($string, $return = 0) function ord_match ($string, $charnum)
{ {
if (preg_match ("-([\\\|\/|\&|\(|\)])-", $string, $badchars)) for ($i = 0; $i < strlen ($string); $i++)
$rstring = $badchars[1]; {
$character = ord (substr ($string, $i, 1));
return trim ((eor ($rstring, $return))); if ($character == $charnum)
{
return True;
}
}
return False;
} }
### ###