Base Path

@param string $file
@return string
503324
public function basePath($file = '')
    {
        $basePath = dirname($_SERVER['PHP_SELF']);
        if ($basePath != '/') {
            $basePath .= '/';
        }

        if (! empty($file)) {
            $basePath.= ltrim($file, '/');
        }

        return $basePath;
    }
112867
public function getPath($id, $file = null)
    {
        if (is_null($file)) {
            return sprintf('%s/%s/', $this->baseDir, $id);
        } else {
            return sprintf('%s/%s/%s', $this->baseDir, $id, $file);
        }
    }
286618
public static function uploadsInternal($file = null)
    {
        return base_path(
            self::appendToPath(
                self::appendToPath(config('pxlcms.paths.base_internal'), config('pxlcms.paths.files')),
                $file
            )
        );
    }
949234
public function basePath($path = null) {
		$route = str_replace('.php', '', trim(Router::$route->route, '/'));

		$url_path = "//".Server::getName();
		$dir = ($route == 'install' || $route == 'update')?'vcs':'themes';
		$theme = ($route != 'install' && $route != 'update')?($this->getTheme().'/'):'';
		$file_path = '/'."$dir/".$theme."$path";

		return $url_path.(($path)?$file_path:'');
	}
305010
public function getPath($file)
    {
        $file = "/".ltrim($file,"/");

        $best = null;
        foreach($this->nodes as $node) {
            $mount = $node->getMountPoint();
            if (strncmp($mount, $file, strlen($mount)) === 0) {
                $nodefile = substr($file, strlen($mount));
                //printf("nodefile=%s mount=%s file=%s\n", $nodefile, $mount, $file);
                if ($node->has($nodefile)) {
                    return $node->getPath($nodefile);
                }
                if (!$best) {
                    $best = $node->getPath($nodefile);
                }
                if ($node->getIsWritable($nodefile)) {
                    $best = $node->getPath($nodefile);
                }
            }
        }
        return $best;

    }
372359
public static function extension($file = false) {

        if ($file && self::isFile($file)) {

            return pathinfo($file, PATHINFO_EXTENSION);
        }

        return false;
    }
421111
public static function storage_path(?string $file = null)
  {
    $file = (substr($file, 0, 1) == DIRECTORY_SEPARATOR ? substr($file, 1) : $file);
    return config('app.dir') . 'storage' . DIRECTORY_SEPARATOR . $file;
  }
933462
public static function pathInfo($file)
    {
        $result = self::_pathInfo($file);
        return self::i()->dump($result, '! pathInfo (' . $file . ') !');
    }
134220
public function basePath($basePath = null)
    {
        if (!func_num_args()) {
            return $this->_basePath;
        }
        $this->_basePathTmp = $basePath;
        if ($this->_ignorePath) {
            $basePath = preg_replace($this->_ignorePath, '', $basePath);
        }
        $this->_basePath = $basePath && $basePath !== '/' ? '/' . trim($basePath, '/') : '';
        return $this;
    }
1025345
public function baseFile($file = null)
    {
        if (!is_null($file) && true !== $file) {
            $this->baseFile = $file;
            return $this;
        } elseif (!$this->baseFile) {
            $url = '';
            if (!$this->isCli()) {
                $script_name = basename($_SERVER['SCRIPT_FILENAME']);
                if (basename($_SERVER['SCRIPT_NAME']) === $script_name) {
                    $url = $_SERVER['SCRIPT_NAME'];
                } elseif (basename($_SERVER['PHP_SELF']) === $script_name) {
                    $url = $_SERVER['PHP_SELF'];
                } elseif (isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === $script_name) {
                    $url = $_SERVER['ORIG_SCRIPT_NAME'];
                } elseif (($pos = strpos($_SERVER['PHP_SELF'], '/' . $script_name)) !== false) {
                    $url = substr($_SERVER['SCRIPT_NAME'], 0, $pos) . '/' . $script_name;
                } elseif (isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'], $_SERVER['DOCUMENT_ROOT']) === 0) {
                    $url = str_replace('\\', '/', str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME']));
                }
            }
            $this->baseFile = $url;
        }
        return true === $file ? $this->domain() . $this->baseFile : $this->baseFile;
    }
825059
public function webroot($file)
    {
        $request = $this->_View->getRequest();

        $asset = explode('?', $file);
        $asset[1] = isset($asset[1]) ? '?' . $asset[1] : null;
        $webPath = $request->getAttribute('webroot') . $asset[0];
        $file = $asset[0];

        if (!empty($this->_View->getTheme())) {
            $file = trim($file, '/');
            $theme = $this->_inflectThemeName($this->_View->getTheme()) . '/';

            if (DIRECTORY_SEPARATOR === '\\') {
                $file = str_replace('/', '\\', $file);
            }

            if (file_exists(Configure::read('App.wwwRoot') . $theme . $file)) {
                $webPath = $request->getAttribute('webroot') . $theme . $asset[0];
            } else {
                $themePath = Plugin::path($this->_View->getTheme());
                $path = $themePath . 'webroot/' . $file;
                if (file_exists($path)) {
                    $webPath = $request->getAttribute('webroot') . $theme . $asset[0];
                }
            }
        }
        if (strpos($webPath, '//') !== false) {
            return str_replace('//', '/', $webPath . $asset[1]);
        }

        return $webPath . $asset[1];
    }
184358
public function path($file = '', $theme = null)
    {
        if (is_null($theme)) {
            $theme = $this->getCurrent();
        }

        $theme = $this->format($theme);

        return base_path("themes/{$theme}/{$file}");
    }
484474
public static function compassResolvePath($file)
	{
		if ($file{0}=='/') {
			return $file;
			}
		if (!$path=realpath($file)) {
			$path=\PHPSass\Script\ScriptFunction::$context->node->token->filename;
			$path=substr($path, 0, strrpos($path, '/')).'/';
			$path=$path.$file;
			$last='';
			while ($path!=$last) {
				$last=$path;
				$path=preg_replace('`(^|/)(?!\.\./)([^/]+)/\.\./`', '$1', $path);
				}
			$path=realpath($path);
			}
		if ($path) {
			return $path;
			}

		return FALSE;
	}
504737
public function path($filename)
    {
        if (preg_match('~^' . $this->base_directory . '~', $filename)) {
            return $filename;
        }

        return rtrim($this->base_directory, '/') . '/' . ltrim($filename, '/');
    }
499713
public static function _getExtension ($file)
	{
		
		// Get Extension
		
		$base	= basename ($file);
		$arr	= explode ('.', $base);
		$ext	= strtolower (array_pop ($arr));
		
		// Return the extension
		
		return $ext;
		
	}
10623
private function realpath($path)
    {
        if (substr($path, 0, 1) === '/' || substr($path, 1, 1) === ':') {
            return $path;
        }

        return $this->baseDir . '/' . $path;
    }
1142250
public function realPath($file)
    {
        $path = parent::realPath($file);

        if($base = $this->getBasePath())
        {
            if(strpos($file, $base) !== 0) {
                return false;
            }
        }

        return $path;
    }