/** * constructor * * @param string $rootFolder */ function __construct($rootFolder) { $this->rootFolder = $rootFolder; $this->sessionAction = new SessionAction(); $objRootFolder = new file($this->rootFolder); $tem = $objRootFolder->getFileInfo(); $obj = new manager($this->rootFolder, false); $obj->setSessionAction($this->sessionAction); $selectedDocuments = $this->sessionAction->get(); $fileType = $obj->getFolderInfo($this->rootFolder); foreach($fileType as $k=>$v) { $tem[$k] = $v; } $tem['path'] = backslashToSlash($this->rootFolder); $tem['type'] = (is_dir($this->rootFolder)?'folder':'file'); $tem['size'] = (is_dir($this->rootFolder)?'':transformFileSize(@filesize($this->rootFolder))); //$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($this->rootFolder); $tem['friendly_path'] = transformFilePath($this->rootFolder); $tem['file'] = 0; $tem['subdir'] = 0; $manager = null; $this->rootFolderInfo = $tem; $tem = null; }
$search->addSearchKeyword('size_from', @$_GET['search_size_from']); $search->addSearchKeyword('size_to', @$_GET['search_size_to']); $search->addSearchKeyword('recursive', @$_GET['search_recursively']); $search->addSearchKeyword('name', @$_GET['search_name']); $search->doSearch(); $fileList = $search->getFoundFiles(); $folderInfo = $search->getRootFolderInfo(); } else { include_once CLASS_MANAGER; include_once CLASS_SESSION_ACTION; $sessionAction = new SessionAction(); include_once DIR_AJAX_INC . "class.manager.php"; $manager = new manager(); $manager->setSessionAction($sessionAction); $fileList = $manager->getFileList(); $folderInfo = $manager->getFolderInfo(); } $pagination->setUrl(CONFIG_URL_FILEnIMAGE_MANAGER); } else { include_once CLASS_PAGINATION; $pagination = new pagination(false); } $pagination->setTotal(sizeof($fileList)); $pagination->setFirstText(PAGINATION_FIRST); $pagination->setPreviousText(PAGINATION_PREVIOUS); $pagination->setNextText(PAGINATION_NEXT); $pagination->setLastText(PAGINATION_LAST); $pagination->setLimit(!empty($_GET['limit']) ? (int) $_GET['limit'] : CONFIG_DEFAULT_PAGINATION_LIMIT); echo $pagination->getPaginationHTML(); echo "<script type=\"text/javascript\">\n"; echo "parentFolder = {path:'" . getParentFolderPath($folderInfo['path']) . "'};\n";
} elseif (empty($_POST['new_folder'])) { $error = ERR_FOLDER_NAME_EMPTY; } elseif (!preg_match("/^[a-zA-Z0-9_\\- ]+\$/", $_POST['new_folder'])) { $error = ERR_FOLDER_FORMAT; } else { if (empty($_POST['currentFolderPath']) || !isUnderRoot($_POST['currentFolderPath'])) { $error = ERR_FOLDER_PATH_NOT_ALLOWED; } elseif (file_exists(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder'])) { $error = ERR_FOLDER_EXISTS; } else { include_once CLASS_FILE; $file = new file(); if ($file->mkdir(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder'], 0775)) { include_once CLASS_MANAGER; $manager = new manager(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder'], false); $pathInfo = $manager->getFolderInfo(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder']); foreach ($pathInfo as $k => $v) { switch ($k) { case "ctime": case "mtime": case "atime": $v = date(DATE_TIME_FORMAT, $v); break; case 'name': $info .= sprintf(", %s:'%s'", 'short_name', shortenFileName($v)); break; case 'cssClass': $v = 'folderEmpty'; break; } $info .= sprintf(", %s:'%s'", $k, $v);
/** * get current or the specified dir information * * @param string $path * @return array */ function getFolderInfo($path = null) { if (is_null($path)) { return $this->currentFolderInfo; } else { $obj = new manager($path, false); $obj->setSessionAction($this->sessionAction); $obj->getFileList(); return $obj->getFolderInfo(); } }
$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 . "' "; } echo "}";