phar + clean urls work fully now
This commit is contained in:
parent
995dbef2a1
commit
f36c79cb7b
@ -25,12 +25,22 @@ function mapUrls($path)
|
||||
if (isset($arMap[$path])) {
|
||||
return $arMap[$path];
|
||||
}
|
||||
$pos = strrpos($path, '.');
|
||||
if ($pos === false || strlen($path) - $pos > 5) {
|
||||
//clean url
|
||||
$path .= '.php';
|
||||
}
|
||||
$parts = explode('/', $path);
|
||||
$partPos = 1;
|
||||
if (in_array($parts[$partPos], array('js', 'player', 'themes'))) {
|
||||
return '/www' . $path;
|
||||
}
|
||||
if (in_array($parts[$partPos], array('ajax', 'api', 'gsearch'))) {
|
||||
$partPos = 2;
|
||||
}
|
||||
$pos = strrpos($parts[$partPos], '.');
|
||||
if ($pos === false) {
|
||||
$parts[$partPos] .= '.php';
|
||||
$_SERVER['PATH_INFO'] = '/' . implode(
|
||||
'/', array_slice($parts, $partPos + 1)
|
||||
);
|
||||
}
|
||||
return '/www' . implode('/', $parts);
|
||||
}
|
||||
|
||||
Phar::webPhar(
|
||||
|
@ -31,7 +31,9 @@ class SemanticScuttle_Environment
|
||||
{
|
||||
if (isset($_SERVER['PHAR_PATH_TRANSLATED'])) {
|
||||
$fscript = '/' . $_SERVER['SCRIPT_NAME'];
|
||||
if ($fscript == $_SERVER['PATH_INFO']) {
|
||||
if ($fscript == $_SERVER['PATH_INFO']
|
||||
|| $fscript == $_SERVER['PATH_INFO'] . '.php'
|
||||
) {
|
||||
return null;
|
||||
} else if (substr($_SERVER['PATH_INFO'], 0, strlen($fscript)) == $fscript) {
|
||||
return substr($_SERVER['PATH_INFO'], strlen($fscript));
|
||||
|
@ -251,6 +251,28 @@ class SemanticScuttle_EnvironmentTest extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetServerPathInfoPharCleanUrl()
|
||||
{
|
||||
$_SERVER = array(
|
||||
'HTTP_HOST' => 'dist.bm.bogo',
|
||||
'SERVER_NAME' => 'dist.bm.bogo',
|
||||
'SERVER_ADDR' => '127.0.0.1',
|
||||
'SERVER_PORT' => '80',
|
||||
'DOCUMENT_ROOT' => '/etc/apache2/htdocs' ,
|
||||
'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/SemanticScuttle-0.98.X.phar' ,
|
||||
'QUERY_STRING' => '',
|
||||
'REQUEST_URI' => '/SemanticScuttle-0.98.X.phar/populartags',
|
||||
'SCRIPT_NAME' => 'populartags.php',
|
||||
'PATH_INFO' => '/populartags',
|
||||
'PATH_TRANSLATED' => 'phar:///home/cweiske/Dev/semanticscuttle/cwdev/dist/SemanticScuttle-0.98.X.phar/www/populartags.php',
|
||||
'PHP_SELF' => '/SemanticScuttle-0.98.X.phar/populartags',
|
||||
'PHAR_PATH_TRANSLATED' => '/home/cweiske/Dev/html/hosts/dist.bm.bogo/populartags',
|
||||
);
|
||||
$this->assertNull(
|
||||
SemanticScuttle_Environment::getServerPathInfo()
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetServerPathInfoPharWithInfo()
|
||||
{
|
||||
$_SERVER = array(
|
||||
|
Loading…
Reference in New Issue
Block a user