The $ _ SERVER variable in PHP5 is no longer protected by magic_quotes_gpc.

Source: Internet
Author: User

In the php5 environment, our $ _ SERVER variable will no longer be protected by magic_quotes_gpc. As for how the program can enhance its security, we will summarize how to protect the cookies in php, get, post and files data. For more information, see.

<? Php

The Code is as follows: Copy code
$ Magic_quotes_gpc = get_magic_quotes_gpc ();
@ Extract (daddslashes ($ _ COOKIE ));
@ Extract (daddslashes ($ _ POST ));
@ Extract (daddslashes ($ _ GET ));
If (! $ Magic_quotes_gpc ){
$ _ FILES = daddslashes ($ _ FILES );
}


Daddslashes Function

The Code is as follows: Copy code

// Translated character Functions
Function daddslashes ($ string ){
If (! Is_array ($ string) return addslashes ($ string );
Foreach ($ string as $ key => $ val) $ string [$ key] = daddslashes ($ val );
Return $ string;
}

?>

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.