Php implements cc attack defense and prevents quick page refreshing. example _ PHP Tutorial

Source: Internet
Author: User
Php implements cc attack defense and prevents quick page refreshing. Copy the code as follows :? Php proxy IP directly exits empty ($ _ SERVER [HTTP_VIA]) orexit (AccessDenied); prevents fast refresh of session_start (); $ seconds3; time period [seconds] The code is as follows:


// Directly exit the proxy IP address
Empty ($ _ SERVER ['http _ vean']) or exit ('Access Denied ');
// Prevents quick refresh
Session_start ();
$ Seconds = '3'; // time period [seconds]
$ Refresh = '5'; // Number of Refreshes
// Set monitoring variables
$ Cur_time = time ();
If (isset ($ _ SESSION ['last _ time']) {
$ _ SESSION ['refresh_times '] + = 1;
} Else {
$ _ SESSION ['refresh_times '] = 1;
$ _ SESSION ['last _ time'] = $ cur_time;
}
// Process monitoring results
If ($ cur_time-$ _ SESSION ['last _ time'] <$ seconds ){
If ($ _ SESSION ['refresh_times ']> = $ refresh ){
// Jump to the attacker's server address
Header (sprintf ('Location: % s', 'http: // 127.0.0.1 '));
Exit ('Access Denied ');
}
} Else {
$ _ SESSION ['refresh_times '] = 0;
$ _ SESSION ['last _ time'] = $ cur_time;
}
?>

The http://www.bkjia.com/PHPjc/735243.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/735243.htmlTechArticle code is as follows :? Php // The proxy IP directly exits empty ($ _ SERVER ['http _ VIA ']) or exit ('Access Denied'); // prevents fast refresh of session_start (); $ seconds = '3'; // time period [seconds]...

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.