过滤参数

public static function getParameter($key,$dafaultValue=NULL)
    {
        if(isset($_REQUEST[$key]) && $_REQUEST[$key] !==''){
            return self::checkStr($key,trim($_REQUEST[$key]));
        }else{
            return $dafaultValue;
        }
    }
    private static function checkStr($key,$param,$dafaultValue=NULL)
    {
        if(!get_magic_quotes_gpc()){
            if(self::inject_check($param)){
                return $dafaultValue;
            }
            return $param;
        }else{
            return $param;
        }

    }
    private static function inject_check($sql_str) {
        return preg_match('/select|insert|and|or|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile/', $sql_str);
    }

posted @ 2016-05-23 14:53  未解  阅读(167)  评论(0编辑  收藏  举报