$extLength) && (strtolower(substr($outName, $extIndex)) === ($ftype))) return substr($outName, 0, $extIndex).$ftype; } return false; } /** * get name of transfer. name cleaned and extension removed. * * @param $transfer * @return string */ function tfb_cleanTransferName($transfer) { global $cfg; return str_replace($cfg["file_types_array"], "", preg_replace("/[^0-9a-zA-Z.-]+/",'_', $transfer)); } /** * split on the "*" coming from Varchar URL * * @param $url * @return string */ function tfb_cleanURL($url) { $arURL = explode("*", $url); return ((is_array($arURL)) && (count($arURL)) > 1) ? $arURL[1] : $url; } /** * Avoid magic_quotes_gpc issues * courtesy of iliaa@php.net * @param ref &$var reference to a $_REQUEST variable * @return null */ function tfb_strip_quotes(&$var){ if (is_array($var)) { foreach ($var as $k => $v) { if (is_array($v)) array_walk($var[$k], 'tfb_strip_quotes'); else $var[$k] = stripslashes($v); } } else { $var = stripslashes($var); } } /** * HTML-encode a string. * * @param $str * @return string */ function tfb_htmlencode($str) { return htmlspecialchars($str, ENT_QUOTES); } /** * HTML-encode a string, transforming spaces into ' '. * Should be used on strings that might contain multiple spaces * (names, paths & filenames, ...), unless string will be output: * - in an HTML attribute, * - in a
element,
* since both of those do not ignore multiple spaces (in that
* case, tfb_htmlencode is enough).
*
* @param $str
* @return string
*/
function tfb_htmlencodekeepspaces($str) {
return str_replace(' ', ' ', htmlspecialchars($str, ENT_QUOTES));
}
/**
* Shell-escape a string. The argument must be one whole (and only one) arg
* (this function adds quotes around it so that the shell sees it as such).
*
* @param $str
* @return string
*/
function tfb_shellencode($str) {
$str = (string)$str;
return isset($str) && strlen($str) > 0 ? escapeshellarg($str) : "''";
}
?>