Invalid Data Processing for the value submitted by Get or Post

Source: Internet
Author: User


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];

}

}

}

?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.