本文整理汇总了PHP中DirectoryIterator::getMTime方法的典型用法代码示例。如果您正苦于以下问题:PHP DirectoryIterator::getMTime方法的具体用法?PHP DirectoryIterator::getMTime怎么用?PHP DirectoryIterator::getMTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirectoryIterator
的用法示例。
在下文中一共展示了DirectoryIterator::getMTime方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* Return the status of the file. Has it finished uploading?
*
* Simple calculation based on the current time and the modification date on
* the file. If it has not been touched for a while, assumed that upload has finished.
*
* @param DirectoryIterator $file File object of the file to check.
* @access private
*/
function __getFileStatus($file)
{
if (time() - $file->getMTime() > 20) {
return 'finished';
} else {
return 'loading';
}
}
示例2: DirectoryIterator
}
echo "<br>";
$editedOutputIterator = new DirectoryIterator($appRoot . trim(Config::_EDITED_CONVERTED_FILEDIR, '/') . DS);
while ($editedOutputIterator->valid()) {
$fname = $editedOutputIterator->getFilename();
if ($fname != '.' && $fname != '..' && $editedOutputIterator->getMTime() + $maxAgeFiles < time()) {
echo $editedOutputIterator->getPathname() . "<br>";
//unlink($editedOutputIterator->getPathname());
}
$editedOutputIterator->next();
}
echo "<br>";
$tempVidsIterator = new DirectoryIterator($appRoot . trim(Config::_TEMPVIDDIR, '/') . DS);
while ($tempVidsIterator->valid()) {
$fname = $tempVidsIterator->getFilename();
if ($fname != '.' && $fname != '..' && $tempVidsIterator->getMTime() + $maxAgeFiles < time()) {
echo $tempVidsIterator->getPathname() . "<br>";
//unlink($tempVidsIterator->getPathname());
}
$tempVidsIterator->next();
}
echo "<br>";
$logsIterator = new DirectoryIterator($appRoot . trim(Config::_LOGSDIR, '/') . DS);
while ($logsIterator->valid()) {
$fname = $logsIterator->getFilename();
if ($fname != '.' && $fname != '..' && $logsIterator->getMTime() + $maxAgeFiles < time()) {
echo $logsIterator->getPathname() . "<br>";
//unlink($logsIterator->getPathname());
}
$logsIterator->next();
}
示例3: buildTableRow
public function buildTableRow(DirectoryIterator $file, $includeParentDirectoryDots = true)
{
if (!$file->isDot() && substr($file->getFilename(), 0, 1) == '.' && Administration::instance()->Configuration->get('show-hidden', 'filemanager') != 'yes') {
return;
} elseif ($file->isDot() && !$includeParentDirectoryDots && $file->getFilename() == '..') {
return;
} elseif ($file->getFilename() == '.') {
return;
}
$relpath = str_replace($this->getStartLocation() == '' ? DOCROOT : DOCROOT . $this->getStartLocation(), NULL, $file->getPathname());
if (!$file->isDir()) {
//if(File::fileType($file->getFilename()) == self::CODE)
// $download_uri = self::baseURL() . 'edit/?file=' . urlencode($relpath);
//else
$download_uri = self::baseURL() . 'download/?file=' . urlencode($relpath);
} else {
$download_uri = self::baseURL() . 'properties/?file=' . urlencode($relpath) . '/';
}
if (!$file->isDot()) {
$td1 = Widget::TableData(Widget::Anchor($file->getFilename(), self::baseURL() . ($file->isDir() ? 'browse' . $relpath . '/' : 'properties/?file=' . urlencode($relpath)), NULL, 'file-type ' . ($file->isDir() ? 'folder' : File::fileType($file->getFilename()))));
//$group = (function_exists('posix_getgrgid') ? posix_getgrgid($file->getGroup()) : $file->getGroup());
//$owner = (function_exists('posix_getpwuid') ? posix_getpwuid($file->getOwner()) : $file->getOwner());
$group = $file->getGroup();
$owner = $file->getOwner();
$td3 = Widget::TableData(File::getOctalPermission($file->getPerms()) . ' <span class="inactive">' . File::getReadablePerm($file->getPerms()), NULL, NULL, NULL, array('title' => (isset($owner['name']) ? $owner['name'] : $owner) . ', ' . (isset($group['name']) ? $group['name'] : $group)) . '</span>');
$td4 = Widget::TableData(DateTimeObj::get(__SYM_DATETIME_FORMAT__, $file->getMTime()));
if ($file->isWritable()) {
if ($file->isDir()) {
$td5 = Widget::TableData(Widget::Anchor('Edit', $download_uri));
} else {
$td5 = Widget::TableData(Widget::Anchor('Download', $download_uri));
}
} else {
$td5 = Widget::TableData('-', 'inactive');
}
} else {
$td1 = Widget::TableData(Widget::Anchor('↵', self::baseURL() . 'browse' . $relpath . '/'));
$td3 = Widget::TableData('-', 'inactive');
$td4 = Widget::TableData('-', 'inactive');
$td5 = Widget::TableData('-', 'inactive');
}
$td2 = Widget::TableData($file->isDir() ? '-' : General::formatFilesize($file->getSize()), $file->isDir() ? 'inactive' : NULL);
$startlocation = DOCROOT . $this->getStartLocation();
if (!$file->isDot()) {
$td5->appendChild(Widget::Input('items[' . str_replace($startlocation, '', $file->getPathname()) . ($file->isDir() ? '/' : NULL) . ']', NULL, 'checkbox'));
}
return Widget::TableRow(array($td1, $td2, $td3, $td4, $td5));
}
示例4: _processFile
/**
* Process file
*
* @param int $directoryID
* @param DirectoryIterator $entries
*/
protected final function _processFile($directoryID, DirectoryIterator $entries)
{
$scanID = $this->_scanRow->scanID;
// Load row when exists
$fileRow = $this->_fileTable->fetchRow(array('directoryID' => $directoryID, 'name' => $entries->getFilename()));
// Already scanned
if ($fileRow && $fileRow->lastScanID == $scanID) {
return;
}
$pathname = $entries->getPathname();
// Data
$data = array('modifyDate' => $this->_normalizeDate($entries->getMTime()), 'owner' => $this->_normalizeUser($entries->getOwner()), 'group' => $this->_normalizeGroup($entries->getGroup()), 'permissions' => $entries->getPerms(), 'size' => $entries->getSize(), 'linkTarget' => $entries->isLink() ? $entries->getLinkTarget() : null);
// Content
$contentHash = null;
if (!$entries->isLink() && ($this->_alwaysCheckContent || !$fileRow || $fileRow->modifyDate != $data['modifyDate'] || $fileRow->size != $data['size'])) {
// Non-accessible file
if (!is_readable($pathname)) {
$this->_log(self::LOG_ERROR, "\t{$pathname} cannot be read.");
if ($fileRow) {
$contentHash = $fileRow->contentHash;
}
} else {
$contentHash = md5_file($pathname);
}
}
// Transaction
$this->_db->beginTransaction();
// New row
if ($newRow = !$fileRow) {
fwrite(STDOUT, "\t{$pathname} is new.\n");
$fileRow = $this->_createFileRow(array('directoryID' => $directoryID, 'name' => $entries->getFilename()) + $data);
}
// Store values
$oldValues = $fileRow->toArray();
// Content
if ($fileRow->contentHash != $contentHash) {
$data['contentHash'] = $contentHash;
if ($this->_storagePath) {
$data['storedAs'] = $this->_copyFile($fileRow->fileID, $entries);
}
}
// Update row
$this->_updateFileRow($pathname, $fileRow, $data);
$fileRow->lastScanID = $scanID;
$fileRow->save();
// Scan row update
$this->_scanRow->lastOperationDate = new SeekR_Expression('NOW()');
$this->_scanRow->save();
// Transaction
$this->_db->commit();
}
示例5: clean_cache
/**
* Delete old cached files based on cache time and cache gc probability set
* in the config file.
*/
private function clean_cache()
{
//gc probability
$gc = rand(1, Kohana::config($this->type . '.cache_gc'));
if ($gc != 1) {
return FALSE;
}
$cache = new DirectoryIterator(Kohana::config($this->type . '.cache_folder'));
while ($cache->valid()) {
// if file is past maximum cache settings delete file
$cached = date('U', $cache->getMTime());
$max = time() + Kohana::config($this->type . '.cache_clean_time');
if ($cache->isFile() and $cached > $max) {
unlink($cache->getPathname());
}
$cache->next();
}
}
示例6: get_pack_data
/**
* Get icon pack data
*
* @since 0.1.0
* @access protected
* @param DirectoryIterator $pack_dir Icon pack directory object.
* @return array Icon pack data array or FALSE.
*/
protected function get_pack_data(DirectoryIterator $pack_dir)
{
$pack_dirname = $pack_dir->getFilename();
$pack_path = $pack_dir->getPathname();
$cache_id = "icon_picker_fontpack_{$pack_dirname}";
$cache_data = get_transient($cache_id);
$config_file = "{$pack_path}/config.json";
if (false !== $cache_data && $cache_data['version'] === $pack_dir->getMTime()) {
return $cache_data;
}
// Make sure the config file exists and is readable.
if (!is_readable($config_file)) {
trigger_error(sprintf(esc_html($this->messages['no_config']), '<code>config.json</code>', sprintf('<code>%s</code>', esc_html($pack_path))));
return false;
}
$config = json_decode(file_get_contents($config_file), true);
$errors = json_last_error();
if (!empty($errors)) {
trigger_error(sprintf(esc_html($this->messages['config_error']), sprintf('<code>%s/config.json</code>', esc_html($pack_path))));
return false;
}
$keys = array('name', 'glyphs', 'css_prefix_text');
$items = array();
// Check each required config.
foreach ($keys as $key) {
if (empty($config[$key])) {
trigger_error(sprintf(esc_html($this->messages['invalid']), sprintf('<code><em>%s</em></code>', esc_html($key)), esc_html($config_file)));
return false;
}
}
// Bail if no glyphs found.
if (!is_array($config['glyphs']) || empty($config['glyphs'])) {
return false;
}
foreach ($config['glyphs'] as $glyph) {
if (!empty($glyph['css'])) {
$items[] = array('id' => $config['css_prefix_text'] . $glyph['css'], 'name' => $glyph['css']);
}
}
if (empty($items)) {
return false;
}
$pack_data = array('id' => "pack-{$config['name']}", 'name' => sprintf(__('Pack: %s', 'icon-picker'), $config['name']), 'version' => $pack_dir->getMTime(), 'items' => $items, 'stylesheet_uri' => "{$this->url}/{$pack_dirname}/css/{$config['name']}.css", 'dir' => "{$this->dir}/{$pack_dirname}", 'url' => "{$this->url}/{$pack_dirname}");
set_transient($cache_id, $pack_data, DAY_IN_SECONDS);
return $pack_data;
}
示例7: _getItemStats
/**
* Determine file/directory statistics for input item.
*
* @param DirectoryIterator $item Item passed from a DirectoryIterator
* @return array Listing with stats
*/
private static function _getItemStats(DirectoryIterator $item)
{
$list = array();
// add filename
$list['name'] = (string) $item;
// add directory/file type
$list['type'] = $item->getType();
// add modification time
$list['modified'] = date('Y-m-d H:i:s', $item->getMTime());
// get permissions
$list['permissions'] = $item->getPerms();
// is writable?
$list['writable'] = $item->isWritable() ? 1 : 0;
// add path
$list['path'] = $item->getPathName();
$list['real_path'] = $item->getRealPath();
// add size
$list['size'] = Fari_Format::bytes($item->getSize());
return $list;
}