Jump to content

Archived

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

jolt

Independence of php.ini settings

Recommended Posts

I propose that one of the design goals in development should be to make osCommerce as independent from the php.ini settings as possible. I think this should be a design goal because it is much easier for people installing the software - especially ones that don't have control over such settings. In the todo for the next version is the ability to run with export_globals set to off - this is great idea. I propose to take this todo one step further and eliminate dependence on the one other primary clincher in the php.ini - magic_quotes.

 

More specifically, there should be a global associative array (maybe $osccgi to imply that it contains data received via CGI - or whatever). This could be a copy of $_REQUEST (actually - bad idea if we want to have backwards compatibility with PHP3) - but you get the idea. Once this array was populated with data, if magic_quotes is on (see get_magic_quotes_gpc()) then we either get rid of the quotes (I prefer this) or add them. For example:

 

(switch to while loop if you are really concerned about PHP3)

 

if (get_magic_quotes_gpc()) {

 

foreach ($osccgi as $key => $value) {

 

$osccgi[$key] = stripslashes($value);

 

}

 

}

 

Or you could take care of this when you made $oscgi in the first place. Hmm - this will fall short in php for form elements ending in "[]". Try this instead (please excuse lack of indents - hard to do in textarea):

 

 

if (get_magic_quotes_gpc()) {

 

foreach ($osccgi as $key => $value) {

 

if (!is_array($value)) {

 

$osccgi[$key] = stripslashes($value);

 

} else {

 

for ($i = count($value); $i--; ) {

 

$osccgi[$key] = stripslashes($value[$i]);

 

}

 

}

}

 

}

 

BUT the code is irrelevant - the idea is however which is to depend on php.ini settings as little as possible.

Share this post


Link to post
Share on other sites

×