Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
98d6987c
Commit
98d6987c
authored
Feb 12, 2007
by
Penny Leach
Browse files
added param_alphanumext - a-zA-Z0-9_-.
parent
d879ac52
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/web.php
View file @
98d6987c
...
...
@@ -578,6 +578,36 @@ function param_alphanum($name) {
throw
new
ParameterException
(
"Parameter '
$name
' = '
$value
' is not an alphanum"
);
}
/**
* This function returns a GET or POST parameter as an alphanumeric string with optional
* default. If the default isn't specified and the parameter hasn't been sent,
* a ParameterException exception is thrown. Likewise, if the parameter isn't a
* valid alpha string, a ParameterException exception is thrown
*
* Valid characters are a-z and A-Z and 0-9 and _ and - and .
*
* @param string The GET or POST parameter you want returned
* @param mixed [optional] the default value for this parameter
*
* @return string The value of the parameter
*
*/
function
param_alphanumext
(
$name
)
{
$args
=
func_get_args
();
list
(
$value
,
$defaultused
)
=
call_user_func_array
(
'_param_retrieve'
,
$args
);
if
(
$defaultused
)
{
return
$value
;
}
if
(
preg_match
(
'/^[a-zA-Z0-9_.-]+$/'
,
$value
))
{
return
$value
;
}
throw
new
ParameterException
(
"Parameter '
$name
' = '
$value
' is not an alphanumext"
);
}
/**
* This function returns a GET or POST parameter as an array of integers with optional
* default. If the default isn't specified and the parameter hasn't been sent,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment