Is SQL injection a risk today?

前端 未结 20 2100
暗喜
暗喜 2020-12-05 13:25

I\'ve been reading about SQL injection attacks and how to avoid them, although I can never seem to make the \"awful\" examples given work, e.g. see this post

20条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 13:56

    I've have to develop for a server which has no way for me to disable magic_quotes! I include this on every page to undo the effects of magic quotes, so I can do proper escaping myself without \'double escaping\'. Even though I can taste vomit just from reading this, I haven't found a better solution.

    if (get_magic_quotes_gpc()) {
    
        $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
    
        while (list($key, $val) = each($process)) {
    
            foreach ($val as $k => $v) {
    
                unset($process[$key][$k]);
    
                if (is_array($v)) {
    
                    $process[$key][stripslashes($k)] = $v;
    
                    $process[] = &$process[$key][stripslashes($k)];
    
                } else {
    
                    $process[$key][stripslashes($k)] = stripslashes($v);
    
                }
    
            }
    
        }
    
        unset($process);
    
    }
    

提交回复
热议问题