首頁 php教程 php手册 php防注入代码方法,过滤所有GET POST

php防注入代码方法,过滤所有GET POST

May 25, 2016 pm 04:40 PM
php防注入

这里我们是告诉各位朋友关于php防注入代码方法,过滤所有GET POST,因为大多数据都是能过get post 方法注入,当然还有files.

<?php
/* 过滤所有GET过来变量 */
foreach ($_GET as $get_key => $get_var) {
    if (is_numeric($get_var)) {
        $get[strtolower($get_key) ] = get_int($get_var);
    } else {
        $get[strtolower($get_key) ] = get_str($get_var);
    }
}
/* 过滤所有POST过来的变量 */
foreach ($_POST as $post_key => $post_var) {
    if (is_numeric($post_var)) {
        $post[strtolower($post_key) ] = get_int($post_var);
    } else {
        $post[strtolower($post_key) ] = get_str($post_var);
    }
}
/* 过滤函数 */
//整型过滤函数
function get_int($number) {
    return intval($number);
}
//字符串型过滤函数
function get_str($string) {
    if (!get_magic_quotes_gpc()) {
        return addslashes($string);
    }
    return $string;
}
登入後複製


本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)