php快速查找數(shù)據(jù)庫中惡意代碼的方法_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:php將12小時制轉(zhuǎn)換成24小時制的方法本文實例講述了php將12小時制轉(zhuǎn)換成24小時制的方法。分享給大家供大家參考。具體如下: php將12小時制轉(zhuǎn)換成24小時制,輸入格式為:02:30:00 pm 轉(zhuǎn)換成:14:30:00
這篇文章主要介紹了php快速查找數(shù)據(jù)庫中惡意代碼的方法,可實現(xiàn)針對特殊字符的過濾功能,非常具有實用價值,需要的朋友可以參考下
本文實例講述了php快速查找數(shù)據(jù)庫中惡意代碼的方法。分享給大家供大家參考。具體如下:
數(shù)據(jù)庫被輸入惡意代碼,為了保證你的數(shù)據(jù)庫的安全,你必須得小心去清理。有了下面一個超級方便的功能,即可快速清除數(shù)據(jù)庫惡意代碼。
- function cleanInput($input) {
- $search = array(
- '@]*?>.*?@si', // Strip out javascript
- '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
- '@
- ]*?>.*?
- @siU', // Strip style tags properly
- '@@' // Strip multi-line comments
- );
- $output = preg_replace($search, '', $input);
- return $output;
- }
- function sanitize($input) {
- if (is_array($input)) {
- foreach($input as $var=>$val) {
- $output[$var] = sanitize($val);
- }
- }
- else {
- if (get_magic_quotes_gpc()) {
- $input = stripslashes($input);
- }
- $input = cleanInput($input);
- $output = mysql_real_escape_string($input);
- }
- return $output;
- }
- // Usage:
- $bad_string = "Hi! It's a good day!";
- $good_string = sanitize($bad_string);
- // $good_string returns "Hi! It\'s a good day!"
- // Also use for getting POST/GET variables
- $_POST = sanitize($_POST);
- $_GET = sanitize($_GET);
分享:php給一組指定關(guān)鍵詞添加span標(biāo)簽的方法具體如下: 這里是php給一組指定的關(guān)鍵詞添加span標(biāo)簽,高亮突出顯示關(guān)鍵詞
相關(guān)PHP教程:
- php生成圓角圖片的方法
- php按單詞截取字符串的方法
- php生成zip文件類實例
- php生成圖片縮略圖的方法
- php獲取網(wǎng)頁里所有圖片并存入數(shù)組的方法
- 經(jīng)典PHP加密解密函數(shù)Authcode()修復(fù)版代碼
- php簡單實現(xiàn)快速排序的方法
- php獲取網(wǎng)頁上所有鏈接的方法
- php將HTML表格每行每列轉(zhuǎn)為數(shù)組實現(xiàn)采集表格數(shù)據(jù)的方法
- PHP常用處理靜態(tài)操作類
- php使用post數(shù)組的鍵值創(chuàng)建同名變量并賦值的方法
- php刪除指定目錄的方法
- 相關(guān)鏈接:
- 教程說明:
PHP教程-php快速查找數(shù)據(jù)庫中惡意代碼的方法。