/** * Return the filesystem absolute path for the relative or absolute URI path. * * Takes the ['Aliases'] mapping array into account; it is processed from top to bottom a la mod_alias. * * Note: as it uses normalize(), any illegal path will throw an FileManagerException * * Returns a fully normalized filesystem absolute path. */ public function url_path2file_path($url_path) { $url_path = $this->rel2abs_url_path($url_path); $replaced_some = false; if (is_array($this->options['Aliases'])) { $alias_arr = $this->options['Aliases']; foreach ($alias_arr as $a_url => $a_path) { // if the uri path matches us (or at least our start), then apply the mapping. // Make sure to only match entire path elements: if (FileManagerUtility::startsWith($url_path . '/', $a_url . '/')) { $url_path = $a_path . substr($url_path, strlen($a_url)); $replaced_some = true; } } } if (!$replaced_some) { $url_path = parent::url_path2file_path($url_path); } return $url_path; }
public function getAllowedMimeTypes($mime_filter = null) { $mimeTypes = array(); if (empty($mime_filter)) { return null; } $mset = explode(',', $mime_filter); for ($i = count($mset) - 1; $i >= 0; $i--) { if (strpos($mset[$i], '/') === false) { $mset[$i] .= '/'; } } $mimes = $this->getMimeTypeDefinitions(); foreach ($mimes as $k => $mime) { if ($k === '.') { continue; } foreach ($mset as $filter) { if (FileManagerUtility::startsWith($mime, $filter)) { $mimeTypes[] = $mime; } } } return $mimeTypes; }
protected function getAllowedMimeTypes() { $filter = $this->options['filter']; if (!$filter) { return null; } if (!FileManagerUtility::endsWith($filter, '/')) { return array($filter); } static $mimes; if (!$mimes) { $mimes = parse_ini_file($this->options['mimeTypesPath']); } foreach ($mimes as $mime) { if (FileManagerUtility::startsWith($mime, $filter)) { $mimeTypes[] = strtolower($mime); } } return $mimeTypes; }
public static function getRealPath($path) { $path = str_replace('\\', '/', $path); $path = preg_replace('#/+#', '/', $path); $path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $path); $path = FileManagerUtility::startsWith($path, '/') ? $_SERVER['DOCUMENT_ROOT'] . $path : $path; $path = FileManagerUtility::startsWith($path, '../') || !FileManagerUtility::startsWith($path, '/') ? realPath($path) : $path; $path = str_replace('\\', '/', $path); $path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $path); $path = FileManagerUtility::endsWith($path, '/') ? $path : $path . '/'; return $path; }