Heres the code that is currently used:
// Check if already set
// WARNING: when PHP register globals is ON, COOKIES get priority over GET and POST with this!!!
if( !isset( $GLOBALS[$var] ) || $override )
{
if( isset($_POST[$var]) )
{
$GLOBALS[$var] = remove_magic_quotes( $_POST[$var] );
// $Debuglog->add( 'param(-): '.$var.'='.$GLOBALS[$var].' set by POST', 'params' );
}
elseif( isset($_GET[$var]) )
{
$GLOBALS[$var] = remove_magic_quotes($_GET[$var]);
// $Debuglog->add( 'param(-): '.$var.'='.$GLOBALS[$var].' set by GET', 'params' );
}
elseif( isset($_COOKIE[$var]))
{
$GLOBALS[$var] = remove_magic_quotes($_COOKIE[$var]);
// $Debuglog->add( 'param(-): '.$var.'='.$GLOBALS[$var].' set by COOKIE', 'params' );
}
elseif( $default === true )
{
debug_die( '<p class="error">'.sprintf( T_('Parameter «%s» is required!'), $var ).'</p>' );
}
elseif( $forceset )
{
$GLOBALS[$var] = $default;
// echo '<br>param(-): '.$var.'='.$GLOBALS[$var].' set by default';
// $Debuglog->add( 'param(-): '.$var.'='.$GLOBALS[$var].' set by default', 'params' );
}
else
{ // param not found! don't set the variable.
// Won't be memorized nor type-forced!
return false;
}
}
Now heres what i want to do:
param('has_GD2', 'boolean', function_exists('imagejpeg') /* memorise = false, override = false, forceset = true */);
And heres what i'm seeing:
Parameter «has_GD2» is required!
So if we are using boolean params we have a problem with this line (in the first code attachment), if the default value is true, in which in the above example it is because the GD2 Library is installed:
elseif( $default === true )
Quite a problem....
Maybe change that line to:
elseif( $default === NULL )
OR
elseif( $default == 'required' )
OR
Just remove it... No params so far are using it, and i cannot see the point in it, as if the param is required they would just test it's existance by makeing default equal something that they can test against. - This is what i've done in my local installation.
Also removing this line would be best as with the above examples you would also run into problems when setting the param as NULL or 'required'....
From the notes inc/_misc/_misc.funcs.php function param()
¥