Discussion:
PHP_SELF deprecated?
gorka
2003-06-05 20:07:20 UTC
Permalink
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=177947#177947
----------------------------------------------------------------

I'm having problems with my store since the hosting company upgraded PHP. They have told me that PHP_SELF is no longer being used. Since oscommerce uses this variable my store does not work properly.

Does anyone know how to fix this?

Thanks!
Dave_L
2003-06-05 20:14:43 UTC
Permalink
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=177951#177951
----------------------------------------------------------------

I think that SCRIPT_NAME is the preferred replacement for PHP_SELF. Technically, it should be accessed as $_SERVER['SCRIPT_NAME'] (or HTTP_SERVER_VARS['SCRIPT_NAME'] if the PHP version is older than 4.1.0).
gorka
2003-06-07 08:24:31 UTC
Permalink
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=178693#178693
----------------------------------------------------------------

I replaced al PHP_SELF ocurrences by $_SERVER['SCRIPT_NAME'] and it worked! Many thanks Dave!

Note 1: I didn't change anything in the admin directory. PHP_SELF worked there. Weird!

Note 2: In some files you will find $GLOBALS['PHP_SELF'] instead of $PHP_SELF. You have to change those also. I'm not sure if I also found $HTTP_SERVER_VARS['PHP_SELF'].

Note 3: Some function define $PHP_SELF as global:

global $PHP_SELF;

I removed those declarations also.
orchard
2003-06-07 14:16:53 UTC
Permalink
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=178739#178739
----------------------------------------------------------------

I wonder if it would work to put [code]$PHP_SELF = $_SERVER['SCRIPT_NAME'][/code] near in application_top.php or somewhere like that instead of substituting everywhere?

Actually, I just looked and it seems like $PHP_SELF is already set up in application_top.php; maybe the code there just needs to be modified a little.
gorka
2003-06-07 16:59:27 UTC
Permalink
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=178802#178802
----------------------------------------------------------------

I tried that but it didn't work for me. Did you try it?
orchard
2003-06-07 17:10:28 UTC
Permalink
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=178806#178806
----------------------------------------------------------------

No, I didn't try it. I haven't had the problem yet, so I thought I should leave it alone until it breaks.
gorka
2003-06-08 01:05:08 UTC
Permalink
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=178969#178969
----------------------------------------------------------------

I've tried to do:

[code]$PHP_SELF = $_SERVER['SCRIPT_NAME'][/code]

but It seems that is not possible to change $PHP_SELF's value. I guess it's because $PHP_SELF is a server variable and can't be changed (please correct me if I'm wrong).
orchard
2003-06-08 02:01:17 UTC
Permalink
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=178996#178996
----------------------------------------------------------------

Where did you put the change?

includes/application_top.php modifies $PHP_SELF and is included in many if not all the other files, so it may have been undoing/overwriting your change.
matzze
2003-07-16 11:55:50 UTC
Permalink
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=197104#197104
----------------------------------------------------------------

Hi,

I had the same problem and heres my solution (thanks to the contributors of this discussion, without you I would still be searching):

(I work on 2.2MS1, The server runs PHP 4.2.3)
I changend ONLY in application_top twice the line
$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
to
$PHP_SELF = $_SERVER['SCRIPT_NAME'];

if you want to use search engine URLS, you will also have to change (in application_top) the line
$PHP_SELF = str_replace(getenv('PATH_INFO'), '', $HTTP_SERVER_VARS['PHP_SELF']);
to
$PHP_SELF = str_replace(getenv('PATH_INFO'), '', $_SERVER['SCRIPT_NAME']);


I hope I could help with this.

Mathias
atoth
2003-08-18 09:35:03 UTC
Permalink
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=215628#215628
----------------------------------------------------------------

html_output.php

old:
$link = str_replace('?', '/', $link);
$link = str_replace('&', '/', $link);
$link = str_replace('=', '/', $link);

new:
$link = str_replace('?', '?', $link);
$link = str_replace('&', '&', $link);
$link = str_replace('=', '=', $link);

greez
Andy
eternalcrow
2003-08-30 08:14:02 UTC
Permalink
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=221832#221832
----------------------------------------------------------------

Matzze, Thanks..... Your suggestions helped fix the problems with /admin

With viewing /catalog it still gives me that error, even after adding $PHP_SELF = str_replace(getenv('PATH_INFO'), '', $_SERVER['SCRIPT_NAME']); to application_top.php in the /catalog/includes dir.

:?:
eternalcrow
2003-08-30 08:20:36 UTC
Permalink
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=221834#221834
----------------------------------------------------------------

OOPS!! I fixed it! In /catalog/includes/appication_top.php I took out the statement if (!isset($PHP_SELF)) and left $PHP_SELF = str_replace(getenv('PATH_INFO'), '', $_SERVER['SCRIPT_NAME']); and it all work!!!

wooo!!

:D
Dave_L
2003-08-30 12:34:29 UTC
Permalink
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=221885#221885
----------------------------------------------------------------

Is there a notice anywhere in the PHP documentation at php.net regarding PHP_SELF being deprecated? My post above was based on second-hand information, and I'd like to know if it's "official".
Loading...