Invalid Data Processing for the value submitted by get or post
<? PHP
//************************************** ******************
//--ProgramName: 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];
}
}
}
?>