Skip to content
Permalink
Browse files

Remove old URL handling code.

This code has been consolidated into the ServerRequestFactory.
We can now get it from there, and no longer need this copy of the code.
  • Loading branch information...
markstory committed Sep 12, 2016
1 parent bc19b3a commit f334cd224effef8e6e6bd09c63d6895c887a4af7
Showing with 0 additions and 111 deletions.
  1. +0 −111 src/Network/Request.php
@@ -398,117 +398,6 @@ protected function _processGet($query, $queryString = '')
return $query;
}
/**
* Get the request uri. Looks in PATH_INFO first, as this is the exact value we need prepared
* by PHP. Following that, REQUEST_URI, PHP_SELF, HTTP_X_REWRITE_URL and argv are checked in that order.
* Each of these server variables have the base path, and query strings stripped off
*
* @param array $config Configuration to set.
* @return string URI The CakePHP request path that is being accessed.
*/
protected static function _url($config)
{
if (!empty($_SERVER['PATH_INFO'])) {
return $_SERVER['PATH_INFO'];
}
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '://') === false) {
$uri = $_SERVER['REQUEST_URI'];
} elseif (isset($_SERVER['REQUEST_URI'])) {
$uri = $_SERVER['REQUEST_URI'];
$fullBaseUrl = Configure::read('App.fullBaseUrl');
if (strpos($uri, $fullBaseUrl) === 0) {
$uri = substr($_SERVER['REQUEST_URI'], strlen($fullBaseUrl));
}
} elseif (isset($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME'])) {
$uri = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['PHP_SELF']);
} elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
$uri = $_SERVER['HTTP_X_REWRITE_URL'];
} elseif ($var = env('argv')) {
$uri = $var[0];
}
$base = $config['base'];
if (strlen($base) > 0 && strpos($uri, $base) === 0) {
$uri = substr($uri, strlen($base));
}
if (strpos($uri, '?') !== false) {
list($uri) = explode('?', $uri, 2);
}
if (empty($uri) || $uri === '/' || $uri === '//' || $uri === '/index.php') {
$uri = '/';
}
$endsWithIndex = '/webroot/index.php';
$endsWithLength = strlen($endsWithIndex);
if (strlen($uri) >= $endsWithLength &&
substr($uri, -$endsWithLength) === $endsWithIndex
) {
$uri = '/';
}
return $uri;
}
/**
* Returns a base URL and sets the proper webroot
*
* If CakePHP is called with index.php in the URL even though
* URL Rewriting is activated (and thus not needed) it swallows
* the unnecessary part from $base to prevent issue #3318.
*
* @return array Base URL, webroot dir ending in /
*/
protected static function _base()
{
$base = $webroot = $baseUrl = null;
$config = Configure::read('App');
extract($config);
if ($base !== false && $base !== null) {
return [$base, $base . '/'];
}
if (!$baseUrl) {
$base = dirname(env('PHP_SELF'));
// Clean up additional / which cause following code to fail..
$base = preg_replace('#/+#', '/', $base);
$indexPos = strpos($base, '/' . $webroot . '/index.php');
if ($indexPos !== false) {
$base = substr($base, 0, $indexPos) . '/' . $webroot;
}
if ($webroot === basename($base)) {
$base = dirname($base);
}
if ($base === DIRECTORY_SEPARATOR || $base === '.') {
$base = '';
}
$base = implode('/', array_map('rawurlencode', explode('/', $base)));
return [$base, $base . '/'];
}
$file = '/' . basename($baseUrl);
$base = dirname($baseUrl);
if ($base === DIRECTORY_SEPARATOR || $base === '.') {
$base = '';
}
$webrootDir = $base . '/';
$docRoot = env('DOCUMENT_ROOT');
$docRootContainsWebroot = strpos($docRoot, $webroot);
if (!empty($base) || !$docRootContainsWebroot) {
if (strpos($webrootDir, '/' . $webroot . '/') === false) {
$webrootDir .= $webroot . '/';
}
}
return [$base . $file, $webrootDir];
}
/**
* Process uploaded files and move things onto the post data.
*

0 comments on commit f334cd2

Please sign in to comment.
You can’t perform that action at this time.