contao/import — Issue #3603: eigener Scriptname wird fehlerhaft ermittelt
Author: importer
Created: 2011-11-29 21:52:40+00:00
State: open
Labels: Accepted, Defect, framework

In **system\libraries\Environment.php** werden in Zeilen 129 und 139 der Name des Skripts ermittelt.

php_sapi_name() liefert bei meinem Hoster "fpm-fcgi". Die relevanten Variablen aus dem $_SERVER-Array werden wie folgt gesetzt:

```
_SERVER["REQUEST_URI"]	/test.php
_SERVER["SCRIPT_NAME"]	/test.php
_SERVER["ORIG_SCRIPT_FILENAME"]	/home/tscgw/cgi-bin/php5.external
_SERVER["ORIG_PATH_INFO"]	/test.php
_SERVER["ORIG_PATH_TRANSLATED"]	/home/tscgw/www/tl/test.php
_SERVER["ORIG_SCRIPT_NAME"]	/cgi-bin/php5.external
_SERVER["PHP_SELF"]	/test.php
```

(Habe das Problem in einem Skript test.php isoliert)

Da der Fall "fpm-fcgi" nicht abgefragt wird, wird ORIG_SCRIPT_NAME als Skriptname zurückgegeben, was nicht korrekt ist. Erweiterung der Abfrage um "fpm-fcgi" liefert ordnungsgemäß ORIG_PATH_INFO.
Neuer Code Zeile 129:

```
return str_replace('//', '/', str_replace('\\', '/', (php_sapi_name() == 'cgi' || php_sapi_name() == 'isapi' || php_sapi_name() == 'cgi-fcgi' || php_sapi_name() == 'fpm_fcgi') && ($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) ? ($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) : ($_SERVER['ORIG_SCRIPT_FILENAME'] ? $_SERVER['ORIG_SCRIPT_FILENAME'] : $_SERVER['SCRIPT_FILENAME'])));
```

Neuer Code Zeile 139:

```
return (php_sapi_name() == 'cgi' || php_sapi_name() == 'cgi-fcgi' || php_sapi_name() == 'fpm-fcgi') && ($_SERVER['ORIG_PATH_INFO'] ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']) ? ($_SERVER['ORIG_PATH_INFO'] ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']) : ($_SERVER['ORIG_SCRIPT_NAME'] ? $_SERVER['ORIG_SCRIPT_NAME'] : $_SERVER['SCRIPT_NAME']);
```

--- _Originally created by dl1ely on November 4th, 2011, at 05:27pm (ID 3603)_