Php anti-injection code (filter parameters)
| Php filters $ _ GET and $ _ POST parameters to prevent injection of code. For more information, see.
The complete code is as follows.
$ Value) {if (! Is_array ($ value) {$ value = get_magic_quotes_gpc ()? $ Value: addslashes ($ value); $ array [$ key] = filterHtml ($ value);} Else {Add_S ($ array [$ key]);} return $ array;} function glstr ($ var) {if (is_array ($ var) {return Add_S ($ var);} elseif (strlen ($ var )) {$ var = get_magic_quotes_gpc ()? $ Var: addslashes ($ var); $ var = filterHtml ($ var);} return $ var;} function filterHtml ($ html) {$ farr = array ("/] *?)> /Eis ","/<(\/?) (Html | body | head | link | meta | base | input) ([^>] *?)> /Eis ","/<(script | I? Frame | style | title | form )(.*?) <\/\ 1>/eis ","/(<[^>] *? \ S +) on [a-z] + \ s *? = (\ "| ') ([^ \ 2] *) \ 2 ([^>] *?>) /IsU ", // filter javascript on events"/\ s +/", // filter excess spaces); $ tarr = array ("","", "", "\ 1 \ 4", "",); $ html = preg_replace ($ farr, $ tarr, $ html); return $ html ;} if (sizeof ($ _ GET) {foreach ($ _ GET as $ key => $ value) {$ _ GET [$ key] = glstr ($ value ); //} if (sizeof ($ _ POST) {foreach ($ _ POST as $ key => $ value) {$ _ POST [$ key] = glstr ($ value); // }}?> |