文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>过滤GET POST COOKIE

过滤GET POST COOKIE

时间:2008-04-21  来源:liuxingyuyuni


?php
    /**
     * @desc    Filter GPC variable
     * @param     String $allow_tags
     * @param     Array $protect_words
     * @return     Array $gpc
     * */
    function filterGpc($allow_tags='', $protect_words='') {
        $gpc = array('get'=>$_GET, 'post'=>$_POST, 'cookie'=>$_COOKIE);
        foreach($gpc as $k1=>$v1) {
            foreach($v1 as $k2=>$v2) {
                $v2 = get_magic_quotes_gpc() ? $v2 : addslashes($v2);
                $v2 = trim($v2);
                $v2 = nl2br($v2);
                 $v2 = strip_tags($v2, $allow_tags);
                 $gpc[$k1][$k2] = $v2;
                 if(! empty($protect_words)) {
                     foreach($protect_words as $word) {
                         if((strpos(strtolower($gpc[$k1][$k2]), $word) !== FALSE)) die("Hack!");
                     }
                 }
            }
        }
        unset($_GET, $_POST, $_COOKIE);
        return $gpc;
    }
    $allow_tags = "";
    $protect_words = array('insert', 'update', 'delete', 'select', 'from', 'or');
    $gpc = filterGpc($allow_tags, $protect_words);
?>


相关阅读 更多 +
排行榜 更多 +
西安交大通

西安交大通

生活实用 下载
长江云通

长江云通

生活实用 下载
translatez

translatez

生活实用 下载