/** * Creates a new absolute file. * * @param FileFactory $file_factory File factory reference. * @param String $absolute_path Absolute path to local file. * @param String $child_name Name of child file (Optional). * @param String $type Optional file type. */ function LocalFileImpl(&$file_factory, $absolute_path, $child_name = "", $type = MC_IS_FILE) { $this->_fileFactory =& $file_factory; $this->_type = $type; if ($child_name != "") { $this->_absPath = removeTrailingSlash($absolute_path) . "/" . $child_name; } else { $this->_absPath = $absolute_path; } }
function addTrailingSlash($string) { return removeTrailingSlash($string) . '/'; }
$error = ERR_RENAME_EXISTS; } elseif (is_file($_POST['original_path']) && !isValidExt($_POST['name'], explode(",", CONFIG_UPLOAD_VALID_EXTS), explode(",", CONFIG_UPLOAD_INVALID_EXTS))) { $error = ERR_RENAME_FILE_TYPE_NOT_PERMITED; } elseif (!rename(removeTrailingSlash($_POST['original_path']), addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name'])) { $error = ERR_RENAME_FAILED; } else { //update record of session if image exists in session for cut or copy 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']);
private function repositoriesAreTheSame($repository) { return removeTrailingSlash($repository) == $this->getRepositoryUrl(); }
/** * Get repository full URL * * @return string */ public function getRepositoryUrl() { return removeTrailingSlash($this->payload->repository->url); }
/** * get the list of folder under a specified folder * which will be used for drop-down menu * @param string $path the path of the specified folder * @param array $outputs * @param string $indexNumber * @param string $prefixNumber the prefix before the index number * @param string $prefixName the prefix before the folder name * @return array */ function getFolderListing($path,$indexNumber=null, $prefixNumber =' ', $prefixName =' - ', $outputs=array()) { $path = removeTrailingSlash(backslashToSlash($path)); if(is_null($indexNumber)) { $outputs[IMG_LBL_ROOT_FOLDER] = removeTrailingSlash(backslashToSlash($path)); } $fh = @opendir($path); if($fh) { $count = 1; while($file = @readdir($fh)) { $newPath = removeTrailingSlash(backslashToSlash($path . "/" . $file)); if(isListingDocument($newPath) && $file != '.' && $file != '..' && is_dir($newPath)) { if(!empty($indexNumber)) {//this is not root folder $outputs[$prefixNumber . $indexNumber . "." . $count . $prefixName . $file] = $newPath; getFolderListing($newPath, $prefixNumber . $indexNumber . "." . $count , $prefixNumber, $prefixName, $outputs); }else {//this is root folder $outputs[$count . $prefixName . $file] = $newPath; getFolderListing($newPath, $count, $prefixNumber, $prefixName, $outputs); } $count++; } } @closedir($fh); } return $outputs; }
/** * Copy a file, or recursively copy a folder and its contents * @author Aidan Lister <*****@*****.**> * @author Paul Scott * @version 1.0.1 * @param string $source Source path * @param string $dest Destination path * @return bool Returns TRUE on success, FALSE on failure */ function copyTo($source, $dest) { $source = removeTrailingSlash(backslashToSlash($source)); $dest = removeTrailingSlash(backslashToSlash($dest)); if (!file_exists($dest) || !is_dir($dest)) { if (!$this->mkdir($dest)) { $this->_debug('Unable to create folder (' . $dest . ")"); return false; } } // Copy in to your self? if (getAbsPath($source) == getAbsPath($dest)) { $this->_debug('Unable to copy itself. source: ' . getAbsPath($source) . "; dest: " . getAbsPath($dest)); return false; } // Simple copy for a file if (is_file($source)) { $dest = addTrailingSlash($dest) . basename($source); if (file_exists($dest)) { return false; } else { return copy($source, $dest); } } elseif (is_dir($source)) { // Loop through the folder if (file_exists(addTrailingSlash($dest) . basename($source))) { return false; } else { if (!file_exists(addTrailingSlash($dest) . basename($source)) || !is_dir(addTrailingSlash($dest) . basename($source))) { if (!$this->mkdir(addTrailingSlash($dest) . basename($source))) { $this->_debug('Unable to create folder (' . addTrailingSlash($dest) . basename($source) . ")"); return false; } } $handle = opendir($source); while (false !== ($readdir = readdir($handle))) { if ($readdir != '.' && $readdir != '..') { $path = addTrailingSlash($source) . '/' . $readdir; $this->copyTo($path, addTrailingSlash($dest) . basename($source)); } } closedir($handle); return true; } } return false; }
<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
$fileCount = 0; $dirCount = 0; $sizeSum = 0; foreach ($files as $file) { if ($file->isFile()) { $fileCount++; } else { $dirCount++; } $sizeSum += $file->length(); } $data['files'] = $fileCount; $data['subdirs'] = $dirCount; $data['filessize'] = getSizeStr($sizeSum); } else { $path = $file->getAbsolutePath(); $wwwroot = removeTrailingSlash(toUnixPath(getWWWRoot($config))); $urlprefix = removeTrailingSlash(toUnixPath($config['preview.urlprefix'])); $urlsuffix = toUnixPath($config['preview.urlsuffix']); $pos = strpos($path, $wwwroot); if ($pos !== false && $pos == 0) { $data['previewurl'] = $urlprefix . substr($path, strlen($wwwroot)) . $urlsuffix; } } // Redirect if ($redirect == "true") { header('location: ' . $data['previewurl']); die; } // Render output renderPage("preview.tpl.php", $data);
function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { $path = removeTrailingSlash($this->fixPath($path)); if (empty($path)) { return false; } return $this->link->mkdir($path); }
} if ($exists && $overwrite == "yes") { $fileObject->delete(); $zip->extract(PCLZIP_OPT_PATH, $targetFile->getAbsolutePath(), PCLZIP_OPT_BY_NAME, $file['filename']); } else { if (!$exists) { $zip->extract(PCLZIP_OPT_PATH, $isDir ? $targetFile->getAbsolutePath() : $targetFile->getAbsolutePath(), PCLZIP_OPT_BY_NAME, $file['filename']); } } } } } // Check what changed foreach ($zipcontents as $filecheck) { $isDir = $filecheck['folder'] == 1 ? true : false; $absolutefilepath = removeTrailingSlash(toUnixPath($targetFile->getAbsolutePath() . "/" . $filecheck['filename'])); $filecheckObj = $fileFactory->getFile($absolutefilepath, "", $isDir ? MC_IS_DIRECTORY : MC_IS_FILE); // Default status message $filecheck['status_message'] = "Passed"; if ($filecheck['status'] == "Accepted") { if ($filecheck['exists'] == "No") { if ($filecheckObj->exists()) { $filecheckObj->importFile(); $filecheck['status'] = "Passed"; $filecheck['exists'] = "Yes"; $itemsresult[] = $filecheck; } else { $filecheck['status'] = "Failed"; $filecheck['status_message'] = "Unzip operation failed, file was not unzipped."; $itemsresult[] = $filecheck; }
} // File info $fileType = getFileType($file->getAbsolutePath()); $fileItem['icon'] = $fileType['icon']; $fileItem['type'] = $fileType['type']; $even = !$even; $fileList[] = $fileItem; } $data['files'] = $fileList; $data['path'] = $path; $data['hasReadAccess'] = $targetFile->canRead() && checkBool($config["filesystem.readable"]) ? "true" : "false"; $data['hasWriteAccess'] = $targetFile->canWrite() && checkBool($config["filesystem.writable"]) ? "true" : "false"; $data['hasPasteData'] = isset($_SESSION['MCFileManager_clipboardAction']) ? "true" : "false"; $toolsCommands = explode(',', $config['general.tools']); $newTools = array(); foreach ($toolsCommands as $command) { foreach ($tools as $tool) { if ($tool['command'] == $command) { $newTools[] = $tool; } } } $data['disabled_tools'] = $config['general.disabled_tools']; $data['tools'] = $newTools; $data['short_path'] = getUserFriendlyPath($path); $data['full_path'] = getUserFriendlyPath($path); $data['errorMsg'] = $errorMsg; $data['action'] = $action; $data['imageManagerURLPrefix'] = removeTrailingSlash($config['imagemanager.urlprefix']); // Render output renderPage("filelist.tpl.php", $data, $config);
/** * Returns the user path, the path that the users sees. * * @param String $path Absolute file path. * @return String Visual path, user friendly path. */ function getUserFriendlyPath($path, $max_len = -1) { global $mcImageManagerConfig; if (checkBool($mcImageManagerConfig['general.user_friendly_paths'])) { $path = substr($path, strlen(removeTrailingSlash(getRealPath($mcImageManagerConfig, 'filesystem.rootpath')))); if ($path == "") { $path = "/"; } } if ($max_len != -1 && strlen($path) > $max_len) { $path = "... " . substr($path, strlen($path) - $max_len); } // Add slash in front if (strlen($path) > 0 && $path[0] != '/') { $path = "/" . $path; } return $path; }
/** * This function should not be called directly, use unzip_file instead. Attempts to unzip an archive using the PclZip library. * * @since 3.0.0 * @see unzip_file * @access private * * @param string $file Full path and filename of zip archive * @param string $to Full path on the filesystem to extract archive to * @param array $neededDirs A partial list of required folders needed to be created. * @return mixed WP_Error on failure, True on success */ function pclZipUnZip($file, $to, $neededDirs = array()) { //global $GLOBALS['FileSystemObj']; // See #15789 - PclZip uses string functions on binary data, If it's overloaded with Multibyte safe functions the results are incorrect. if (ini_get('mbstring.func_overload') && function_exists('mb_internal_encoding')) { $previous_encoding = mb_internal_encoding(); mb_internal_encoding('ISO-8859-1'); } require_once APP_ROOT . '/lib/pclzip.php'; $archive = new PclZip($file); $archive_files = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING); if (isset($previous_encoding)) { mb_internal_encoding($previous_encoding); } // Is the archive valid? if (!is_array($archive_files)) { //return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true)); appUpdateMsg('Incompatible Archive ' . $archive->errorInfo(true), true); return false; } if (0 == count($archive_files)) { //return new WP_Error('empty_archive', __('Empty archive.')); appUpdateMsg('Empty archive', true); return false; } // Determine any children directories needed (From within the archive) foreach ($archive_files as $file) { if ('__MACOSX/' === substr($file['filename'], 0, 9)) { // Skip the OS X-created __MACOSX directory continue; } $neededDirs[] = $to . removeTrailingSlash($file['folder'] ? $file['filename'] : dirname($file['filename'])); } $neededDirs = array_unique($neededDirs); foreach ($neededDirs as $dir) { // Check the parent folders of the folders all exist within the creation array. if (removeTrailingSlash($to) == $dir) { // Skip over the working directory, We know this exists (or will exist) continue; } if (strpos($dir, $to) === false) { // If the directory is not within the working directory, Skip it continue; } $parentFolder = dirname($dir); while (!empty($parentFolder) && removeTrailingSlash($to) != $parentFolder && !in_array($parentFolder, $neededDirs)) { $neededDirs[] = $parentFolder; $parentFolder = dirname($parentFolder); } } asort($neededDirs); // Create those directories if need be: foreach ($neededDirs as $_dir) { if (!$GLOBALS['FileSystemObj']->mkDir($_dir, FS_CHMOD_DIR) && !$GLOBALS['FileSystemObj']->isDir($_dir)) { // Only check to see if the dir exists upon creation failure. Less I/O this way. //return new WP_Error('mkdir_failed', __('Could not create directory.'), $_dir); appUpdateMsg('Could not create directory while unzipping(pclZip) ' . $_dir, true); return false; } } unset($neededDirs); // Extract the files from the zip foreach ($archive_files as $file) { if ($file['folder']) { continue; } if ('__MACOSX/' === substr($file['filename'], 0, 9)) { // Don't extract the OS X-created __MACOSX directory files continue; } if (!$GLOBALS['FileSystemObj']->putContents($to . $file['filename'], $file['content'], FS_CHMOD_FILE)) { //return new WP_Error('copy_failed', __('Could not copy file.'), $to . $file['filename']); appUpdateMsg('Could not copy file ' . $to . $file['filename'], true); return false; } } return true; }
/** * Get repository full URL * * @return string */ public function getRepositoryUrl() { return removeTrailingSlash($this->payload->canon_url . $this->payload->repository->absolute_url); }
<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()
/** * Returns a new file instance of a absolute path. * * @param String $abs_path Absolute file path. * @param String $file_name Optional file name. * @param String $type Optional file type. * @return File File object instance based on absolute path. */ function &getFile($abs_path, $file_name = "", $type = MC_IS_FILE) { $rootPath = removeTrailingSlash(toUnixPath(getRealPath($this->_config, 'filesystem.rootpath'))); if (!$this->verifyPath($abs_path)) { trigger_error("Trying to get out of defined root path. Root: " . $rootPath . ", Path: " . $abs_path, E_USER_ERROR); die; } // Fix the absolute path $abs_path = removeTrailingSlash(toUnixPath($abs_path)); $abs_path = $abs_path == "" ? "/" : $abs_path; $file =& new $this->_config['filesystem']($this, $abs_path, $file_name, $type); return $file; }
<?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
function mkDir($path, $chmod = false, $chown = false, $chgrp = false) { $path = removeTrailingSlash($path); if (empty($path)) { return false; } if (!@ftp_mkdir($this->link, $path)) { return false; } $this->chmod($path, $chmod); if ($chown) { $this->chown($path, $chown); } if ($chgrp) { $this->chgrp($path, $chgrp); } return true; }
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>
$orgHeight = getRequestParam("orgheight"); $newWidth = getRequestParam("newwidth"); $newHeight = getRequestParam("newheight"); $left = getRequestParam("left"); $top = getRequestParam("top"); $action = getRequestParam("action"); $path = getRequestParam("path"); $orgpath = getRequestParam("orgpath", ""); $filename = getRequestParam("filename", ""); $msg = ""; if ($orgpath == "") { $orgpath = $path; } $temp_image = "mcic_" . session_id() . ""; verifyAccess($mcImageManagerConfig); $rootpath = removeTrailingSlash(getRequestParam("rootpath", toUnixPath(getRealPath($mcImageManagerConfig, 'filesystem.rootpath')))); $fileFactory =& new FileFactory($mcImageManagerConfig, $rootPath); addFileEventListeners($fileFactory); $file =& $fileFactory->getFile($path); $config = $file->getConfig(); $demo = checkBool($config['general.demo']) ? "true" : "false"; $imageutils = new $config['thumbnail'](); $tools = explode(',', $config['thumbnail.image_tools']); if (!in_array("edit", $tools)) { trigger_error("The thumbnail.image_tools needs to include edit.", WARNING); } // File info $fileInfo = getFileType($file->getAbsolutePath()); $file_icon = $fileInfo['icon']; $file_type = $fileInfo['type']; $file_ext = $fileInfo['ext'];
$imageTools = array(); $imageTools = explode(',', $config['thumbnail.image_tools']); $information = array(); $information = explode(',', $config['thumbnail.information']); $data['js'] = getRequestParam("js", ""); $data['formname'] = getRequestParam("formname", ""); $data['elementnames'] = getRequestParam("elementnames", ""); $data['disabled_tools'] = $config['general.disabled_tools']; $data['image_tools'] = $imageTools; $data['toolbar'] = $tools; $data['full_path'] = $path; $data['root_path'] = $rootpath; $data['errorMsg'] = "dfdf"; //addslashes($errorMsg); $data['selectedPath'] = $selectedPath; $data['dirlist'] = $dirList; $data['anchor'] = $anchor; $data['exif_support'] = exifExists(); $data['gd_support'] = $isGD; $data['edit_enabled'] = checkBool($config["thumbnail.gd.enabled"]); $data['demo'] = checkBool($config["general.demo"]); $data['demo_msg'] = $config["general.demo_msg"]; $data['information'] = $information; $data['extension_image'] = checkBool($config["thumbnail.extension_image"]); $data['insert'] = checkBool($config["thumbnail.insert"]); $data['filemanager_urlprefix'] = removeTrailingSlash($config["filemanager.urlprefix"]); $data['thumbnail_width'] = $config['thumbnail.width']; $data['thumbnail_height'] = $config['thumbnail.height']; $data['thumbnail_border_style'] = $config['thumbnail.border_style']; $data['thumbnail_margin_around'] = $config['thumbnail.margin_around']; renderPage("images.tpl.php", $data);
function mkDir($path, $chmod = false, $chown = false, $chgrp = false) { // safe mode fails with a trailing slash under certain PHP versions. $path = removeTrailingSlash($path); if (empty($path)) { return false; } if (!$chmod) { $chmod = FS_CHMOD_DIR; } if (!@mkdir($path)) { return false; } $this->chmod($path, $chmod); if ($chown) { $this->chown($path, $chown); } if ($chgrp) { $this->chgrp($path, $chgrp); } return true; }