当前位置: 首页>>代码示例>>PHP>>正文


PHP phpthumb_functions::GetAllFilesInSubfolders方法代码示例

本文整理汇总了PHP中phpthumb_functions::GetAllFilesInSubfolders方法的典型用法代码示例。如果您正苦于以下问题:PHP phpthumb_functions::GetAllFilesInSubfolders方法的具体用法?PHP phpthumb_functions::GetAllFilesInSubfolders怎么用?PHP phpthumb_functions::GetAllFilesInSubfolders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpthumb_functions的用法示例。


在下文中一共展示了phpthumb_functions::GetAllFilesInSubfolders方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetAllFilesInSubfolders

 function GetAllFilesInSubfolders($dirname)
 {
     $AllFiles = array();
     $dirname = rtrim(realpath($dirname), '/\\');
     if ($dirhandle = @opendir($dirname)) {
         while (($file = readdir($dirhandle)) !== false) {
             $fullfilename = $dirname . DIRECTORY_SEPARATOR . $file;
             if (is_file($fullfilename)) {
                 $AllFiles[] = $fullfilename;
             } elseif (is_dir($fullfilename)) {
                 switch ($file) {
                     case '.':
                     case '..':
                         break;
                     default:
                         $AllFiles[] = $fullfilename;
                         $subfiles = phpthumb_functions::GetAllFilesInSubfolders($fullfilename);
                         foreach ($subfiles as $filename) {
                             $AllFiles[] = $filename;
                         }
                         break;
                 }
             } else {
                 // ignore?
             }
         }
         closedir($dirhandle);
     }
     sort($AllFiles);
     return array_unique($AllFiles);
 }
开发者ID:mashbro,项目名称:Codefight-CMS,代码行数:31,代码来源:phpthumb.functions.php

