Prevent any possible XSS attacks via $_GET


/ Published in: PHP
Save to your folder(s)

This function from php-fusion - great CMS.


Copy this code and paste it in your HTML
  1. // Prevent any possible XSS attacks via $_GET.
  2. foreach ($_GET as $check_url) {
  3. if ((eregi("<[^>]*script*\"?[^>]*>", $check_url)) || (eregi("<[^>]*object*\"?[^>]*>", $check_url)) ||
  4. (eregi("<[^>]*iframe*\"?[^>]*>", $check_url)) || (eregi("<[^>]*applet*\"?[^>]*>", $check_url)) ||
  5. (eregi("<[^>]*meta*\"?[^>]*>", $check_url)) || (eregi("<[^>]*style*\"?[^>]*>", $check_url)) ||
  6. (eregi("<[^>]*form*\"?[^>]*>", $check_url)) || (eregi("\([^>]*\"?[^)]*\)", $check_url)) ||
  7. (eregi("\"", $check_url))) {
  8. die ();
  9. }
  10. }
  11. unset($check_url);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.