Michal Čihař a écrit :
Hi
On Wed, 07 Dec 2005 10:06:41 -0500 Marc Delisle Marc.Delisle@cegepsherbrooke.qc.ca wrote:
Sebastian Mendel a écrit :
Michal Čihař schrieb:
I suggested to create some function like:
PMA_grabParameter($name, $request, $sanitizing = 'none', $required = TRUE)
The request parameter might not be needed, but it's up to discussion.
While Marc came with way how Moodle does it:
Michal, I showed this Moodle example because you wanted to know what other products are doing. I am not advocating for their mechanism.
About PMA_grabParameter(), is the second parameter used for the origin of the variable, like GET, POST, COOKIE, SESSION?
It was original purpose.
Comments?
// ifsetor() ;-) function checkRequest($name, $default = null) { if ( isset( $_REQUEST[$name] ) ) { return $_REQUEST[$name]; }
return $default; }
i think in most cases PMA should use $_REQUEST directly and use one of the above function only to set default values
using of $_REQUEST makes it more clear where this variable came from, reminding the developer always to take care with this variables!
I don't understand why using $_REQUEST makes more clear where this variable came from. In $_REQUEST, variables can come from EGPCS, as defined by the variables_order directive. I think that it's better to say explicitly where we expect each variable to come from.
Many variables can come at least either from POST or GET (see PMA_linkOrButton [or what's it's name]).
Yes, we would have to mention all the possible sources. But I don't want to argue ad vitam aeternam about this :) If you all prefer using $_REQUEST, let's do it.
FYI, look what the Mambo team has done in their globals.php script. They are populating $GLOBALS. Not sure I approve their method. Comments?
----------- $raw = phpversion(); list($v_Upper,$v_Major,$v_Minor) = explode(".",$raw);
if (($v_Upper == 4 && $v_Major < 1) || $v_Upper < 4) { $_FILES = $HTTP_POST_FILES; $_ENV = $HTTP_ENV_VARS; $_GET = $HTTP_GET_VARS; $_POST = $HTTP_POST_VARS; $_COOKIE = $HTTP_COOKIE_VARS; $_SERVER = $HTTP_SERVER_VARS; $_SESSION = $HTTP_SESSION_VARS; $_FILES = $HTTP_POST_FILES; }
if (!ini_get('register_globals')) { while(list($key,$value)=each($_FILES)) $GLOBALS[$key]=$value; while(list($key,$value)=each($_ENV)) $GLOBALS[$key]=$value; while(list($key,$value)=each($_GET)) $GLOBALS[$key]=$value; while(list($key,$value)=each($_POST)) $GLOBALS[$key]=$value; while(list($key,$value)=each($_COOKIE)) $GLOBALS[$key]=$value; while(list($key,$value)=each($_SERVER)) $GLOBALS[$key]=$value; while(list($key,$value)=@each($_SESSION)) $GLOBALS[$key]=$value; foreach($_FILES as $key => $value){ $GLOBALS[$key]=$_FILES[$key]['tmp_name']; foreach($value as $ext => $value2){ $key2 = $key . '_' . $ext; $GLOBALS[$key2] = $value2; } } } ===============