Topic: Problem with $_SERVER['REQUEST_URI'] & $_SERVER['PHP_SELF']

Many mods and plugins use

<?php echo $_SERVER['REQUEST_URI'] ?>

or

<?php echo $_SERVER['PHP_SELF'] ?>

as part of the action attribute of forms (ex: action="<?php echo $_SERVER['PHP_SELF'] ?>?foo=bar").

However, this causes a problem for me - my forums are located at "http://mcawesome.hysellstuff.com/forum/" (the subdomain "mcawesome.hysellstuff.com" points to "hysellstuff.com/awesome/") - but rather than generating a URL pointing to "forum/somescript.php", these variables both point to "//awesome///forum/somescript.php".

The result is that the form action is "http://awesome///forum/somecript.php" which causes my browser (Firefox) to do a Google I'm feeling lucky search that takes me too "http://www.awesomelibrary.org/".

Is there any way to fix this? I mean, I can go into the plugins and mods and edit form actions to point to the correct location, but this gets old quickly.

Thanks in advance for your help.

Looking for a certain modification for your forum? Please take a look here before posting.

Re: Problem with $_SERVER['REQUEST_URI'] & $_SERVER['PHP_SELF']

i dunno if you can just say
$_SERVER['REQUEST_URI'] = "what/ever";
in the top of common.php

3 (edited by pogenwurst 2005-09-10 12:34)

Re: Problem with $_SERVER['REQUEST_URI'] & $_SERVER['PHP_SELF']

Connorhd wrote:

i dunno if you can just say
$_SERVER['REQUEST_URI'] = "what/ever";
in the top of common.php

I don't know if I could, but it would probably breaksomething. Why?

pogenwurst wrote:

(ex: action="<?php echo $_SERVER['PHP_SELF'] ?>?foo=bar")

That is an example I have encounterd in some install_mod.php files. If I said $_SERVER['PHP_SELF'] = forum/, the resulting form action would be mcawesome.hysellstuff.com/forum/?foo=bar instead of mcawesome.hysellstuff.com/forum/install_mod?foo=bar, which would still result in a broken form.

I'm pretty sure that's what would happen (not quite positive though).

Sorry if I wasn't clear enough in my original post.

BTW, before anyone asks, my base url in admin_options.php is http://mcawesome.hysellstuff.com/forum.

Looking for a certain modification for your forum? Please take a look here before posting.

Re: Problem with $_SERVER['REQUEST_URI'] & $_SERVER['PHP_SELF']

if i were you, i would look at php_info() and find a combination of text and vairables that makes what $_SERVER['REQUEST_URI'] should be then do $_SERVER['REQUEST_URI'] = that
you can probably do $_SERVER['REQUEST_URI'] = "what/ever".$_SERVER['SCRIPT_NAME'] or something like that

5 (edited by pogenwurst 2005-09-10 12:47)

Re: Problem with $_SERVER['REQUEST_URI'] & $_SERVER['PHP_SELF']

Connorhd wrote:

if i were you, i would look at php_info() and find a combination of text and vairables that makes what $_SERVER['REQUEST_URI'] should be then do $_SERVER['REQUEST_URI'] = that
you can probably do $_SERVER['REQUEST_URI'] = "what/ever".$_SERVER['SCRIPT_NAME'] or something like that

Just about all of the variables concerning paths or urls have the same problem. I think I might want to consult my host's tech support on this one.

I have an idea though - how do take the base url of PunBB and make it a variable, so then I can take that and add the filename by stripping all the directories out of REQUEST_URI or PHP_SELF?

Looking for a certain modification for your forum? Please take a look here before posting.