本文整理汇总了PHP中PerchUtil::tidy_file_name方法的典型用法代码示例。如果您正苦于以下问题:PHP PerchUtil::tidy_file_name方法的具体用法?PHP PerchUtil::tidy_file_name怎么用?PHP PerchUtil::tidy_file_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerchUtil
的用法示例。
在下文中一共展示了PerchUtil::tidy_file_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write_file
public function write_file($file, $name)
{
$filename = PerchUtil::tidy_file_name($name);
if (strpos($filename, '.php') !== false) {
$filename .= '.txt';
}
// diffuse PHP files
if (strpos($filename, '.phtml') !== false) {
$filename .= '.txt';
}
// diffuse PHP files
$target = PerchUtil::file_path($this->file_path . '/' . $filename);
if (file_exists($target)) {
$dot = strrpos($filename, '.');
$filename_a = substr($filename, 0, $dot);
$filename_b = substr($filename, $dot);
$count = 1;
while (file_exists(PerchUtil::file_path($this->file_path . '/' . PerchUtil::tidy_file_name($filename_a . '-' . $count . $filename_b)))) {
$count++;
}
$filename = PerchUtil::tidy_file_name($filename_a . '-' . $count . $filename_b);
$target = PerchUtil::file_path($this->file_path . '/' . $filename);
}
PerchUtil::move_uploaded_file($file, $target);
return array('name' => $filename, 'path' => $target);
}
示例2: is_writable
$Image = $result;
} else {
$message = $HTML->failure_message('Sorry, that image could not be updated.');
}
}
if ($result) {
$image_folder_writable = is_writable(PERCH_RESFILEPATH);
$filesize = 0;
if (isset($_FILES['upload'])) {
$file = $_FILES['upload']['name'];
$filesize = $_FILES['upload']['size'];
}
// if file is greater than 0 process it into resources
if ($filesize > 0) {
if ($image_folder_writable && isset($file)) {
$filename = PerchUtil::tidy_file_name($file);
if (strpos($filename, '.php') !== false) {
$filename .= '.txt';
}
//checking for naughty uploading of php files.
$target = PERCH_RESFILEPATH . DIRECTORY_SEPARATOR . $filename;
if (file_exists($target)) {
$ext = strrpos($filename, '.');
$fileName_a = substr($filename, 0, $ext);
$fileName_b = substr($filename, $ext);
$count = 1;
while (file_exists(PERCH_RESFILEPATH . DIRECTORY_SEPARATOR . $fileName_a . '_' . $count . $fileName_b)) {
$count++;
}
$filename = $fileName_a . '_' . $count . $fileName_b;
$target = PERCH_RESFILEPATH . DIRECTORY_SEPARATOR . $filename;