本文整理汇总了PHP中Vtiger_Functions::slug方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Functions::slug方法的具体用法?PHP Vtiger_Functions::slug怎么用?PHP Vtiger_Functions::slug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vtiger_Functions
的用法示例。
在下文中一共展示了Vtiger_Functions::slug方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sanitizeUploadFileName
/** Function to sanitize the upload file name when the file name is detected to have bad extensions
* @param String -- $fileName - File name to be sanitized
* @return String - Sanitized file name
*/
function sanitizeUploadFileName($fileName, $badFileExtensions)
{
$fileName = Vtiger_Functions::slug($fileName);
$fileName = rtrim($fileName, '\\/<>?*:"<>|');
$fileNameParts = explode(".", $fileName);
$countOfFileNameParts = count($fileNameParts);
$badExtensionFound = false;
for ($i = 0; $i < $countOfFileNameParts; ++$i) {
$partOfFileName = $fileNameParts[$i];
if (in_array(strtolower($partOfFileName), $badFileExtensions)) {
$badExtensionFound = true;
$fileNameParts[$i] = $partOfFileName . 'file';
}
}
$newFileName = implode(".", $fileNameParts);
if ($badExtensionFound) {
$newFileName .= ".txt";
}
return $newFileName;
}