[Reprinted] Php anti-injection code provided by 360
[Reprinted] 360 Provided Php anti-injection code
Error number:[$ Errno], error on line $ errline in $ errfile
"; Die () ;}set_error_handler (" customError ", E_ERROR); $ getfilter =" '| (and | or) \ B. +? (>|<|=| In | like) |\/\\ *. +? \ * \/| <\ S * script \ B | \ bEXEC \ B | UNION. +? Select | Update. +? SET | Insert \ s + INTO. +? VALUES | (Select | Delete). +? FROM | (Create | Alter | Drop | TRUNCATE) \ s + (TABLE | DATABASE) "; $ postfilter =" \ B (and | or) \ B. {1, 6 }? (=|>|<|\\ Bin \ B |\\ blike \ B) |\\/ \\ *. +? \ * \/| <\ S * script \ B | \ bEXEC \ B | UNION. +? Select | Update. +? SET | Insert \ s + INTO. +? VALUES | (Select | Delete). +? FROM | (Create | Alter | Drop | TRUNCATE) \ s + (TABLE | DATABASE) "; $ cookiefilter =" \ B (and | or) \ B. {1, 6 }? (=|>|<|\\ Bin \ B |\\ blike \ B) |\\/ \\ *. +? \ * \/| <\ S * script \ B | \ bEXEC \ B | UNION. +? Select | Update. +? SET | Insert \ s + INTO. +? VALUES | (Select | Delete). +? FROM | (Create | Alter | Drop | TRUNCATE) \ s + (TABLE | DATABASE) "; function StopAttack ($ StrFiltKey, $ StrFiltValue, $ ArrFiltReq) {if (is_array ($ StrFiltValue) {$ StrFiltValue = implode ($ StrFiltValue);} if (preg_match ("/". $ ArrFiltReq. "/is", $ StrFiltValue) = 1) {// slog ("
Operation IP address: ". $ _ SERVER [" REMOTE_ADDR "]."
Operation Time: ". strftime (" % Y-% m-% d % H: % M: % S ")."
Operation page: ". $ _ SERVER [" PHP_SELF "]."
Submission method: ". $ _ SERVER [" REQUEST_METHOD "]."
Parameter submitted: ". $ StrFiltKey ."
Submit data: ". $ StrFiltValue); print" 360 websec notice: Illegal operation! "; Exit () ;}// $ ArrPGC = array_merge ($ _ GET, $ _ POST, $ _ COOKIE ); foreach ($ _ GET as $ key = >$ value) {StopAttack ($ key, $ value, $ getfilter);} foreach ($ _ POST as $ key => $ value) {StopAttack ($ key, $ value, $ postfilter);} foreach ($ _ COOKIE as $ key => $ value) {StopAttack ($ key, $ value, $ cookiefilter);}/* if (file_exists ('update360. php ') {echo "please rename the file update360.php to prevent hackers from using
"; Die ();} */function slog ($ logs) {$ toppath = $ _ SERVER [" DOCUMENT_ROOT "]. "/log.htm"; $ Ts = fopen ($ toppath, "a +"); fputs ($ Ts, $ logs. "\ r \ n"); fclose ($ Ts );}
The above is the content of Php anti-injection code provided in [Reprinted] 360. For more information, see PHP Chinese network (www.php1.cn )!