PHP get the current page of the previous page URL address, that is, the current page from which page chain received, you can use $_server[' http_referer '], but this source page URL address can be forged and deceived, this article to introduce the forgery of HTTP_ Referer page URL of the three ways, the need for friends can refer to.
$_server[' Http_referer ' is a super variable that PHP uses to determine the page's superior source, and we can use $_server[' http_referer ' to determine from which page we are entering this page, So we can do a better job of tracking.
But $_server[' http_referer ' can also be forged and deceived, and there are three ways to forge and deceive $_server[' http_referer '
The first method: File_get_contents
$opt =array (' http ' =>array (' header ' => ' Referer: $refer '));
$context =stream_context_create ($opt);
$file _contents = file_get_contents ($url, False, $context);
In file_get_contents, stream_context_create the important parameters for forging the source.
The second method: CURL
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, "http://www.manongjc.com");
curl_setopt ($ch, Curlopt_referer, "http://www.manongjc.com");
Curl_exec ($ch);
Parameter http://www.manongjc.com is a spoofed URL address.
The third method: Fsockopen
$server = ' www.manongjc.com ';
$host = ' www.manongjc.com ';
$target = ' index.php ';
$referer = ' http://www.manongjc.com/'; Referer
$port =;
$fp = Fsockopen ($server, $port, $errno, $errstr,);
if (! $fp) {
echo $errstr ($errno) \ n ";
} else{
$out = "Get $target http/1.1\r\n";
$out. = "Host: $host \ r \ n";
$out. = "Referer: $referer \ r \ n";
$out. = "connection:close\r\n\r\n";
Fwrite ($fp, $out);
while (!feof ($fp)) {
echo fgets ($FP, 128);
}
Fclose ($FP);
Of the top three methods, the third method is best fsockopen performance and effectiveness, so it is recommended that you use a third method.
Above is the PHP forged http_referer page URL source data collation, follow-up continue to supplement the relevant information, thank you for your support of this site!