Illegal Data Processing of the value submitted by Get or Post <? Php
//************************************** ******************
// -- Program name: StrSwap V1.01
// -- Programming: [email] cngift@163.com [/email]
// -- Completed: 2002-8-1
// -- Program purpose: illegal data processing of the value submitted by Get or Post
// -- Note: This program needs to be loaded before all programs are processed for automatic
// -- Replace the variables used in the program
// -- Urgent upgrade due to detected serious bugs
// -- Copyright By cngift ◎ 2002
//************************************** ******************
Class StrSwap {
// The connector used to connect variables when you submit variables in Get Mode
Var $ GetSplitStr = "&&";
Var $ TempArray = array ();
Var $ VariableArray = array ();
//************************************** ******************
// -- Program name: Main ()
// -- Program purpose: the default running mode of this class
// -- Input parameter: None
//************************************** ******************
Function Main (){
Global $ REQUEST_METHOD;
If ("GET" = $ REQUEST_METHOD ){
$ This-> SubGetStrToArray ();
}
If ("POST" = $ REQUEST_METHOD ){
$ This-> SubPostStrToArray ();
}
$ This-> GlobalVariable ();
}
//************************************** ******************
// -- Program name: SubGetStrToArray ()
// -- Program purpose: the method called when the variable is submitted in Get mode.
// -- Input parameter: None
//************************************** ******************
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]);
}
}
//************************************** ******************
// -- Program name: SubPostStrToArray ()
// -- Program purpose: the method called when the variable is submitted in POST mode.
// -- Input parameter: None
//************************************** ******************
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 );
}
}
//************************************** ******************
// -- Program name: StrReplace ()
// -- Program purpose: replace invalid characters in the Variable
// -- Input parameter: variable value
//************************************** ******************
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 ('<', "<", $ str );
$ Str = str_replace ('>', ">", $ str );
$ Str = str_replace (';', ";", $ str );
$ Str = str_replace ('"'," ", $ str );
$ Str = str_replace ("'", "'", $ str );
$ Str = str_replace ("", "", $ str );
$ Str = str_replace ("/**/", "", $ str );
Return trim ($ str );
}
//************************************** ******************
// -- Program name: GlobalVariable ()
// -- Program purpose: declare variables as global variables for other programs to call
// -- Input parameter: None
//************************************** ******************
Function GlobalVariable (){
For ($ I = 0; $ I <sizeof ($ this-> VariableArray); $ I ++ ){
Global $ this-> VariableArray [$ I] [0];
$ {$ This-> VariableArray [$ I] [0] }=$ this-> VariableArray [$ I] [1];
}
}
}
?>