#85 PHP CGI version fails to format URL



I am using php 4.0.6 compiled as a cgi executeable
rather than a loadable module. I know this affects
certain php global variables and wonder if this is the
case with the wiki error I am receiving.

I repaired the problem by editing lib/config.php as

161 //changed below for php as a cgi compatibilityi

by Tim
162 if (!defined('SCRIPT_NAME'))
163 {
164 $tmp = $GLOBALS["REQUEST_URI"];
165 //split of URL from post vars
166 $pos = strpos ($tmp, "?");
167 if ($pos === false)
168 {
169 define('SCRIPT_NAME',
170 }
171 else
172 {
173 define('SCRIPT_NAME',
174 }
175 }
176 //end of chnages by Tim

Probably more elegant ways to do this but it seems to
work ok. Can you patch your cvs copy with the above

Thanks Tim


  • Geoffrey T. Dairiki

    Logged In: YES

    I'd really like to keep $GLOBALS['SCRIPT_NAME'] as the
    default value of SCRIPT_NAME, at least whenever possible.

    Can you provide a few more details as to your set up? If
    you could set up a public phpinfo script I could look at,
    that would be great. At the very least could you tell me
    what the bad URLs that the stock PhpWiki was generating look

    (A phpinfo script being a PHP script containing nothing but
    the line:

    <?php phpinfo(); ?>

    Sample output at http://phpwiki.sf.net/test/phpinfo.php .)


  • Tim Sutton

    Tim Sutton - 2002-01-13

    Logged In: YES


    Thanks for the reply.

    I have set up a phpinfo page at:


    The main problem is that when php is a cgi,
    $GLOBALS['SCRIPT_NAME'] returns /cgi-bin/php rather than
    the actual script file name.

    My fix submitted still does completely not fix the problem
    anyway, so if you have an alternative approach, I would be
    interested to hear it. In particular the login functions
    don't work. One restriction is that I need to run php as a
    cgi for another application on the same machine. Although
    I could possibly run it as both a .so and a cgi I suppose?



  • Geoffrey T. Dairiki

    Logged In: YES

    I'd try setting SCRIPT_NAME to $REDIRECT_URL, e.g.:

    if (!defined('SCRIPT_NAME'))
    define('SCRIPT_NAME', empty($GLOBALS['REDIRECT_URL']) ?

    How so is it that your fix did not completely fix the problem?

    As for the log-in problem. Yes, PhpWiki's login method does
    not currently work if running as CGI. This will be fixed
    sometime (hopefully fairly soon...). Until then, if you can
    run PhpWiki using mod_php, while running your other app as
    CGI, that's a fine solution. (Mod_php is generally
    preferable from a preformance standpoint, in any case.)

  • Marc-Etienne Vargenau

    • status: open --> closed
  • Marc-Etienne Vargenau

    Closing very old bugs.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks