From:             [EMAIL PROTECTED]
Operating system: Linux 2.4.19
PHP version:      4.2.3
PHP Bug Type:     Other web server
Bug description:  FastCGI : Wrong SCRIPT_NAME and SCRIPT_FILENAME

When running PHP under FastCGI (with Suexec wrapper enabled), the variables
_SERVER["SCRIPT_NAME"] and _SERVER["SCRIPT_FILENAME"] are returning the
path and filename of the PHP-FCGI binary instead of the path and filename
of the current executing script, that is, the values of
_ENV["SCRIPT_NAME"] and _ENV["SCRIPT_FILENAME"] respectively. This breaks
a lot of scripts relying on just $SCRIPT_NAME and $SCRIPT_FILENAME;

ie, when setting up this in httpd.conf :

ScriptAlias /fcgi-bin/ /usr/local/apache/bin/
<Location /fcgi-bin/>
  SetHandler fastcgi-script
</Location>
AddType application/x-httpd-php .php .php3 .php4
Action application/x-httpd-php /fcgi-bin/php.fcgi

When called from a script,
$SCRIPT_NAME becomes : /fcgi-bin/php.fcgi
$SCRIPT_FILENAME becomes : /usr/local/apache/bin/php.fcgi

Versions :
PHP 4.2.3 compiled with --with-fastcgi
mod_fastcgi 2.2.12
Apache 1.3.26

I modified sapi/fastcgi.c to register the correct _SERVER vars, and it
works OK. At line 164, add :

        php_register_variable("SCRIPT_NAME", (SG(request_info).request_uri
? SG(request_info).request_uri:""), track_vars_array TSRM
LS_CC);
        php_register_variable("SCRIPT_FILENAME",
(SG(request_info).path_translated ? SG(request_info).path_translated:""),
track_var
s_array TSRMLS_CC);


Best,
[EMAIL PROTECTED]

-- 
Edit bug report at http://bugs.php.net/?id=19656&edit=1
-- 
Try a CVS snapshot:  http://bugs.php.net/fix.php?id=19656&r=trysnapshot
Fixed in CVS:        http://bugs.php.net/fix.php?id=19656&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=19656&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=19656&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=19656&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=19656&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=19656&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=19656&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=19656&r=submittedtwice
register_globals:    http://bugs.php.net/fix.php?id=19656&r=globals

Reply via email to