Skip to content

Commit

Permalink
Fix an "strpos(): Empty needle" warning
Browse files Browse the repository at this point in the history
Signed-off-by: Cyrille TOULET <[email protected]>
  • Loading branch information
Cyrille TOULET committed Mar 29, 2015
1 parent dabdbe4 commit ead327f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions system/core/URI.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,17 @@ protected function _parse_request_uri()
$query = isset($uri['query']) ? $uri['query'] : '';
$uri = isset($uri['path']) ? $uri['path'] : '';

if (!empty($_SERVER['SCRIPT_NAME']) && strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
{
$uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME']));
}
elseif (!empty($_SERVER['SCRIPT_NAME']) && strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
{
$uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
}
if (isset($_SERVER['SCRIPT_NAME'][0]))
{
if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
{
$uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME']));
}
elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
{
$uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
}
}

// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
Expand Down

0 comments on commit ead327f

Please sign in to comment.