<?php
public function sanitizeString($str,$chars = array('/',"'",'"','(',')',';','>','<'),$allowedTags = '') {
$str = str_replace($chars,'',strip_tags($str,$allowedTags));
return preg_replace("/[^A-Za-z0-9_\-\.\/]/",'',$str);
}
$allowedTags only applies to the first line, then not anymore on the second line?
Don’t you think that it could be:
<?php
public function sanitizeString($str, $chars = array('/', "'", '"', '(', ')', ';', '>', '<'), $allowedTags = array()) {
$allowedTagStr = @implode('', $allowedTags);
$str = str_replace($chars, '', strip_tags($str, $allowedTagStr));
$allowedTagPreg = (!empty($allowedTags) ? '|\\' . @implode('\\', $allowedTags) : '');
return preg_replace("/[^A-Za-z0-9_\-\.\/" . $allowedTagPreg . "]/", '', $str);
}