several updates in admin controller (buildURL)

implemented two new functions (variable cleaning) to use in future
This commit is contained in:
2015-02-15 23:32:03 +01:00
parent 5899fffb29
commit 8354bd53a3
2 changed files with 50 additions and 25 deletions

View File

@@ -20,4 +20,29 @@ function buildURL($URI, $https = false)
return $url;
}
function post_default($key, $default='')
{
$_POST[$key] = (isset($_POST[$key])) ? stripslashes($_POST[$key]) : $default;
}
function clean_input(&$input, $dbobj, $opts = null)
{
$input = trim($input);
$input = $dbobj->real_escape_string($input);
if ($opts != null)
{
if (in_array('spchars', $opts)) //special chars
$input = htmlspecialchars($input);
if (in_array('nnegint', $opts)) //non-negative integer
{
$int_options = array('options' => array('min_range' => 0));
$input = var_dump(filter_var($input, FILTER_VALIDATE_INT, $int_options));
}
}
else
$input = strip_tags($input);
}
?>