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:
Or is associated from left to right.
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.
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 Denied
To prevent external attacks.