Empty ($ _ SERVER ['HTTP _ VIA ']) orexit ('accesssdenied'); what is the role of this line of php?

Source: Internet
Author: User
Looking at other people's attack prevention code, there is such a line: {code...} What is the role? The following is a line in the anti-attack code of others:

empty($_SERVER['HTTP_VIA']) or exit('Access Denied');

What is the function?

Reply content:

The following is a line in the anti-attack code of others:

empty($_SERVER['HTTP_VIA']) or exit('Access Denied');

What is the function?

The landlord may be confused about the or issue.
This method is a common php program method.
Or means that A or B, as long as a AB satisfies true, will immediately execute the following statement.
When A is not true, or cannot be determined immediately. It also needs to judge the second condition B, and Result B exits directly, which looks shorter and clearer than the if statement. In other words, if A is true, Access Denied will not be executed.

In fact, the main use of the following points:

  1. Or is associated from left to right.

  2. In the or condition, only one condition is true, so the remaining conditions are not judged, and the code segment in the Large arc is directly executed.

  3. This method is better than if (empty (xxx) {xxxx }.

If any error occurs, please correct it.

Prevent users from running the program in the correct way.

$_SERVER['HTTP_VIA']It is the proxy server address, that is, if the user accesses the server through the proxy, it will exit directly and will not continue to execute. This is a measure to ensure security.

When the Proxy Server ip address is not blank, exit the current program and OutputAccess DeniedTo prevent external attacks.

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.