非法字元替換類

來源:互聯網
上載者:User

簡介:這是非法字元替換類的詳細頁面,介紹了和php,有關的知識、技巧、經驗,和一些php源碼等。

class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=323735' scrolling='no'>

<?php

//********************************************************
//-- 程式名稱:StrSwap V1.01
//-- 程式編寫:cngift@163.com
//-- 完成: 2002-8-1
//-- 程式用途:Get或Post提交值的非法資料處理
//-- 備忘: 本程式需要載入在所有程式處理前使用,以便自動進行
//-- 程式中使用的變數的替換
//-- 由於發現嚴重BUG緊急升級
//-- Copyright By cngift ◎ 2002
//********************************************************

class StrSwap{

//當以Get方式提交變數時用於串連變數的串連符
var $GetSplitStr = "&&";
var $TempArray = array();
var $VariableArray = array();

//********************************************************
//-- 程式名稱:Main()
//-- 程式用途:本類的預設運行方式
//-- 傳入參數:無
//********************************************************

function Main(){

global $REQUEST_METHOD;
if("GET"==$REQUEST_METHOD){

$this->SubGetStrToArray();

}
if("POST"==$REQUEST_METHOD){

$this->SubPostStrToArray();

}

$this->GlobalVariable();

}

//********************************************************
//-- 程式名稱:SubGetStrToArray()
//-- 程式用途:當變數以Get方式提交時所調用的方法
//-- 傳入參數:無
//********************************************************

function SubGetStrToArray(){

global $QUERY_STRING;
$this->TempArray = explode($this->GetSplitStr,$QUERY_STRING);

for($i=0;$i<sizeof($this->TempArray);$i++){

$temp = explode('=',$this->TempArray[$i]);
$this->VariableArray[$i][0] = $temp[0];
$this->VariableArray[$i][1] = $this->StrReplace($temp[1]);

}

}

//********************************************************
//-- 程式名稱:SubPostStrToArray()
//-- 程式用途:當變數以POST方式提交時所調用的方法
//-- 傳入參數:無
//********************************************************

function SubPostStrToArray(){

global $_POST;
reset($_POST);
for($i=0;$i<count($_POST);$i++){

$this->VariableArray[$i][0] = key($_POST);
$this->VariableArray[$i][1] = $this->StrReplace($_POST[key($_POST)]);
next($_POST);
}

}

//********************************************************
//-- 程式名稱:StrReplace()
//-- 程式用途:替換變數中的非法字元
//-- 傳入參數:變數值
//********************************************************

function StrReplace($str){

$str = StripSlashes($str);
$str = str_replace(chr(92),'',$str);
$str = str_replace(chr(47),'',$str);
$str = str_replace(chr(10).chr(13),"<br>",$str);
$str = str_replace('<',"&lt;",$str);
$str = str_replace('>',"&gt;",$str);
$str = str_replace(';',";",$str);
$str = str_replace('"',"“",$str);
$str = str_replace("'","‘",$str);
$str = str_replace(" "," ",$str);
$str = str_replace("/**/"," ",$str);

return trim($str);

}

//********************************************************
//-- 程式名稱:GlobalVariable()
//-- 程式用途:聲明變數為全域變數方便其他程式調用
//-- 傳入參數:無
//********************************************************

function GlobalVariable(){

for($i=0;$i<sizeof($this->VariableArray);$i++){

global $$this->VariableArray[$i][0];
${$this->VariableArray[$i][0]} = $this->VariableArray[$i][1];

}

}

}

?>

“非法字元替換類”的更多相關文章 》

愛J2EE關注Java邁克爾傑克遜視頻站JSON線上工具

http://biancheng.dnbcw.info/php/323735.html pageNo:16

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.