Get the fully resolved path to the application's front controller.

@param  string  $sitePath
@param  string  $siteName
@param  string  $uri
@return string
331931
public function frontControllerPath($sitePath, $siteName, $uri)
    {
        // Needed to force Kirby to use *.dev to generate its URLs...
        $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];

        if (preg_match('/^\/panel/', $uri) && file_exists($sitePath . '/panel/index.php')) {
            $_SERVER['SCRIPT_NAME'] = '/panel/index.php';

            return $sitePath.'/panel/index.php';
        }

        if (file_exists($indexPath = $sitePath.'/index.php')) {
            $_SERVER['SCRIPT_NAME'] = '/index.php';

            return $indexPath;
        }
    }
577569
public static function site(string $site, string $uri = null): string
    {
        $otherSite = Application::getConfig('sites')->get($site);

        if ($otherSite === null) {
            throw new Exception("Unable to construct URL to site={$site}, site is not defined in configs/sites.php");
        }

        if ($uri === null || strlen($uri) === 0) {
            return $otherSite;
        } else {
            if ($uri[0] != '/') {
                $uri = '/' . $uri;
            }

            return $otherSite . $uri;
        }
    }
13098
public static function url(string $path, $uri)
  {
    $path = substr($path, 0, 1) != '/' ? '/' . $path : $path;

    $root = isset($_SERVER["SCRIPT_NAME"]) ? $_SERVER['SCRIPT_NAME'] : '';
    $dir = pathinfo($root)['dirname'];

    if (isset($_SERVER['HTTP_HOST'])) {
      if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
        $http = 'https://';
      } else {
        $http = 'http://';
      }

      $url = $http . $_SERVER['HTTP_HOST'] . ($dir == '/' ? '' : $dir) . $path;
    } else {
      $url = ($uri ? config('app.url') : '') . $path;
    }

    if (isset($_SERVER['QUERY_STRING'])) {
      if (str_contains($url, '?')) $url .= '&' . $_SERVER['QUERY_STRING'];
      if (!str_contains($url, '?')) $url .= '?' . $_SERVER['QUERY_STRING'];
    }

    return $url;
  }
457358
public function getRootApplicationDirectoryPathByFilePath(string $filePath): string
    {
        if ($this->isApplicationRootDefined()) {
            return ${static::CONST_NAME_APPLICATION_ROOT_DIR};
        }

        $vendorPosition = strpos($filePath, 'vendor');

        if ($vendorPosition !== false) {
            return substr($filePath, 0, $vendorPosition);
        }

        $sourcePosition = strpos($filePath, 'src');

        return substr($filePath, 0, $sourcePosition);
    }
1131096
public function getWebPath()
    {
        $webPath = $this->environment->getCurrentEnvironmentConfig()->get('Domain', false);
        if (!$webPath) {
            $webPath = Request::getInstance()->getCurrentUrl(true)->getDomain() . '/';
        }

        return $webPath;
    }
255782
public function isStaticFile($sitePath, $siteName, $uri)
    {
        $frontControllerDirectory = $this->frontControllerDirectory($sitePath);

        if ($this->isActualFile($staticFilePath = $sitePath.'/'.$frontControllerDirectory.$uri)) {
            return $staticFilePath;
        }

        return false;
    }
223078
public static wisite_binding get(nitro_service service, String sitepath) throws Exception{
		wisite_binding obj = new wisite_binding();
		obj.set_sitepath(sitepath);
		wisite_binding response = (wisite_binding) obj.get_resource(service);
		return response;
	}
43932
public function getResourceUrl($pathinfo, Site $site = null)
    {
        return $this->getUri($pathinfo, null, $site, RouteCollection::RESOURCE_URL);
    }
801835
public function getFullPath()
    {
        /** @var Uri $uri */
        $uri = $this->getUri();

        return rtrim($uri->getBasePath(), '/') . '/' . ltrim($uri->getPath(), '/');
    }
888663
private function serveScript($sitePath, $siteName, $uri)
    {
        $docroot = $sitePath . $this->documentRoot;
        $abspath = $docroot . $uri;

        $_SERVER['SERVER_NAME'] = $siteName . '.dev';
        $_SERVER['DOCUMENT_ROOT'] = $docroot;
        $_SERVER['DOCUMENT_URI'] = $uri;
        $_SERVER['SCRIPT_FILENAME'] = $abspath;
        $_SERVER['SCRIPT_NAME'] = $uri;
        $_SERVER['PHP_SELF'] = $uri;

        return $abspath;
    }
