public static function clean($path, $dirSep = DIRECTORY_SEPARATOR)
{
if (!is_string($path) || empty($path)) {
return '';
}
$path = trim((string) $path);
if (empty($path)) {
$path = Vars::get($_SERVER['DOCUMENT_ROOT'], '');
} elseif ($dirSep == '\\' && $path[0] == '\\' && $path[1] == '\\') {
$path = "\\" . preg_replace('#[/\\\\]+#', $dirSep, $path);
} else {
$path = preg_replace('#[/\\\\]+#', $dirSep, $path);
}
return $path;
}