本文整理汇总了PHP中file::getFileInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP file::getFileInfo方法的具体用法?PHP file::getFileInfo怎么用?PHP file::getFileInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::getFileInfo方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFileList
/**
* get the list of files and folders under this current fold
* @return array
*/
function getFileList()
{
$outputs = array();
$files = array();
$folders = array();
$tem = array();
$dirHandler = @opendir($this->currentFolderPath);
if ($dirHandler) {
while (false !== ($file = readdir($dirHandler))) {
if ($file != '.' && $file != '..') {
$flag = $this->flags['no'];
if ($this->sessionAction->getFolder() == $this->currentFolderPath) {
//check if any flag associated with this folder or file
$folder = addTrailingSlash(backslashToSlash($this->currentFolderPath));
if (in_array($folder . $file, $this->sessionAction->get())) {
if ($this->sessionAction->getAction() == "copy") {
$flag = $this->flags['copy'];
} else {
$flag = $this->flags['cut'];
}
}
}
$path = $this->currentFolderPath . $file;
if (is_dir($path) && isListingDocument($path)) {
$this->currentFolderInfo['subdir']++;
if (!$this->calculateSubdir) {
} else {
$folder = $this->getFolderInfo($path);
$folder['flag'] = $flag;
$folders[$file] = $folder;
$outputs[$file] = $folders[$file];
}
} elseif (is_file($path) && isListingDocument($path)) {
$obj = new file($path);
$tem = $obj->getFileInfo();
if (sizeof($tem)) {
$fileType = $this->getFileType($file);
foreach ($fileType as $k => $v) {
$tem[$k] = $v;
}
$this->currentFolderInfo['size'] += $tem['size'];
$this->currentFolderInfo['file']++;
$tem['path'] = backslashToSlash($path);
$tem['type'] = "file";
$tem['flag'] = $flag;
$files[$file] = $tem;
$outputs[$file] = $tem;
$tem = array();
$obj->close();
}
}
}
}
if ($this->forceFolderOnTop) {
uksort($folders, "strnatcasecmp");
uksort($files, "strnatcasecmp");
$outputs = array();
foreach ($folders as $v) {
$outputs[] = $v;
}
foreach ($files as $v) {
$outputs[] = $v;
}
} else {
uksort($outputs, "strnatcasecmp");
}
@closedir($dirHandler);
} else {
trigger_error('Unable to locate the folder ' . $this->currentFolderPath, E_NOTICE);
}
return $outputs;
}
示例2: if
}else if(!$upload->moveUploadedFile($_GET['folder']))
{
$error = ERR_FILE_MOVE_FAILED;
}
elseif(!$upload->isPermittedFileExt(explode(",", CONFIG_UPLOAD_VALID_EXTS)))
{
$error = ERR_FILE_TYPE_NOT_ALLOWED;
}elseif(defined('CONFIG_UPLOAD_MAXSIZE') && CONFIG_UPLOAD_MAXSIZE && $upload->isSizeTooBig(CONFIG_UPLOAD_MAXSIZE))
{
$error = sprintf(ERROR_FILE_TOO_BID, transformFileSize(CONFIG_UPLOAD_MAXSIZE));
}else
{
include_once(CLASS_FILE);
$path = $upload->getFilePath();
$obj = new file($path);
$tem = $obj->getFileInfo();
if(sizeof($tem))
{
include_once(CLASS_MANAGER);
$manager = new manager($upload->getFilePath(), false);
$fileType = $manager->getFileType($upload->getFileName());
foreach($fileType as $k=>$v)
{
$tem[$k] = $v;
}
$tem['path'] = backslashToSlash($path);
$tem['type'] = "file";
示例3: getRealPath
$allDocs[] = getRealPath($destFolderPath . $file);
}
}
include_once CLASS_FILE;
$file = new file();
//check if all files are allowed to cut or copy
foreach ($selectedDocuments as $doc) {
if (file_exists($doc) && isUnderRoot($doc)) {
if (array_search(getRealPath($doc), $allDocs) === false || CONFIG_OVERWRITTEN) {
if (CONFIG_OVERWRITTEN) {
$file->delete($doc);
}
if ($file->copyTo($doc, $_GET['current_folder_path'])) {
$finalPath = $destFolderPath . basename($doc);
$objFile = new file($finalPath);
$tem = $objFile->getFileInfo();
$obj = new manager($finalPath, false);
$fileType = $obj->getFileType($finalPath, is_dir($finalPath) ? true : false);
foreach ($fileType as $k => $v) {
$tem[$k] = $v;
}
/* foreach ($folderInfo as $k=>$v)
{
$tem['i_' . $k] = $v;
}
if($folderInfo['type'] == 'folder' && empty($folderInfo['subdir']) && empty($folderInfo['file']))
{
$tem['cssClass'] = 'folderEmpty';
}*/
$tem['final_path'] = $finalPath;
$tem['path'] = backslashToSlash($finalPath);
示例4: doSearch
/**
* get the file according to the search keywords
*
*/
function doSearch($baseFolderPath = null)
{
$baseFolderPath = addTrailingSlash(backslashToSlash((is_null($baseFolderPath)?$this->rootFolder:$baseFolderPath)));
$dirHandler = @opendir($baseFolderPath);
if($dirHandler)
{
while(false !== ($file = readdir($dirHandler)))
{
if($file != '.' && $file != '..')
{
$path = $baseFolderPath . $file;
if(is_file($path))
{
$isValid = true;
$fileTime = @filemtime($path);
$fileSize = @filesize($path);
if($this->searchkeywords['name'] !== '' && @eregi($this->searchkeywords['name'], $file) === false)
{
$isValid = false;
}
if($this->searchkeywords['mtime_from'] != '' && $fileTime < @strtotime($this->searchkeywords['mtime_from']))
{
$isValid = false;
}
if($this->searchkeywords['mtime_to'] != '' && $fileTime > @strtotime($this->searchkeywords['mtime_to']))
{
$isValid = false;
}
if($this->searchkeywords['size_from'] != '' && $fileSize < @strtotime($this->searchkeywords['size_from']))
{
$isValid = false;
}
if($this->searchkeywords['size_to'] != '' && $fileSize > @strtotime($this->searchkeywords['size_to']))
{
$isValid = false;
}
if($isValid && isListingDocument($path))
{
$finalPath = $path;
$objFile = new file($finalPath);
$tem = $objFile->getFileInfo();
$obj = new manager($finalPath, false);
$obj->setSessionAction($this->sessionAction);
$selectedDocuments = $this->sessionAction->get();
$fileType = $obj->getFileType($finalPath);
foreach($fileType as $k=>$v)
{
$tem[$k] = $v;
}
$tem['path'] = backslashToSlash($finalPath);
$tem['type'] = (is_dir($finalPath)?'folder':'file');
/* $tem['size'] = transformFileSize($tem['size']);
$tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']);
$tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);*/
$tem['flag'] = (array_search($tem['path'], $selectedDocuments) !== false?($this->sessionAction->getAction() == "copy"?'copyFlag':'cutFlag'):'noFlag');
$tem['url'] = getFileUrl($tem['path']);
$this->rootFolderInfo['file']++;
$manager = null;
$this->files[] = $tem;
$tem = null;
}
}elseif(is_dir($path) && $this->searchkeywords['recursive'])
{
$this->Search($baseFolderPath);
}
}
}
}
}
示例5: SessionAction
include_once CLASS_SESSION_ACTION;
$sessionAction = new SessionAction();
$selectedDocuments = $sessionAction->get();
if (removeTrailingSlash($sessionAction->getFolder()) == getParentPath($_POST['original_path']) && sizeof($selectedDocuments)) {
if (($key = array_search(basename($_POST['original_path']), $selectedDocuments)) !== false) {
$selectedDocuments[$key] = $_POST['name'];
$sessionAction->set($selectedDocuments);
}
} elseif (removeTrailingSlash($sessionAction->getFolder()) == removeTrailingSlash($_POST['original_path'])) {
$sessionAction->setFolder($_POST['original_path']);
}
$path = addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name'];
if (is_file($path)) {
include_once CLASS_FILE;
$file = new file($path);
$fileInfo = $file->getFileInfo();
$fileInfo['mtime'] = date(DATE_TIME_FORMAT, $fileInfo['mtime']);
} else {
include_once CLASS_MANAGER;
$manager = new manager($path, false);
$fileInfo = $manager->getFolderInfo();
$fileInfo['mtime'] = date(DATE_TIME_FORMAT, $fileInfo['mtime']);
}
event_system(LOG_MY_FOLDER_CHANGE, LOG_MY_FOLDER_PATH, $_POST['original_path']);
event_system(LOG_MY_FOLDER_CHANGE, LOG_MY_FOLDER_NEW_PATH, $path);
}
echo "{";
echo "error:'" . $error . "' ";
foreach ($fileInfo as $k => $v) {
echo "," . $k . ":'" . $v . "' ";
}
示例6: getFileList
/**
* get the list of files and folders under this current fold
* @return array
*/
function getFileList()
{
$outputs = array();
$files = array();
$folders = array();
$tem = array();
$to_group_id = api_get_group_id();
global $is_user_in_group;
$dirHandler = @opendir($this->getCurrentFolderPath());
if ($dirHandler) {
while (false !== ($file = readdir($dirHandler))) {
if ($file != '.' && $file != '..') {
$flag = $this->flags['no'];
if ($this->sessionAction->getFolder() == $this->getCurrentFolderPath()) {
//check if any flag associated with this folder or file
$folder = addTrailingSlash(backslashToSlash($this->getCurrentFolderPath()));
if (in_array($folder . $file, $this->sessionAction->get())) {
if ($this->sessionAction->getAction() == "copy") {
$flag = $this->flags['copy'];
} else {
$flag = $this->flags['cut'];
}
}
}
$path = $this->getCurrentFolderPath() . $file;
if (is_dir($path) && isListingDocument($path)) {
$this->currentFolderInfo['subdir']++;
//fix count left folders for Chamilo
$deleted_by_Chamilo_folder = '_DELETED_';
$css_folder_Chamilo = 'css';
$hotpotatoes_folder_Chamilo = 'HotPotatoes_files';
$chat_files_Chamilo = 'chat_files';
$certificates_Chamilo = 'certificates';
//show group's directory only if I'm member. Or if I'm a teacher.
//@todo: check groups not necessary because the student dont have access to main folder documents (only to document/group or document/shared_folder).
//Teachers can access to all groups ?
$group_folder = '_groupdocs';
$hide_doc_group = false;
if (preg_match("/{$group_folder}/", $path)) {
$hide_doc_group = true;
if ($is_user_in_group || $to_group_id != 0 && api_is_allowed_to_edit()) {
$hide_doc_group = false;
}
}
if (preg_match("/{$deleted_by_Chamilo_folder}/", $path) || preg_match("/{$css_folder_Chamilo}/", $path) || preg_match("/{$hotpotatoes_folder_Chamilo}/", $path) || preg_match("/{$chat_files_Chamilo}/", $path) || preg_match("/{$certificates_Chamilo}/", $path) || $hide_doc_group || $file[0] == '.') {
$this->currentFolderInfo['subdir'] = $this->currentFolderInfo['subdir'] - 1;
}
//end fix for Chamilo
if (!$this->calculateSubdir) {
} else {
$folder = $this->getFolderInfo($path);
$folder['flag'] = $flag;
$folders[$file] = $folder;
$outputs[$file] = $folders[$file];
}
} elseif (is_file($path) && isListingDocument($path)) {
$obj = new file($path);
$tem = $obj->getFileInfo();
if (sizeof($tem)) {
$fileType = $this->getFileType($file);
foreach ($fileType as $k => $v) {
$tem[$k] = $v;
}
$this->currentFolderInfo['size'] += $tem['size'];
$this->currentFolderInfo['file']++;
//fix count left files for Chamilo
$deleted_by_Chamilo_file = ' DELETED ';
// ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php
if (preg_match("/{$deleted_by_Chamilo_file}/", $tem['name']) || $tem['name'][0] == '.') {
$this->currentFolderInfo['file'] = $this->currentFolderInfo['file'] - 1;
}
///end fix for Chamilo
//Try a course file
$tem['path'] = backslashToSlash($path);
$pos = strpos($this->getCurrentFolderPath(), 'courses/');
if ($pos === false) {
//try my_files
$pos = strpos($this->getCurrentFolderPath(), 'main/');
$tem['public_path'] = api_get_path(WEB_PATH) . substr($this->getCurrentFolderPath(), $pos, strlen($this->getCurrentFolderPath())) . $file;
} else {
$tem['public_path'] = api_get_path(WEB_PATH) . substr($this->getCurrentFolderPath(), $pos, strlen($this->getCurrentFolderPath())) . $file;
}
$tem['type'] = "file";
$tem['flag'] = $flag;
$files[$file] = $tem;
$outputs[$file] = $tem;
$tem = array();
$obj->close();
}
}
}
}
if ($this->forceFolderOnTop) {
uksort($folders, "strnatcasecmp");
uksort($files, "strnatcasecmp");
$outputs = array();
//.........这里部分代码省略.........