- $_POST = sql_injection($_POST);
- $_GET = sql_injection($_GET);
-
-
-
-
- function sql_injection($content)
- {
- if (!get_magic_quotes_gpc()) {
- if (is_array($content)) {
- foreach ($content as $key=>$value) {
- $content[$key] = addslashes($value);
- }
- } else {
- addslashes($content);
- }
- }
- return $content;
- }
-
-
-
-
-
-
-
-
-
- 做系统的话,可以用下面的代码,也是copy来的:
-
-
-
-
-
-
-
-
-
-
- function inject_check($sql_str) {
- return eregi('select|insert|update|delete|'|
-
-
-
-
-
-
-
-
- function verify_id($id=null) {
- if (!$id) { exit('没有提交参数!'); }
- elseif (inject_check($id)) { exit('提交的参数非法!'); }
- elseif (!is_numeric($id)) { exit('提交的参数非法!'); }
- $id = intval($id);
-
- return $id;
- }
-
-
-
-
-
-
-
- function str_check( $str ) {
- if (!get_magic_quotes_gpc()) {
- $str = addslashes($str);
- }
- $str = str_replace("_", "\_", $str);
- $str = str_replace("%", "\%", $str);
-
- return $str;
- }
-
-
-
-
-
-
-
- function post_check($post) {
- if (!get_magic_quotes_gpc()) {
- $post = addslashes($post);
- }
- $post = str_replace("_", "\_", $post);
- $post = str_replace("%", "\%", $post);
- $post = nl2br($post);
- $post = htmlspecialchars($post);
-
- return $post;
- }
- ?>
|
请发表评论