當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PerchUtil::tidy_file_name方法代碼示例

本文整理匯總了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);
 }
開發者ID:Bloom-web,項目名稱:bloom-web,代碼行數:26,代碼來源:PerchResourceBucket.class.php

示例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;
開發者ID:pete-naish,項目名稱:4hair,代碼行數:31,代碼來源:image.edit.pre.php


注:本文中的PerchUtil::tidy_file_name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。