Recent Topics

1 Jul 10, 2006 08:52    

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 &laquo;%s&raquo; 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'....

2 Jul 10, 2006 09:02

From the notes inc/_misc/_misc.funcs.php function param()

* - boolean (will force type to boolean, but you can't use 'true' as a default since it has special meaning. There is no real reason to pass booleans on a URL though. Passing 0 and 1 as integers seems to be best practice).

¥

3 Jul 10, 2006 09:08

But these params wouldn't be used in a url...

But spose if they were to be used in urls 0 or 1 would be better, or a conversion from true to 'true' and false to 'false' which is what i currently do with my other projects...


Form is loading...