/** * constructor * */ function __construct() { //check if the session folder read and writable $dir = new file(); if(!file_exists(CONFIG_SYS_DIR_SESSION_PATH)) { if(!$dir->mkdir(CONFIG_SYS_DIR_SESSION_PATH)) { die('Unable to create session folder.'); } } if(!$dir->isReadable(CONFIG_SYS_DIR_SESSION_PATH)) { die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not readable."); } if(!$dir->isWritable(CONFIG_SYS_DIR_SESSION_PATH)) { die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not writable."); } $this->dir = backslashToSlash(addTrailingSlash(CONFIG_SYS_DIR_SESSION_PATH)); $this->lifeTime = get_cfg_var("session.gc_maxlifetime"); $this->gcCounterFile = $this->dir . $this->gcCounterFileName; $this->gcLogFile = $this->dir . $this->gcLogFileName; $this->sessionDir = backslashToSlash($this->dir.session_id().DIRECTORY_SEPARATOR); $this->init(); }
$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"; $tem['size'] = transformFileSize($tem['size']); $tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']); $tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']); $tem['short_name'] = shortenFileName($tem['name']); $tem['flag'] = 'noFlag'; $obj->close(); foreach($tem as $k=>$v) { $info .= sprintf(", %s:'%s'", $k, $v); } $info .= sprintf(", url:'%s'", getFileUrl($path)); $info .= sprintf(", tipedit:'%s'", TIP_DOC_RENAME);
$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); $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'] = 'noFlag'; $tem['url'] = getFileUrl($doc); $manager = null; if ($sessionAction->getAction() == "cut") { $file->delete($doc); } $fileMoved[sizeof($fileMoved)] = $tem; $tem = null; } } else { $unmovedDocDueToSamePath[] = $doc;
/** * 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); } } } } }
/** * get the parent path of the specified path * * @param string $path * @return string */ function getParentFolderPath($path) { $realPath = addTrailingSlash(backslashToSlash(getRealPath($path))); $parentRealPath = addTrailingSlash(backslashToSlash(dirname($realPath))); $differentPath = addTrailingSlash(substr($realPath, strlen($parentRealPath))); $parentPath = substr($path, 0, strlen(addTrailingSlash(backslashToSlash($path))) - strlen($differentPath)); /* echo $realPath . "<br>"; echo $parentRealPath . "<br>"; echo $differentPath . "<br>"; echo $parentPath . "<br>";*/ if(isUnderRoot($parentPath)) { return $parentPath; }else { return CONFIG_SYS_DEFAULT_PATH; } }
ajaxStart('#searchFolderContainer'); $('#searchFolderContainer').load('<?php echo CONFIG_URL_LOAD_FOLDERS; ?>'); } ); </script> <?php }else { ?> <select class="input inputSearch" name="search_folder" id="search_folder"> <?php foreach(getFolderListing(CONFIG_SYS_ROOT_PATH) as $k=>$v) { ?> <option value="<?php echo $v; ?>" <?php echo (removeTrailingSlash(backslashToSlash(($folderInfo['path']))) == removeTrailingSlash(backslashToSlash(($v)))?' selected="selected"':''); ?>><?php echo shortenFileName($k, 30); ?></option> <?php } ?> </select> <?php } ?></span> </td> </tr> <tr> <td> <b><?php echo LBL_SEARCH_MTIME; ?></b><br /> <input type="text" class="input inputMtime" name="search_mtime_from" id="search_mtime_from" value="<?php echo (!empty($_GET['search_mtime_from'])?$_GET['search_mtime_from']:''); ?>" /> <span class="leftToRightArrow"> </span>
/** * 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(); 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->getCurrentFolderPath(), E_NOTICE); } return $outputs; }
function getCurrentFolderPath() { $folderPathIndex = 'path'; $lastVisitedFolderPathIndex = 'ajax_last_visited_folder'; if(isset($_GET[$folderPathIndex]) && file_exists($_GET[$folderPathIndex]) && !is_file($_GET[$folderPathIndex]) ) { $currentFolderPath = $_GET[$folderPathIndex]; } elseif(isset($_SESSION[$lastVisitedFolderPathIndex]) && file_exists($_SESSION[$lastVisitedFolderPathIndex]) && !is_file($_SESSION[$lastVisitedFolderPathIndex])) { $currentFolderPath = $_SESSION[$lastVisitedFolderPathIndex]; }else { $currentFolderPath = CONFIG_SYS_DEFAULT_PATH; } $currentFolderPath = (isUnderRoot($currentFolderPath)?backslashToSlash((addTrailingSlash($currentFolderPath))):CONFIG_SYS_DEFAULT_PATH); //keep track of this folder path in session $_SESSION[$lastVisitedFolderPathIndex] = $currentFolderPath; if(!file_exists($currentFolderPath)) { die(ERR_FOLDER_NOT_FOUND . $currentFolderPath); } }
<script type="text/javascript" src="js/jqModal.js"></script> <script type="text/javascript" src="js/rotate.js"></script> <script type="text/javascript" src="js/interface.js"></script>--> <script type="text/javascript" src="js/ajaximageeditor.js"></script> <script type="text/javascript"> var imageHistory = false; var currentFolder = '<?php echo removeTrailingSlash(backslashToSlash(dirname($path))); ?> '; var warningLostChanges = '<?php echo IMG_WARNING_LOST_CHANAGES; ?> '; var warningReset = '<?php echo IMG_WARNING_REST; ?> '; var warningResetEmpty = '<?php echo IMG_WARNING_EMPTY_RESET; ?> '; var warningEditorClose = '<?php
<?php } else { ?> <select class="input inputSearchSelect" name="search_folder" id="search_folder"> <!-- Chamilo integrating, modify name class for disable by css --> <?php foreach (getFolderListing(CONFIG_SYS_ROOT_PATH) as $k => $v) { if (hideFolderName($k)) { //show only those permitted by Chamilo ?> <option value="<?php echo $v; ?> " <?php echo removeTrailingSlash(backslashToSlash($folderInfo['path'])) == removeTrailingSlash(backslashToSlash($v)) ? ' selected="selected"' : ''; ?> ><?php echo hideFolderName(shortenFileName($k, 30)); ?> </option> <?php } } ?> </select> <?php } ?> </span> <b><?php
<script type="text/javascript" src="jscripts/select.js"></script> <script type="text/javascript" src="jscripts/jqModal.js"></script> <script type="text/javascript" src="jscripts/rotate.js"></script> <script type="text/javascript" src="jscripts/interface.js"></script>--> <script type="text/javascript" src="jscripts/ajaximageeditor.js"></script> <script type="text/javascript"> var imageHistory = false; var currentFolder = '<?php echo removeTrailingSlash(backslashToSlash(dirname($path))); ?>'; var warningLostChanges = '<?php echo IMG_WARNING_LOST_CHANAGES; ?>'; var warningReset = '<?php echo IMG_WARNING_REST; ?>'; var warningResetEmpty = '<?php echo IMG_WARNING_EMPTY_RESET; ?>'; var warningEditorClose = '<?php echo IMG_WARING_WIN_CLOSE; ?>'; var warningUndoImage = '<?php echo IMG_WARNING_UNDO; ?>'; var warningFlipHorizotal = '<?php echo IMG_WARING_FLIP_H; ?>'; var warningFlipVertical = '<?php echo IMG_WARING_FLIP_V; ?>'; var numSessionHistory = <?php echo $history->getNumRestorable(); ?>; var noChangeMadeBeforeSave = '<?php echo IMG_WARNING_NO_CHANGE_BEFORE_SAVE; ?>'; var warningInvalidNewName = '<?php echo IMG_SAVE_AS_ERR_NAME_INVALID; ?>'; var wordCloseWindow = '<?php echo LBL_ACTION_CLOSE; ?>'; var warningNoFolderSelected = '<?php echo IMG_SAVE_AS_NOT_FOLDER_SELECTED; ?>'; var urlGetFolderList = '<?php echo appendQueryString(CONFIG_URL_GET_FOLDER_LIST, makeQueryString(array('path'))); ?>'; $(document).ready( function()
if (!$is_allowed_to_edit && DocumentManager::check_readonly($_course, api_get_user_id(), $chamiloPath)) { $error = get_lang('CantDeleteReadonlyFiles'); //From Chamilo to Ajaxfilemanager } else { $deleted = DocumentManager::delete_document($_course, $chamiloPath, $base_work_dir); //deleted by Chamilo //$file->delete(addTrailingSlash(backslashToSlash($doc))); // disabled deleted by ajaxfilemanager } } else { $error = get_lang('ProtectFolder'); //From Chamilo to Ajaxfilemanager } } else { $file->delete(addTrailingSlash(backslashToSlash($doc))); //deleted by ajaxfilemanager event_system(LOG_USER_PERSONAL_DOC_DELETED, 'document_path', addTrailingSlash(backslashToSlash($doc))); event_system(LOG_MY_FOLDER_DELETE, LOG_MY_FOLDER_PATH, $doc); } //////end bridge to Chamilo } elseif (is_file($doc) && isValidPattern(CONFIG_SYS_INC_FILE_PATTERN, $doc) && !isInvalidPattern(CONFIG_SYS_EXC_FILE_PATTERN, $doc)) { /////////////bridge to Chamilo by Juan Carlos Ra�a Trabado if (!empty($_course['path'])) { //find path $mainPath = '../../../../../../../courses/' . $_course['path'] . '/document/'; //get Chamilo $fullPath = $doc; //get Ajaxfilemanager $chamiloPath = substr($fullPath, strlen($mainPath) - strlen($fullPath) - 1); //find base_work_dir $course_dir = $_course['path'] . "/document"; //get Chamilo
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); foreach($fileType as $k=>$v) { $tem[$k] = $v; } $tem['path'] = backslashToSlash($doc); $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'] = 'noFlag'; $tem['url'] = getFileUrl($doc); $manager = null; if($sessionAction->getAction() == "cut") { $file->delete($doc); } $fileMoved[sizeof($fileMoved)] = $tem; $tem = null; }
/** * 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; }
/** * get next available file name * * @param string $fileToMove the path of the file will be moved to * @param string $destFolder the path of destination folder * @return string */ function getNextAvailableFileName($fileToMove, $destFolder) { $folderPath = addslashes(backslashToSlash(getParentPath($fileToMove))); $destFolder = addslashes(backslashToSlash(getParentPath($destFolder))); $finalPath = $destFolder . basename($fileToMove); if (file_exists($fileToMove)) { if (is_file()) { $fileExt = getFileExt($fileToMove); $fileBaseName = basename($fileToMove, '.' . $fileExt); $count = 1; while (file_exists($destFolder . $fileBaseName . $count . "." . $fileExt)) { $count++; } $filePath = $destFolder . $fileBaseName . $count . "." . $fileExt; } elseif (is_dir()) { $folderName = basename($fileToMove); $count = 1; while (file_exists($destFolder . $folderName . $count)) { $count++; } $filePath = $destFolder . $fileBaseName . $count; } } return $finalPath; }
$error = IMG_UNDO_COPY_FAILED; } else { //remove the session image if (@unlink($sessionImage)) { $history->restore(); } //only one left, remove the session original if demo if ($history->getNumRestorable() == 0 && CONFIG_SYS_DEMO_ENABLE && sizeof($originalSessionImageInfo)) { @unlink($session->getSessionDir() . $originalSessionImageInfo['info']['name']); $originalImage = $_POST['file_path']; } } $imagePath = $originalImage; } else { $error = IMG_SAVE_IMG_OPEN_FAILED; } if (isset($imageInfo)) { $info .= ",width:" . $imageInfo['width'] . "\n"; $info .= ",height:" . $imageInfo['height'] . "\n"; $info .= ",size:'" . transformFileSize($imageInfo['size']) . "'\n"; $info .= ",path:'" . backslashToSlash($imagePath) . "'\n"; } } } echo "error:'" . $error . "'\n"; if (isset($image) && is_object($image)) { $image->DestroyImages(); } echo $info; echo ",history:" . $history->getNumRestorable() . "\n"; echo "}";
if (!defined('_PS_ADMIN_DIR_')) { define('_PS_ADMIN_DIR_', getcwd() . '/../'); } require_once _PS_ADMIN_DIR_ . '/../config/config.inc.php'; require_once _PS_ADMIN_DIR_ . '/init.php'; /** * ajax save name * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn) * @link www.phpletter.com * @since 22/May/2007 * */ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php"; $error = ''; $path = addTrailingSlash(backslashToSlash($_POST['folder'])) . $_POST['name']; if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_EDITABLE) { $error = SYS_DISABLED; } elseif (isset($_POST['save_as_request'])) { if (!preg_match('/^[a-zA-Z0-9_\\-.]+$/', $_POST['name'])) { $error = TXT_SAVE_AS_ERR_NAME_INVALID; } elseif (array_search(strtolower(getFileExt($_POST['name'])), getValidTextEditorExts()) === false) { $error = TXT_DISALLOWED_EXT; } elseif (!isUnderRoot($_POST['folder'])) { $error = ERR_FOLDER_PATH_NOT_ALLOWED; } else { if (!empty($_POST['save_as_request'])) { //save as request if (file_exists($path)) { $error = TXT_FILE_EXIST; } else {
if (!file_exists($_GET['delete'])) { $error = ERR_FILE_NOT_AVAILABLE; } elseif (!isUnderRoot($_GET['delete'])) { $error = ERR_FOLDER_PATH_NOT_ALLOWED; } else { include_once CLASS_FILE; $file = new file(); if (is_dir($_GET['delete']) && isValidPattern(CONFIG_SYS_INC_DIR_PATTERN, getBaseName($_GET['delete'])) && !isInvalidPattern(CONFIG_SYS_EXC_DIR_PATTERN, getBaseName($_GET['delete']))) { $file->delete(addTrailingSlash(backslashToSlash($_GET['delete']))); } elseif (is_file($_GET['delete']) && isValidPattern(CONFIG_SYS_INC_FILE_PATTERN, getBaseName($_GET['delete'])) && !isInvalidPattern(CONFIG_SYS_EXC_FILE_PATTERN, getBaseName($_GET['delete']))) { $file->delete($_GET['delete']); } } } else { if (!isset($_POST['selectedDoc']) || !is_array($_POST['selectedDoc']) || sizeof($_POST['selectedDoc']) < 1) { $error = ERR_NOT_FILE_SELECTED; } else { include_once CLASS_FILE; $file = new file(); foreach ($_POST['selectedDoc'] as $doc) { if (file_exists($doc) && isUnderRoot($doc)) { if (is_dir($doc) && isValidPattern(CONFIG_SYS_INC_DIR_PATTERN, $doc) && !isInvalidPattern(CONFIG_SYS_EXC_DIR_PATTERN, $doc)) { $file->delete(addTrailingSlash(backslashToSlash($doc))); } elseif (is_file($doc) && isValidPattern(CONFIG_SYS_INC_FILE_PATTERN, $doc) && !isInvalidPattern(CONFIG_SYS_EXC_FILE_PATTERN, $doc)) { $file->delete($doc); } } } } } echo "{error:'" . $error . "'}";
$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'] = addslashes(backslashToSlash($path)); $tem['type'] = "file"; $tem['size'] = transformFileSize($tem['size']); $tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']); $tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']); $tem['short_name'] = shortenFileName($tem['name']); $tem['flag'] = 'noFlag'; $obj->close(); foreach ($tem as $k => $v) { $info .= sprintf(", %s:'%s'", $k, $v); } $info .= sprintf(", url:'%s'", addslashes(getFileUrl($path))); $info .= sprintf(", tipedit:'%s'", TIP_DOC_RENAME); } else { $error = ERR_FILE_NOT_AVAILABLE; }