503340
public function isStaticFile($sitePath, $siteName, $uri)
    {
        if (file_exists($staticFilePath = $sitePath.'/public'.$uri)
           && is_file($staticFilePath)) {
            return $staticFilePath;
        }

        $storageUri = $uri;

        if (strpos($uri, '/storage/') === 0) {
            $storageUri = substr($uri, 8);
        }

        if ($this->isActualFile($storagePath = $sitePath.'/storage/app/public'.$storageUri)) {
            return $storagePath;
        }

        return false;
    }
135767
public void updateSitePath(String sitepath, I_CmsSitemapController controller) {

        if (!isLeafType() && !sitepath.endsWith("/")) {
            sitepath = sitepath + "/";
        }
        if (!m_sitePath.equals(sitepath)) {
            // update the vfs path as well
            int start = m_vfsPath.lastIndexOf(m_sitePath);
            int stop = start + m_sitePath.length();
            m_vfsPath = CmsStringUtil.joinPaths(m_vfsPath.substring(0, start), sitepath, m_vfsPath.substring(stop));
            if (isLeafType() && m_vfsPath.endsWith("/")) {
                m_vfsPath = m_vfsPath.substring(0, m_vfsPath.length() - 1);
            }
            String oldPath = m_sitePath;
            m_sitePath = sitepath;
            String name = CmsResource.getName(sitepath);
            if (name.endsWith("/")) {
                name = name.substring(0, name.length() - 1);
            }
            m_name = name;
            for (CmsClientSitemapEntry child : m_subEntries) {
                child.updateSitePath(CmsStringUtil.joinPaths(sitepath, child.getName()), controller);
            }
            if (controller != null) {
                controller.registerPathChange(this, oldPath);
            }
        }
    }
698719
protected function resolvePath()
    {
        if (!isset($this->server['REQUEST_URI'])) {
            return null;
        }

        $url = $this->server['REQUEST_URI'];

        if (false !== $queryStart = strpos($url, '?')) {
            $url = substr($url, 0, $queryStart);
        }

        $url = preg_replace('/^' . preg_quote($this->dir, '/') . '/', null, $url);
        $url = '/' . trim($url, '/');

        return $url;
    }
739005
public function frontControllerPath($sitePath, $siteName, $uri)
    {
        $sitePath = $this->addSubdirectory($sitePath);

        if (!isset($_GET['q']) && !empty($uri) && $uri !== '/') {
          $_GET['q'] = $uri;
        }

        $matches = [];
        if (preg_match('/^\/(.*?)\.php/', $uri, $matches)) {
            $filename = $matches[0];
            if (file_exists($sitePath.$filename) && ! is_dir($sitePath.$filename)) {
                $_SERVER['SCRIPT_FILENAME'] = $sitePath.$filename;
                $_SERVER['SCRIPT_NAME'] = $filename;
                return $sitePath.$filename;
            }
        }

        // Fallback
        $_SERVER['SCRIPT_FILENAME'] = $sitePath.'/index.php';
        $_SERVER['SCRIPT_NAME'] = '/index.php';
        return $sitePath.'/index.php';
    }
681204
public function baseUrl($targetPath = null)
    {
        if (!isset($this->baseUrl)) {
            throw new RuntimeException(sprintf(
                'The base URI is not defined for [%s]',
                get_class($this)
            ));
        }

        if ($targetPath !== null) {
            return $this->createAbsoluteUrl($this->baseUrl, $targetPath);
        }

        return rtrim($this->baseUrl, '/').'/';
    }
1114306
function getSourcepath(filepath, htmlpath, rootpath) {
  if (!filepath) {
    return ['', ''];
  }

  if (isRemoteFilepath(filepath)) {
    const url = new URL(filepath);

    filepath = `./${url.pathname.slice(1).replace(RE_FORWARD_SLASH, '_')}`;
  }
  // Strip query params
  filepath = filepath.replace(RE_QUERY, '');
  // Relative path
  if (htmlpath && isRelativeFilepath(filepath)) {
    filepath = path.resolve(path.dirname(htmlpath), filepath);
    // Strip leading '/'
  } else if (filepath.indexOf('/') == 0) {
    filepath = filepath.slice(1);
  }
  if (filepath.includes('#')) {
    filepath = filepath.split('#');
  }

  return Array.isArray(filepath)
    ? [path.resolve(rootpath, filepath[0]), filepath[1]]
    : [path.resolve(rootpath, filepath), ''];
}
273721
function site_url($uri = '')
	{
		if ($uri == '')
		{
			return $this->slash_item('base_url').$this->item('index_page');
		}

		if ($this->item('enable_query_strings') == FALSE)
		{
			$suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
			return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix;
		}
		else
		{
			return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri);
		}
	}