Skip to content

Instantly share code, notes, and snippets.

@rscata
Created June 13, 2013 12:38
Show Gist options
  • Save rscata/5773350 to your computer and use it in GitHub Desktop.
Save rscata/5773350 to your computer and use it in GitHub Desktop.
cleen catch data, post or get
$clean = array();
switch($_POST['color']) {
case 'red':
case 'green':
case 'blue'
$clean['color'] = $_POST['color'];
default: /*ERROR*/
break;
}
/*numere si liter*/
$clean = array();
$length = mb_strlen($_POST['username']);
if (ctype_alnum($_POST['username']) && ($length > 0) && ($length <= 32)) {
$clean['username'] = $_POST['username'];
}
else {
/* ERROR */
}
/*expresii regulate*/
$clean = array();
if (preg_match('/[^A-Za-z \'\-]/', $_POST['last_name'])) {
/* ERROR */
}
else {
$clean['last_name'] = $_POST['last_name'];
}
/*XSS*/
$html = array(
'username' => htmlentities($_POST['username'], ENT_QUOTES, 'UTF-8'),
);
echo $html['username'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment