$fileItem['name'] = basename($file->getAbsolutePath()); $fileItem['path'] = $file->getAbsolutePath(); $fileItem['modificationdate'] = date($config['filesystem.datefmt'], $file->lastModified()); $fileItem['even'] = $even; $fileItem['hasReadAccess'] = $file->canRead() && checkBool($config["filesystem.readable"]) ? "true" : "false"; $fileItem['hasWriteAccess'] = $file->canWrite() && checkBool($config["filesystem.writable"]) ? "true" : "false"; // File info $fileType = getFileType($file->getAbsolutePath()); $fileItem['icon'] = $fileType['icon']; $fileItem['type'] = $fileType['type']; $fileItem['ext'] = $fileType['ext']; $fileItem['editable'] = $isGD && ($fileType['ext'] == "gif" || $fileType['ext'] == "jpg" || $fileType['ext'] == "jpeg" || $fileType['ext'] == "png"); // Preview path $wwwroot = removeTrailingSlash(toUnixPath(getWWWRoot($config))); $urlprefix = removeTrailingSlash(toUnixPath($config['preview.urlprefix'])); $urlsuffix = toUnixPath($config['preview.urlsuffix']); $fileItem['previewurl'] = ""; $pos = strpos($filepath, $wwwroot); if ($pos !== false && $pos == 0) { $fileItem['previewurl'] = $urlprefix . substr($filepath, strlen($wwwroot)) . $urlsuffix; } else { $fileItem['previewurl'] = "ERROR IN PATH"; } if ($fileItem['editable'] == true and checkBool($config['thumbnail.gd.enabled']) == true) { $fileItem['url'] = "thumbnail.php?path=" . $fileItem['path'] . "&width=" . $fileItem['width'] . "&height=" . $fileItem['height'] . "&ext=" . $fileItem['ext']; } else { $fileItem['url'] = $fileItem['previewurl']; } $even = !$even; $fileList[] = $fileItem; }
$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'];
/** * fileprops.php * * @package MCFileManager.pages * @author Moxiecode * @copyright Copyright © 2005, Moxiecode Systems AB, All rights reserved. */ require_once "includes/general.php"; require_once "classes/FileSystems/FileFactory.php"; require_once "classes/FileSystems/LocalFileImpl.php"; require_once "classes/pclzip/pclzip.lib.php"; $data = array(); verifyAccess($mcFileManagerConfig); $path = getRequestParam("path", ""); $rootpath = getRequestParam("rootpath", toUnixPath(getRealPath($mcFileManagerConfig, 'filesystem.rootpath'))); $fileFactory =& new FileFactory($mcFileManagerConfig, $rootpath); $targetFile =& $fileFactory->getFile($path); $config = $targetFile->getConfig(); addFileEventListeners($fileFactory); $filename = getRequestParam("filename", false); $submitted = getRequestParam("submitted", false); $data['path'] = $path; $data['submitted'] = $submitted; $data['short_path'] = getUserFriendlyPath($path, 30); $data['full_path'] = getUserFriendlyPath($path); $data['errorMsg'] = ""; $data['filename'] = ""; $data['demo'] = checkBool($config['general.demo']) ? "true" : "false"; $data['demo_msg'] = $config['general.demo_msg']; // Create zip
/** * Returns a merged name/value array of config elements. * * @return Array Merged name/value array of config elements. */ function getConfig() { $globalConf = $this->_fileFactory->getConfig(); $rootpath = $this->_fileFactory->getRootPath(); // Not cached config if (!$this->_config) { $localConfig = array(); $this->_config = $globalConf; // Get files up the tree $accessFiles = array(); $file =& $this; if ($file->isFile()) { $file =& $file->getParentFile(); } while ($file->exists() && $file->getAbsolutePath() != "/") { $accessFile =& new LocalFileImpl($this->_fileFactory, $file->getAbsolutePath(), $globalConf["filesystem.local.access_file_name"]); if ($accessFile->exists()) { $accessFiles[] = $accessFile; } if (strpos(strtolower(toOSPath($file->getParent())), strtolower(toOSPath($rootpath))) === false) { break; } $file =& $file->getParentFile(); } // Parse and merge $allowoverrideKeys = array(); foreach ($this->_config as $key => $value) { $keyChunks = explode('.', $key); if ($keyChunks[count($keyChunks) - 1] == "allow_override") { foreach (explode(',', $value) as $keySuffix) { $keyChunks[count($keyChunks) - 1] = $keySuffix; $allowoverrideKeys[] = implode('.', $keyChunks); } } } foreach (array_reverse($accessFiles) as $accessFile) { $config = array(); // Parse ini file if ($fp = fopen(toOSPath($accessFile->getAbsolutePath()), "r")) { while (!feof($fp)) { $line = trim(fgets($fp)); // Skip comments if (substr($line, 0, 1) == "#") { continue; } // Split rows if (($pos = strpos($line, "=")) !== FALSE) { $config[substr($line, 0, $pos)] = substr($line, $pos + 1); } } fclose($fp); } // Handle local config values $curDir = $this->isFile() ? $this->getParent() : $this->getAbsolutePath(); if ($accessFile->getParent() == $curDir) { foreach ($config as $key => $value) { if (substr($key, 0, 1) == '_') { $localConfig[substr($key, 1)] = $value; } } } // Parse allow keys and deny keys $denyOverrideKeys = array(); foreach ($config as $key => $value) { $keyChunks = explode('.', $key); $lastChunk = $keyChunks[count($keyChunks) - 1]; if ($lastChunk == "allow_override" || $lastChunk == "deny_override") { foreach (explode(',', $value) as $keySuffix) { $keyChunks[count($keyChunks) - 1] = $keySuffix; $allowDenyKey = implode('.', $keyChunks); if (in_array($allowDenyKey, $allowoverrideKeys)) { if ($lastChunk == "allow_override") { $allowoverrideKeys[] = $allowDenyKey; } else { $denyOverrideKeys[] = $allowDenyKey; } } } } } // Remove the denied keys from the allow list /* foreach ($denyOverrideKeys as $denyKey) { for ($i=0; $i<count($allowoverrideKeys); $i++) { if ($denyKey == $allowoverrideKeys[$i]) unset($allowoverrideKeys[$i]); } }*/ // Add all overriden values foreach ($config as $key => $value) { $validAllKey = false; foreach ($allowoverrideKeys as $allowkey) { if (strpos($allowkey, "*") > 0) { $allowkey = str_replace("*", "", $allowkey); // echo $allowkey . "," . $key . strpos($allowkey, $key) . "<br>"; if (strpos($key, $allowkey) === 0) { $validAllKey = true; break; } } } if ((in_array($key, $allowoverrideKeys) || $validAllKey) && !in_array($key, $denyOverrideKeys)) { if (strpos($value, '${') !== false) { $value = str_replace('${configpath}', $accessFile->getParent(), $value); } $this->_config[$key] = $value; } } } // Variable substitute the values foreach ($this->_config as $key => $value) { if (!is_array($value) && strpos($value, '${') !== false) { if ($this->isFile()) { $path = $this->getAbsolutePath(); } else { $path = $this->getParent(); } $this->_config[$key] = str_replace('${path}', $path, $value); $this->_config[$key] = str_replace('${rootpath}', toUnixPath(getRealPath($this->_config, 'filesystem.rootpath')), $value); } } // Force local config foreach ($localConfig as $key => $value) { $this->_config[$key] = $value; } /* foreach ($this->_config as $key => $value) { if (in_array($key, $allowoverrideKeys)) { // Seems to be a variable if (strpos($value, '${') !== false) { $matches = array(); preg_match_all('/\${(.*)}/i', $value, $matches); var_dump($matches); foreach ($matches as $match) $this->_config[$key] = str_replace('${' . $match . '}', $this->_config[$match], $this->_config[$key]); } } }*/ } return $this->_config; }
/** * 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; }
} 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; }
// Invalid path, use root path if (!$fileFactory->verifyPath($path)) { $path = $rootPath; } // Get file and config $targetFile =& $fileFactory->getFile($path); $config = $targetFile->getConfig(); addFileEventListeners($fileFactory); $previewpath = $path; // Get parent dir if path points to a file $fileFactory =& new FileFactory($mcFileManagerConfig, $rootPath); $file =& $fileFactory->getFile($path); if ($file->exists()) { if ($file->isFile()) { $path = $file->getParent(); } $previewpath = $file->getAbsolutePath(); } else { $path = toUnixPath(getRealPath($mcFileManagerConfig, 'filesystem.path')); $previewpath = toUnixPath(getRealPath($mcFileManagerConfig, 'filesystem.path')); } $data['path'] = $path; $data['previewpath'] = $previewpath; $data['previewfilename'] = basename($previewpath); $data['rootpath'] = $rootPath; $data['showpreview'] = checkBool($mcFileManagerConfig['preview']); $data['formname'] = getRequestParam("formname", ""); $data['elementnames'] = getRequestParam("elementnames", ""); $data['js'] = getRequestParam("js", ""); // Render output renderPage("frameset.tpl.php", $data);
/** * Resolves relative path to absolute path. The output path is in unix format. */ function resolvePath($path, $verify = true) { $result = realpath($path); $result = preg_replace("/(\\\\)/", "\\", $result); if ($result == "" && $verify) { trigger_error("Check your rootpath & path config (or other paths), could not resolve path: \"" . $path . "\".", FATAL); } return toUnixPath($result); }