From cf14306c2b3f82a81f8d56669a71633b4d4b5fce Mon Sep 17 00:00:00 2001 From: marvin-borner@live.com Date: Mon, 16 Apr 2018 21:09:05 +0200 Subject: Main merge to user management system - files are now at /main/public/ --- .../path-converter/src/Converter.php | 195 --------------------- 1 file changed, 195 deletions(-) delete mode 100755 assets/php/vendor/matthiasmullie/path-converter/src/Converter.php (limited to 'assets/php/vendor/matthiasmullie/path-converter/src/Converter.php') diff --git a/assets/php/vendor/matthiasmullie/path-converter/src/Converter.php b/assets/php/vendor/matthiasmullie/path-converter/src/Converter.php deleted file mode 100755 index b92b24c..0000000 --- a/assets/php/vendor/matthiasmullie/path-converter/src/Converter.php +++ /dev/null @@ -1,195 +0,0 @@ - - * @copyright Copyright (c) 2015, Matthias Mullie. All rights reserved - * @license MIT License - */ -class Converter implements ConverterInterface -{ - /** - * @var string - */ - protected $from; - - /** - * @var string - */ - protected $to; - - /** - * @param string $from The original base path (directory, not file!) - * @param string $to The new base path (directory, not file!) - */ - public function __construct($from, $to) - { - $shared = $this->shared($from, $to); - if ($shared === '') { - // when both paths have nothing in common, one of them is probably - // absolute while the other is relative - $cwd = getcwd(); - $from = strpos($from, $cwd) === 0 ? $from : $cwd.'/'.$from; - $to = strpos($to, $cwd) === 0 ? $to : $cwd.'/'.$to; - - // or traveling the tree via `..` - // attempt to resolve path, or assume it's fine if it doesn't exist - $from = @realpath($from) ?: $from; - $to = @realpath($to) ?: $to; - } - - $from = $this->dirname($from); - $to = $this->dirname($to); - - $from = $this->normalize($from); - $to = $this->normalize($to); - - $this->from = $from; - $this->to = $to; - } - - /** - * Normalize path. - * - * @param string $path - * - * @return string - */ - protected function normalize($path) - { - // deal with different operating systems' directory structure - $path = rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $path), '/'); - - /* - * Example: - * /home/forkcms/frontend/cache/compiled_templates/../../core/layout/css/../images/img.gif - * to - * /home/forkcms/frontend/core/layout/images/img.gif - */ - do { - $path = preg_replace('/[^\/]+(? $chunk) { - if (isset($path2[$i]) && $path1[$i] == $path2[$i]) { - $shared[] = $chunk; - } else { - break; - } - } - - return implode('/', $shared); - } - - /** - * Convert paths relative from 1 file to another. - * - * E.g. - * ../images/img.gif relative to /home/forkcms/frontend/core/layout/css - * should become: - * ../../core/layout/images/img.gif relative to - * /home/forkcms/frontend/cache/minified_css - * - * @param string $path The relative path that needs to be converted - * - * @return string The new relative path - */ - public function convert($path) - { - // quit early if conversion makes no sense - if ($this->from === $this->to) { - return $path; - } - - $path = $this->normalize($path); - // if we're not dealing with a relative path, just return absolute - if (strpos($path, '/') === 0) { - return $path; - } - - // normalize paths - $path = $this->normalize($this->from.'/'.$path); - - // strip shared ancestor paths - $shared = $this->shared($path, $this->to); - $path = mb_substr($path, mb_strlen($shared)); - $to = mb_substr($this->to, mb_strlen($shared)); - - // add .. for every directory that needs to be traversed to new path - $to = str_repeat('../', mb_substr_count($to, '/')); - - return $to.ltrim($path, '/'); - } - - /** - * Attempt to get the directory name from a path. - * - * @param string $path - * - * @return string - */ - protected function dirname($path) - { - if (@is_file($path)) { - return dirname($path); - } - - if (@is_dir($path)) { - return rtrim($path, '/'); - } - - // no known file/dir, start making assumptions - - // ends in / = dir - if (mb_substr($path, -1) === '/') { - return rtrim($path, '/'); - } - - // has a dot in the name, likely a file - if (preg_match('/.*\..*$/', basename($path)) !== 0) { - return dirname($path); - } - - // you're on your own here! - return $path; - } -} -- cgit v1.2.3