示例2: CleanUpCacheDirectory

 function CleanUpCacheDirectory()
 {
     $this->DebugMessage('CleanUpCacheDirectory() set to purge (' . (is_null($this->config_cache_maxage) ? 'NULL' : number_format($this->config_cache_maxage / 86400, 1)) . ' days; ' . (is_null($this->config_cache_maxsize) ? 'NULL' : number_format($this->config_cache_maxsize / 1048576, 2)) . ' MB; ' . (is_null($this->config_cache_maxfiles) ? 'NULL' : number_format($this->config_cache_maxfiles)) . ' files)', __FILE__, __LINE__);
     if (!is_writable($this->config_cache_directory)) {
         $this->DebugMessage('CleanUpCacheDirectory() skipped because "' . $this->config_cache_directory . '" is not writable', __FILE__, __LINE__);
         return true;
     }
     // cache status of cache directory for 1 hour to avoid hammering the filesystem functions
     $phpThumbCacheStats_filename = $this->config_cache_directory . DIRECTORY_SEPARATOR . 'phpThumbCacheStats.txt';
     if (file_exists($phpThumbCacheStats_filename) && is_readable($phpThumbCacheStats_filename) && filemtime($phpThumbCacheStats_filename) >= time() - 3600) {
         $this->DebugMessage('CleanUpCacheDirectory() skipped because "' . $phpThumbCacheStats_filename . '" is recently modified', __FILE__, __LINE__);
         return true;
     }
     touch($phpThumbCacheStats_filename);
     $DeletedKeys = array();
     $AllFilesInCacheDirectory = array();
     if ($this->config_cache_maxage > 0 || $this->config_cache_maxsize > 0 || $this->config_cache_maxfiles > 0) {
         $CacheDirOldFilesAge = array();
         $CacheDirOldFilesSize = array();
         $AllFilesInCacheDirectory = phpthumb_functions::GetAllFilesInSubfolders($this->config_cache_directory);
         foreach ($AllFilesInCacheDirectory as $fullfilename) {
             if (preg_match('#' . preg_quote($this->config_cache_prefix) . '#i', $fullfilename) && file_exists($fullfilename)) {
                 $CacheDirOldFilesAge[$fullfilename] = @fileatime($fullfilename);
                 if ($CacheDirOldFilesAge[$fullfilename] == 0) {
                     $CacheDirOldFilesAge[$fullfilename] = @filemtime($fullfilename);
                 }
                 $CacheDirOldFilesSize[$fullfilename] = @filesize($fullfilename);
             }
         }
         if (empty($CacheDirOldFilesSize)) {
             return true;
         }
         $DeletedKeys['zerobyte'] = array();
         foreach ($CacheDirOldFilesSize as $fullfilename => $filesize) {
             // purge all zero-size files more than an hour old (to prevent trying to delete just-created and/or in-use files)
             $cutofftime = time() - 3600;
             if ($filesize == 0 && $CacheDirOldFilesAge[$fullfilename] < $cutofftime) {
                 $this->DebugMessage('deleting "' . $fullfilename . '"', __FILE__, __LINE__);
                 if (@unlink($fullfilename)) {
                     $DeletedKeys['zerobyte'][] = $fullfilename;
                     unset($CacheDirOldFilesSize[$fullfilename]);
                     unset($CacheDirOldFilesAge[$fullfilename]);
                 }
             }
         }
         $this->DebugMessage('CleanUpCacheDirectory() purged ' . count($DeletedKeys['zerobyte']) . ' zero-byte files', __FILE__, __LINE__);
         asort($CacheDirOldFilesAge);
         if ($this->config_cache_maxfiles > 0) {
             $TotalCachedFiles = count($CacheDirOldFilesAge);
             $DeletedKeys['maxfiles'] = array();
             foreach ($CacheDirOldFilesAge as $fullfilename => $filedate) {
                 if ($TotalCachedFiles > $this->config_cache_maxfiles) {
                     $this->DebugMessage('deleting "' . $fullfilename . '"', __FILE__, __LINE__);
                     if (@unlink($fullfilename)) {
                         $TotalCachedFiles--;
                         $DeletedKeys['maxfiles'][] = $fullfilename;
                     }
                 } else {
                     // there are few enough files to keep the rest
                     break;
                 }
             }
             $this->DebugMessage('CleanUpCacheDirectory() purged ' . count($DeletedKeys['maxfiles']) . ' files based on (config_cache_maxfiles=' . $this->config_cache_maxfiles . ')', __FILE__, __LINE__);
             foreach ($DeletedKeys['maxfiles'] as $fullfilename) {
                 unset($CacheDirOldFilesAge[$fullfilename]);
                 unset($CacheDirOldFilesSize[$fullfilename]);
             }
         }
         if ($this->config_cache_maxage > 0) {
             $mindate = time() - $this->config_cache_maxage;
             $DeletedKeys['maxage'] = array();
             foreach ($CacheDirOldFilesAge as $fullfilename => $filedate) {
                 if ($filedate > 0) {
                     if ($filedate < $mindate) {
                         $this->DebugMessage('deleting "' . $fullfilename . '"', __FILE__, __LINE__);
                         if (@unlink($fullfilename)) {
                             $DeletedKeys['maxage'][] = $fullfilename;
                         }
                     } else {
                         // the rest of the files are new enough to keep
                         break;
                     }
                 }
             }
             $this->DebugMessage('CleanUpCacheDirectory() purged ' . count($DeletedKeys['maxage']) . ' files based on (config_cache_maxage=' . $this->config_cache_maxage . ')', __FILE__, __LINE__);
             foreach ($DeletedKeys['maxage'] as $fullfilename) {
                 unset($CacheDirOldFilesAge[$fullfilename]);
                 unset($CacheDirOldFilesSize[$fullfilename]);
             }
         }
         if ($this->config_cache_maxsize > 0) {
             $TotalCachedFileSize = array_sum($CacheDirOldFilesSize);
             $DeletedKeys['maxsize'] = array();
             foreach ($CacheDirOldFilesAge as $fullfilename => $filedate) {
                 if ($TotalCachedFileSize > $this->config_cache_maxsize) {
                     $this->DebugMessage('deleting "' . $fullfilename . '"', __FILE__, __LINE__);
                     if (@unlink($fullfilename)) {
                         $TotalCachedFileSize -= $CacheDirOldFilesSize[$fullfilename];
                         $DeletedKeys['maxsize'][] = $fullfilename;
                     }
//.........这里部分代码省略.........
开发者ID:notzen,项目名称:exponent-cms,代码行数:101,代码来源:phpthumb.class.php

示例3: GetAllFilesInSubfolders

 function GetAllFilesInSubfolders($dirname)
 {
     $AllFiles = array();
     $dirname = rtrim(realpath($dirname), '/\\');
     if ($dirhandle = @opendir($dirname)) {
         while ($file = readdir($dirhandle)) {
             $fullfilename = $dirname . DIRECTORY_SEPARATOR . $file;
             if (is_file($fullfilename)) {
                 $AllFiles[] = $fullfilename;
             } elseif (is_dir($fullfilename)) {
                 if ($file == '.' || $file == '..') {
                     continue;
                 }
                 $subfiles = phpthumb_functions::GetAllFilesInSubfolders($fullfilename);
                 foreach ($subfiles as $filename) {
                     $AllFiles[] = $filename;
                 }
             } else {
                 // ignore?
             }
         }
         closedir($dirhandle);
     }
     sort($AllFiles);
     return array_unique($AllFiles);
 }
开发者ID:paulToro,项目名称:webrocket,代码行数:26,代码来源:phpthumb.functions.php

示例4: CleanUpCacheDirectory

 function CleanUpCacheDirectory()
 {
     $this->DebugMessage('skipping CleanUpCacheDirectory() set to purge (' . number_format($this->config_cache_maxage / 86400, 1) . ' days; ' . number_format($this->config_cache_maxsize / 1048576, 2) . 'MB; ' . number_format($this->config_cache_maxfiles) . ' files)', __FILE__, __LINE__);
     $DeletedKeys = array();
     $AllFilesInCacheDirectory = array();
     if ($this->config_cache_maxage > 0 || $this->config_cache_maxsize > 0 || $this->config_cache_maxfiles > 0) {
         $CacheDirOldFilesAge = array();
         $CacheDirOldFilesSize = array();
         $AllFilesInCacheDirectory = phpthumb_functions::GetAllFilesInSubfolders($this->config_cache_directory);
         foreach ($AllFilesInCacheDirectory as $fullfilename) {
             if (preg_match('/^phpThumb\\_cache\\_/i', basename($fullfilename)) && file_exists($fullfilename)) {
                 $CacheDirOldFilesAge[$fullfilename] = @fileatime($fullfilename);
                 if ($CacheDirOldFilesAge[$fullfilename] == 0) {
                     $CacheDirOldFilesAge[$fullfilename] = @filemtime($fullfilename);
                 }
                 $CacheDirOldFilesSize[$fullfilename] = @filesize($fullfilename);
             }
         }
         if (empty($CacheDirOldFilesSize)) {
             return true;
         }
         $DeletedKeys['zerobyte'] = array();
         foreach ($CacheDirOldFilesSize as $fullfilename => $filesize) {
             // purge all zero-size files more than an hour old (to prevent trying to delete just-created and/or in-use files)
             $cutofftime = time() - 3600;
             if ($filesize == 0 && $CacheDirOldFilesAge[$fullfilename] < $cutofftime) {
                 if (@unlink($fullfilename)) {
                     $DeletedKeys['zerobyte'][] = $fullfilename;
                     unset($CacheDirOldFilesSize[$fullfilename]);
                     unset($CacheDirOldFilesAge[$fullfilename]);
                 }
             }
         }
         $this->DebugMessage('CleanUpCacheDirectory() purged ' . count($DeletedKeys['zerobyte']) . ' zero-byte files', __FILE__, __LINE__);
         asort($CacheDirOldFilesAge);
         if ($this->config_cache_maxfiles > 0) {
             $TotalCachedFiles = count($CacheDirOldFilesAge);
             $DeletedKeys['maxfiles'] = array();
             foreach ($CacheDirOldFilesAge as $fullfilename => $filedate) {
                 if ($TotalCachedFiles > $this->config_cache_maxfiles) {
                     if (@unlink($fullfilename)) {
                         $TotalCachedFiles--;
                         $DeletedKeys['maxfiles'][] = $fullfilename;
                     }
                 } else {
                     // there are few enough files to keep the rest
                     break;
                 }
             }
             $this->DebugMessage('CleanUpCacheDirectory() purged ' . count($DeletedKeys['maxfiles']) . ' files based on (config_cache_maxfiles=' . $this->config_cache_maxfiles . ')', __FILE__, __LINE__);
             foreach ($DeletedKeys['maxfiles'] as $fullfilename) {
                 unset($CacheDirOldFilesAge[$fullfilename]);
                 unset($CacheDirOldFilesSize[$fullfilename]);
             }
         }
         if ($this->config_cache_maxage > 0) {
             $mindate = time() - $this->config_cache_maxage;
             $DeletedKeys['maxage'] = array();
             foreach ($CacheDirOldFilesAge as $fullfilename => $filedate) {
                 if ($filedate > 0) {
                     if ($filedate < $mindate) {
                         if (@unlink($fullfilename)) {
                             $DeletedKeys['maxage'][] = $fullfilename;
                         }
                     } else {
                         // the rest of the files are new enough to keep
                         break;
                     }
                 }
             }
             $this->DebugMessage('CleanUpCacheDirectory() purged ' . count($DeletedKeys['maxage']) . ' files based on (config_cache_maxage=' . $this->config_cache_maxage . ')', __FILE__, __LINE__);
             foreach ($DeletedKeys['maxage'] as $fullfilename) {
                 unset($CacheDirOldFilesAge[$fullfilename]);
                 unset($CacheDirOldFilesSize[$fullfilename]);
             }
         }
         if ($this->config_cache_maxsize > 0) {
             $TotalCachedFileSize = array_sum($CacheDirOldFilesSize);
             $DeletedKeys['maxsize'] = array();
             foreach ($CacheDirOldFilesAge as $fullfilename => $filedate) {
                 if ($TotalCachedFileSize > $this->config_cache_maxsize) {
                     if (@unlink($fullfilename)) {
                         $TotalCachedFileSize -= $CacheDirOldFilesSize[$fullfilename];
                         $DeletedKeys['maxsize'][] = $fullfilename;
                     }
                 } else {
                     // the total filesizes are small enough to keep the rest of the files
                     break;
                 }
             }
             $this->DebugMessage('CleanUpCacheDirectory() purged ' . count($DeletedKeys['maxsize']) . ' files based on (config_cache_maxsize=' . $this->config_cache_maxsize . ')', __FILE__, __LINE__);
             foreach ($DeletedKeys['maxsize'] as $fullfilename) {
                 unset($CacheDirOldFilesAge[$fullfilename]);
                 unset($CacheDirOldFilesSize[$fullfilename]);
             }
         }
     } else {
         $this->DebugMessage('skipping CleanUpCacheDirectory() because config set to not use it', __FILE__, __LINE__);
     }
     $totalpurged = 0;
//.........这里部分代码省略.........
开发者ID:CrazyBobik,项目名称:allotaxi.test,代码行数:101,代码来源:phpthumb.class.php

示例5: CleanUpCacheDirectory

 function CleanUpCacheDirectory()
 {
     if ($this->config_cache_maxage > 0 || $this->config_cache_maxsize > 0 || $this->config_cache_maxfiles > 0) {
         $CacheDirOldFilesAge = array();
         $CacheDirOldFilesSize = array();
         $AllFilesInCacheDirectory = phpthumb_functions::GetAllFilesInSubfolders($this->config_cache_directory);
         foreach ($AllFilesInCacheDirectory as $fullfilename) {
             if (eregi('^phpThumb_cache_', $fullfilename) && file_exists($fullfilename)) {
                 $CacheDirOldFilesAge[$fullfilename] = @fileatime($fullfilename);
                 if ($CacheDirOldFilesAge[$fullfilename] == 0) {
                     $CacheDirOldFilesAge[$fullfilename] = @filemtime($fullfilename);
                 }
                 $CacheDirOldFilesSize[$fullfilename] = @filesize($fullfilename);
             }
         }
         if (empty($CacheDirOldFilesSize)) {
             return true;
         }
         $DeletedKeys = array();
         foreach ($CacheDirOldFilesSize as $fullfilename => $filesize) {
             // purge all zero-size files more than an hour old (to prevent trying to delete just-created and/or in-use files)
             $cutofftime = time() - 3600;
             if ($filesize == 0 && $CacheDirOldFilesAge[$fullfilename] < $cutofftime) {
                 if (@unlink($fullfilename)) {
                     $DeletedKeys[] = $fullfilename;
                     unset($CacheDirOldFilesSize[$fullfilename]);
                     unset($CacheDirOldFilesAge[$fullfilename]);
                 }
             }
         }
         $this->DebugMessage('CleanUpCacheDirectory() purged ' . count($DeletedKeys) . ' zero-byte files', __FILE__, __LINE__);
         asort($CacheDirOldFilesAge);
         if ($this->config_cache_maxfiles > 0) {
             $TotalCachedFiles = count($CacheDirOldFilesAge);
             $DeletedKeys = array();
             foreach ($CacheDirOldFilesAge as $fullfilename => $filedate) {
                 if ($TotalCachedFiles > $this->config_cache_maxfiles) {
                     if (@unlink($fullfilename)) {
                         $TotalCachedFiles--;
                         $DeletedKeys[] = $fullfilename;
                     }
                 } else {
                     // there are few enough files to keep the rest
                     break;
                 }
             }
             $this->DebugMessage('CleanUpCacheDirectory() purged ' . count($DeletedKeys) . ' files based on (config_cache_maxfiles=' . $this->config_cache_maxfiles . ')', __FILE__, __LINE__);
             foreach ($DeletedKeys as $fullfilename) {
                 unset($CacheDirOldFilesAge[$fullfilename]);
                 unset($CacheDirOldFilesSize[$fullfilename]);
             }
         }
         if ($this->config_cache_maxage > 0) {
             $mindate = time() - $this->config_cache_maxage;
             $DeletedKeys = array();
             foreach ($CacheDirOldFilesAge as $fullfilename => $filedate) {
                 if ($filedate > 0) {
                     if ($filedate < $mindate) {
                         if (@unlink($fullfilename)) {
                             $DeletedKeys[] = $fullfilename;
                         }
                     } else {
                         // the rest of the files are new enough to keep
                         break;
                     }
                 }
             }
             $this->DebugMessage('CleanUpCacheDirectory() purged ' . count($DeletedKeys) . ' files based on (config_cache_maxage=' . $this->config_cache_maxage . ')', __FILE__, __LINE__);
             foreach ($DeletedKeys as $fullfilename) {
                 unset($CacheDirOldFilesAge[$fullfilename]);
                 unset($CacheDirOldFilesSize[$fullfilename]);
             }
         }
         if ($this->config_cache_maxsize > 0) {
             $TotalCachedFileSize = array_sum($CacheDirOldFilesSize);
             $DeletedKeys = array();
             foreach ($CacheDirOldFilesAge as $fullfilename => $filedate) {
                 if ($TotalCachedFileSize > $this->config_cache_maxsize) {
                     if (@unlink($fullfilename)) {
                         $TotalCachedFileSize -= $CacheDirOldFilesSize[$fullfilename];
                         $DeletedKeys[] = $fullfilename;
                     }
                 } else {
                     // the total filesizes are small enough to keep the rest of the files
                     break;
                 }
             }
             $this->DebugMessage('CleanUpCacheDirectory() purged ' . count($DeletedKeys) . ' files based on (config_cache_maxsize=' . $this->config_cache_maxsize . ')', __FILE__, __LINE__);
             foreach ($DeletedKeys as $fullfilename) {
                 unset($CacheDirOldFilesAge[$fullfilename]);
                 unset($CacheDirOldFilesSize[$fullfilename]);
             }
         }
     } else {
         $this->DebugMessage('skipping CleanUpCacheDirectory() because config set to not use it', __FILE__, __LINE__);
     }
     return true;
 }
开发者ID:searchfirst,项目名称:Lenore,代码行数:98,代码来源:phpthumb_class.php


注:本文中的phpthumb_functions::GetAllFilesInSubfolders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。