国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > PHP > 正文

php 對(duì)輸入信息的進(jìn)行安全過(guò)濾的函數(shù)代碼

2024-05-04 23:14:50
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

復(fù)制代碼 代碼如下:


// define constannts for input reading
define('INPUT_GET', 0x0101);
define('INPUT_POST', 0x0102);
define('INPUT_GPC', 0x0103);

/**
* Read input value and convert it for internal use
* Performs stripslashes() and charset conversion if necessary
*
* @param string Field name to read
* @param int Source to get value from (GPC)
* @param boolean Allow HTML tags in field value
* @param string Charset to convert into
* @return string Field value or NULL if not available
*/
function get_input_value($fname, $source, $allow_html=FALSE, $charset=NULL) {
$value = NULL;

if ($source == INPUT_GET && isset($_GET[$fname]))
$value = $_GET[$fname];
else if ($source == INPUT_POST && isset($_POST[$fname]))
$value = $_POST[$fname];
else if ($source == INPUT_GPC) {
if (isset($_POST[$fname]))
$value = $_POST[$fname];
else if (isset($_GET[$fname]))
$value = $_GET[$fname];
else if (isset($_COOKIE[$fname]))
$value = $_COOKIE[$fname];
}

if (empty($value))
return $value;

// strip single quotes if magic_quotes_sybase is enabled
if (ini_get('magic_quotes_sybase'))
$value = str_replace("''", "'", $value);
// strip slashes if magic_quotes enabled
else if (get_magic_quotes_gpc() || get_magic_quotes_runtime())
$value = stripslashes($value);

// remove HTML tags if not allowed
if (!$allow_html)
$value = strip_tags($value);

// convert to internal charset
return $value;
}


用法:get_input_value('_uid', INPUT_GET)
發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 南靖县| 平邑县| 康定县| 抚州市| 乐东| 阿城市| 高青县| 内江市| 衡山县| 大关县| 哈密市| 新巴尔虎右旗| 玛多县| 锦州市| 集安市| 通化县| 汕头市| 神农架林区| 岳普湖县| 丹棱县| 黔西县| 昌邑市| 织金县| 三原县| 承德县| 陇川县| 瓦房店市| 白水县| 晋宁县| 万安县| 晋中市| 共和县| 读书| 衢州市| 和龙市| 三台县| 金堂县| 龙州县| 水富县| 阿拉善盟| 梅河口市|