Briefly explain the above code. Get_headers is used to access a remote address and return the HTTP header sent by the server as an array. $ Header [0] indicates the status code returned by the server (if no exception occurs, the status code should be the first one ). Make sure that a file is in.. SyntaxHighlighter. all ();
Briefly explain the above code. Get_headers is used to access a remote address and return the HTTP header sent by the server as an array. $ Header [0] indicates the status code returned by the server (if no exception occurs, the status code should be the first one ).
To determine whether a file exists on the remote server, you only need to confirm that the status code returned when accessing this file is "HTTP/1.1 200 OK" (of course, you can also determine that if the status code is Not "HTTP/1.1 404 Not Found ", file exists, but I always feel insecure. after all, there are other status codes such as 301,400 ).
Example of getting three HTTP response codes:
Function get_http_response_code ($ theURL ){
$ Headers = get_headers ($ theURL );
Return substr ($ headers [0], 9, 3 );
}
?>
Example of how to exclude redirection:
/**
* Fetches all the real headers sent by the server in response to a HTTP request without redirects
* Obtain a header that does not contain redirection.
*/
Function get_real_headers ($ url, $ format = 0, $ follow_redirect = 0 ){
If (! $ Follow_redirect ){
// Set new default options
$ Opts = array ('http' =>
Array ('max _ redirects' => 1, 'Ignore _ errors '=> 1)
);
Stream_context_get_default ($ opts );
}
// Get headers
$ Headers = get_headers ($ url, $ format );
// Restore default options
If (isset ($ opts )){
$ Opts = array ('http' =>
Array ('max _ redirects' => 20, 'Ignore _ errors '=> 0)
);
Stream_context_get_default ($ opts );
}
// Return
Return $ headers;
}
?>
This article fixed link: http://www.xssxss.com/fuck/323.xss | Shine's holy heaven-Min Chen 〃