Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PHP_SELF deprecated?


gorka

Recommended Posts

Posted

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!

Posted

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).

Posted

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.

Posted

I wonder if it would work to put

$PHP_SELF = $_SERVER['SCRIPT_NAME']

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.

In olden times the men were made of iron and the ships were made of wood; now it's the other way around. :wink:

Posted

No, I didn't try it. I haven't had the problem yet, so I thought I should leave it alone until it breaks.

In olden times the men were made of iron and the ships were made of wood; now it's the other way around. :wink:

Posted

I've tried to do:

 

$PHP_SELF = $_SERVER['SCRIPT_NAME']

 

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).

Posted

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.

In olden times the men were made of iron and the ships were made of wood; now it's the other way around. :wink:

  • 1 month later...
Posted

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

  • 1 month later...
Posted

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

  • 2 weeks later...
Posted

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.

 

:?:

Posted

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

Posted

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".

  • 2 years later...
Posted

The funny thing I worked out is my store have such problem as described above when I use the http://name.of.the.store address . When I add /index.php it works like charm. For some of the ppl that could be a solution.

 

Kind regards,

Raul

PS. With admin section it's the same :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...